Commit 03fa7dcd416552d8ed0e42492dc557d5643bce27

Authored by Igor Kulikov
1 parent 6f2a4409

Do not use dashboard state param from url location inside embed dashboard dialog

@@ -53,6 +53,7 @@ @@ -53,6 +53,7 @@
53 [isMobile]="isMobile" 53 [isMobile]="isMobile"
54 [state]="dashboardCtx.state" 54 [state]="dashboardCtx.state"
55 [currentState]="currentState" 55 [currentState]="currentState"
  56 + [syncStateWithQueryParam]="syncStateWithQueryParam"
56 [states]="dashboardConfiguration.states"> 57 [states]="dashboardConfiguration.states">
57 </tb-states-component> 58 </tb-states-component>
58 </div> 59 </div>
@@ -124,6 +124,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC @@ -124,6 +124,9 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
124 hideToolbar: boolean; 124 hideToolbar: boolean;
125 125
126 @Input() 126 @Input()
  127 + syncStateWithQueryParam = true;
  128 +
  129 + @Input()
127 dashboard: Dashboard; 130 dashboard: Dashboard;
128 dashboardConfiguration: DashboardConfiguration; 131 dashboardConfiguration: DashboardConfiguration;
129 132
@@ -88,6 +88,8 @@ export abstract class StateControllerComponent implements IStateControllerCompon @@ -88,6 +88,8 @@ export abstract class StateControllerComponent implements IStateControllerCompon
88 88
89 currentState: string; 89 currentState: string;
90 90
  91 + syncStateWithQueryParam: boolean;
  92 +
91 private rxSubscriptions = new Array<Subscription>(); 93 private rxSubscriptions = new Array<Subscription>();
92 94
93 private inited = false; 95 private inited = false;
@@ -99,18 +101,20 @@ export abstract class StateControllerComponent implements IStateControllerCompon @@ -99,18 +101,20 @@ export abstract class StateControllerComponent implements IStateControllerCompon
99 } 101 }
100 102
101 ngOnInit(): void { 103 ngOnInit(): void {
102 - this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => {  
103 - const dashboardId = this.route.snapshot.params.dashboardId || '';  
104 - if (this.dashboardId === dashboardId) {  
105 - const newState = this.decodeStateParam(paramMap.get('state'));  
106 - if (this.currentState !== newState) {  
107 - this.currentState = newState;  
108 - if (this.inited) {  
109 - this.onStateChanged(); 104 + if (this.syncStateWithQueryParam) {
  105 + this.rxSubscriptions.push(this.route.queryParamMap.subscribe((paramMap) => {
  106 + const dashboardId = this.route.snapshot.params.dashboardId || '';
  107 + if (this.dashboardId === dashboardId) {
  108 + const newState = this.decodeStateParam(paramMap.get('state'));
  109 + if (this.currentState !== newState) {
  110 + this.currentState = newState;
  111 + if (this.inited) {
  112 + this.onStateChanged();
  113 + }
110 } 114 }
111 } 115 }
112 - }  
113 - })); 116 + }));
  117 + }
114 this.init(); 118 this.init();
115 this.inited = true; 119 this.inited = true;
116 } 120 }
@@ -124,16 +128,18 @@ export abstract class StateControllerComponent implements IStateControllerCompon @@ -124,16 +128,18 @@ export abstract class StateControllerComponent implements IStateControllerCompon
124 128
125 protected updateStateParam(newState: string) { 129 protected updateStateParam(newState: string) {
126 this.currentState = newState; 130 this.currentState = newState;
127 - const queryParams: Params = { state: this.currentState };  
128 - this.ngZone.run(() => {  
129 - this.router.navigate(  
130 - [],  
131 - {  
132 - relativeTo: this.route,  
133 - queryParams,  
134 - queryParamsHandling: 'merge',  
135 - });  
136 - }); 131 + if (this.syncStateWithQueryParam) {
  132 + const queryParams: Params = {state: this.currentState};
  133 + this.ngZone.run(() => {
  134 + this.router.navigate(
  135 + [],
  136 + {
  137 + relativeTo: this.route,
  138 + queryParams,
  139 + queryParamsHandling: 'merge',
  140 + });
  141 + });
  142 + }
137 } 143 }
138 144
139 public openRightLayout(): void { 145 public openRightLayout(): void {
@@ -24,6 +24,7 @@ export interface IStateControllerComponent extends IStateController { @@ -24,6 +24,7 @@ export interface IStateControllerComponent extends IStateController {
24 stateControllerInstanceId: string; 24 stateControllerInstanceId: string;
25 state: string; 25 state: string;
26 currentState: string; 26 currentState: string;
  27 + syncStateWithQueryParam: boolean;
27 isMobile: boolean; 28 isMobile: boolean;
28 states: {[id: string]: DashboardState }; 29 states: {[id: string]: DashboardState };
29 dashboardId: string; 30 dashboardId: string;
@@ -54,6 +54,9 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges { @@ -54,6 +54,9 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
54 currentState: string; 54 currentState: string;
55 55
56 @Input() 56 @Input()
  57 + syncStateWithQueryParam: boolean;
  58 +
  59 + @Input()
57 isMobile: boolean; 60 isMobile: boolean;
58 61
59 stateControllerComponentRef: ComponentRef<IStateControllerComponent>; 62 stateControllerComponentRef: ComponentRef<IStateControllerComponent>;
@@ -89,6 +92,8 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges { @@ -89,6 +92,8 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
89 this.stateControllerComponent.state = this.state; 92 this.stateControllerComponent.state = this.state;
90 } else if (propName === 'currentState') { 93 } else if (propName === 'currentState') {
91 this.stateControllerComponent.currentState = this.currentState; 94 this.stateControllerComponent.currentState = this.currentState;
  95 + } else if (propName === 'syncStateWithQueryParam') {
  96 + this.stateControllerComponent.syncStateWithQueryParam = this.syncStateWithQueryParam;
92 } 97 }
93 } 98 }
94 } 99 }
@@ -119,6 +124,7 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges { @@ -119,6 +124,7 @@ export class StatesComponentDirective implements OnInit, OnDestroy, OnChanges {
119 this.stateControllerComponent.stateControllerInstanceId = stateControllerInstanceId; 124 this.stateControllerComponent.stateControllerInstanceId = stateControllerInstanceId;
120 this.stateControllerComponent.state = this.state; 125 this.stateControllerComponent.state = this.state;
121 this.stateControllerComponent.currentState = this.currentState; 126 this.stateControllerComponent.currentState = this.currentState;
  127 + this.stateControllerComponent.syncStateWithQueryParam = this.syncStateWithQueryParam;
122 this.stateControllerComponent.isMobile = this.isMobile; 128 this.stateControllerComponent.isMobile = this.isMobile;
123 this.stateControllerComponent.states = this.states; 129 this.stateControllerComponent.states = this.states;
124 this.stateControllerComponent.dashboardId = this.dashboardId; 130 this.stateControllerComponent.dashboardId = this.dashboardId;
@@ -27,7 +27,8 @@ @@ -27,7 +27,8 @@
27 </mat-progress-bar> 27 </mat-progress-bar>
28 <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div> 28 <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
29 <div class="dashboard-state-dialog-content" mat-dialog-content fxFlex fxLayout="column" style="padding: 8px;"> 29 <div class="dashboard-state-dialog-content" mat-dialog-content fxFlex fxLayout="column" style="padding: 8px;">
30 - <tb-dashboard-page [embedded]="true" [hideToolbar]="hideToolbar" [currentState]="state" [dashboard]="dashboard" style="width: 100%; height: 100%;"></tb-dashboard-page> 30 + <tb-dashboard-page [embedded]="true" [syncStateWithQueryParam]="false" [hideToolbar]="hideToolbar"
  31 + [currentState]="state" [dashboard]="dashboard" style="width: 100%; height: 100%;"></tb-dashboard-page>
31 </div> 32 </div>
32 <div mat-dialog-actions fxLayoutAlign="end center"> 33 <div mat-dialog-actions fxLayoutAlign="end center">
33 <button mat-button color="primary" 34 <button mat-button color="primary"