Skip to content

Commit

Permalink
bugfix: search monitors error when pageable #1470 (#1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
avvCode authored Jan 16, 2024
1 parent ade96e1 commit 58c2dc8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ export class MonitorListComponent implements OnInit {
}
);
}
changeMonitorTable(sortField?: string | null, sortOrder?: string | null) {
this.tableLoading = true;
let monitorInit$ = this.monitorSvc
.searchMonitors(this.app, this.tag, this.filterContent, this.filterStatus, this.pageIndex - 1, this.pageSize, sortField, sortOrder)
.subscribe(
message => {
this.tableLoading = false;
this.checkedAll = false;
this.checkedMonitorIds.clear();
if (message.code === 0) {
let page = message.data;
this.monitors = page.content;
this.pageIndex = page.number + 1;
this.total = page.totalElements;
} else {
console.warn(message.msg);
}
monitorInit$.unsubscribe();
},
error => {
this.tableLoading = false;
monitorInit$.unsubscribe();
}
);
}

onEditOneMonitor(monitorId: number) {
if (monitorId == null) {
Expand Down Expand Up @@ -422,7 +447,7 @@ export class MonitorListComponent implements OnInit {
const currentSort = sort.find(item => item.value !== null);
const sortField = (currentSort && currentSort.key) || null;
const sortOrder = (currentSort && currentSort.value) || null;
this.loadMonitorTable(sortField, sortOrder);
this.changeMonitorTable(sortField, sortOrder);
}

protected readonly sliceTagName = formatTagName;
Expand Down
10 changes: 9 additions & 1 deletion web-app/src/app/service/monitor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export class MonitorService {
searchValue: string,
status: number,
pageIndex: number,
pageSize: number
pageSize: number,
sortField?: string | null,
sortOrder?: string | null
): Observable<Message<Page<Monitor>>> {
pageIndex = pageIndex ? pageIndex : 0;
pageSize = pageSize ? pageSize : 8;
Expand All @@ -148,6 +150,12 @@ export class MonitorService {
if (app != undefined) {
httpParams = httpParams.append('app', app);
}
if (sortField != null && sortOrder != null) {
httpParams = httpParams.appendAll({
sort: sortField,
order: sortOrder == 'ascend' ? 'asc' : 'desc'
});
}
if (searchValue != undefined && searchValue != '' && searchValue.trim() != '') {
httpParams = httpParams.append('name', searchValue);
httpParams = httpParams.append('host', searchValue);
Expand Down

0 comments on commit 58c2dc8

Please sign in to comment.