[webapp] 批量处理eslint格式告警
This commit is contained in:
@@ -1,31 +1,32 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import {NzTableQueryParams} from "ng-zorro-antd/table";
|
||||
import {NzModalService} from "ng-zorro-antd/modal";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {AlertDefineService} from "../../../service/alert-define.service";
|
||||
import {AlertDefine} from "../../../pojo/AlertDefine";
|
||||
import {finalize, map} from "rxjs/operators";
|
||||
import {AppDefineService} from "../../../service/app-define.service";
|
||||
import {TransferChange, TransferItem} from "ng-zorro-antd/transfer";
|
||||
import {zip} from "rxjs";
|
||||
import {MonitorService} from "../../../service/monitor.service";
|
||||
import {Message} from "../../../pojo/Message";
|
||||
import {AlertDefineBind} from "../../../pojo/AlertDefineBind";
|
||||
import {Monitor} from "../../../pojo/Monitor";
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
||||
import { NzTableQueryParams } from 'ng-zorro-antd/table';
|
||||
import { TransferChange, TransferItem } from 'ng-zorro-antd/transfer';
|
||||
import { zip } from 'rxjs';
|
||||
import { finalize, map } from 'rxjs/operators';
|
||||
|
||||
import { AlertDefine } from '../../../pojo/AlertDefine';
|
||||
import { AlertDefineBind } from '../../../pojo/AlertDefineBind';
|
||||
import { Message } from '../../../pojo/Message';
|
||||
import { Monitor } from '../../../pojo/Monitor';
|
||||
import { AlertDefineService } from '../../../service/alert-define.service';
|
||||
import { AppDefineService } from '../../../service/app-define.service';
|
||||
import { MonitorService } from '../../../service/monitor.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-alert-setting',
|
||||
templateUrl: './alert-setting.component.html',
|
||||
styles: [
|
||||
]
|
||||
styles: []
|
||||
})
|
||||
export class AlertSettingComponent implements OnInit {
|
||||
|
||||
constructor(private modal: NzModalService,
|
||||
private notifySvc: NzNotificationService,
|
||||
private appDefineSvc: AppDefineService,
|
||||
private monitorSvc: MonitorService,
|
||||
private alertDefineSvc: AlertDefineService) { }
|
||||
constructor(
|
||||
private modal: NzModalService,
|
||||
private notifySvc: NzNotificationService,
|
||||
private appDefineSvc: AppDefineService,
|
||||
private monitorSvc: MonitorService,
|
||||
private alertDefineSvc: AlertDefineService
|
||||
) {}
|
||||
|
||||
pageIndex: number = 1;
|
||||
pageSize: number = 8;
|
||||
@@ -39,19 +40,25 @@ export class AlertSettingComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.loadAlertDefineTable();
|
||||
// 查询监控层级
|
||||
const getHierarchy$ = this.appDefineSvc.getAppHierarchy()
|
||||
.pipe(finalize(() => {
|
||||
getHierarchy$.unsubscribe();
|
||||
}))
|
||||
.subscribe(message => {
|
||||
if (message.code === 0) {
|
||||
this.appHierarchies = message.data;
|
||||
} else {
|
||||
console.warn(message.msg);
|
||||
const getHierarchy$ = this.appDefineSvc
|
||||
.getAppHierarchy()
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
getHierarchy$.unsubscribe();
|
||||
})
|
||||
)
|
||||
.subscribe(
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.appHierarchies = message.data;
|
||||
} else {
|
||||
console.warn(message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
console.warn(error.msg);
|
||||
}
|
||||
}, error => {
|
||||
console.warn(error.msg);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
sync() {
|
||||
@@ -60,8 +67,8 @@ export class AlertSettingComponent implements OnInit {
|
||||
|
||||
loadAlertDefineTable() {
|
||||
this.tableLoading = true;
|
||||
let alertDefineInit$ = this.alertDefineSvc.getAlertDefines(this.pageIndex - 1, this.pageSize)
|
||||
.subscribe(message => {
|
||||
let alertDefineInit$ = this.alertDefineSvc.getAlertDefines(this.pageIndex - 1, this.pageSize).subscribe(
|
||||
message => {
|
||||
this.tableLoading = false;
|
||||
this.checkedAll = false;
|
||||
this.checkedDefineIds.clear();
|
||||
@@ -74,10 +81,12 @@ export class AlertSettingComponent implements OnInit {
|
||||
console.warn(message.msg);
|
||||
}
|
||||
alertDefineInit$.unsubscribe();
|
||||
}, error => {
|
||||
},
|
||||
error => {
|
||||
this.tableLoading = false;
|
||||
alertDefineInit$.unsubscribe();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onNewAlertDefine() {
|
||||
@@ -89,7 +98,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
|
||||
onEditOneAlertDefine(alertDefineId: number) {
|
||||
if (alertDefineId == null) {
|
||||
this.notifySvc.warning("未选中任何待编辑项!","");
|
||||
this.notifySvc.warning('未选中任何待编辑项!', '');
|
||||
return;
|
||||
}
|
||||
this.editAlertDefine(alertDefineId);
|
||||
@@ -98,15 +107,15 @@ export class AlertSettingComponent implements OnInit {
|
||||
onEditAlertDefine() {
|
||||
// 编辑时只能选中一个
|
||||
if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) {
|
||||
this.notifySvc.warning("未选中任何待编辑项!","");
|
||||
this.notifySvc.warning('未选中任何待编辑项!', '');
|
||||
return;
|
||||
}
|
||||
if (this.checkedDefineIds.size > 1) {
|
||||
this.notifySvc.warning("只能对一个选中项进行编辑!","");
|
||||
this.notifySvc.warning('只能对一个选中项进行编辑!', '');
|
||||
return;
|
||||
}
|
||||
let alertDefineId = 0;
|
||||
this.checkedDefineIds.forEach(item => alertDefineId = item);
|
||||
this.checkedDefineIds.forEach(item => (alertDefineId = item));
|
||||
this.editAlertDefine(alertDefineId);
|
||||
}
|
||||
|
||||
@@ -115,25 +124,31 @@ export class AlertSettingComponent implements OnInit {
|
||||
this.isManageModalVisible = true;
|
||||
this.isManageModalOkLoading = false;
|
||||
// 查询告警定义信息
|
||||
const getDefine$ = this.alertDefineSvc.getAlertDefine(alertDefineId)
|
||||
.pipe(finalize(() => {
|
||||
getDefine$.unsubscribe();
|
||||
}))
|
||||
.subscribe(message => {
|
||||
if (message.code === 0) {
|
||||
this.define = message.data;
|
||||
this.cascadeValues = [this.define.app, this.define.metric, this.define.field];
|
||||
} else {
|
||||
this.notifySvc.error("查询此监控定义详情失败!",message.msg);
|
||||
const getDefine$ = this.alertDefineSvc
|
||||
.getAlertDefine(alertDefineId)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
getDefine$.unsubscribe();
|
||||
})
|
||||
)
|
||||
.subscribe(
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.define = message.data;
|
||||
this.cascadeValues = [this.define.app, this.define.metric, this.define.field];
|
||||
} else {
|
||||
this.notifySvc.error('查询此监控定义详情失败!', message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('查询此监控定义详情失败!', error.msg);
|
||||
}
|
||||
}, error => {
|
||||
this.notifySvc.error("查询此监控定义详情失败!",error.msg);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
onDeleteAlertDefines() {
|
||||
if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) {
|
||||
this.notifySvc.warning("未选中任何待删除项!","");
|
||||
this.notifySvc.warning('未选中任何待删除项!', '');
|
||||
return;
|
||||
}
|
||||
this.modal.confirm({
|
||||
@@ -141,7 +156,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzOkDanger: true,
|
||||
nzOkType: "primary",
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteAlertDefines(this.checkedDefineIds)
|
||||
});
|
||||
}
|
||||
@@ -154,33 +169,34 @@ export class AlertSettingComponent implements OnInit {
|
||||
nzOkText: '确定',
|
||||
nzCancelText: '取消',
|
||||
nzOkDanger: true,
|
||||
nzOkType: "primary",
|
||||
nzOkType: 'primary',
|
||||
nzOnOk: () => this.deleteAlertDefines(defineIds)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
deleteAlertDefines(defineIds: Set<number>) {
|
||||
if (defineIds == null || defineIds.size == 0) {
|
||||
this.notifySvc.warning("未选中任何待删除项!","");
|
||||
this.notifySvc.warning('未选中任何待删除项!', '');
|
||||
return;
|
||||
}
|
||||
this.tableLoading = true;
|
||||
const deleteDefines$ = this.alertDefineSvc.deleteAlertDefines(defineIds)
|
||||
.subscribe(message => {
|
||||
const deleteDefines$ = this.alertDefineSvc.deleteAlertDefines(defineIds).subscribe(
|
||||
message => {
|
||||
deleteDefines$.unsubscribe();
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success("删除成功!", "");
|
||||
this.notifySvc.success('删除成功!', '');
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.tableLoading = false;
|
||||
this.notifySvc.error("删除失败!", message.msg);
|
||||
this.notifySvc.error('删除失败!', message.msg);
|
||||
}
|
||||
}, error => {
|
||||
},
|
||||
error => {
|
||||
this.tableLoading = false;
|
||||
deleteDefines$.unsubscribe();
|
||||
this.notifySvc.error("删除失败!", error.msg)
|
||||
})
|
||||
this.notifySvc.error('删除失败!', error.msg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// begin: 列表多选分页逻辑
|
||||
@@ -201,6 +217,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
}
|
||||
/**
|
||||
* 分页回调
|
||||
*
|
||||
* @param params 页码信息
|
||||
*/
|
||||
onTablePageChange(params: NzTableQueryParams) {
|
||||
@@ -211,7 +228,6 @@ export class AlertSettingComponent implements OnInit {
|
||||
}
|
||||
// end: 列表多选逻辑
|
||||
|
||||
|
||||
// start 新增修改告警定义model
|
||||
isManageModalVisible = false;
|
||||
isManageModalOkLoading = false;
|
||||
@@ -227,39 +243,51 @@ export class AlertSettingComponent implements OnInit {
|
||||
this.define.metric = this.cascadeValues[1];
|
||||
this.define.field = this.cascadeValues[2];
|
||||
if (this.isManageModalAdd) {
|
||||
const modalOk$ = this.alertDefineSvc.newAlertDefine(this.define)
|
||||
.pipe(finalize(() => {
|
||||
modalOk$.unsubscribe();
|
||||
this.isManageModalOkLoading = false;
|
||||
}))
|
||||
.subscribe(message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageModalVisible = false;
|
||||
this.notifySvc.success("新增成功!", "");
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error("新增失败!", message.msg);
|
||||
const modalOk$ = this.alertDefineSvc
|
||||
.newAlertDefine(this.define)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
modalOk$.unsubscribe();
|
||||
this.isManageModalOkLoading = false;
|
||||
})
|
||||
)
|
||||
.subscribe(
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageModalVisible = false;
|
||||
this.notifySvc.success('新增成功!', '');
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error('新增失败!', message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('新增失败!', error.msg);
|
||||
}
|
||||
}, error => {
|
||||
this.notifySvc.error("新增失败!", error.msg);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
const modalOk$ = this.alertDefineSvc.editAlertDefine(this.define)
|
||||
.pipe(finalize(() => {
|
||||
modalOk$.unsubscribe();
|
||||
this.isManageModalOkLoading = false;
|
||||
}))
|
||||
.subscribe(message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageModalVisible = false;
|
||||
this.notifySvc.success("修改成功!", "");
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error("修改失败!", message.msg);
|
||||
const modalOk$ = this.alertDefineSvc
|
||||
.editAlertDefine(this.define)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
modalOk$.unsubscribe();
|
||||
this.isManageModalOkLoading = false;
|
||||
})
|
||||
)
|
||||
.subscribe(
|
||||
message => {
|
||||
if (message.code === 0) {
|
||||
this.isManageModalVisible = false;
|
||||
this.notifySvc.success('修改成功!', '');
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error('修改失败!', message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('修改失败!', error.msg);
|
||||
}
|
||||
}, error => {
|
||||
this.notifySvc.error("修改失败!", error.msg);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
// end 新增修改告警定义model
|
||||
@@ -280,7 +308,7 @@ export class AlertSettingComponent implements OnInit {
|
||||
if (defineBindData.data != undefined) {
|
||||
defineBindData.data.forEach(bind => {
|
||||
bindRecode[bind.monitorId] = bind.monitorName;
|
||||
})
|
||||
});
|
||||
}
|
||||
let listTmp: any[] = [];
|
||||
if (monitorData.data != undefined) {
|
||||
@@ -290,12 +318,13 @@ export class AlertSettingComponent implements OnInit {
|
||||
name: monitor.name,
|
||||
key: monitor.id,
|
||||
direction: bindRecode[monitor.id] == undefined ? 'left' : 'right'
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
return listTmp;
|
||||
})
|
||||
).subscribe(list => this.transferData = list);
|
||||
)
|
||||
.subscribe(list => (this.transferData = list));
|
||||
}
|
||||
onConnectModalCancel() {
|
||||
this.isConnectModalVisible = false;
|
||||
@@ -311,23 +340,29 @@ export class AlertSettingComponent implements OnInit {
|
||||
bind.monitorName = item.name;
|
||||
defineBinds.push(bind);
|
||||
}
|
||||
})
|
||||
const applyBind$ = this.alertDefineSvc.applyAlertDefineMonitorsBind(this.currentAlertDefineId, defineBinds)
|
||||
.pipe(finalize(() => {
|
||||
applyBind$.unsubscribe();
|
||||
}))
|
||||
.subscribe(message => {
|
||||
this.isConnectModalOkLoading = false;
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success("应用成功!", "");
|
||||
this.isConnectModalVisible = false;
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error("应用失败!", message.msg);
|
||||
});
|
||||
const applyBind$ = this.alertDefineSvc
|
||||
.applyAlertDefineMonitorsBind(this.currentAlertDefineId, defineBinds)
|
||||
.pipe(
|
||||
finalize(() => {
|
||||
applyBind$.unsubscribe();
|
||||
})
|
||||
)
|
||||
.subscribe(
|
||||
message => {
|
||||
this.isConnectModalOkLoading = false;
|
||||
if (message.code === 0) {
|
||||
this.notifySvc.success('应用成功!', '');
|
||||
this.isConnectModalVisible = false;
|
||||
this.loadAlertDefineTable();
|
||||
} else {
|
||||
this.notifySvc.error('应用失败!', message.msg);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
this.notifySvc.error('应用失败!', error.msg);
|
||||
}
|
||||
}, error => {
|
||||
this.notifySvc.error("应用失败!", error.msg);
|
||||
})
|
||||
);
|
||||
}
|
||||
change(ret: TransferChange): void {
|
||||
const listKeys = ret.list.map(l => l.key);
|
||||
@@ -344,5 +379,4 @@ export class AlertSettingComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
// end 告警定义与监控关联model
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user