Dashboard Auto-Refresh
In order to make the dashboard auto refresh every x seconds, we can use the following script:
In the Dashboard Script:
Set the widget to refresh every 10 seconds by setting refreshIntervalMiliSec to 10000.
dashboard.on('initialized', function(dashboard, ev){ var refreshIntervalMiliSec = 10000; var refreshDashboard = function(){ dashboard.refresh(); setTimeout(refreshDashboard, refreshIntervalMiliSec); } setTimeout(refreshDashboard, refreshIntervalMiliSec); })
-
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
-
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 scriptAlthough, Eli, although I believe this is working now, if you have any tips or pointers I'd still love to hear them! Thanks again.
-
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!
-
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
-
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
-
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
-
*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?
-
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?
Please sign in to leave a comment.
Comments
11 comments