Commit d81c8f47 authored by wangqinghua's avatar wangqinghua

网站监测

parent 6031f40d
......@@ -75,4 +75,4 @@
<smart-alarm-group #smartAlarmGroup (add)="getGroupAlarm()"></smart-alarm-group>
<!--新增告警推送-->
<smart-alarm-modal #smartAlarmModal></smart-alarm-modal>
\ No newline at end of file
<smart-alarm-modal #smartAlarmModal (done)="getList()" ></smart-alarm-modal>
\ No newline at end of file
......@@ -113,4 +113,9 @@ export class AlarmService {
getMediaType(params): Observable<any>{
return this.http.get(SERVER_API_URL + '/mediaType/find/' + params);
}
//查找告警目标
findAlertTarget(): Observable<any>{
return this.http.get(SERVER_API_URL + '/action/findAlertTarget');
}
}
\ No newline at end of file
import {Component, OnInit, ViewChild} from '@angular/core';
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';
......@@ -20,6 +20,7 @@ import {OverAllService} from '../../overAll/overAll.service';
export class AlarmModalComponent implements OnInit {
@ViewChild('smartFindUser') smartFindUser: FindUserComponent;
@ViewChild('nzTree') nzTree: NzTreeComponent;
@Output() done = new EventEmitter<any>();
modalTitle = '添加告警';
tabNum = 0;
......@@ -27,11 +28,9 @@ export class AlarmModalComponent implements OnInit {
nodes;
nodeList;
groupList;
sendOption = [];
userObj = {
alias: '',
userid: ''
};
objList;
selectTreeList = [];
validateForm;
......@@ -43,7 +42,9 @@ export class AlarmModalComponent implements OnInit {
ngOnInit() {
this.initForm();
this.getSendFun();
this.getACtion();
this.getGroup();
this.getZabbixObj();
}
//初始化
......@@ -52,11 +53,18 @@ export class AlarmModalComponent implements OnInit {
this.validateForm = {
name: null,
alertGroupId: null,
warn:0,
serious:0,
mediaTypeIds:[],
def_longdata:null,
r_longdata:null,
r_shortdata:null,
userIds:null,
};
}
//获取告警目标
getGroup() {
getACtion() {
this.overAllSer.findGroup().subscribe(
(res) => {
if (res.errCode == 10000) {
......@@ -74,6 +82,17 @@ export class AlarmModalComponent implements OnInit {
);
}
//获取告警分组
getGroup(){
this.alarmSer.alertGroupFind().subscribe(
(res) => {
if (res.errCode == 10000) {
this.groupList = res.data;
}
}
);
}
toNode(data) {
this.nodes = data.map(res => {
return new NzTreeNode(res);
......@@ -141,15 +160,15 @@ export class AlarmModalComponent implements OnInit {
);
}
//选择对象
showUserModa() {
this.smartFindUser.showModal();
}
//获取对象
getUser(data) {
this.userObj = data;
console.log(data);
//获取发送对象 zabbix
getZabbixObj() {
this.alarmSer.zUserFind({}).subscribe(
(res) => {
if (res.errCode == 10000) {
this.objList = res.data;
}
}
);
}
showModal(data) {
......@@ -165,24 +184,45 @@ export class AlarmModalComponent implements OnInit {
}
handEditleOk() {
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
}
const data = {
name: this.validateForm.name,
operations: [
{
opmessage_usr: [
{
userid: this.userObj.userid
}
]
}
]
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,
};
this.alarmSer.actionCreate(data).subscribe(
(res) => {
if(res.errCode == 10000){
this.isShow = false;
this.initForm();
this.done.emit();
}
this.message.info(res.errMsg);
}
);
// this.isShow = false;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment