|
|
|
@ -88,6 +88,8 @@ export abstract class StateControllerComponent implements IStateControllerCompon |
|
|
|
|
|
|
|
currentState: string; |
|
|
|
|
|
|
|
syncStateWithQueryParam: boolean; |
|
|
|
|
|
|
|
private rxSubscriptions = new Array<Subscription>(); |
|
|
|
|
|
|
|
private inited = false; |
|
|
|
@ -99,18 +101,20 @@ export abstract class StateControllerComponent implements IStateControllerCompon |
|
|
|
} |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => { |
|
|
|
const dashboardId = this.route.snapshot.params.dashboardId || ''; |
|
|
|
if (this.dashboardId === dashboardId) { |
|
|
|
const newState = this.decodeStateParam(paramMap.get('state')); |
|
|
|
if (this.currentState !== newState) { |
|
|
|
this.currentState = newState; |
|
|
|
if (this.inited) { |
|
|
|
this.onStateChanged(); |
|
|
|
if (this.syncStateWithQueryParam) { |
|
|
|
this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => { |
|
|
|
const dashboardId = this.route.snapshot.params.dashboardId || ''; |
|
|
|
if (this.dashboardId === dashboardId) { |
|
|
|
const newState = this.decodeStateParam(paramMap.get('state')); |
|
|
|
if (this.currentState !== newState) { |
|
|
|
this.currentState = newState; |
|
|
|
if (this.inited) { |
|
|
|
this.onStateChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
this.init(); |
|
|
|
this.inited = true; |
|
|
|
} |
|
|
|
@ -124,16 +128,18 @@ export abstract class StateControllerComponent implements IStateControllerCompon |
|
|
|
|
|
|
|
protected updateStateParam(newState: string) { |
|
|
|
this.currentState = newState; |
|
|
|
const queryParams: Params = { state: this.currentState }; |
|
|
|
this.ngZone.run(() => { |
|
|
|
this.router.navigate( |
|
|
|
[], |
|
|
|
{ |
|
|
|
relativeTo: this.route, |
|
|
|
queryParams, |
|
|
|
queryParamsHandling: 'merge', |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (this.syncStateWithQueryParam) { |
|
|
|
const queryParams: Params = {state: this.currentState}; |
|
|
|
this.ngZone.run(() => { |
|
|
|
this.router.navigate( |
|
|
|
[], |
|
|
|
{ |
|
|
|
relativeTo: this.route, |
|
|
|
queryParams, |
|
|
|
queryParamsHandling: 'merge', |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public openRightLayout(): void { |
|
|
|
|