Hello Thwackers
I have been looking for a way to include NetPaths in a widget. In this thread https://thwack.solarwinds.com/ideas/7115#comment-303243 (scroll way down), lazyrabbitt has provided an ingenious solution which uses JavaScript to place the NetPath in an iFrame. The screen shot you see is produced by the lazyrabbitt's script below. I've bolded the problem; I can't seem to suppress the Mega Menu with this piece of the script: frameContents.find(".sw-mega-menu").css("display","none");
Any suggestions for troubleshooting this problem with be greatly appreciated.
Cheers!
Brent Papworth
lazyrabbitt's Script:
<script>
//////////////////////////////////////////////
//////////////// Variables
//////////////////////////////////////////////
// Refresh period for the iframe 1 second X 60 = 1 minute (iFrame Refresh)
var refreshPeriod = 1000 * 60;
// Refresh period for the iframe 1 second X 4 = 4 seconds (CSS wait time)
var cssWait = 1000 * 4;
// GMT Offset
var offset = 60000;
// iFrame height
var vheight = 500;
// NetPath Array (first value is the NetPathID, second value is the PollingEngineID)
var NetPaths = [];
NetPaths[0] = [54,46];
NetPaths[1] = [55,46];
NetPaths[2] = [56,46];
//////////////////////////////////////////////
//////////////// Process Array to Build DIVs and iFrames
//////////////////////////////////////////////
jQuery.each(NetPaths, function(index, item) {
document.write('<div id="NetPathDiv' + index + '"></div>');
// Initial load of the iframe
$("#NetPathDiv" + index).html(updateDIV(index, item[0], item[1], offset, vheight));
setTimeout(function(){ hideHF(index); }, cssWait );
// Reload of the html iframe based on refresh period
var myVar = setInterval(function() {
$("#NetPathDiv"+index).html(updateDIV(index, item[0], item[1], offset, vheight));
setTimeout(function(){ hideHF(index); }, cssWait );
}, refreshPeriod);
});
//////////////////////////////////////////////
//////////////// Functions
//////////////////////////////////////////////
// Function that determines the current date and time, adjusts for the GMT offset and then formats the iframe HTML with the latest URL
function updateDIV(id, pathID, pollingEngineID, offset, vheight){
// Automatically pulls the current hostname
var urlPath = "https://" + window.location.hostname;
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * offset);
var nd = new Date(utc);
var path = urlPath + "/ui/netpath/routeinspector/" + pathID + "/" + pollingEngineID + "/" + nd.getFullYear() + "/" + ( nd.getMonth() + 1 ) + "/" + nd.getDate() + "/" + nd.getHours() + "/" + nd.getMinutes() + "/0";
return '<iframe id="NetPathiFrame' + id + '" src="' + path + '" width="100%" height="' + vheight + '" frameborder="0" scrolling="no"></iframe>';
}
// Hides the Header and Footer from the Netpath iframe
function hideHF(id){
var frameContents = $("#NetPathiFrame"+id).contents();
frameContents.find(".sw-mega-menu").css("display","none");
frameContents.find(".sw-footer").css("display","none");
frameContents.find("#content").css("padding-top","0px");
frameContents.find(".xui-page-content").css("padding","0px");
}
</script>
Change the path to the page a bit, add "?Printable=true", that will remove all header and footer info.
So changed line will be:
var path = urlPath + "/ui/netpath/routeinspector/" + pathID + "/" + pollingEngineID + "/" + nd.getFullYear() + "/" + ( nd.getMonth() + 1 ) + "/" + nd.getDate() + "/" + nd.getHours() + "/" + nd.getMinutes() + "/0?Printable=true";
/Thomas
We upgraded just a few days ago and we are running Core 2018.4 HF Two, NetPath 1.1.4, NPM 12.4. Note the HF2, wonder if that's it.
Maybe they broke something on the menu display with HF2. On HF3 it shows the below in the release notes.
I will plan to upgrade to HF3 and see if the CSS still works.
What version of SolarWinds are you running? Its possible an older version is using a different ID for the menu bar. We are running Orion Platform 2018.4 HF1, ... NetPath 1.1.4, NPM 12.4 ... and it is working fine.
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 150,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process.