Do not use dashboard state param from url location inside embed dashboard dialog
This commit is contained in:
parent
6f2a4409c1
commit
03fa7dcd41
@ -53,6 +53,7 @@
|
|||||||
[isMobile]="isMobile"
|
[isMobile]="isMobile"
|
||||||
[state]="dashboardCtx.state"
|
[state]="dashboardCtx.state"
|
||||||
[currentState]="currentState"
|
[currentState]="currentState"
|
||||||
|
[syncStateWithQueryParam]="syncStateWithQueryParam"
|
||||||
[states]="dashboardConfiguration.states">
|
[states]="dashboardConfiguration.states">
|
||||||
</tb-states-component>
|
</tb-states-component>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -123,6 +123,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
|
|||||||
@Input()
|
@Input()
|
||||||
hideToolbar: boolean;
|
hideToolbar: boolean;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
syncStateWithQueryParam = true;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
dashboard: Dashboard;
|
dashboard: Dashboard;
|
||||||
dashboardConfiguration: DashboardConfiguration;
|
dashboardConfiguration: DashboardConfiguration;
|
||||||
|
|||||||
@ -88,6 +88,8 @@ export abstract class StateControllerComponent implements IStateControllerCompon
|
|||||||
|
|
||||||
currentState: string;
|
currentState: string;
|
||||||
|
|
||||||
|
syncStateWithQueryParam: boolean;
|
||||||
|
|
||||||
private rxSubscriptions = new Array<Subscription>();
|
private rxSubscriptions = new Array<Subscription>();
|
||||||
|
|
||||||
private inited = false;
|
private inited = false;
|
||||||
@ -99,18 +101,20 @@ export abstract class StateControllerComponent implements IStateControllerCompon
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => {
|
if (this.syncStateWithQueryParam) {
|
||||||
const dashboardId = this.route.snapshot.params.dashboardId || '';
|
this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => {
|
||||||
if (this.dashboardId === dashboardId) {
|
const dashboardId = this.route.snapshot.params.dashboardId || '';
|
||||||
const newState = this.decodeStateParam(paramMap.get('state'));
|
if (this.dashboardId === dashboardId) {
|
||||||
if (this.currentState !== newState) {
|
const newState = this.decodeStateParam(paramMap.get('state'));
|
||||||
this.currentState = newState;
|
if (this.currentState !== newState) {
|
||||||
if (this.inited) {
|
this.currentState = newState;
|
||||||
this.onStateChanged();
|
if (this.inited) {
|
||||||
|
this.onStateChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
}));
|
}
|
||||||
this.init();
|
this.init();
|
||||||
this.inited = true;
|
this.inited = true;
|
||||||
}
|
}
|
||||||
@ -124,16 +128,18 @@ export abstract class StateControllerComponent implements IStateControllerCompon
|
|||||||
|
|
||||||
protected updateStateParam(newState: string) {
|
protected updateStateParam(newState: string) {
|
||||||
this.currentState = newState;
|
this.currentState = newState;
|
||||||
const queryParams: Params = { state: this.currentState };
|
if (this.syncStateWithQueryParam) {
|
||||||
this.ngZone.run(() => {
|
const queryParams: Params = {state: this.currentState};
|
||||||
this.router.navigate(
|
this.ngZone.run(() => {
|
||||||
[],
|
this.router.navigate(
|
||||||
{
|
[],
|
||||||
relativeTo: this.route,
|
{
|
||||||
queryParams,
|
relativeTo: this.route,
|
||||||
queryParamsHandling: 'merge',
|
queryParams,
|
||||||
});
|
queryParamsHandling: 'merge',
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public openRightLayout(): void {
|
public openRightLayout(): void {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ export interface IStateControllerComponent extends IStateController {
|
|||||||
stateControllerInstanceId: string;
|
stateControllerInstanceId: string;
|
||||||
state: string;
|
state: string;
|
||||||
currentState: string;
|
currentState: string;
|
||||||
|
syncStateWithQueryParam: boolean;
|
||||||
isMobile: boolean;
|
isMobile: boolean;
|
||||||
states: {[id: string]: DashboardState };
|
states: {[id: string]: DashboardState };
|
||||||
dashboardId: string;
|
dashboardId: string;
|
||||||
|
|||||||
@ -53,6 +53,9 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
currentState: string;
|
currentState: string;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
syncStateWithQueryParam: boolean;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
isMobile: boolean;
|
isMobile: boolean;
|
||||||
|
|
||||||
@ -89,6 +92,8 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
|
|||||||
this.stateControllerComponent.state = this.state;
|
this.stateControllerComponent.state = this.state;
|
||||||
} else if (propName === 'currentState') {
|
} else if (propName === 'currentState') {
|
||||||
this.stateControllerComponent.currentState = this.currentState;
|
this.stateControllerComponent.currentState = this.currentState;
|
||||||
|
} else if (propName === 'syncStateWithQueryParam') {
|
||||||
|
this.stateControllerComponent.syncStateWithQueryParam = this.syncStateWithQueryParam;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,6 +124,7 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
|
|||||||
this.stateControllerComponent.stateControllerInstanceId = stateControllerInstanceId;
|
this.stateControllerComponent.stateControllerInstanceId = stateControllerInstanceId;
|
||||||
this.stateControllerComponent.state = this.state;
|
this.stateControllerComponent.state = this.state;
|
||||||
this.stateControllerComponent.currentState = this.currentState;
|
this.stateControllerComponent.currentState = this.currentState;
|
||||||
|
this.stateControllerComponent.syncStateWithQueryParam = this.syncStateWithQueryParam;
|
||||||
this.stateControllerComponent.isMobile = this.isMobile;
|
this.stateControllerComponent.isMobile = this.isMobile;
|
||||||
this.stateControllerComponent.states = this.states;
|
this.stateControllerComponent.states = this.states;
|
||||||
this.stateControllerComponent.dashboardId = this.dashboardId;
|
this.stateControllerComponent.dashboardId = this.dashboardId;
|
||||||
|
|||||||
@ -27,7 +27,8 @@
|
|||||||
</mat-progress-bar>
|
</mat-progress-bar>
|
||||||
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
|
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
|
||||||
<div class="dashboard-state-dialog-content" mat-dialog-content fxFlex fxLayout="column" style="padding: 8px;">
|
<div class="dashboard-state-dialog-content" mat-dialog-content fxFlex fxLayout="column" style="padding: 8px;">
|
||||||
<tb-dashboard-page [embedded]="true" [hideToolbar]="hideToolbar" [currentState]="state" [dashboard]="dashboard" style="width: 100%; height: 100%;"></tb-dashboard-page>
|
<tb-dashboard-page [embedded]="true" [syncStateWithQueryParam]="false" [hideToolbar]="hideToolbar"
|
||||||
|
[currentState]="state" [dashboard]="dashboard" style="width: 100%; height: 100%;"></tb-dashboard-page>
|
||||||
</div>
|
</div>
|
||||||
<div mat-dialog-actions fxLayoutAlign="end center">
|
<div mat-dialog-actions fxLayoutAlign="end center">
|
||||||
<button mat-button color="primary"
|
<button mat-button color="primary"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user