Newer
Older
import {Component, EventEmitter, OnInit, Output, ViewChild} from '@angular/core';
import {BasicKeyComponent} from '../basic-key/basic-key.component';
import {NzMessageService} from 'ng-zorro-antd';
import {NewTypeComponent} from '../new-type/new-type.component';
selector: 'smart-basi-check',
templateUrl: './basi-check.component.html',
styles: [
`.tag-button[disabled],
.tag-button {
width: 80%;
height: 30px;
color: rgba(0, 0, 0, 0.65);
background-color: #fff;
border-color: #d9d9d9;
:host ::ng-deep .ant-tabs-nav .ant-tabs-tab-disabled {
color: rgba(0, 0, 0, .65);
@ViewChild('basicKey') basicKey: BasicKeyComponent;
@ViewChild('newType') newType: NewTypeComponent;
constructor(private overAllSer: OverAllService, private fb: FormBuilder,
private message: NzMessageService) {
}
ngOnInit() {
hostid: [this.hostId],
name: [null, [Validators.required]],
interfaceid: [null, [Validators.required]],
key_: [null, [Validators.required]],
value_type: [null, [Validators.required]],
type: [null, [Validators.required]],
units: [null],
formula: [null, [Validators.required]],
history: ['3600'],
trends: [null],
valuemapid: ['0'],
delay: [null, [Validators.required]],
snmp_oid: [null],
snmp_community: ['public'],
this.title = '添加监测点';
this.isCheck = true;
this.hostId = hostId;
//主机接口
this.overAllSer.findDetailed(this.hostId).subscribe(
(res) => {
this.interfaceList = res.data[0].interfaces;
}
);
this.getItemType();
}
let con = '';
let a = str.split(' ');
a.forEach((e) => { // 符号数组
let index1 = e.indexOf('}');
if (e == 'and' || e == 'or') {
if (index1 > -1) {
let f = e.substring(index1 + 1, e.length);
con += '{' + this.hostName + ':' + this.validateForm.value.key_ + '.last()}' + f + ' ';
} else {
con += e + ' ';
let c = str.replace(/and/g, '').replace(/or/g, '').split(' ');
c.forEach((val, index) => {
let index1 = val.indexOf('}');
let d = val.substring(index1 + 1, val.length);
this.faultConditionList = arr;
this.triggerObj.condition = con;
this.conditionList = arr;
this.triggerObj.faultCondition = con;
this.overAllSer.findDetailed(this.hostId).subscribe(
(res) => {
this.interfaceList = res.data[0].interfaces;
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
if (this.validateForm.invalid) {
this.message.error('请输入必填信息');
this.validateForm.value.applications = [this.validateForm.value.applications];
update() {
this.validateForm.addControl('itemid', new FormControl(this.itemId));
};
if (this.conditionType == 'commonly') { //常规
this.conditionList.forEach(res => {
if(!res.and){
res.and = "";
}
data.condition += res.and + '{' + this.hostName + ':' + this.validateForm.value.key_ + '.last()}' + res.equal + '' + res.value ;
});
if(!res.and){
res.and = "";
}
data.faultCondition += res.and + '{' + this.hostName + ':' + this.validateForm.value.key_ + '.last()}' + res.equal + '' + res.value ;
data.condition = this.triggerObj.condition;
data.faultCondition = this.triggerObj.faultCondition;
if(!this.checkFun()){
this.message.error("请输入阈值");
return false;
}
if(this.conditionList.length == 0 && this.faultConditionList.length == 0){
this.isCheck = false;
this.initForm();
return false;
}
//校验是否填值
checkFun(){
let error = true;
this.conditionList.map(e=>{
if(e.value.length > 0){
console.log(e.value)
}else{
error = false;
}
});
this.faultConditionList.map(e=>{
if(e.value.length > 0){
console.log(e.value)
}else{
error = false;
}
});
return error;
}
itemName: this.validateForm.value.name,
faultCondition: data.faultCondition,
condition: data.condition
(response) => {
if (response.errCode == 10000) {
this.message.success('创建阈值成功');
faultCondition: {
itemName: this.validateForm.value.name,
faultCondition: data.faultCondition,
triggerid: this.triggerFaultConditionId
},
condition: {
itemName: this.validateForm.value.name,
condition: data.condition,
triggerid: this.triggerConditionId
}
this.overAllSer.updateTrigger(res).subscribe(res => {
if (res.errCode == 10000) {
this.message.success('修改阈值成功');