Commit d81c8f47 authored by wangqinghua's avatar wangqinghua

网站监测

parent 6031f40d
...@@ -75,4 +75,4 @@ ...@@ -75,4 +75,4 @@
<smart-alarm-group #smartAlarmGroup (add)="getGroupAlarm()"></smart-alarm-group> <smart-alarm-group #smartAlarmGroup (add)="getGroupAlarm()"></smart-alarm-group>
<!--新增告警推送--> <!--新增告警推送-->
<smart-alarm-modal #smartAlarmModal></smart-alarm-modal> <smart-alarm-modal #smartAlarmModal (done)="getList()" ></smart-alarm-modal>
\ No newline at end of file \ No newline at end of file
...@@ -113,4 +113,9 @@ export class AlarmService { ...@@ -113,4 +113,9 @@ export class AlarmService {
getMediaType(params): Observable<any>{ getMediaType(params): Observable<any>{
return this.http.get(SERVER_API_URL + '/mediaType/find/' + params); 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 {AlarmService} from '../../alarm/alarm.service';
import {FindUserComponent} from '../../alarm/modal/find-user/find-user.component'; import {FindUserComponent} from '../../alarm/modal/find-user/find-user.component';
import {NzFormatEmitEvent, NzMessageService, NzTreeComponent, NzTreeNode} from 'ng-zorro-antd'; import {NzFormatEmitEvent, NzMessageService, NzTreeComponent, NzTreeNode} from 'ng-zorro-antd';
...@@ -20,6 +20,7 @@ import {OverAllService} from '../../overAll/overAll.service'; ...@@ -20,6 +20,7 @@ import {OverAllService} from '../../overAll/overAll.service';
export class AlarmModalComponent implements OnInit { export class AlarmModalComponent implements OnInit {
@ViewChild('smartFindUser') smartFindUser: FindUserComponent; @ViewChild('smartFindUser') smartFindUser: FindUserComponent;
@ViewChild('nzTree') nzTree: NzTreeComponent; @ViewChild('nzTree') nzTree: NzTreeComponent;
@Output() done = new EventEmitter<any>();
modalTitle = '添加告警'; modalTitle = '添加告警';
tabNum = 0; tabNum = 0;
...@@ -27,11 +28,9 @@ export class AlarmModalComponent implements OnInit { ...@@ -27,11 +28,9 @@ export class AlarmModalComponent implements OnInit {
nodes; nodes;
nodeList; nodeList;
groupList;
sendOption = []; sendOption = [];
userObj = { objList;
alias: '',
userid: ''
};
selectTreeList = []; selectTreeList = [];
validateForm; validateForm;
...@@ -43,7 +42,9 @@ export class AlarmModalComponent implements OnInit { ...@@ -43,7 +42,9 @@ export class AlarmModalComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.initForm(); this.initForm();
this.getSendFun(); this.getSendFun();
this.getACtion();
this.getGroup(); this.getGroup();
this.getZabbixObj();
} }
//初始化 //初始化
...@@ -52,11 +53,18 @@ export class AlarmModalComponent implements OnInit { ...@@ -52,11 +53,18 @@ export class AlarmModalComponent implements OnInit {
this.validateForm = { this.validateForm = {
name: null, name: null,
alertGroupId: 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( this.overAllSer.findGroup().subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
...@@ -74,6 +82,17 @@ export class AlarmModalComponent implements OnInit { ...@@ -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) { toNode(data) {
this.nodes = data.map(res => { this.nodes = data.map(res => {
return new NzTreeNode(res); return new NzTreeNode(res);
...@@ -141,15 +160,15 @@ export class AlarmModalComponent implements OnInit { ...@@ -141,15 +160,15 @@ export class AlarmModalComponent implements OnInit {
); );
} }
//选择对象 //获取发送对象 zabbix
showUserModa() { getZabbixObj() {
this.smartFindUser.showModal(); this.alarmSer.zUserFind({}).subscribe(
} (res) => {
if (res.errCode == 10000) {
//获取对象 this.objList = res.data;
getUser(data) { }
this.userObj = data; }
console.log(data); );
} }
showModal(data) { showModal(data) {
...@@ -165,24 +184,45 @@ export class AlarmModalComponent implements OnInit { ...@@ -165,24 +184,45 @@ export class AlarmModalComponent implements OnInit {
} }
handEditleOk() { 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 = { const data = {
name: this.validateForm.name, name: this.validateForm.name,
operations: [ alertGroupId: this.validateForm.alertGroupId,
{ warn:this.validateForm.warn,
opmessage_usr: [ serious:this.validateForm.serious,
{ mediaTypeIds:optionArr,
userid: this.userObj.userid 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( this.alarmSer.actionCreate(data).subscribe(
(res) => { (res) => {
if(res.errCode == 10000){
this.isShow = false;
this.initForm();
this.done.emit();
}
this.message.info(res.errMsg); 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