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 | 67 | KeyFilter, |
68 | 68 | updateDatasourceFromEntityInfo |
69 | 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 | 71 | import { AlarmDataListener } from '@core/api/alarm-data.service'; |
72 | 72 | import { RpcStatus } from '@shared/models/rpc.models'; |
73 | 73 | |
... | ... | @@ -139,6 +139,11 @@ export class WidgetSubscription implements IWidgetSubscription { |
139 | 139 | executingSubjects: Array<Subject<any>>; |
140 | 140 | |
141 | 141 | subscribed = false; |
142 | + widgetTimewindowChangedSubject: Subject<WidgetTimewindow> = new ReplaySubject<WidgetTimewindow>(); | |
143 | + | |
144 | + widgetTimewindowChanged = this.widgetTimewindowChangedSubject.asObservable().pipe( | |
145 | + distinct() | |
146 | + ); | |
142 | 147 | |
143 | 148 | constructor(subscriptionContext: WidgetSubscriptionContext, public options: WidgetSubscriptionOptions) { |
144 | 149 | const subscriptionSubject = new ReplaySubject<IWidgetSubscription>(); |
... | ... | @@ -805,6 +810,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
805 | 810 | |
806 | 811 | update(isTimewindowTypeChanged = false) { |
807 | 812 | if (this.type !== widgetType.rpc) { |
813 | + this.widgetTimewindowChangedSubject.next(this.timeWindowConfig); | |
808 | 814 | if (this.type === widgetType.alarm) { |
809 | 815 | this.updateAlarmDataSubscription(); |
810 | 816 | } else { | ... | ... |
... | ... | @@ -139,6 +139,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI |
139 | 139 | private rowStylesInfo: RowStyleInfo; |
140 | 140 | |
141 | 141 | private subscriptions: Subscription[] = []; |
142 | + private widgetTimewindowChangedSubscription: Subscription; | |
142 | 143 | |
143 | 144 | private searchAction: WidgetAction = { |
144 | 145 | name: 'action.search', |
... | ... | @@ -169,6 +170,23 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI |
169 | 170 | this.datasources = this.ctx.datasources; |
170 | 171 | this.initialize(); |
171 | 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 | 192 | ngAfterViewInit(): void { | ... | ... |