Newer
Older
import {OverAllService} from '../../overAll/overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
selector: 'smart-website',
templateUrl: './website.component.html',
styles: []
})
export class WebsiteComponent implements OnInit {
constructor(private overAllSer:OverAllService,private message:NzMessageService) {
this.steps = [
{
name:'',
url:'',
status_codes:200,
posts:'',
no:this.indexNo,
timeout:'15',
follow_redirects:'1',
condition:'',
faultCondition:'',
}
];
delay:'',
retries:'',
http_proxy:'',
ssl_cert_file:'',
ssl_key_file:'',
ssl_key_password:'',
}
showAddModal() {
this.title = '添加网站监测';
this.isVisible = true;
}
this.overAllSer.findWeb(id).subscribe(
(res)=>{
if(res.errCode == 10000){
this.validateForm = res.data;
this.steps = res.data.steps;
}
}
)
// this.isVisible = false;
if(this.title == '添加网站监测'){
this.create();
}else{
this.update();
}
}
//创建
create(){
const data = {};
this.overAllSer.createWebscenario(this.validateForm).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.info('添加成功');
this.overAllSer.updateWebscenario(this.validateForm).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.info('添加成功');
this.isVisible = false;
this.done.emit();
this.initForm();
}else{
this.message.info(res.apiResponse.errMsg);
}
}
)
//添加步骤
addStep(){
this.indexNo += 1;
const data =
{
name:'',
url:'',
status_codes:200,
posts:'',
no:this.indexNo,
timeout:'15',
follow_redirects:'1',
condition:'',
faultCondition:'',
};
this.steps.push(data);
}
deleteStep(index){
this.steps.splice(index,1);
}