[web-app,manager] 监控启动取消纳管功能

This commit is contained in:
tomsun28
2021-12-03 21:25:26 +08:00
parent 96f962736e
commit 204072cb92
6 changed files with 206 additions and 8 deletions

View File

@@ -26,11 +26,11 @@
<i nz-icon nzType="delete" nzTheme="outline"></i>
删除
</button>
<button nz-button nzType="primary">
<button nz-button nzType="primary" (click)="onEnableManageMonitors()">
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
纳管
纳管
</button>
<button nz-button nzType="primary">
<button nz-button nzType="primary" (click)="onCancelManageMonitors()">
<i nz-icon nzType="down-circle" nzTheme="outline"></i>
取消纳管
</button>
@@ -93,13 +93,13 @@
<button nz-button nzType="primary" (click)="onEditOneMonitor(data.id)">
<i nz-icon nzType="edit" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary"(click)="onDeleteOneMonitor(data.id)">
<button nz-button nzType="primary" (click)="onDeleteOneMonitor(data.id)">
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary">
<button nz-button nzType="primary" (click)="onEnableManageOneMonitor(data.id)">
<i nz-icon nzType="up-circle" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary">
<button nz-button nzType="primary" (click)="onCancelManageOneMonitor(data.id)">
<i nz-icon nzType="down-circle" nzTheme="outline"></i>
</button>
</td>

View File

@@ -38,6 +38,8 @@ export class MonitorListComponent implements OnInit {
this.app = paramMap.get("app") || '';
this.pageIndex = 1;
this.pageSize = 8;
this.checkedMonitorIds = new Set<number>();
this.tableLoading = true;
this.loadMonitorTable();
});
}
@@ -138,6 +140,97 @@ export class MonitorListComponent implements OnInit {
);
}
onCancelManageMonitors() {
if (this.checkedMonitorIds == null || this.checkedMonitorIds.size === 0) {
this.notifySvc.warning("未选中任何待取消项!","");
return;
}
this.modal.confirm({
nzTitle: '请确认是否批量取消纳管!',
nzOkText: '确定',
nzCancelText: '取消',
nzOkDanger: true,
nzOkType: "primary",
nzOnOk: () => this.cancelManageMonitors(this.checkedMonitorIds)
});
}
onCancelManageOneMonitor(monitorId: number) {
let monitors = new Set<number>();
monitors.add(monitorId);
this.modal.confirm({
nzTitle: '请确认是否取消纳管!',
nzOkText: '确定',
nzCancelText: '取消',
nzOkDanger: true,
nzOkType: "primary",
nzOnOk: () => this.cancelManageMonitors(monitors)
});
}
cancelManageMonitors(monitors: Set<number>) {
const cancelManage$ = this.monitorSvc.cancelManageMonitors(monitors)
.subscribe(message => {
cancelManage$.unsubscribe();
if (message.code === 0) {
this.notifySvc.success("取消纳管成功!", "");
this.loadMonitorTable();
} else {
this.notifySvc.error("取消纳管失败!", message.msg);
}
},
error => {
cancelManage$.unsubscribe();
this.notifySvc.error("取消纳管失败!", error.msg)
}
);
}
onEnableManageMonitors() {
if (this.checkedMonitorIds == null || this.checkedMonitorIds.size === 0) {
this.notifySvc.warning("未选中任何待启用纳管项!","");
return;
}
this.modal.confirm({
nzTitle: '请确认是否批量启用纳管!',
nzOkText: '确定',
nzCancelText: '取消',
nzOkDanger: true,
nzOkType: "primary",
nzOnOk: () => this.enableManageMonitors(this.checkedMonitorIds)
});
}
onEnableManageOneMonitor(monitorId: number) {
let monitors = new Set<number>();
monitors.add(monitorId);
this.modal.confirm({
nzTitle: '请确认是否启用纳管!',
nzOkText: '确定',
nzCancelText: '取消',
nzOkDanger: true,
nzOkType: "primary",
nzOnOk: () => this.enableManageMonitors(monitors)
});
}
enableManageMonitors(monitors: Set<number>) {
const enableManage$ = this.monitorSvc.enableManageMonitors(monitors)
.subscribe(message => {
enableManage$.unsubscribe();
if (message.code === 0) {
this.notifySvc.success("启用纳管成功!", "");
this.loadMonitorTable();
} else {
this.notifySvc.error("启用纳管失败!", message.msg);
}
},
error => {
enableManage$.unsubscribe();
this.notifySvc.error("启用纳管失败!", error.msg)
}
);
}
// begin: 列表多选逻辑
checkedAll: boolean = false;

View File

@@ -8,6 +8,7 @@ import {Monitor} from "../pojo/Monitor";
const monitor_uri = "/monitor";
const monitors_uri = "/monitors";
const detect_monitor_uri = "/monitor/detect"
const manage_monitors_uri = "/monitors/manage";
@Injectable({
providedIn: 'root'
@@ -31,13 +32,34 @@ export class MonitorService {
public deleteMonitors(monitorIds: Set<number>) : Observable<Message<any>> {
let httpParams = new HttpParams();
monitorIds.forEach(monitorId => {
// 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象
httpParams = httpParams.set('ids', monitorId);
// 注意HttpParams是不可变对象 需要保存append后返回的对象为最新对象
// append方法可以叠加同一key, set方法会把key之前的值覆盖只留一个key-value
httpParams = httpParams.append('ids', monitorId);
})
const options = { params: httpParams };
return this.http.delete<Message<any>>(monitors_uri, options);
}
public cancelManageMonitors(monitorIds: Set<number>) : Observable<Message<any>> {
let httpParams = new HttpParams();
monitorIds.forEach(monitorId => {
// 注意HttpParams是不可变对象 需要保存append后返回的对象为最新对象
// append方法可以叠加同一key, set方法会把key之前的值覆盖只留一个key-value
httpParams = httpParams.append('ids', monitorId);
})
const options = { params: httpParams };
return this.http.delete<Message<any>>(manage_monitors_uri, options);
}
public enableManageMonitors(monitorIds: Set<number>) : Observable<Message<any>> {
let httpParams = new HttpParams();
monitorIds.forEach(monitorId => {
httpParams = httpParams.append('ids', monitorId);
})
const options = { params: httpParams };
return this.http.get<Message<any>>(manage_monitors_uri, options);
}
public detectMonitor(body: any) : Observable<Message<any>> {
return this.http.post<Message<any>>(detect_monitor_uri, body);
}