diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts index 06e0cb73ad..8d776ce239 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/alarm/alarms-table-widget.component.ts +++ b/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) => { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts index cd43dbdf19..7c84293b37 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/entity/entities-table-widget.component.ts +++ b/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) => {