Skip to content

Commit 3946646

Browse files
committed
dashboard strings are now in dashboard_info.js; dashboard now downloads requires js files in parallel
1 parent 83b0c68 commit 3946646

4 files changed

Lines changed: 2597 additions & 2558 deletions

File tree

web/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dist_web_DATA = \
99
demosites.html \
1010
dashboard.html \
1111
dashboard.js \
12+
dashboard_info.js \
1213
dashboard.css \
1314
dashboard.slate.css \
1415
favicon.ico \

web/dashboard.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
//
2121
// var netdataRegistryAfterMs = 1500 // the time to consult to registry on startup
2222
//
23+
// var netdataCallback = null; // a function to call when netdata is ready
24+
// // netdata will be running while this is called (call NETDATA.pause to stop it)
25+
// var netdataPrepCallback = null; // a callback to be called before netdata does anything else
26+
//
2327
// You can also set the default netdata server, using the following.
2428
// When this variable is not set, we assume the page is hosted on your
2529
// netdata server already.
@@ -3476,6 +3480,9 @@
34763480

34773481
// Registry initialization
34783482
setTimeout(NETDATA.registry.init, netdataRegistryAfterMs);
3483+
3484+
if(typeof netdataCallback === 'function')
3485+
netdataCallback();
34793486
};
34803487

34813488
// ----------------------------------------------------------------------------------------------------------------
@@ -5546,14 +5553,12 @@
55465553
}
55475554
];
55485555

5556+
NETDATA.loadedRequiredJs = 0;
55495557
NETDATA.loadRequiredJs = function(index, callback) {
5550-
if(index >= NETDATA.requiredJs.length) {
5551-
if(typeof callback === 'function')
5552-
callback();
5553-
return;
5554-
}
5558+
if(index >= NETDATA.requiredJs.length) return;
55555559

55565560
if(NETDATA.requiredJs[index].isAlreadyLoaded()) {
5561+
NETDATA.loadedRequiredJs++;
55575562
NETDATA.loadRequiredJs(++index, callback);
55585563
return;
55595564
}
@@ -5564,18 +5569,24 @@
55645569
$.ajax({
55655570
url: NETDATA.requiredJs[index].url,
55665571
cache: true,
5572+
async: true,
55675573
dataType: "script",
55685574
xhrFields: { withCredentials: true } // required for the cookie
55695575
})
55705576
.done(function() {
55715577
if(NETDATA.options.debug.main_loop === true)
55725578
console.log('loaded ' + NETDATA.requiredJs[index].url);
5573-
5574-
NETDATA.loadRequiredJs(++index, callback);
55755579
})
55765580
.fail(function() {
55775581
alert('Cannot load required JS library: ' + NETDATA.requiredJs[index].url);
55785582
})
5583+
.always(function() {
5584+
NETDATA.loadedRequiredJs++;
5585+
if(typeof callback === 'function' && NETDATA.loadedRequiredJs >= NETDATA.requiredJs.length)
5586+
callback();
5587+
})
5588+
5589+
NETDATA.loadRequiredJs(++index, callback);
55795590
};
55805591

55815592
NETDATA.loadRequiredCSS = function(index) {
@@ -6113,6 +6124,9 @@
61136124
// ----------------------------------------------------------------------------------------------------------------
61146125
// Boot it!
61156126

6127+
if(typeof netdataPrepCallback === 'function')
6128+
netdataPrepCallback();
6129+
61166130
NETDATA.errorReset();
61176131
NETDATA.loadRequiredCSS(0);
61186132

0 commit comments

Comments
 (0)