Browse Source

Fixed "Navigate to other dashboard" opening the target dashboard in its root state without the entity when the dashboard page is reused (#16892)

* Fixed "Navigate to other dashboard" opening the target dashboard in its root state without the entity when the dashboard page is reused

* Fixed license headers
hotfix-4.4
Maksym Tsymbarov 14 hours ago
committed by GitHub
parent
commit
6c253049aa
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts
  2. 4
      ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.models.ts
  3. 12
      ui-ngx/src/app/modules/home/components/dashboard-page/states/states-component.directive.ts

4
ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.component.ts

@ -79,6 +79,10 @@ export abstract class StateControllerComponent implements IStateControllerCompon
return this.statesValue;
}
public replaceStates(states: { [id: string]: DashboardState }) {
this.statesValue = states;
}
currentState: string;
syncStateWithQueryParam: boolean;

4
ui-ngx/src/app/modules/home/components/dashboard-page/states/state-controller.models.ts

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import { IStateController, StateObject } from '@core/api/widget-api.models';
import { DashboardState } from '@shared/models/dashboard.models';
@ -15,4 +16,5 @@ export interface IStateControllerComponent extends IStateController {
dashboardId: string;
preservedState: any;
init(): void;
replaceStates(states: {[id: string]: DashboardState }): void;
}

12
ui-ngx/src/app/modules/home/components/dashboard-page/states/states-component.directive.ts

@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import {
ComponentRef,
Directive,
@ -71,13 +72,20 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
ngOnChanges(changes: SimpleChanges): void {
let reInitController = false;
let initController = false;
const dashboardIdChange = changes.dashboardId;
const dashboardChanged = !!dashboardIdChange && !dashboardIdChange.firstChange &&
dashboardIdChange.currentValue !== dashboardIdChange.previousValue;
for (const propName of Object.keys(changes)) {
const change = changes[propName];
if (!change.firstChange && change.currentValue !== change.previousValue) {
if (propName === 'statesControllerId') {
this.reInit();
} else if (propName === 'states') {
this.stateControllerComponent.states = this.states;
if (dashboardChanged) {
this.stateControllerComponent.replaceStates(this.states);
} else {
this.stateControllerComponent.states = this.states;
}
} else if (propName === 'dashboardId') {
this.stateControllerComponent.dashboardId = this.dashboardId;
reInitController = true;

Loading…
Cancel
Save