Auto Refresh Dashboard Based On Elasticube Build Or Refresh Every Dashboard Widget
Auto-Refresh Dashboard based on Elasticube Build:
This dashboard script queries the elasticube on the server, and checks to see if a new build has completed. As soon as a build is finished, the dashboard will auto-refresh, and all widgets will be based on the most recent build.
Add this to a dashboard script
//Variables + Settings to check elasticube build on the server
//Currently configured to check the build status of the cube every 15 seconds
var serverURL = 'http://10.60.4.38';
var elasticubeName = 'ItayAnalysis-Elliott';
var seconds = 15;
var revision = null;
var settings = {
"async": true,
"crossDomain": true,
"url": serverURL + "/api/v1/elasticubes/localhost/" + elasticubeName + "/revision",
"method": "GET",
"headers": {
"content-type": "application/x-www-form-urlencoded"
}
}
//looks up the revision history of the build, and if the revision changes, than that
//means a build occurred and a auto-refresh occurs
function checkElasticubeBuildStatus(){
$.ajax(settings).done(function (response) {
if(revision === null) {
revision = response;
}
else if(revision != response) {
location.reload();
}
setTimeout(checkElasticubeBuildStatus, seconds*1000);
});
}
//Recursive function to keep checking build status
checkElasticubeBuildStatus();
Auto-Refresh every widget on a dashboard every minute:
This dashboard script auto-refreshes each widget on the page without having to do a page refresh. As of right now it is configured to refresh every widget every 60 seconds.
Add this to a dashboard script
dashboard.on('widgetinitialized', function(w, args) {
var seconds = 60;
var refreshWidget = function(){
args.widget.refresh();
setTimeout(refreshWidget, seconds*1000);
}
setTimeout(refreshWidget, seconds*1000);
});
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022