thingsboard icon indicating copy to clipboard operation
thingsboard copied to clipboard

After changing dashboard state to another dashboard state the top panel is doubled.

Open psxbox opened this issue 2 years ago • 1 comments

Component

  • UI

Description After changing dashboard state to another dashboard state the top panel is doubled (see below). How to fix?

image default state

image after changing the state to another dashboard state

Environment

  • OS: Windows 10
  • ThingsBoard: 3.4.4 PE
  • Browser: Chrome

psxbox avatar Jan 30 '24 15:01 psxbox

I'm navigating to another dashboard with this function:

function openDashboardState(dashboardId, stateId) {
    var params = {
        entityId: entityId,
        entityName: entityName,
        currentStateId: widgetContext.stateController
            .getStateId()
    };

    var stateObject = {
        id: stateId,
        params: {}
    };

    stateObject.params = params;
    var state = objToBase64URI([stateObject]);
    let url = "/dashboards/" + dashboardId +
        "?state=" + state + "";
    widgetContext.router.navigateByUrl(url);
}

function objToBase64URI(obj) {
    return encodeURIComponent(objToBase64(obj));
}

function objToBase64(obj) {
    const json = JSON.stringify(obj);
    return btoa(encodeURIComponent(json).replace(
        /%([0-9A-F]{2})/g,
        function toSolidBytes(match, p1) {
            return String.fromCharCode(Number('0x' +
                p1));
        }));
}

psxbox avatar Feb 06 '24 05:02 psxbox

This problem is solved by changing the url:

stateObject.params = params;
    var state = objToBase64URI([stateObject]);
    let url = "/dashboard/" + dashboardId +
        "?state=" + state + "";
    widgetContext.router.navigateByUrl(url);

psxbox avatar Mar 05 '24 15:03 psxbox