From 4f23631e194d25d8fc03d309a53acd5bb804d3bf Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sat, 16 Apr 2022 22:11:40 +0800 Subject: [PATCH] [web-app]bugfix: filter is missing when alert-center pageSize change --- .../layout/basic/widgets/notify.component.ts | 2 +- .../alert-center/alert-center.component.html | 4 +- .../alert-center/alert-center.component.ts | 43 ++++--------------- .../routes/dashboard/dashboard.component.ts | 2 +- web-app/src/app/service/alert.service.ts | 17 +------- 5 files changed, 14 insertions(+), 54 deletions(-) diff --git a/web-app/src/app/layout/basic/widgets/notify.component.ts b/web-app/src/app/layout/basic/widgets/notify.component.ts index 3fe728d..ea89ed0 100644 --- a/web-app/src/app/layout/basic/widgets/notify.component.ts +++ b/web-app/src/app/layout/basic/widgets/notify.component.ts @@ -54,7 +54,7 @@ export class HeaderNotifyComponent implements OnInit { return; } this.loading = true; - let loadAlerts$ = this.alertSvc.searchAlerts(0, undefined, undefined, 0, 5).subscribe( + let loadAlerts$ = this.alertSvc.loadAlerts(0, undefined, undefined, 0, 5).subscribe( message => { loadAlerts$.unsubscribe(); if (message.code === 0) { diff --git a/web-app/src/app/routes/alert/alert-center/alert-center.component.html b/web-app/src/app/routes/alert/alert-center/alert-center.component.html index 482aab1..9d6877f 100644 --- a/web-app/src/app/routes/alert/alert-center/alert-center.component.html +++ b/web-app/src/app/routes/alert/alert-center/alert-center.component.html @@ -30,7 +30,7 @@ - { - filterAlerts$.unsubscribe(); this.tableLoading = false; this.checkedAll = false; this.checkedAlertIds.clear(); @@ -54,44 +57,16 @@ export class AlertCenterComponent implements OnInit { } else { console.warn(message.msg); } + alertsInit$.unsubscribe(); }, error => { this.tableLoading = false; - filterAlerts$.unsubscribe(); + alertsInit$.unsubscribe(); console.error(error.msg); } ); } - sync() { - this.loadAlertsTable(); - } - - loadAlertsTable() { - this.tableLoading = true; - let alertsInit$ = this.alertSvc.getAlerts(this.pageIndex - 1, this.pageSize).subscribe( - message => { - this.tableLoading = false; - this.checkedAll = false; - this.checkedAlertIds.clear(); - if (message.code === 0) { - let page = message.data; - this.alerts = page.content; - this.pageIndex = page.number + 1; - this.total = page.totalElements; - } else { - console.warn(message.msg); - } - alertsInit$.unsubscribe(); - }, - error => { - this.tableLoading = false; - alertsInit$.unsubscribe(); - console.error(error.msg); - } - ); - } - onDeleteAlerts() { if (this.checkedAlertIds == null || this.checkedAlertIds.size === 0) { this.notifySvc.warning(this.i18nSvc.fanyi('alert.center.notify.no-delete'), ''); diff --git a/web-app/src/app/routes/dashboard/dashboard.component.ts b/web-app/src/app/routes/dashboard/dashboard.component.ts index c8c9be8..68fa74e 100644 --- a/web-app/src/app/routes/dashboard/dashboard.component.ts +++ b/web-app/src/app/routes/dashboard/dashboard.component.ts @@ -347,7 +347,7 @@ export class DashboardComponent implements OnInit, OnDestroy { alertsDealLoading: boolean = true; refreshAlertContentList(): void { - let alertsInit$ = this.alertSvc.getAlerts(0, 4).subscribe( + let alertsInit$ = this.alertSvc.loadAlerts(undefined, undefined, undefined, 0, 4).subscribe( message => { if (message.code === 0) { let page = message.data; diff --git a/web-app/src/app/service/alert.service.ts b/web-app/src/app/service/alert.service.ts index 5280c98..439c2bd 100644 --- a/web-app/src/app/service/alert.service.ts +++ b/web-app/src/app/service/alert.service.ts @@ -16,22 +16,7 @@ const alerts_status_uri = '/alerts/status'; export class AlertService { constructor(private http: HttpClient) {} - public getAlerts(pageIndex: number, pageSize: number): Observable>> { - pageIndex = pageIndex ? pageIndex : 0; - pageSize = pageSize ? pageSize : 8; - // 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象 - let httpParams = new HttpParams(); - httpParams = httpParams.appendAll({ - sort: 'id', - order: 'desc', - pageIndex: pageIndex, - pageSize: pageSize - }); - const options = { params: httpParams }; - return this.http.get>>(alerts_uri, options); - } - - public searchAlerts( + public loadAlerts( status: number | undefined, priority: number | undefined, content: string | undefined,