Newer
Older
import {OverAllService} from '../../overAll/overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
selector: 'smart-website',
templateUrl: './website.component.html',
styles: [
`
.middle {
height: 39px;
line-height: 39px;
}
.modal-footer-btn {
margin: 10px 0;
text-align: center;
}
.trigger-class {
border: 1px solid #ddd;
padding: 10px;
margin: 10px;
}
`
]
constructor(private overAllSer: OverAllService, private message: NzMessageService) {
name: '',
url: '',
status_codes: 200,
posts: '',
no: this.indexNo,
timeout: '15',
follow_redirects: '1',
conditionList: [],
condition: '',
faultConditionList: [],
faultCondition: '',
show: false
delay: '',
retries: '',
http_proxy: '',
ssl_cert_file: '',
ssl_key_file: '',
ssl_key_password: '',
}
showAddModal() {
this.title = '添加网站监测';
this.isVisible = true;
}
(res) => {
if (res.errCode == 10000) {
res.data.steps.forEach(e => {
e.follow_redirects += '';
});
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
);
}
//回显阈值
viewtrigger() {
this.steps.forEach(e => {
if (e.condition) {
e.condition = ' and ' + e.condition;
let strCon = e.condition.split(' ');
let arrCon = [];
let andArrCon = [];
strCon.forEach((value) => {
if (value.length > 0) {
if (value == 'and' || value == 'or') {
andArrCon.push(value);
} else {
const index = value.indexOf('}');
if (value.indexOf('0.0.0.0:web.test.time') > -1) { //响应时间
const obj1 = {
time: '0',
equal: value[index + 1],
value: value.substr(index + 2, value.length),
};
arrCon.push(obj1);
}
if (value.indexOf('0.0.0.0:web.test.rspcode') > -1) { //响应代码
const obj2 = {
time: '1',
equal: value[index + 1],
value: value.substr(index + 2, value.length),
};
arrCon.push(obj2);
}
}
}
});
arrCon.forEach((value, index) => {
value.and = ' ' + andArrCon[index] + ' ';
});
e.conditionList = arrCon;
}else{
e.condition = '';
e.conditionList = [];
}
if (e.faultCondition) {
e.faultCondition = ' and ' +e.faultCondition;
let strFau = e.faultCondition.split(' ');
let arrFau = [];
let andArrFau = [];
strFau.forEach((value) => {
if (value.length > 0) {
if (value == 'and' || value == 'or') {
andArrFau.push(value);
} else {
const index = value.indexOf('}');
if (value.indexOf('0.0.0.0:web.test.time') > -1) { //响应时间
const obj1 = {
time: '0',
equal: value[index + 1],
value: value.substr(index + 2, value.length),
};
arrFau.push(obj1);
}
if (value.indexOf('0.0.0.0:web.test.rspcode') > -1) { //响应代码
const obj2 = {
time: '1',
equal: value[index + 1],
value: value.substr(index + 2, value.length),
};
arrFau.push(obj2);
}
}
}
});
arrFau.forEach((value, index) => {
value.and = ' ' + andArrFau[index] + ' ';
});
e.faultConditionList = arrFau;
}else{
e.faultCondition = '';
e.faultConditionList = [];
}
});
this.isOkLoading = true;
this.getCondition();
if (this.title == '添加网站监测') {
this.isVisible = false;
this.done.emit();
this.initForm();
}
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
// 合成阈值
getCondition() {
this.validateForm.steps.forEach(e => { //步骤列表
if(e.conditionList){
e.condition = '';
e.conditionList.forEach(e1 => { //危险阈值列表
if (e1.time == '0') { //响应时间
e.condition += e1.and + '{0.0.0.0:web.test.time[' + this.validateForm.name + ',' + e.name + ',resp].last()}' + e1.equal + e1.value;
}
if (e1.time == '1') { //响应代码
e.condition += e1.and + '{0.0.0.0:web.test.rspcode[' + this.validateForm.name + ',' + e.name + '].last()}' + e1.equal + e1.value;
}
});
}
if(e.faultConditionList){
e.faultCondition = '';
e.faultConditionList.forEach(e2 => { //故障阈值列表
if (e2.time == '0') { //响应时间
e.faultCondition += e2.and + '{0.0.0.0:web.test.time[' + this.validateForm.name + ',' + e.name + ',resp].last()}' + e2.equal + e2.value;
}
if (e2.time == '1') { //响应代码
e.faultCondition += e2.and + '{0.0.0.0:web.test.rspcode[' + this.validateForm.name + ',' + e.name + '].last()}' + e2.equal + e2.value;
}
});
}
});
}
{
name: '',
url: '',
status_codes: 200,
posts: '',
no: this.indexNo,
timeout: '15',
follow_redirects: '1',
condition: '',
conditionList: [],
faultCondition: '',
faultConditionList: [],
show: false,
};
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
showCon(i) {
this.steps[i].show = true;
}
closeCon(i, bool) {
if (!bool) {
this.steps[i].conditionList = [];
this.steps[i].faultConditionList = [];
}
this.steps[i].show = false;
}
//删除步骤
deleteStep(index) {
this.steps.splice(index, 1);
}
/**
* 故障阈值添加
* @param i 步骤下标
*/
addFault(i) {
const demo = {
time: '0',
and: ' and ',
equal: '=',
value: '',
};
this.steps[i].faultConditionList.push(demo);
}
/**
* 危险阈值增加
* @param i 步骤下标
*/
addcondition(i) {
const demo = {
time: '0',
and: ' and ',
equal: '=',
value: '',
};
this.steps[i].conditionList.push(demo);
}
/**
* 删除故障阈值
* @param i 步骤下标
* @param index 故障下标
*/
deleteFault(i, index) {
this.steps[i].faultConditionList.splice(index, 1);
}
/**
* 删除危险阈值
* @param i 步骤下标
* @param index 故障下标
*/
deleteCondition(i, index) {
this.steps[i].conditionList.splice(index, 1);