Fix pagination on timewindow updated
This commit is contained in:
parent
4cb3319f1d
commit
c8ce826b7c
@ -67,7 +67,7 @@ import {
|
||||
KeyFilter,
|
||||
updateDatasourceFromEntityInfo
|
||||
} from '@shared/models/query/query.models';
|
||||
import { filter, map, switchMap, takeUntil } from 'rxjs/operators';
|
||||
import { distinct, filter, map, switchMap, takeUntil } from 'rxjs/operators';
|
||||
import { AlarmDataListener } from '@core/api/alarm-data.service';
|
||||
import { RpcStatus } from '@shared/models/rpc.models';
|
||||
|
||||
@ -139,6 +139,11 @@ export class WidgetSubscription implements IWidgetSubscription {
|
||||
executingSubjects: Array<Subject<any>>;
|
||||
|
||||
subscribed = false;
|
||||
widgetTimewindowChangedSubject: Subject<WidgetTimewindow> = new ReplaySubject<WidgetTimewindow>();
|
||||
|
||||
widgetTimewindowChanged = this.widgetTimewindowChangedSubject.asObservable().pipe(
|
||||
distinct()
|
||||
);
|
||||
|
||||
constructor(subscriptionContext: WidgetSubscriptionContext, public options: WidgetSubscriptionOptions) {
|
||||
const subscriptionSubject = new ReplaySubject<IWidgetSubscription>();
|
||||
@ -805,6 +810,7 @@ export class WidgetSubscription implements IWidgetSubscription {
|
||||
|
||||
update(isTimewindowTypeChanged = false) {
|
||||
if (this.type !== widgetType.rpc) {
|
||||
this.widgetTimewindowChangedSubject.next(this.timeWindowConfig);
|
||||
if (this.type === widgetType.alarm) {
|
||||
this.updateAlarmDataSubscription();
|
||||
} else {
|
||||
|
||||
@ -139,6 +139,7 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
|
||||
private rowStylesInfo: RowStyleInfo;
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
private widgetTimewindowChangedSubscription: Subscription;
|
||||
|
||||
private searchAction: WidgetAction = {
|
||||
name: 'action.search',
|
||||
@ -169,6 +170,23 @@ export class TimeseriesTableWidgetComponent extends PageComponent implements OnI
|
||||
this.datasources = this.ctx.datasources;
|
||||
this.initialize();
|
||||
this.ctx.updateWidgetParams();
|
||||
|
||||
this.widgetTimewindowChangedSubscription = this.ctx.defaultSubscription.widgetTimewindowChanged.subscribe(
|
||||
() => {
|
||||
this.sources.forEach((source) => {
|
||||
if (this.displayPagination) {
|
||||
source.pageLink.page = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
if (this.widgetTimewindowChangedSubscription) {
|
||||
this.widgetTimewindowChangedSubscription.unsubscribe();
|
||||
this.widgetTimewindowChangedSubscription = null;
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user