cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
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);

});
Rate this article:
Comments
benson
7 - Data Storage
7 - Data Storage

Hi @intapiuser ,

thank you for the effort and your shared scripts. 
But the first script doesn't work for me, because i can't find the endpoint /elasticcubes/{server}/{title}/revision and i receive just a "can not get elasticcubes/{server}/...../.

Maybe i'm totally wrong ... 

Do you have an idea?

Many thanks and greetings
benson

Version history
Last update:
‎03-02-2023 09:20 AM
Updated by:
Contributors