Dashboard Auto-Refresh

Comments

11 comments

  • Avatar
    Sarah

    Hi Eli,

     

    I'm trying to extend this script a little so that it only refreshes the browser when the local time is between 5AM and 10PM. This is what I have come up with and it's not working out for me. Could you offer any help or advice?

     

    ```

    dashboard.on('initialized', function(se, ev){
        var DoTheThing = function(){
            var h = new Date().getHours();
            if (h >= 5 && h < 22) {
                location.reload(true);
            }
        }
        setInterval(DoTheThing, 3000);
    }

    ```

    I'm pretty newbie with js so I'm sure it's some gross misunderstanding on my part.

    Thanks!

    Sarah

    0
    Comment actions Permalink
  • Avatar
    Sarah

    Ah, I should add I had 3000 in there while testing it but I'd like to tone that down to 300000 once I get it working.

    Also, how do you format your code in your post? Is there a guide to how to format comments on this board? Thanks

    0
    Comment actions Permalink
  • Avatar
    Sarah

    Hi again, Eli,

    Never mind, I figured it out ><

    In case anybody else is working on this, here's what I got:

        // Refresh Browser every 5 minutes between 5AM and 10PM
        var DoTheThing = function(){
            var h = new Date().getHours();
            if (h >= 5 && h < 22) {
                location.reload(true);
            }
        }
        setInterval(DoTheThing, 300000);
        // End of Refresh Browser script

     

    Although, Eli, although I believe this is working now, if you have any tips or pointers I'd still love to hear them! Thanks again.

    0
    Comment actions Permalink
  • Avatar
    Rajeev Natarajan

    Hi Eli,

    How do I refresh only a single widget within a dashboard and not the entire dashboard?

    Best regards,

    Santhosh

    0
    Comment actions Permalink
  • Avatar
    Takashi Binns

    Hi Rajeev,

    You can use a dashboard script like this, to refresh only specific widgets. 

    dashboard.on('initialized', function(dashboard, ev){
        
    	//	Settings
    	var refreshIntervalMiliSec = 1000 * 10,		//	10 seconds
    		widgets = ["57a9e50da6b919a4120000c3"];
    		
    	//	Find any matching widget
    	var widgetsList = $.grep(dashboard.widgets.$$widgets, function(w){ 
    		return widgets.indexOf(w.oid)>=0; 
    	});
    		
    	//	Function to refresh
            var refreshWidgets = function(){
    		
    		//	Loop through and refresh the widgets
    		$.each(widgetsList, function(){
    			this.refresh();
    		});
            
        }
        setInterval(refreshWidgets, refreshIntervalMiliSec);
    })
    

    Hope this helps!

    0
    Comment actions Permalink
  • Avatar
    Blake Sloan

    This is great functionality.  I have implemented it but was wondering how I can update the "Data as of " elasticube info at the top of the Dashboard.  Although the dashboard refreshes the elasticube date does not change.

    Thanks

    0
    Comment actions Permalink
  • Avatar
    Max Bradley

    Hi Blake,

    The "Data as of" information refers to the last ElastiCube build that occurred. The Dashboard refreshing does not necessarily mean that an ElastiCube has been rebuilt. Once an ElastiCube has been rebuilt, upon refresh, the dashboard will display the new build time in the "Data as of" info section.

    Hope this clarifies.

    Max

    0
    Comment actions Permalink
  • Avatar
    Santhosh Prabhakaran

    Hi Takashi,

     

    Thanks for the code to refresh only a widget.  I have an indicator widget with conditional formatting. How do I refresh the widget only when it is in a particular color?  Also, is there any way I can get the color of the widget and then trigger different actions based on the color of the widget?'

     

    Thanks,

    Santhosh

    0
    Comment actions Permalink
  • Avatar
    Takashi Binns

    Hi Santhosh,

    If you want to check the indicator's color when it renders, you can use our API to hook into the "render" event.  Check out this forum post that hooks into this event, for an example.  That post shows to to add different images based on the value, but the color being shown is also available if you want to use it as a trigger for different functions.

    Hope this helps!

    -Takashi

    1
    Comment actions Permalink
  • Avatar
    Nishad Amin (Edited )

    *UPDATE: Sorry for the post, turns out https://support.sisense.com/hc/en-us/community/posts/360001595354-Auto-Refresh-Dashboard-based-on-Elasticube-Build-or-Refresh-Every-Dashboard-Widget solves our problem*

     

    Max, 

    I believe what Blake was referring  to was The Last Build date on the top of the Dashboard  (next to cube name). See attached.

    The widget refresh works well, we have clients that post the dashboards onto monitors mounted in their offices. While the widgets refresh whilst picking changes from cube builds, clients gravitate towards that date/time, their perception is that the dashboard is behind. 

    We tried modifying the script to do a complete page refresh, but we have sisense embedded in an IFrame and has a bad user experience.

    Any thoughts on how we can update that last cube build when the build changes?

    0
    Comment actions Permalink
  • Avatar
    Malinda Jepsen

    Look at this posting regarding hiding the cube build date/time: https://support.sisense.com/hc/en-us/community/posts/115008238487-Hide-Dashboard-Refresh-Time.  Maybe that will work?

    0
    Comment actions Permalink

Please sign in to leave a comment.