aboutsummaryrefslogtreecommitdiffstats
path: root/gui-pdp-monitoring/src/webapp/js/MonitoringMain.js
diff options
context:
space:
mode:
authorHenry.Sun <henry.a.sun@est.tech>2020-03-24 15:16:46 +0800
committerHenry.Sun <henry.a.sun@est.tech>2020-03-25 12:48:02 +0800
commitfd5306f16f1e1f1bd07c706f073d57a700eff603 (patch)
tree81cc348197a2014422bc9fc54d2477e3368ddf84 /gui-pdp-monitoring/src/webapp/js/MonitoringMain.js
parentf9e85b70f97c139911466336f29fb365de53306c (diff)
add coverage test for JS
Issue-ID: POLICY-2311 Change-Id: I12a041f59bf07ed4e8688545522e64a338cdb326 Signed-off-by: Henry.Sun <henry.a.sun@est.tech>
Diffstat (limited to 'gui-pdp-monitoring/src/webapp/js/MonitoringMain.js')
-rw-r--r--gui-pdp-monitoring/src/webapp/js/MonitoringMain.js60
1 files changed, 31 insertions, 29 deletions
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