From fd5306f16f1e1f1bd07c706f073d57a700eff603 Mon Sep 17 00:00:00 2001 From: "Henry.Sun" Date: Tue, 24 Mar 2020 15:16:46 +0800 Subject: add coverage test for JS Issue-ID: POLICY-2311 Change-Id: I12a041f59bf07ed4e8688545522e64a338cdb326 Signed-off-by: Henry.Sun --- gui-pdp-monitoring/src/webapp/js/MonitoringMain.js | 60 +++++++++++----------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'gui-pdp-monitoring/src/webapp/js/MonitoringMain.js') diff --git a/gui-pdp-monitoring/src/webapp/js/MonitoringMain.js b/gui-pdp-monitoring/src/webapp/js/MonitoringMain.js index 456f3a9..9198d63 100644 --- a/gui-pdp-monitoring/src/webapp/js/MonitoringMain.js +++ b/gui-pdp-monitoring/src/webapp/js/MonitoringMain.js @@ -64,46 +64,48 @@ function servicesCallback(data){ /* * Called after the DOM is ready */ -$(document).ready( - function() { - window.restRootURL = location.protocol +function readyCallback() { + window.restRootURL = location.protocol + "//" + window.location.hostname + ':' + config.restPort + (location.pathname.endsWith("/monitoring/") ? location.pathname.substring(0, location.pathname.indexOf("monitoring/")) : location.pathname) + "papservices/monitoring/"; - // Initialize tooltip for the charts - initTooltip(); + // Initialize tooltip for the charts + initTooltip(); - // Set up the structure of the page - setUpPage(true); + // Set up the structure of the page + setUpPage(true); - // Check cookies for engine URL - getEngineURL(); + // Check cookies for engine URL + getEngineURL(); - // Add click event to config icon for clearing engine URL - $(".ebSystemBar-config").click( - function() { + // Add click event to config icon for clearing engine URL + $(".ebSystemBar-config").click( + function() { // Clear the engine URL clearEngineURL(true); // Request the engine URL getEngineURL(); - } - ); + } + ); - ['hashchange', 'load'].forEach(event => window.addEventListener(event, function() { - // Get ID from url - window.id = window.location.hash.replace('#', ''); - if (window.id !== ''){ - var arr = window.id.split("/"); - window.groupName = arr[0]; - window.subGroupName = arr[1]; - highlightSelected(window.id); - ajax_get_statistics(restRootURL + "statistics/", servicesCallback, - window.services.useHttps, window.services.hostname, window.services.port, - window.services.username, window.services.password, window.id); - } - })); - } -); \ No newline at end of file + ['hashchange', 'load'].forEach(event => window.addEventListener(event, function () { + // Get ID from url + window.id = window.location.hash.replace('#', ''); + if (window.id !== '') { + var arr = window.id.split("/"); + window.groupName = arr[0]; + window.subGroupName = arr[1]; + highlightSelected(window.id); + ajax_get_statistics(restRootURL + "statistics/", servicesCallback, + window.services.useHttps, window.services.hostname, window.services.port, + window.services.username, window.services.password, window.id); + } + })); +} + +$(document).ready(readyCallback); +// Export for unit testing +export { readyCallback, servicesCallback }; \ No newline at end of file -- cgit 1.2.3-korg