Forum Discussion

amelia's avatar
06-23-2022
Solved

Show Last Updated Date on Dashboard

Hi! I'm creating a dashboard and want to show when the data source for the dashboard was last refreshed at the top of the dashboard, since the users will want this. Is there any widget I can add or script to add to achieve this? 

  • amelia 

    Create a text box and add below script to it. (Update elasticube name in the script.)

     

    function runHTTP() {
    	
    	datasource = [
    					{
    						"elasticube": "elasticube name",
    						"server": "localhost"
    					}
    				]
      // Use $internalHttp service if exists
      const $internalHttp = prism.$injector.has("base.factories.internalHttp") ?
      prism.$injector.get("base.factories.internalHttp") : null;
      // Ajax configurations
      const ajaxConfig = {
        url: "/api/v1/elasticubes/getElasticubes",
        method: "POST",
        data: JSON.stringify(datasource),
        contentType: "application/json",
        dataType: "json",
        async: false
      };
      // Use $internalHttp service for v8.0.1+
      // else use default ajax request
      const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);
    
      // Return response
      return httpPromise.responseJSON;
    };
    
    
    widget.on('domready', function(se, ev) {
      elasticubedetails = runHTTP();
      ev.widget.style.content.html = '<font size=\"5\">' + moment(elasticubedetails[0].lastBuildTime).format('MMMM Do YYYY, h:mm:ss a') + '</font>' //change this to update style and text
    })

    Thanks Ophir_Buchman for the post 'how to run HTTP request from sisense'

    -Hari

     

12 Replies

Replies have been turned off for this discussion
  • harikm007's avatar
    harikm007
    Data Warehouse

    Hi amelia ,

    We can see 'Last Built' date and time at the top of dashboard. Are you for a widget instead of this?

    -Hari

     

    • amelia's avatar
      amelia
      ETL

      Yes, if possible I want to have a widget that shows this! Or a text box. I want the user to see the last time the data for the dashboard was updated.

      • harikm007's avatar
        harikm007
        Data Warehouse

        amelia 

        Create a text box and add below script to it. (Update elasticube name in the script.)

         

        function runHTTP() {
        	
        	datasource = [
        					{
        						"elasticube": "elasticube name",
        						"server": "localhost"
        					}
        				]
          // Use $internalHttp service if exists
          const $internalHttp = prism.$injector.has("base.factories.internalHttp") ?
          prism.$injector.get("base.factories.internalHttp") : null;
          // Ajax configurations
          const ajaxConfig = {
            url: "/api/v1/elasticubes/getElasticubes",
            method: "POST",
            data: JSON.stringify(datasource),
            contentType: "application/json",
            dataType: "json",
            async: false
          };
          // Use $internalHttp service for v8.0.1+
          // else use default ajax request
          const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);
        
          // Return response
          return httpPromise.responseJSON;
        };
        
        
        widget.on('domready', function(se, ev) {
          elasticubedetails = runHTTP();
          ev.widget.style.content.html = '<font size=\"5\">' + moment(elasticubedetails[0].lastBuildTime).format('MMMM Do YYYY, h:mm:ss a') + '</font>' //change this to update style and text
        })

        Thanks Ophir_Buchman for the post 'how to run HTTP request from sisense'

        -Hari

         

  • Hello  reached out the people at sisense customer service and they helped me to find the issue. It is an issue with my version of sisense which hasn't been updated in a while.

  • Hello,

    To display the last refresh time on your dashboard, add a timestamp widget or use a simple JavaScript script. Check your dashboard tool's documentation for built-in features. Here's a basic script:

    <p id="lastRefresh">Data last refreshed: </p> <script>devops course>function updateRefreshTime() {document.getElementById('lastRefresh').textContent = 'Data last refreshed: ' + new Date().toLocaleString();} window.onload = updateRefreshTime;</script>

    Adjust based on your tool's capabilities.

    I hope this will help you.

    Thanks.