Hi Cesaccenturefed,
so basically what I did was:
On your dashboard:
1) Add refresh_charts_en.js to your form scripts section.
2) Add this code to your dashboard:
<input type="dropdown" token="refreshPeriod" searchWhenChanged="true" id="row0Element4">
<label>Refresh period</label>
<choice value="0">Off</choice>
<choice value="1">1 min</choice>
<choice value="2">2 min</choice>
<choice value="5">5 min</choice>
<choice value="10">10 min</choice>
<choice value="30">30 min</choice>
<choice value="60">1 hour</choice>
<default>0</default>
</input>
Create the refresh_charts_en.js script in appserver\static with following content:
require(['jquery', 'splunkjs/mvc/simplexml/ready!','splunkjs/mvc','splunkjs/mvc/utils','splunkjs/mvc/tokenutils'], function($) {
require(['splunkjs/ready!'], function(mvc,utils,TokenUtils){
var defaultTokenModel = mvc.Components.get("default");
var tokenValue = defaultTokenModel.get("refreshPeriod");
if(tokenValue==0){
ref = setInterval(showDashboard, 1000);
clearInterval(ref);
}else{
var intervalOnLoad = tokenValue * 60 * 1000;
ref = setInterval(showDashboard, intervalOnLoad);
}
defaultTokenModel.on("change:refreshPeriod", function(newIndexName, indexName, options) {
var interval = indexName * 60 * 1000;
clearInterval(ref);
if (interval > 0) {
ref = setInterval(showDashboard, interval)
}});
function showDashboard() {
var list = document.getElementsByClassName("refresh-button");
for (var i = 0; i < list.length; i++) {
doScaledTimeout(list[i],i);
}
}
function doScaledTimeout(listofI,i) {
setTimeout(function() {
listofI.click();
}, (i+1) * 30);
}
});
})
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null
}
;
This iterates through all refresh buttons on your grapghs and clicks them.
Kind regards, and I hope this works well for you,
David Lisin
... View more