Commit 7ba2c671 authored by wangqinghua's avatar wangqinghua

update

parent 7ec5a6ec
export const VERSION = process.env.VERSION; export const VERSION = process.env.VERSION;
export const DEBUG_INFO_ENABLED: boolean = !!process.env.DEBUG_INFO_ENABLED; export const DEBUG_INFO_ENABLED: boolean = !!process.env.DEBUG_INFO_ENABLED;
export const SERVER_API_URL_COMS = '/coms'; export const SERVER_API_URL_COMS = '/coms';
// export const SERVER_API_URL = '/anke'; export const SERVER_API_URL = '/anke';
export const SERVER_API_URL = '/zhouxi'; // export const SERVER_API_URL = '/zhouxi';
// export const SERVER_API_URL = '/zabbixBox'; // export const SERVER_API_URL = '/zabbixBox';
export const SERVER_API_URL_MONITOR = '/api'; export const SERVER_API_URL_MONITOR = '/api';
export const BUILD_TIMESTAMP = process.env.BUILD_TIMESTAMP; export const BUILD_TIMESTAMP = process.env.BUILD_TIMESTAMP;
......
...@@ -72,8 +72,16 @@ export class BasiCheckComponent implements OnInit { ...@@ -72,8 +72,16 @@ export class BasiCheckComponent implements OnInit {
history: ['3600'], history: ['3600'],
snmpCommunity: ['public'], snmpCommunity: ['public'],
delay: [null, [Validators.required]], delay: [null, [Validators.required]],
interfaceid: [null], interfaceid: [null,[Validators.required]],
templateid: [null], templateid: [null],
status: [null],
applicationid: [null],
lastclock: [null],
lastvalue: [null],
maxLevel: [null],
createTime: [null],
error: [null],
triggers: [null],
description: [null, [Validators.required]], description: [null, [Validators.required]],
}); });
this.triggerObj = { this.triggerObj = {
......
...@@ -6,100 +6,12 @@ ...@@ -6,100 +6,12 @@
</div> </div>
<nz-form-item nzFlex> <nz-form-item nzFlex>
<nz-form-control [nzOffset]="4" [nzSpan]="14"> <nz-form-control [nzOffset]="4" [nzSpan]="14">
<nz-radio-group [(ngModel)]="conditionType"> <p>告警阈值</p>
<!-- <label nz-radio-button nzValue="commonly"><span>常规</span></label>--> <textarea rows="4" nz-input [(ngModel)]="conditionExpression"></textarea>
<label nz-radio-button nzValue="high"><span>高级</span></label> <p>严重阈值</p>
</nz-radio-group> <textarea rows="4" nz-input [(ngModel)]="faultConditionExpression"></textarea>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<ng-container *ngIf="conditionType == 'commonly'">
<nz-form-item class="form-select">
<nz-form-control class="form-select">
<div nz-row [nzGutter]="12">
<nz-form-control nz-col [nzPush]="3" [nzSpan]="6">
<button nz-button nzType="primary" nzSize="small" (click)="addcondition()">添加条件</button>
<span>危险阈值</span>
</nz-form-control>
</div>
<div nz-row [nzGutter]="12" *ngFor="let fault of conditionList;let i = index;">
<nz-form-control nz-col [nzSpan]="3"></nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<nz-select name="interfaces_main" nzPlaceHolder="选择接口类型" [(ngModel)]="fault.and"
*ngIf="i>0">
<nz-option nzValue=" and " nzLabel="并且"></nz-option>
<nz-option nzValue=" or " nzLabel="或"></nz-option>
</nz-select>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="4">
<button class="tag-button" nz-button nzType="default">返回值</button>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<nz-select name="interfaces_main" nzPlaceHolder="选择接口类型" [(ngModel)]="fault.equal">
<nz-option nzValue="=" nzLabel="="></nz-option>
<nz-option nzValue=">" nzLabel=">"></nz-option>
<nz-option nzValue="<" nzLabel="<"></nz-option>
</nz-select>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<input type="text" placeholder="值" nz-input name="value" [(ngModel)]="fault.value">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="2">
<button nz-button nzType="primary" (click)="deleteCondition(i)"><i style="color: #fff"
class="anticon anticon-close-circle-o"></i>
</button>
</nz-form-control>
</div>
</nz-form-control>
</nz-form-item>
<nz-form-item class="form-select">
<nz-form-control class="form-select">
<div nz-row [nzGutter]="12">
<nz-form-control nz-col [nzPush]="3" [nzSpan]="6">
<button nz-button nzType="primary" nzSize="small" (click)="addFault()">添加条件</button>
<span>故障阈值</span>
</nz-form-control>
</div>
<div nz-row [nzGutter]="12" *ngFor="let fault of faultConditionList;let i = index;">
<nz-form-control nz-col [nzSpan]="3"></nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<nz-select name="interfaces_main" [(ngModel)]="fault.and" *ngIf="i>0">
<nz-option nzValue=" and " nzLabel="并且"></nz-option>
<nz-option nzValue=" or " nzLabel="或"></nz-option>
</nz-select>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="4">
<button class="tag-button" nz-button nzType="default">返回值</button>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<nz-select name="interfaces_main" nzPlaceHolder="选择接口类型" [(ngModel)]="fault.equal">
<nz-option nzValue="=" nzLabel="="></nz-option>
<nz-option nzValue=">" nzLabel=">"></nz-option>
<nz-option nzValue="<" nzLabel="<"></nz-option>
</nz-select>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<input type="text" placeholder="值" nz-input name="value" [(ngModel)]="fault.value">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="2">
<button nz-button nzType="primary" (click)="deleteFault(i)"><i style="color: #fff"
class="anticon anticon-close-circle-o"></i>
</button>
</nz-form-control>
</div>
</nz-form-control>
</nz-form-item>
</ng-container>
<ng-container *ngIf="conditionType == 'high'">
<nz-form-item nzFlex>
<nz-form-control [nzOffset]="4" [nzSpan]="14">
<p>危险阈值</p>
<textarea rows="4" nz-input [(ngModel)]="triggerObj.condition"></textarea>
<p>故障阈值</p>
<textarea rows="4" nz-input [(ngModel)]="triggerObj.faultCondition"></textarea>
</nz-form-control>
</nz-form-item>
</ng-container>
</nz-modal> </nz-modal>
...@@ -17,18 +17,19 @@ export class ThresholdComponent implements OnInit { ...@@ -17,18 +17,19 @@ export class ThresholdComponent implements OnInit {
itemId; //监控项ID itemId; //监控项ID
hostName; //主机name hostName; //主机name
itemObj; //监控项对象 itemObj; //监控项对象
conditionType = 'high';
faultConditionList = []; //故障阈值
conditionList = []; //危险阈值
triggerConditionId; triggerConditionId;
triggerFaultConditionId; triggerFaultConditionId;
triggerObj = { triggerObj = {
condition: '', condition: null,
faultCondition: '', faultCondition: null,
itemName: '' itemName: ''
}; };
conditionExpression; //严重
faultConditionExpression; //告警
demo = `示例1.{监测点id}>10 or {监测点id}=1 示例2. {监测点id}<10 and {监测点id}>3`; demo = `示例1.{监测点id}>10 or {监测点id}=1 示例2. {监测点id}<10 and {监测点id}>3`;
constructor(private overAllSer: OverAllService, private fb: FormBuilder, constructor(private overAllSer: OverAllService, private fb: FormBuilder,
...@@ -39,45 +40,16 @@ export class ThresholdComponent implements OnInit { ...@@ -39,45 +40,16 @@ export class ThresholdComponent implements OnInit {
} }
initForm() { initForm() {
this.faultConditionList = []; //危险阀值list this.isOkLoading = false;
this.conditionList = []; //故障list this.conditionExpression = '';
this.faultConditionExpression = '';
this.triggerObj = { this.triggerObj = {
condition: '', condition: null,
faultCondition: '', faultCondition: null,
itemName: '' itemName: ''
}; };
} }
//危险add
addFault() {
const demo = {
and: ' and ',
equal: '=',
value: '',
};
this.faultConditionList.push(demo);
}
//危险add
addcondition() {
const demo = {
and: ' and ',
equal: '=',
value: '',
};
this.conditionList.push(demo);
}
//故障delete
deleteFault(index) {
this.faultConditionList.splice(index, 1);
}
//危险delete
deleteCondition(index) {
this.conditionList.splice(index, 1);
}
//新增 //新增
showAddModal(item, title, itemId, hostName) { showAddModal(item, title, itemId, hostName) {
this.title = title; this.title = title;
...@@ -93,103 +65,42 @@ export class ThresholdComponent implements OnInit { ...@@ -93,103 +65,42 @@ export class ThresholdComponent implements OnInit {
} }
//编辑 //编辑
showEditModal(title, itemId, hostId, hostName) { showEditModal(title, item, itemId, hostId, hostName) {
this.title = title; this.title = title;
this.itemId = itemId; this.itemId = itemId;
this.isVisiable = true; this.isVisiable = true;
this.hostName = hostName; this.hostName = hostName;
this.overAllSer.findItemDetail(this.itemId).subscribe( item.triggers.forEach((value) => {
(res) => { if (value.priority == 1) { //告警
this.itemObj = res.data; this.triggerObj.condition = value;
this.itemObj.triggers.forEach((value) => { this.conditionExpression = value.expression;
if (value.priority == 2 || value.priority == 3) { //危险
this.triggerObj.condition = value.expression;
this.triggerConditionId = value.id; this.triggerConditionId = value.id;
} }
if (value.priority == 4 || value.priority == 5) { //故障 if (value.priority == 2) { //严重
this.triggerObj.faultCondition = value.expression; this.triggerObj.faultCondition = value;
this.faultConditionExpression = value.expression;
this.triggerFaultConditionId = value.id; this.triggerFaultConditionId = value.id;
} }
}); })
}
);
} }
//阈值--start //2.修改阈值
saveTrigger() { saveTrigger() {
const data = { if (!this.conditionExpression && !this.faultConditionExpression) {
condition: '',
faultCondition: ''
};
if (this.conditionType == 'commonly') { //常规
this.conditionList.forEach(res => {
if (!res.and) {
res.and = '';
}
data.condition += res.and + '{' + this.hostName + ':' + this.itemObj.key + '.last()}' + res.equal + '' + res.value;
});
this.faultConditionList.forEach(res => {
if (!res.and) {
res.and = '';
}
data.faultCondition += res.and + '{' + this.hostName + ':' + this.itemObj.key + '.last()}' + res.equal + '' + res.value;
});
} else { //高级
data.condition = this.triggerObj.condition;
data.faultCondition = this.triggerObj.faultCondition;
}
if (!this.checkFun() && !this.triggerObj.condition && !this.triggerObj.faultCondition) {
this.message.error('请输入阈值'); this.message.error('请输入阈值');
return false; return false;
} }
this.isOkLoading = true; if (!this.triggerObj.condition && this.conditionExpression) { //告警触发器创建
if (this.title == '添加阈值') {
// if (this.conditionList.length == 0 && this.faultConditionList.length == 0) {
// this.isVisiable = false;
// this.initForm();
// return false;
// }else{
this.createTrigger(data);
// }
}
if (this.title == '编辑阈值') {
this.updateTrigger(data);
}
}
//校验是否填值
checkFun() {
let error = true;
this.conditionList.map(e => {
if (e.value.length > 0) {
} else {
error = false;
}
});
this.faultConditionList.map(e => {
if (e.value.length > 0) {
} else {
error = false;
}
});
return error;
}
//1.创建阈值
createTrigger(data) {
const res = { const res = {
itemName: this.itemObj.name, itemName: this.itemObj.name,
faultCondition: data.faultCondition, condition: this.conditionExpression,
condition: data.condition,
itemid: this.itemId itemid: this.itemId
}; };
this.overAllSer.createTrigger(res).subscribe( this.overAllSer.createTrigger(res).subscribe(
(response) => { (response) => {
if (response.errCode == 10000) { if (response.errCode == 10000) {
this.message.success('创建阈值成功'); this.message.success('创建告警阈值成功');
this.initForm(); this.initForm();
this.done.emit(); this.done.emit();
this.isVisiable = false; this.isVisiable = false;
...@@ -200,32 +111,43 @@ export class ThresholdComponent implements OnInit { ...@@ -200,32 +111,43 @@ export class ThresholdComponent implements OnInit {
} }
); );
} }
if (this.triggerObj.condition) { //告警触发器更新
//2.修改阈值 this.triggerObj.condition.expression = this.conditionExpression;
updateTrigger(data) { this.overAllSer.updateTrigger(this.triggerObj.condition).subscribe(res => {
const condition = {
id: this.triggerConditionId,
itemid: this.itemId,
expression: data.condition,
};
const faultCondition = {
id: this.triggerFaultConditionId,
itemid: this.itemId,
expression: data.faultCondition,
};
if (this.triggerConditionId) {
this.overAllSer.updateTrigger(condition).subscribe(res => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.success('更新告警阈值成功');
this.initForm(); this.initForm();
this.done.emit(); this.done.emit();
this.isOkLoading = false;
this.isVisiable = false; this.isVisiable = false;
} }
this.isOkLoading = false;
}); });
} }
if (this.triggerFaultConditionId) { if (!this.triggerObj.faultCondition && this.faultConditionExpression) { //严重触发器创建
this.overAllSer.updateTrigger(faultCondition).subscribe(res => { const res = {
itemName: this.itemObj.name,
faultCondition: this.faultConditionExpression,
itemid: this.itemId
};
this.overAllSer.createTrigger(res).subscribe(
(response) => {
if (response.errCode == 10000) {
this.message.success('创建严重阈值成功');
this.initForm();
this.done.emit();
this.isVisiable = false;
} else {
this.message.error(response.errMsg);
}
this.isOkLoading = false;
}
);
}
if (this.triggerObj.faultCondition) { //严重触发器更新
this.triggerObj.faultCondition.expression = this.faultConditionExpression;
this.overAllSer.updateTrigger(this.triggerObj.faultCondition).subscribe(res => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.success('更新严重阈值成功');
this.initForm(); this.initForm();
this.done.emit(); this.done.emit();
this.isVisiable = false; this.isVisiable = false;
......
...@@ -662,7 +662,7 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -662,7 +662,7 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
//编辑阈值 //编辑阈值
showEditThresholdModal(item) { showEditThresholdModal(item) {
this.smartThreshold.showEditModal('编辑阈值', item.id, this.hostId, item.name); this.smartThreshold.showEditModal('编辑阈值', item,item.id, this.hostId, item.name);
} }
//添加or编辑监测点 之后 //添加or编辑监测点 之后
......
...@@ -196,7 +196,7 @@ export class OverAllService { ...@@ -196,7 +196,7 @@ export class OverAllService {
} }
itemUpdata(data): Observable<any> { itemUpdata(data): Observable<any> {
return this.http.put(SERVER_API_URL + '/item/update', data); return this.http.post(SERVER_API_URL + '/item/update', data);
} }
//临时暂停 //临时暂停
......
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