Newer
Older
import {Component, EventEmitter, OnInit, Output, ViewChild} from '@angular/core';
import {AlarmService} from '../../alarm/alarm.service';
import {FindUserComponent} from '../../alarm/modal/find-user/find-user.component';
import {NzFormatEmitEvent, NzMessageService, NzTreeComponent, NzTreeNode} from 'ng-zorro-antd';
import {OverAllService} from '../../overAll/overAll.service';
selector: 'smart-alarm-modal',
templateUrl: './alarm-modal.component.html',
border: 1px solid #dadada;
height: 200px;
overflow: auto;
margin-top: 10px;
@ViewChild('smartFindUser') smartFindUser: FindUserComponent;
@ViewChild('nzTree') nzTree: NzTreeComponent;
constructor(private alarmSer: AlarmService, private message: NzMessageService,
private overAllSer: OverAllService) {
warn:0,
serious:0,
mediaTypeIds:[],
def_longdata:null,
r_longdata:null,
r_shortdata:null,
userIds:null,
this.overAllSer.findGroup().subscribe(
(res) => {
if (res.errCode == 10000) {
const dataSet = res.data;
dataSet.forEach(res => {
res.title = res.name;
res.key = res.groupid;
});
this.nodeList = dataSet;
this.toNode(dataSet);
} else {
this.message.info(res.errMsg);
}
}
);
}
//获取告警分组
getGroup(){
this.alarmSer.alertGroupFind().subscribe(
(res) => {
if (res.errCode == 10000) {
this.groupList = res.data;
}
}
);
}
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
toNode(data) {
this.nodes = data.map(res => {
return new NzTreeNode(res);
});
}
//下级
mouseAction(name: string, event: NzFormatEmitEvent) {
const index = <any>event.node.key - 1;
const data = {
'groupids': [event.node.origin.groupid],
'hostExtend': {
'superiorHostid': null
}
};
this.overAllSer.findDetail(data).subscribe(
(res) => {
if (res.data) {
const dataSet = res.data;
dataSet.forEach(res => {
res.title = res.name;
res.key = res.groupid;
res.isLeaf = true;
});
event.node.addChildren(dataSet);
this.nodeList[index].children = dataSet;
this.nodeList[index].expanded = true;
} else {
event.node.addChildren([]);
this.message.info('该分组下无资源');
}
}
);
setTimeout(_ => {
}, 1000);
// }
}
//选择树节点
selectCheckTree(event: NzFormatEmitEvent) {
if (event.node.isChecked) {
this.selectTreeList.push(event.node.origin.hostid);
} else {
const index = this.selectTreeList.indexOf(event.node.origin.hostid);
this.selectTreeList.splice(index, 1);
}
}
//获取发送方式
getSendFun() {
this.alarmSer.mediaTypeFind({}).subscribe(
(res) => {
if (res.errCode == 10000) {
this.sendOption = res.data;
this.sendOption.forEach(res => {
res.label = res.description;
res.value = res.mediatypeid;
res.checked = false;
});
}
}
);
}
//获取发送对象 zabbix
getZabbixObj() {
this.alarmSer.zUserFind({}).subscribe(
(res) => {
if (res.errCode == 10000) {
this.objList = res.data;
}
}
);
const optionArr = [];
this.sendOption.forEach(res=>{
if(res.checked){
optionArr.push(res.value);
}
});
if(this.validateForm.warn){
this.validateForm.warn = 1;
}else{
this.validateForm.warn = 0
}
if(this.validateForm.serious){
this.validateForm.serious = 1;
}else{
this.validateForm.serious = 0
}
alertGroupId: this.validateForm.alertGroupId,
warn:this.validateForm.warn,
serious:this.validateForm.serious,
mediaTypeIds:optionArr,
userIds:this.validateForm.userIds,
def_longdata:this.validateForm.def_longdata,
r_longdata:this.validateForm.r_longdata,
r_shortdata:this.validateForm.r_shortdata,
if(res.errCode == 10000){
this.isShow = false;
this.initForm();
this.done.emit();
}