Auto Refresh Dashboard based on Elasticube Build or Refresh Every Dashboard Widget

Comments

1 comment

  • Avatar
    Daan Krijnen

    Been using this script up until I updated to 7.2, which broke the revision API for me. Awaiting the support ticket on the API I rewrote this to work with a different API call (getElasticube). I'm no Javascript coder, so probably not the smoothest way to get this working.

     

    var serverURL = 'http://[yourserverip]:8081';

    var elasticubeName = '[ElasticubeName]';

    var seconds = 15;

    var lastBuild = null;

    var settings = {

    "async": true,

    "crossDomain": true,

    "url": serverURL + "/api/v1/elasticubes/getElasticubes",

    "method": "GET",

    "headers": {

    "content-type": "application/x-www-form-urlencoded"

    }

    }



    //looks up the build time of the build, and if the build time changes, than that

    //means a build occurred and a auto-refresh occurs

    function checkElasticubeBuildStatus(){

    $.ajax(settings).done(function (response) {

    for( x in response) {

    if(response[x].title === elasticubeName) {

    if(lastBuild === null){
    lastBuild = response[x].lastBuildTime;
    console.log(response[x].lastBuildTime);
    }
    else if(lastBuild != response[x].lastBuildTime) {

    location.reload();

    }
    else{

    }

    }

    else{
    }

    }
    }

    setTimeout(checkElasticubeBuildStatus, seconds*1000);

    });

    }



    //Recursive function to keep checking build status

    checkElasticubeBuildStatus();
    0
    Comment actions Permalink

Please sign in to leave a comment.