Commit c8ce826b7cc7b7898f7328958bb8d73ed7d469b1
1 parent
4cb3319f
Fix pagination on timewindow updated
Showing
2 changed files
with
25 additions
and
1 deletions
@@ -67,7 +67,7 @@ import { | @@ -67,7 +67,7 @@ import { | ||
67 | KeyFilter, | 67 | KeyFilter, |
68 | updateDatasourceFromEntityInfo | 68 | updateDatasourceFromEntityInfo |
69 | } from '@shared/models/query/query.models'; | 69 | } from '@shared/models/query/query.models'; |
70 | -import { filter, map, switchMap, takeUntil } from 'rxjs/operators'; | 70 | +import { distinct, filter, map, switchMap, takeUntil } from 'rxjs/operators'; |
71 | import { AlarmDataListener } from '@core/api/alarm-data.service'; | 71 | import { AlarmDataListener } from '@core/api/alarm-data.service'; |
72 | import { RpcStatus } from '@shared/models/rpc.models'; | 72 | import { RpcStatus } from '@shared/models/rpc.models'; |
73 | 73 | ||
@@ -139,6 +139,11 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -139,6 +139,11 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
139 | executingSubjects: Array<Subject<any>>; | 139 | executingSubjects: Array<Subject<any>>; |
140 | 140 | ||
141 | subscribed = false; | 141 | subscribed = false; |
142 | + widgetTimewindowChangedSubject: Subject<WidgetTimewindow> = new ReplaySubject<WidgetTimewindow>(); | ||
143 | + | ||
144 | + widgetTimewindowChanged = this.widgetTimewindowChangedSubject.asObservable().pipe( | ||
145 | + distinct() | ||
146 | + ); | ||
142 | 147 | ||
143 | constructor(subscriptionContext: WidgetSubscriptionContext, public options: WidgetSubscriptionOptions) { | 148 | constructor(subscriptionContext: WidgetSubscriptionContext, public options: WidgetSubscriptionOptions) { |
144 | const subscriptionSubject = new ReplaySubject<IWidgetSubscription>(); | 149 | const subscriptionSubject = new ReplaySubject<IWidgetSubscription>(); |
@@ -805,6 +810,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -805,6 +810,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
805 | 810 | ||
806 | update(isTimewindowTypeChanged = false) { | 811 | update(isTimewindowTypeChanged = false) { |
807 | if (this.type !== widgetType.rpc) { | 812 | if (this.type !== widgetType.rpc) { |
813 | + this.widgetTimewindowChangedSubject.next(this.timeWindowConfig); | ||
808 | if (this.type === widgetType.alarm) { | 814 | if (this.type === widgetType.alarm) { |
809 | this.updateAlarmDataSubscription(); | 815 | this.updateAlarmDataSubscription(); |
810 | } else { | 816 | } else { |
@@ -139,6 +139,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | @@ -139,6 +139,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | ||
139 | private rowStylesInfo: RowStyleInfo; | 139 | private rowStylesInfo: RowStyleInfo; |
140 | 140 | ||
141 | private subscriptions: Subscription[] = []; | 141 | private subscriptions: Subscription[] = []; |
142 | + private widgetTimewindowChangedSubscription: Subscription; | ||
142 | 143 | ||
143 | private searchAction: WidgetAction = { | 144 | private searchAction: WidgetAction = { |
144 | name: 'action.search', | 145 | name: 'action.search', |
@@ -169,6 +170,23 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | @@ -169,6 +170,23 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | ||
169 | this.datasources = this.ctx.datasources; | 170 | this.datasources = this.ctx.datasources; |
170 | this.initialize(); | 171 | this.initialize(); |
171 | this.ctx.updateWidgetParams(); | 172 | this.ctx.updateWidgetParams(); |
173 | + | ||
174 | + this.widgetTimewindowChangedSubscription = this.ctx.defaultSubscription.widgetTimewindowChanged.subscribe( | ||
175 | + () => { | ||
176 | + this.sources.forEach((source) => { | ||
177 | + if (this.displayPagination) { | ||
178 | + source.pageLink.page = 0; | ||
179 | + } | ||
180 | + }); | ||
181 | + } | ||
182 | + ); | ||
183 | + } | ||
184 | + | ||
185 | + ngOnDestroy(): void { | ||
186 | + if (this.widgetTimewindowChangedSubscription) { | ||
187 | + this.widgetTimewindowChangedSubscription.unsubscribe(); | ||
188 | + this.widgetTimewindowChangedSubscription = null; | ||
189 | + } | ||
172 | } | 190 | } |
173 | 191 | ||
174 | ngAfterViewInit(): void { | 192 | ngAfterViewInit(): void { |