Dashboards & Visualizations

Was showing time of last update of dashboard in 6.4 using javascript. Stopped working in 6.5. Need suggestion on how to get working in 6.5.

simpkins1958
Contributor

The following XML/Javascript was working in 6.4 to update the lastupdatedtime id. In 6.5 the javascript is now only being called on initial page load. Anyway to get the javascript code called on every refresh like it was in 6.5? Thanks.

Simple XML:

<form refresh="300" script="pageinit.js,system_summary_widths.js">
  <label>System Summary</label>
  <fieldset submitButton="false">
    <html>
        Last updated: <span id="lastupdatetime"></span>
    </html>

Javascript:

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc) {

    var d = new Date();
    var n = d.toLocaleString();
    document.getElementById("lastupdatetime").innerHTML = n;
});
0 Karma

simpkins1958
Contributor

Change my javascript to update the time when one of the searches on the page finishes.

require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc) {

    var mySearch = splunkjs.mvc.Components.getInstance("baseSearch_wifi_bytes");

     mySearch.on('search:done', function(properties) {
        var currentDateTime = new Date();
        var currentDateTimeLocalizedString = currentDateTime.toLocaleString();
        document.getElementById("lastupdatetime").innerHTML = currentDateTimeLocalizedString;
    }); 
});
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...