UI: Improve dashboard state component synchronization
This commit is contained in:
parent
29ccfaa23e
commit
d416103e74
@ -134,6 +134,7 @@ import {
|
||||
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
|
||||
import cssjs from '@core/css/css';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { IAliasController } from '@core/api/widget-api.models';
|
||||
|
||||
// @dynamic
|
||||
@Component({
|
||||
@ -179,6 +180,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
||||
@Input()
|
||||
parentDashboard?: IDashboardComponent = null;
|
||||
|
||||
@Input()
|
||||
parentAliasController?: IAliasController = null;
|
||||
|
||||
@ViewChild('dashboardContainer') dashboardContainer: ElementRef<HTMLElement>;
|
||||
|
||||
prevDashboard: Dashboard;
|
||||
@ -419,7 +423,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
||||
this.readonly = this.embedded || (this.singlePageMode && !this.widgetEditMode && !this.route.snapshot.queryParamMap.get('edit'))
|
||||
|| this.forceFullscreen || this.isMobileApp || this.authUser.authority === Authority.CUSTOMER_USER;
|
||||
|
||||
this.dashboardCtx.aliasController = new AliasController(this.utils,
|
||||
this.dashboardCtx.aliasController = this.parentAliasController ? this.parentAliasController : new AliasController(this.utils,
|
||||
this.entityService,
|
||||
this.translate,
|
||||
() => this.dashboardCtx.stateController,
|
||||
|
||||
@ -21,7 +21,8 @@
|
||||
[hideToolbar]="true"
|
||||
[currentState]="currentState"
|
||||
[dashboard]="dashboard"
|
||||
[parentDashboard]="parentDashboard">
|
||||
[parentDashboard]="parentDashboard"
|
||||
[parentAliasController]="parentAliasController">
|
||||
</tb-dashboard-page>
|
||||
<div class="tb-absolute-fill tb-widget-error" *ngIf="!stateExists">
|
||||
<span>{{ 'dashboard.non-existent-dashboard-state-error' | translate:{stateId} }}</span>
|
||||
|
||||
@ -19,7 +19,7 @@ import { PageComponent } from '@shared/components/page.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppState } from '@core/core.state';
|
||||
import { Dashboard, DashboardLayoutId } from '@shared/models/dashboard.models';
|
||||
import { StateObject } from '@core/api/widget-api.models';
|
||||
import { IAliasController, StateObject } from '@core/api/widget-api.models';
|
||||
import { updateEntityParams, WidgetContext } from '@home/models/widget-component.models';
|
||||
import { deepClone, isDefinedAndNotNull, isNotEmptyStr, objToBase64 } from '@core/utils';
|
||||
import { IDashboardComponent } from '@home/models/dashboard-component.models';
|
||||
@ -63,6 +63,8 @@ export class DashboardStateComponent extends PageComponent implements OnInit, On
|
||||
|
||||
parentDashboard: IDashboardComponent;
|
||||
|
||||
parentAliasController: IAliasController;
|
||||
|
||||
stateExists = true;
|
||||
|
||||
private stateSubscription: Subscription;
|
||||
@ -92,6 +94,7 @@ export class DashboardStateComponent extends PageComponent implements OnInit, On
|
||||
this.parentDashboard = this.ctx.parentDashboard ?
|
||||
this.ctx.parentDashboard : this.ctx.dashboard;
|
||||
if (this.syncParentStateParams) {
|
||||
this.parentAliasController = this.parentDashboard.aliasController;
|
||||
this.stateSubscription = this.ctx.stateController.dashboardCtrl.dashboardCtx.stateChanged.subscribe(() => {
|
||||
this.updateCurrentState();
|
||||
this.cd.markForCheck();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user