Commit 3bb0c10b authored by wangqinghua's avatar wangqinghua

网站监测

parent a75ad9c1
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
[nzMultiple]="true" [nzMultiple]="true"
[nzAsyncData] = "true"" [nzAsyncData] = "true""
(nzClick)="mouseAction('expand',$event)" (nzClick)="mouseAction('expand',$event)"
(nzExpandChange)="mouseAction('expand',$event)" (nzExpandChange)="mouseAction('expand',$event)" >
>
</nz-tree> </nz-tree>
</div> </div>
</nz-modal> </nz-modal>
\ No newline at end of file
...@@ -14,7 +14,17 @@ ...@@ -14,7 +14,17 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="host1">告警目标</nz-form-label> <nz-form-label [nzSpan]="4" nzRequired nzFor="host1">告警目标</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<input id="host1" type="text" nz-input name="host1"> <div class="tree-div">
<nz-tree #nzTree
[(ngModel)]="nodes"
[nzCheckable]="true"
[nzAsyncData]="true"
[nzCheckStrictly]="true"
(nzCheckBoxChange)="selectCheckTree($event)"
(nzClick)="mouseAction('expand',$event)"
(nzExpandChange)="mouseAction('expand',$event)" >
</nz-tree>
</div>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
...@@ -109,11 +119,11 @@ ...@@ -109,11 +119,11 @@
<nz-form-label [nzSpan]="4" nzFor="serviceid">过滤条件</nz-form-label> <nz-form-label [nzSpan]="4" nzFor="serviceid">过滤条件</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-radio-group> <nz-radio-group>
<label nz-radio nzValue="1"> <label nz-radio nzValue="1">
当事件连续发生<input type="text" nz-input style="width: 100px; margin-left: 10px;">时,发送告警, 当事件连续发生<input type="text" nz-input style="width: 100px; margin-left: 10px;">时,发送告警,
再没每<input type="text" nz-input style="width: 100px; margin-left: 10px;">次发送一次告警 再没每<input type="text" nz-input style="width: 100px; margin-left: 10px;">次发送一次告警
</label> </label>
<label nz-radio nzValue="2"> <label nz-radio nzValue="2">
<input type="text" nz-input style="width: 100px; margin-left: 10px;">分钟内, <input type="text" nz-input style="width: 100px; margin-left: 10px;">分钟内,
<input type="text" nz-input style="width: 100px; margin-left: 10px;">次同样状态事件发送告警 <input type="text" nz-input style="width: 100px; margin-left: 10px;">次同样状态事件发送告警
</label> </label>
...@@ -130,7 +140,7 @@ ...@@ -130,7 +140,7 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4" nzFor="serviceid">生成事件</nz-form-label> <nz-form-label [nzSpan]="4" nzFor="serviceid">生成事件</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-radio-group > <nz-radio-group>
<label nz-radio nzValue="1"></label> <label nz-radio nzValue="1"></label>
<label nz-radio nzValue="2"></label> <label nz-radio nzValue="2"></label>
</nz-radio-group> </nz-radio-group>
......
import {Component, OnInit, ViewChild} from '@angular/core'; import {Component, OnInit, 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 {OverAllService} from '../../overAll/overAll.service';
@Component({ @Component({
selector: 'smart-alarm-modal', selector: 'smart-alarm-modal',
templateUrl: './alarm-modal.component.html', templateUrl: './alarm-modal.component.html',
styles: [] styles: [
`
.tree-div {
border: 1px solid #999;
max-height: 200px;
overflow: auto
}
`
]
}) })
export class AlarmModalComponent implements OnInit { export class AlarmModalComponent implements OnInit {
@ViewChild('smartFindUser') smartFindUser:FindUserComponent; @ViewChild('smartFindUser') smartFindUser: FindUserComponent;
@ViewChild('nzTree') nzTree: NzTreeComponent;
modalTitle = '添加告警'; modalTitle = '添加告警';
tabNum = 0; tabNum = 0;
isShow = false; isShow = false;
nodes;
nodeList;
sendOption = []; sendOption = [];
userObj; userObj = {
alias: '',
userid: ''
};
selectTreeList = [];
validateForm; validateForm;
constructor(private alarmSer: AlarmService) { constructor(private alarmSer: AlarmService, private message: NzMessageService,
private overAllSer: OverAllService) {
} }
ngOnInit() { ngOnInit() {
this.initForm(); this.initForm();
this.getSendFun(); this.getSendFun();
this.getGroup();
} }
//初始化 //初始化
initForm() { initForm() {
this.selectTreeList = [];
this.validateForm = { this.validateForm = {
name: null, name: null,
alertGroupId: null, alertGroupId: null,
}; };
} }
//获取告警目标
getGroup() {
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);
}
}
);
}
toNode(data) {
this.nodes = data.map(res => {
return new NzTreeNode(res);
});
}
//下级
mouseAction(name: string, event: NzFormatEmitEvent) {
console.log(name);
console.log(event);
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() { getSendFun() {
this.alarmSer.mediaTypeFind({}).subscribe( this.alarmSer.mediaTypeFind({}).subscribe(
...@@ -52,7 +142,7 @@ export class AlarmModalComponent implements OnInit { ...@@ -52,7 +142,7 @@ export class AlarmModalComponent implements OnInit {
} }
//选择对象 //选择对象
showUserModa(){ showUserModa() {
this.smartFindUser.showModal(); this.smartFindUser.showModal();
} }
...@@ -75,7 +165,24 @@ export class AlarmModalComponent implements OnInit { ...@@ -75,7 +165,24 @@ export class AlarmModalComponent implements OnInit {
} }
handEditleOk() { handEditleOk() {
this.isShow = false; const data = {
name: this.validateForm.name,
operations: [
{
opmessage_usr: [
{
userid: this.userObj.userid
}
]
}
]
};
this.alarmSer.actionCreate(data).subscribe(
(res) => {
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