[web-app] bugfix-监控列表分页问题
This commit is contained in:
@@ -40,7 +40,7 @@ public class MonitorController {
|
|||||||
public ResponseEntity<Message<Void>> addNewMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
public ResponseEntity<Message<Void>> addNewMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
||||||
// 校验请求数据
|
// 校验请求数据
|
||||||
monitorService.validate(monitorDto, false);
|
monitorService.validate(monitorDto, false);
|
||||||
if (monitorDto.getDetected()) {
|
if (monitorDto.isDetected()) {
|
||||||
// 进行探测
|
// 进行探测
|
||||||
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class MonitorController {
|
|||||||
public ResponseEntity<Message<Void>> modifyMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
public ResponseEntity<Message<Void>> modifyMonitor(@Valid @RequestBody MonitorDto monitorDto) {
|
||||||
// 校验请求数据
|
// 校验请求数据
|
||||||
monitorService.validate(monitorDto, true);
|
monitorService.validate(monitorDto, true);
|
||||||
if (monitorDto.getDetected()) {
|
if (monitorDto.isDetected()) {
|
||||||
// 进行探测
|
// 进行探测
|
||||||
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
monitorService.detectMonitor(monitorDto.getMonitor(), monitorDto.getParams());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,5 +41,5 @@ public class MonitorDto {
|
|||||||
* 是否探测
|
* 是否探测
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "是否进行探测", accessMode = READ_WRITE, position = 2)
|
@ApiModelProperty(value = "是否进行探测", accessMode = READ_WRITE, position = 2)
|
||||||
private Boolean detected;
|
private boolean detected;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ export class MonitorEditComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.paramMap.pipe(
|
this.route.paramMap.pipe(
|
||||||
switchMap((paramMap: ParamMap) => {
|
switchMap((paramMap: ParamMap) => {
|
||||||
|
this.isSpinning = false;
|
||||||
|
this.passwordVisible = false;
|
||||||
let id = paramMap.get("monitorId");
|
let id = paramMap.get("monitorId");
|
||||||
this.monitor.id = Number(id);
|
this.monitor.id = Number(id);
|
||||||
// 查询监控信息
|
// 查询监控信息
|
||||||
@@ -51,7 +53,7 @@ export class MonitorEditComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.params = message.data.params;
|
this.params = message.data.params;
|
||||||
this.detected = message.data.detected;
|
this.detected = message.data.detected? message.data.detected : true;
|
||||||
} else {
|
} else {
|
||||||
console.warn(message.msg);
|
console.warn(message.msg);
|
||||||
this.notifySvc.error("查询异常,此监控不存在", message.msg);
|
this.notifySvc.error("查询异常,此监控不存在", message.msg);
|
||||||
@@ -132,7 +134,7 @@ export class MonitorEditComponent implements OnInit {
|
|||||||
"params": this.params
|
"params": this.params
|
||||||
};
|
};
|
||||||
this.isSpinning = true;
|
this.isSpinning = true;
|
||||||
this.monitorSvc.editMonitor(detectMonitor)
|
this.monitorSvc.detectMonitor(detectMonitor)
|
||||||
.subscribe(message => {
|
.subscribe(message => {
|
||||||
this.isSpinning = false;
|
this.isSpinning = false;
|
||||||
if (message.code === 0) {
|
if (message.code === 0) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</nz-breadcrumb-item>
|
</nz-breadcrumb-item>
|
||||||
<nz-breadcrumb-item>
|
<nz-breadcrumb-item>
|
||||||
<i nz-icon nzType="monitor"></i>
|
<i nz-icon nzType="monitor"></i>
|
||||||
<span>监控列表 {{app?app.toUpperCase() : ""}}</span>
|
<span>{{app?app.toUpperCase() : ""}} 监控列表</span>
|
||||||
</nz-breadcrumb-item>
|
</nz-breadcrumb-item>
|
||||||
</nz-breadcrumb>
|
</nz-breadcrumb>
|
||||||
<nz-divider></nz-divider>
|
<nz-divider></nz-divider>
|
||||||
@@ -36,16 +36,17 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<nz-table #fixedTable [nzData]="monitors"
|
<nz-table #fixedTable [nzData]="monitors"
|
||||||
[nzPageIndex]="pageIndex" [nzPageSize]="pageSize"
|
[nzPageIndex]="pageIndex" [nzPageSize]="pageSize" [nzTotal]="total"
|
||||||
|
nzFrontPagination ="false"
|
||||||
[nzLoading] = "tableLoading"
|
[nzLoading] = "tableLoading"
|
||||||
nzShowSizeChanger
|
nzShowSizeChanger
|
||||||
[nzTotal]="pageTotal"
|
|
||||||
[nzShowTotal]="rangeTemplate"
|
[nzShowTotal]="rangeTemplate"
|
||||||
[nzPageSizeOptions]="[8,15,25]"
|
[nzPageSizeOptions]="[8,15,25]"
|
||||||
|
(nzQueryParams)="onTablePageChange($event)"
|
||||||
nzShowPagination = "true" [nzScroll]="{ x: '1150px', y: '1240px' }">
|
nzShowPagination = "true" [nzScroll]="{ x: '1150px', y: '1240px' }">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th nzAlign="center" nzLeft nzWidth="50px" [nzChecked]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
|
<th nzAlign="center" nzLeft nzWidth="60px" [nzChecked]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
|
||||||
<th nzAlign="center">监控名称</th>
|
<th nzAlign="center">监控名称</th>
|
||||||
<th nzAlign="center">监控状态</th>
|
<th nzAlign="center">监控状态</th>
|
||||||
<th nzAlign="center">监控主机Host</th>
|
<th nzAlign="center">监控主机Host</th>
|
||||||
@@ -81,5 +82,5 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<ng-template #rangeTemplate>
|
<ng-template #rangeTemplate>
|
||||||
总量 {{ pageTotal }}
|
总量 {{ total }}
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {Page} from "../../../pojo/Page";
|
|||||||
import {NzModalService} from "ng-zorro-antd/modal";
|
import {NzModalService} from "ng-zorro-antd/modal";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {NzMessageService} from "ng-zorro-antd/message";
|
import {NzMessageService} from "ng-zorro-antd/message";
|
||||||
|
import {NzTableQueryParams} from "ng-zorro-antd/table";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-monitor-list',
|
selector: 'app-monitor-list',
|
||||||
@@ -25,7 +26,7 @@ export class MonitorListComponent implements OnInit {
|
|||||||
app!: string;
|
app!: string;
|
||||||
pageIndex: number = 1;
|
pageIndex: number = 1;
|
||||||
pageSize: number = 8;
|
pageSize: number = 8;
|
||||||
pageTotal: number = 0;
|
total: number = 0;
|
||||||
monitors!: Monitor[];
|
monitors!: Monitor[];
|
||||||
pageMonitors!: Page<Monitor>;
|
pageMonitors!: Page<Monitor>;
|
||||||
tableLoading: boolean = true;
|
tableLoading: boolean = true;
|
||||||
@@ -35,11 +36,13 @@ export class MonitorListComponent implements OnInit {
|
|||||||
this.route.queryParamMap
|
this.route.queryParamMap
|
||||||
.subscribe(paramMap => {
|
.subscribe(paramMap => {
|
||||||
this.app = paramMap.get("app") || '';
|
this.app = paramMap.get("app") || '';
|
||||||
this.initMonitorTable();
|
this.pageIndex = 1;
|
||||||
|
this.pageSize = 8;
|
||||||
|
this.loadMonitorTable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initMonitorTable() {
|
loadMonitorTable() {
|
||||||
let monitorInit$ = this.monitorSvc.getMonitors(this.app, this.pageIndex - 1, this.pageSize)
|
let monitorInit$ = this.monitorSvc.getMonitors(this.app, this.pageIndex - 1, this.pageSize)
|
||||||
.subscribe(message => {
|
.subscribe(message => {
|
||||||
this.tableLoading = false;
|
this.tableLoading = false;
|
||||||
@@ -47,7 +50,7 @@ export class MonitorListComponent implements OnInit {
|
|||||||
this.pageMonitors = message.data;
|
this.pageMonitors = message.data;
|
||||||
this.monitors = this.pageMonitors.content;
|
this.monitors = this.pageMonitors.content;
|
||||||
this.pageIndex = this.pageMonitors.number + 1;
|
this.pageIndex = this.pageMonitors.number + 1;
|
||||||
this.pageTotal = this.pageMonitors.totalElements;
|
this.total = this.pageMonitors.totalElements;
|
||||||
} else {
|
} else {
|
||||||
console.warn(message.msg);
|
console.warn(message.msg);
|
||||||
}
|
}
|
||||||
@@ -123,7 +126,7 @@ export class MonitorListComponent implements OnInit {
|
|||||||
deleteMonitors$.unsubscribe();
|
deleteMonitors$.unsubscribe();
|
||||||
if (message.code === 0) {
|
if (message.code === 0) {
|
||||||
this.notifySvc.success("删除成功!", "");
|
this.notifySvc.success("删除成功!", "");
|
||||||
this.initMonitorTable();
|
this.loadMonitorTable();
|
||||||
} else {
|
} else {
|
||||||
this.notifySvc.error("删除失败!", message.msg);
|
this.notifySvc.error("删除失败!", message.msg);
|
||||||
}
|
}
|
||||||
@@ -154,5 +157,15 @@ export class MonitorListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
// end: 列表多选逻辑
|
// end: 列表多选逻辑
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页回调
|
||||||
|
* @param params 页码信息
|
||||||
|
*/
|
||||||
|
onTablePageChange(params: NzTableQueryParams) {
|
||||||
|
const { pageSize, pageIndex, sort, filter } = params;
|
||||||
|
this.pageIndex = pageIndex;
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
this.loadMonitorTable();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,12 @@ export class MonitorNewComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const paramDefine$ = this.route.queryParamMap.pipe(
|
this.route.queryParamMap.pipe(
|
||||||
switchMap((paramMap: ParamMap) => {
|
switchMap((paramMap: ParamMap) => {
|
||||||
this.monitor.app = paramMap.get("app") || '';
|
this.monitor.app = paramMap.get("app") || '';
|
||||||
|
this.detected = true;
|
||||||
|
this.passwordVisible = false;
|
||||||
|
this.isSpinning = false;
|
||||||
return this.appDefineSvc.getAppParamsDefine(this.monitor.app);
|
return this.appDefineSvc.getAppParamsDefine(this.monitor.app);
|
||||||
})
|
})
|
||||||
).subscribe(message => {
|
).subscribe(message => {
|
||||||
@@ -57,7 +60,6 @@ export class MonitorNewComponent implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
console.warn(message.msg);
|
console.warn(message.msg);
|
||||||
}
|
}
|
||||||
paramDefine$.unsubscribe();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export class MonitorService {
|
|||||||
|
|
||||||
public getMonitors(app: string, pageIndex: number, pageSize: number) : Observable<Message<Page<Monitor>>> {
|
public getMonitors(app: string, pageIndex: number, pageSize: number) : Observable<Message<Page<Monitor>>> {
|
||||||
app = app.trim();
|
app = app.trim();
|
||||||
pageIndex = pageIndex ? 1 : pageIndex;
|
pageIndex = pageIndex ? pageIndex : 0;
|
||||||
pageSize = pageSize ? 10 : pageSize;
|
pageSize = pageSize ? pageSize : 8;
|
||||||
// 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象
|
// 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象
|
||||||
let httpParams = new HttpParams();
|
let httpParams = new HttpParams();
|
||||||
httpParams = httpParams.appendAll({
|
httpParams = httpParams.appendAll({
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { MyServiceService } from './my-service.service';
|
|
||||||
|
|
||||||
describe('MyServiceService', () => {
|
|
||||||
let service: MyServiceService;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
TestBed.configureTestingModule({});
|
|
||||||
service = TestBed.inject(MyServiceService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be created', () => {
|
|
||||||
expect(service).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class MyServiceService {
|
|
||||||
|
|
||||||
constructor() { }
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user