Browse Source

UI: Fix handling dashboard page router data

pull/7758/head
Igor Kulikov 4 years ago
parent
commit
3a3771db64
  1. 33
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts
  2. 7
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts

33
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -56,7 +56,7 @@ import { WINDOW } from '@core/services/window.service';
import { WindowMessage } from '@shared/models/window-message.model';
import { deepClone, guid, isDefined, isDefinedAndNotNull, isNotEmptyStr } from '@app/core/utils';
import {
DashboardContext,
DashboardContext, DashboardPageInitData,
DashboardPageLayout,
DashboardPageLayoutContext,
DashboardPageLayouts,
@ -365,15 +365,23 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
ngOnInit() {
this.rxSubscriptions.push(this.route.data.subscribe(
(data) => {
let dashboardPageInitData: DashboardPageInitData;
if (this.embedded) {
data.dashboard = this.dashboardUtils.validateAndUpdateDashboard(this.dashboard);
data.currentDashboardId = this.dashboard.id ? this.dashboard.id.id : null;
data.widgetEditMode = false;
data.singlePageMode = false;
dashboardPageInitData = {
dashboard: this.dashboardUtils.validateAndUpdateDashboard(this.dashboard),
currentDashboardId: this.dashboard.id ? this.dashboard.id.id : null,
widgetEditMode: false,
singlePageMode: false
};
} else {
data.currentDashboardId = this.route.snapshot.params.dashboardId;
dashboardPageInitData = {
dashboard: data.dashboard,
currentDashboardId: this.route.snapshot.params.dashboardId,
widgetEditMode: data.widgetEditMode,
singlePageMode: data.singlePageMode
};
}
this.init(data);
this.init(dashboardPageInitData);
this.runChangeDetection();
}
));
@ -406,7 +414,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
}
}
private init(data: any) {
private init(data: DashboardPageInitData) {
this.reset();
@ -1492,11 +1500,12 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
versionControlPopover.tbComponentRef.instance.versionRestored.subscribe(() => {
this.dashboardService.getDashboard(this.currentDashboardId).subscribe((dashboard) => {
dashboard = this.dashboardUtils.validateAndUpdateDashboard(dashboard);
const data = {
const data: DashboardPageInitData = {
dashboard,
widgetEditMode: false,
currentDashboardId: this.currentDashboardId
} as any;
currentDashboardId: this.currentDashboardId,
widgetEditMode: this.widgetEditMode,
singlePageMode: this.singlePageMode
};
this.init(data);
this.dashboardCtx.stateController.cleanupPreservedStates();
this.dashboardCtx.stateController.resetState();

7
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.models.ts

@ -24,6 +24,13 @@ import { Observable } from 'rxjs';
export declare type DashboardPageScope = 'tenant' | 'customer';
export interface DashboardPageInitData {
dashboard: Dashboard;
currentDashboardId?: string;
widgetEditMode?: boolean;
singlePageMode?: boolean;
}
export interface DashboardContext {
instanceId: string;
state: string;

Loading…
Cancel
Save