[web-app]bugfix: filter is missing when alert-center pageSize change (#97)

This commit is contained in:
tomsun28
2022-04-16 22:16:55 +08:00
committed by GitHub
parent 7c54bf0203
commit 589d178586
5 changed files with 14 additions and 54 deletions

View File

@@ -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) {

View File

@@ -30,7 +30,7 @@
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="onFilterSearchAlerts()">
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="loadAlertsTable()">
{{ 'common.search' | i18n }}
</button>
<input
@@ -39,7 +39,7 @@
type="text"
[placeholder]="'alert.center.search' | i18n"
nzSize="default"
(keyup.enter)="onFilterSearchAlerts()"
(keyup.enter)="loadAlertsTable()"
[(ngModel)]="filterContent"
/>
<nz-select

View File

@@ -36,13 +36,16 @@ export class AlertCenterComponent implements OnInit {
this.loadAlertsTable();
}
onFilterSearchAlerts() {
sync() {
this.loadAlertsTable();
}
loadAlertsTable() {
this.tableLoading = true;
let filterAlerts$ = this.alertSvc
.searchAlerts(this.filterStatus, this.filterPriority, this.filterContent, this.pageIndex - 1, this.pageSize)
let alertsInit$ = this.alertSvc
.loadAlerts(this.filterStatus, this.filterPriority, this.filterContent, this.pageIndex - 1, this.pageSize)
.subscribe(
message => {
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'), '');

View File

@@ -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;

View File

@@ -16,22 +16,7 @@ const alerts_status_uri = '/alerts/status';
export class AlertService {
constructor(private http: HttpClient) {}
public getAlerts(pageIndex: number, pageSize: number): Observable<Message<Page<Alert>>> {
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<Message<Page<Alert>>>(alerts_uri, options);
}
public searchAlerts(
public loadAlerts(
status: number | undefined,
priority: number | undefined,
content: string | undefined,