cancel
Showing results for 
Search instead for 
Did you mean: 

Last Updated DAte on Dashboard (Dynamic Elasticubes_

liamcameron
9 - Travel Pro
9 - Travel Pro

I have a dashboard that i want to display at the top in a text box the lastupdated build date of my elasitube

 

I've seen https://community.sisense.com/t5/build-analytics/show-last-updated-date-on-dashboard/m-p/3690?search...

But my dashboard is hooked up to many elasticubes... 

ideally i want the date to appear on the right hand side of this blue bar... possible?

liamcameron_0-1728336205114.png

 

5 REPLIES 5

harikm007
13 - Data Warehouse
13 - Data Warehouse

Hi @liamcameron ,

You can definitely use the same script you mentioned to find the last updated build date of any elasticube—just update the elasticube name in the 'datasource' variable.

To display the date on the right side of the blue bar:

  • If you're using a text widget: It’s tricky to align text left and right within the same widget. Instead, create two text widgets placed side by side: make the first widget left-aligned and the second one right-aligned.

  • Alternatively, consider using Blox: It offers more flexibility for aligning your text as needed.

 

-Hari

https://www.binextlevel.com/ 

Hey hari! Thank you for the reply, 

 

we’re using the  dynamicelasticubes plugin so one dashboard will have 10 cubes viewing it depending on the user’s group. Can that cube just be an array then? 

Hey @liamcameron ,

the Dynamic Elasicube require the Datasource info in the script to be Dynamic Variable. 

datasource = [
					{
						"elasticube": "elasticube name",
						"server": "localhost"
					}
				]

This sample script demonstrates the following:

  • Wrapping the HTTP request inside a dashboard script using the 'initialized' event.
  • Dynamically creating the 'elasticube' variable based on the dashboard's datasource.
  • Triggering the HTTP request once the dashboard is fully initialized.
  • Tested by manually switching the data source (Has not been tested with Dynamic Elasticube plugin).
let datasource;

dashboard.on('initialized', function(dashboard) {
    // Extract the Elasticube title from the dashboard's datasource
    datasource = [
        {
            "elasticube": dashboard.datasource.title,  // Replace with the actual datasource title
            "server": "localhost"
        }
    ];
    
    // Run the HTTP request once the datasource is ready
    runHTTP();
});

function runHTTP() {
    // Ensure datasource is available
    if (!datasource) {
        console.error("Datasource not available");
        return;
    }

    // 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+ or default ajax request
    const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);

    // Return the response
    return httpPromise.responseJSON;
}
Please test and confirm if it works
 
Best Regards
Assaf

hey Assaf!

 

Thank you for the reply, i've tried the second script in a text widget, doesn't seem to work, is there something else i need to input? i.e you define the data sources, do i need to outline my cubes beforethe script?

Hey @liamcameron ,

The copy was missing the necessary code to update the text.
in addition, instead of Using Text option, the Last Build time can be used in Blox Widget.

please review the updated script, Using Text, and update if that's works.

 

let datasource;

dashboard.on('initialized', function(dashboard) {
// Extract the Elasticube title from the dashboard's datasource
datasource = [
{
"elasticube": dashboard.datasource.title, // Replace with the actual datasource title
"server": "localhost"
}
];

// Run the HTTP request once the datasource is ready
runHTTP();
});

function runHTTP() {
// Ensure datasource is available
if (!datasource) {
console.error("Datasource not available");
return;
}

// 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+ or default ajax request
const httpPromise = $internalHttp ? $internalHttp(ajaxConfig, true) : $.ajax(ajaxConfig);

// Return the response
return httpPromise.responseJSON;
}

// display last build in Text 

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
})

 

Best Regards

 

Assaf