[bugfix] retain sorting state after monitor list auto-refresh (#3156)

Co-authored-by: tomsun28 <tomsun28@outlook.com>
This commit is contained in:
LL-LIN
2025-03-22 11:48:34 +08:00
committed by GitHub
co-authored by tomsun28
parent 63d3d18428
commit a331c045ae
@@ -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