Commit e2e5694013a271b31c0b975ad070472afb7a1485
Committed by
GitHub
Merge pull request #5330 from ArtemDzhereleiko/bug-fix/table/pagination
[3.3.2] UI:Fixed tables pagination after updated
Showing
8 changed files
with
52 additions
and
3 deletions
@@ -282,6 +282,7 @@ export interface IWidgetSubscription { | @@ -282,6 +282,7 @@ export interface IWidgetSubscription { | ||
282 | hiddenData?: Array<{data: DataSet}>; | 282 | hiddenData?: Array<{data: DataSet}>; |
283 | timeWindowConfig?: Timewindow; | 283 | timeWindowConfig?: Timewindow; |
284 | timeWindow?: WidgetTimewindow; | 284 | timeWindow?: WidgetTimewindow; |
285 | + widgetTimewindowChanged$: Observable<WidgetTimewindow>; | ||
285 | comparisonEnabled?: boolean; | 286 | comparisonEnabled?: boolean; |
286 | comparisonTimeWindow?: WidgetTimewindow; | 287 | comparisonTimeWindow?: WidgetTimewindow; |
287 | 288 |
@@ -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 { |
@@ -1118,6 +1124,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -1118,6 +1124,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
1118 | 1124 | ||
1119 | destroy(): void { | 1125 | destroy(): void { |
1120 | this.unsubscribe(); | 1126 | this.unsubscribe(); |
1127 | + this.widgetTimewindowChangedSubject.complete(); | ||
1121 | for (const cafId of Object.keys(this.cafs)) { | 1128 | for (const cafId of Object.keys(this.cafs)) { |
1122 | if (this.cafs[cafId]) { | 1129 | if (this.cafs[cafId]) { |
1123 | this.cafs[cafId](); | 1130 | this.cafs[cafId](); |
@@ -198,6 +198,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -198,6 +198,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
198 | attributeScopeChanged(attributeScope: TelemetryType) { | 198 | attributeScopeChanged(attributeScope: TelemetryType) { |
199 | this.attributeScope = attributeScope; | 199 | this.attributeScope = attributeScope; |
200 | this.mode = 'default'; | 200 | this.mode = 'default'; |
201 | + this.paginator.pageIndex = 0; | ||
201 | this.updateData(true); | 202 | this.updateData(true); |
202 | } | 203 | } |
203 | 204 | ||
@@ -447,7 +448,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | @@ -447,7 +448,7 @@ export class AttributeTableComponent extends PageComponent implements AfterViewI | ||
447 | if (this.mode === 'widget') { | 448 | if (this.mode === 'widget') { |
448 | this.widgetsList = []; | 449 | this.widgetsList = []; |
449 | this.widgetsListCache = []; | 450 | this.widgetsListCache = []; |
450 | - this.widgetsCarouselIndex = 0; | 451 | + this.widgetsCarouselIndex = 0; |
451 | if (widgetsBundle) { | 452 | if (widgetsBundle) { |
452 | this.widgetsLoaded = false; | 453 | this.widgetsLoaded = false; |
453 | const bundleAlias = widgetsBundle.alias; | 454 | const bundleAlias = widgetsBundle.alias; |
@@ -242,6 +242,7 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo | @@ -242,6 +242,7 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo | ||
242 | if (this.breakpointObserverSubscription) { | 242 | if (this.breakpointObserverSubscription) { |
243 | this.breakpointObserverSubscription.unsubscribe(); | 243 | this.breakpointObserverSubscription.unsubscribe(); |
244 | } | 244 | } |
245 | + this.dashboardTimewindowChangedSubject.complete(); | ||
245 | this.gridster = null; | 246 | this.gridster = null; |
246 | } | 247 | } |
247 | 248 |
@@ -432,6 +432,9 @@ export class EntitiesTableComponent extends PageComponent implements AfterViewIn | @@ -432,6 +432,9 @@ export class EntitiesTableComponent extends PageComponent implements AfterViewIn | ||
432 | } | 432 | } |
433 | 433 | ||
434 | onTimewindowChange() { | 434 | onTimewindowChange() { |
435 | + if (this.displayPagination) { | ||
436 | + this.paginator.pageIndex = 0; | ||
437 | + } | ||
435 | this.updateData(); | 438 | this.updateData(); |
436 | } | 439 | } |
437 | 440 |
@@ -124,6 +124,7 @@ export class RelationTableComponent extends PageComponent implements AfterViewIn | @@ -124,6 +124,7 @@ export class RelationTableComponent extends PageComponent implements AfterViewIn | ||
124 | directionChanged(direction: EntitySearchDirection) { | 124 | directionChanged(direction: EntitySearchDirection) { |
125 | this.direction = direction; | 125 | this.direction = direction; |
126 | this.updateColumns(); | 126 | this.updateColumns(); |
127 | + this.paginator.pageIndex = 0; | ||
127 | this.updateData(true); | 128 | this.updateData(true); |
128 | } | 129 | } |
129 | 130 |
@@ -48,7 +48,7 @@ import cssjs from '@core/css/css'; | @@ -48,7 +48,7 @@ import cssjs from '@core/css/css'; | ||
48 | import { sortItems } from '@shared/models/page/page-link'; | 48 | import { sortItems } from '@shared/models/page/page-link'; |
49 | import { Direction } from '@shared/models/page/sort-order'; | 49 | import { Direction } from '@shared/models/page/sort-order'; |
50 | import { CollectionViewer, DataSource, SelectionModel } from '@angular/cdk/collections'; | 50 | import { CollectionViewer, DataSource, SelectionModel } from '@angular/cdk/collections'; |
51 | -import { BehaviorSubject, forkJoin, fromEvent, merge, Observable } from 'rxjs'; | 51 | +import { BehaviorSubject, forkJoin, fromEvent, merge, Observable, Subscription } from 'rxjs'; |
52 | import { emptyPageData, PageData } from '@shared/models/page/page-data'; | 52 | import { emptyPageData, PageData } from '@shared/models/page/page-data'; |
53 | import { entityTypeTranslations } from '@shared/models/entity-type.models'; | 53 | import { entityTypeTranslations } from '@shared/models/entity-type.models'; |
54 | import { debounceTime, distinctUntilChanged, map, take, tap } from 'rxjs/operators'; | 54 | import { debounceTime, distinctUntilChanged, map, take, tap } from 'rxjs/operators'; |
@@ -193,6 +193,8 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, | @@ -193,6 +193,8 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, | ||
193 | 193 | ||
194 | private rowStylesInfo: RowStyleInfo; | 194 | private rowStylesInfo: RowStyleInfo; |
195 | 195 | ||
196 | + private widgetTimewindowChanged$: Subscription; | ||
197 | + | ||
196 | private searchAction: WidgetAction = { | 198 | private searchAction: WidgetAction = { |
197 | name: 'action.search', | 199 | name: 'action.search', |
198 | show: true, | 200 | show: true, |
@@ -248,6 +250,19 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, | @@ -248,6 +250,19 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit, | ||
248 | this.initializeConfig(); | 250 | this.initializeConfig(); |
249 | this.updateAlarmSource(); | 251 | this.updateAlarmSource(); |
250 | this.ctx.updateWidgetParams(); | 252 | this.ctx.updateWidgetParams(); |
253 | + | ||
254 | + if (this.displayPagination) { | ||
255 | + this.widgetTimewindowChanged$ = this.ctx.defaultSubscription.widgetTimewindowChanged$.subscribe( | ||
256 | + () => this.pageLink.page = 0 | ||
257 | + ); | ||
258 | + } | ||
259 | + } | ||
260 | + | ||
261 | + ngOnDestroy(): void { | ||
262 | + if (this.widgetTimewindowChanged$) { | ||
263 | + this.widgetTimewindowChanged$.unsubscribe(); | ||
264 | + this.widgetTimewindowChanged$ = null; | ||
265 | + } | ||
251 | } | 266 | } |
252 | 267 | ||
253 | ngAfterViewInit(): void { | 268 | ngAfterViewInit(): void { |
@@ -147,6 +147,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | @@ -147,6 +147,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | ||
147 | private rowStylesInfo: RowStyleInfo; | 147 | private rowStylesInfo: RowStyleInfo; |
148 | 148 | ||
149 | private subscriptions: Subscription[] = []; | 149 | private subscriptions: Subscription[] = []; |
150 | + private widgetTimewindowChanged$: Subscription; | ||
150 | 151 | ||
151 | private searchAction: WidgetAction = { | 152 | private searchAction: WidgetAction = { |
152 | name: 'action.search', | 153 | name: 'action.search', |
@@ -176,6 +177,25 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | @@ -176,6 +177,25 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI | ||
176 | this.datasources = this.ctx.datasources; | 177 | this.datasources = this.ctx.datasources; |
177 | this.initialize(); | 178 | this.initialize(); |
178 | this.ctx.updateWidgetParams(); | 179 | this.ctx.updateWidgetParams(); |
180 | + | ||
181 | + if (this.displayPagination) { | ||
182 | + this.widgetTimewindowChanged$ = this.ctx.defaultSubscription.widgetTimewindowChanged$.subscribe( | ||
183 | + () => { | ||
184 | + this.sources.forEach((source) => { | ||
185 | + if (this.displayPagination) { | ||
186 | + source.pageLink.page = 0; | ||
187 | + } | ||
188 | + }); | ||
189 | + } | ||
190 | + ); | ||
191 | + } | ||
192 | + } | ||
193 | + | ||
194 | + ngOnDestroy(): void { | ||
195 | + if (this.widgetTimewindowChanged$) { | ||
196 | + this.widgetTimewindowChanged$.unsubscribe(); | ||
197 | + this.widgetTimewindowChanged$ = null; | ||
198 | + } | ||
179 | } | 199 | } |
180 | 200 | ||
181 | ngAfterViewInit(): void { | 201 | ngAfterViewInit(): void { |