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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...