From a331c045aede72652987f58445ea192bdbfaea46 Mon Sep 17 00:00:00 2001 From: LL-LIN <43002118+LL-LIN@users.noreply.github.com> Date: Sat, 22 Mar 2025 11:48:34 +0800 Subject: [PATCH] [bugfix] retain sorting state after monitor list auto-refresh (#3156) Co-authored-by: tomsun28 --- .../monitor/monitor-list/monitor-list.component.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.ts b/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.ts index f977a6e90a..70ff6aa4df 100644 --- a/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.ts +++ b/web-app/src/app/routes/monitor/monitor-list/monitor-list.component.ts @@ -72,6 +72,9 @@ export class MonitorListComponent implements OnInit, OnDestroy { appSearchOrigin: any[] = []; appSearchLoading = false; intervalId: any; + // save the current sorting status + currentSortField: string | null = null; + currentSortOrder: string | null = null; switchExportTypeModalFooter: ModalButtonOptions[] = [ { label: this.i18nSvc.fanyi('common.button.cancel'), type: 'default', onClick: () => (this.isSwitchExportTypeModalVisible = false) } @@ -149,7 +152,7 @@ export class MonitorListComponent implements OnInit, OnDestroy { } sync() { - this.loadMonitorTable(); + this.loadMonitorTable(this.currentSortField, this.currentSortOrder); } getAppIconName(app: string | undefined): string { @@ -499,9 +502,9 @@ export class MonitorListComponent implements OnInit, OnDestroy { this.pageIndex = pageIndex; this.pageSize = pageSize; const currentSort = sort.find(item => item.value !== null); - const sortField = (currentSort && currentSort.key) || null; - const sortOrder = (currentSort && currentSort.value) || null; - this.changeMonitorTable(sortField, sortOrder); + this.currentSortField = (currentSort && currentSort.key) || null; + this.currentSortOrder = (currentSort && currentSort.value) || null; + this.changeMonitorTable(this.currentSortField, this.currentSortOrder); } // begin: app type search filter