Browse Source

Fixed reset of Entities table widget pagination on dashboard state update

pull/15549/head
Maksym Tsymbarov 1 month ago
parent
commit
5aedafc3ff
  1. 22
      ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts
  2. 13
      ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts

22
ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts

@ -37,7 +37,16 @@ import { DataKey, WidgetActionDescriptor, WidgetConfig } from '@shared/models/wi
import { IWidgetSubscription } from '@core/api/widget-api.models';
import { UtilsService } from '@core/services/utils.service';
import { TranslateService } from '@ngx-translate/core';
import { deepClone, hashCode, isDefined, isDefinedAndNotNull, isNotEmptyStr, isObject, isUndefined } from '@core/utils';
import {
deepClone,
hashCode,
isDefined,
isDefinedAndNotNull,
isEqual,
isNotEmptyStr,
isObject,
isUndefined
} from '@core/utils';
import cssjs from '@core/css/css';
import { sortItems } from '@shared/models/page/page-link';
import { Direction } from '@shared/models/page/sort-order';
@ -324,6 +333,17 @@ export class AlarmsTableWidgetComponent extends PageComponent implements OnInit,
if (this.displayPagination) {
this.sort.sortChange.pipe(takeUntil(this.destroy$)).subscribe(() => this.paginator.pageIndex = 0);
let currentStateParams = deepClone(this.ctx.stateController?.getStateParams());
this.ctx.stateController?.stateChanged().pipe(
takeUntil(this.destroy$)
).subscribe(() => {
const newStateParams = this.ctx.stateController.getStateParams();
if (!isEqual(currentStateParams, newStateParams)) {
currentStateParams = deepClone(newStateParams);
this.paginator.firstPage();
}
});
this.ctx.aliasController?.filtersChanged.pipe(
takeUntil(this.destroy$)
).subscribe((filters) => {

13
ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts

@ -42,7 +42,7 @@ import {
import { IWidgetSubscription } from '@core/api/widget-api.models';
import { UtilsService } from '@core/services/utils.service';
import { TranslateService } from '@ngx-translate/core';
import { deepClone, hashCode, isDefined, isDefinedAndNotNull, isObject, isUndefined } from '@core/utils';
import { deepClone, hashCode, isDefined, isDefinedAndNotNull, isEqual, isObject, isUndefined } from '@core/utils';
import cssjs from '@core/css/css';
import { CollectionViewer, DataSource } from '@angular/cdk/collections';
import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
@ -267,6 +267,17 @@ export class EntitiesTableWidgetComponent extends PageComponent implements OnIni
if (this.displayPagination) {
this.sort.sortChange.pipe(takeUntil(this.destroy$)).subscribe(() => this.paginator.pageIndex = 0);
let currentStateParams = deepClone(this.ctx.stateController?.getStateParams());
this.ctx.stateController?.stateChanged().pipe(
takeUntil(this.destroy$)
).subscribe(() => {
const newStateParams = this.ctx.stateController.getStateParams();
if (!isEqual(currentStateParams, newStateParams)) {
currentStateParams = deepClone(newStateParams);
this.paginator.firstPage();
}
});
this.ctx.aliasController?.filtersChanged.pipe(
takeUntil(this.destroy$)
).subscribe((filters) => {

Loading…
Cancel
Save