Commit cfb94508 authored by wangqinghua's avatar wangqinghua

update

parent 4a988a1f
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
</nz-form-item> </nz-form-item>
<ng-container *ngIf="isInterface"> <ng-container *ngIf="isInterface">
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="interfaceid">主机接口</nz-form-label> <nz-form-label [nzSpan]="6" nzFor="interfaceid">主机接口</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-select name="interfaceid" formControlName="interfaceid" nzPlaceHolder="选择主机接口"> <nz-select name="interfaceid" formControlName="interfaceid" nzPlaceHolder="选择主机接口">
<nz-option *ngFor="let item of interfaceList" nzValue="{{item.interfaceid}}" <nz-option *ngFor="let item of interfaceList" nzValue="{{item.interfaceid}}"
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="port">端口</nz-form-label> <nz-form-label [nzSpan]="6" nzFor="port">端口</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<input placeholder="输入端口" type="text" name="port" nz-input formControlName="port"> <input placeholder="输入端口" type="text" name="port" nz-input formControlName="port">
<nz-form-explain *ngIf="validateForm.get('port').dirty && validateForm.get('port').errors">请选择键值!</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('port').dirty && validateForm.get('port').errors">请选择键值!</nz-form-explain>
......
...@@ -27,8 +27,6 @@ export class DiscoveryComponent implements OnInit { ...@@ -27,8 +27,6 @@ export class DiscoveryComponent implements OnInit {
checkList; //监测点分类 checkList; //监测点分类
interval; //间隔时长 interval; //间隔时长
tabNum: number;
constructor(private overAllSer: OverAllService, private fb: FormBuilder, constructor(private overAllSer: OverAllService, private fb: FormBuilder,
private message: NzMessageService) { private message: NzMessageService) {
} }
...@@ -38,7 +36,6 @@ export class DiscoveryComponent implements OnInit { ...@@ -38,7 +36,6 @@ export class DiscoveryComponent implements OnInit {
} }
initForm() { initForm() {
this.tabNum = 0;
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
hostid: [this.hostId], hostid: [this.hostId],
name: [null, [Validators.required]], name: [null, [Validators.required]],
...@@ -74,7 +71,7 @@ export class DiscoveryComponent implements OnInit { ...@@ -74,7 +71,7 @@ export class DiscoveryComponent implements OnInit {
this.hostId = hostId; this.hostId = hostId;
this.isVisiable = true; this.isVisiable = true;
this.itemId = discoveryid; this.itemId = discoveryid;
this.overAllSer.findItemDetail(discoveryid).subscribe( this.overAllSer.findLldrule(discoveryid).subscribe(
(res) => { (res) => {
const data = res.data[0]; const data = res.data[0];
data.type += ''; data.type += '';
...@@ -102,7 +99,10 @@ export class DiscoveryComponent implements OnInit { ...@@ -102,7 +99,10 @@ export class DiscoveryComponent implements OnInit {
this.message.error('请输入必填信息'); this.message.error('请输入必填信息');
return false; return false;
} }
this.validateForm.value.status = this.validateForm.value.status ? 1:0; let d = this.validateForm.value.status == true ? 1 : 0;
this.validateForm.patchValue({
status:d
})
this.validateForm.value.hostid = this.hostId; this.validateForm.value.hostid = this.hostId;
if (this.title == '添加自动发现') { if (this.title == '添加自动发现') {
this.create(); this.create();
...@@ -118,7 +118,6 @@ export class DiscoveryComponent implements OnInit { ...@@ -118,7 +118,6 @@ export class DiscoveryComponent implements OnInit {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.success('创建自动发现成功'); this.message.success('创建自动发现成功');
this.done.emit(); this.done.emit();
this.tabNum = 1;
this.isVisiable = false; this.isVisiable = false;
} else { } else {
this.message.error(res.errMsg); this.message.error(res.errMsg);
...@@ -133,12 +132,12 @@ export class DiscoveryComponent implements OnInit { ...@@ -133,12 +132,12 @@ export class DiscoveryComponent implements OnInit {
//修改监控项 //修改监控项
update() { update() {
this.validateForm.addControl('itemid', new FormControl(this.itemId)); this.validateForm.addControl('itemid', new FormControl(this.itemId));
console.log(this.validateForm.value);
this.overAllSer.updateLldrule(this.validateForm.value).subscribe( this.overAllSer.updateLldrule(this.validateForm.value).subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.success('修改自动发现成功'); this.message.success('修改自动发现成功');
this.done.emit(); this.done.emit();
this.tabNum = 1;
this.isVisiable = false; this.isVisiable = false;
} else { } else {
this.message.error(res.errMsg); this.message.error(res.errMsg);
......
...@@ -21,6 +21,7 @@ export class StrategyComponent implements OnInit { ...@@ -21,6 +21,7 @@ export class StrategyComponent implements OnInit {
validateForm; validateForm;
tempId; //模版Id tempId; //模版Id
templateList = []; //模版组 templateList = []; //模版组
templatesResoure; //old模版
tempList; //模版 tempList; //模版
...@@ -116,9 +117,12 @@ export class StrategyComponent implements OnInit { ...@@ -116,9 +117,12 @@ export class StrategyComponent implements OnInit {
if (data.parentTemplates) { if (data.parentTemplates) {
//模版回显 //模版回显
this.validateForm.templates = data.parentTemplates.map(e => { let tempArr = [];
tempArr = data.parentTemplates.map(e => {
return e.templateid; return e.templateid;
}); });
this.validateForm.templates = tempArr;
this.templatesResoure = tempArr;
} }
} }
); );
...@@ -191,6 +195,16 @@ export class StrategyComponent implements OnInit { ...@@ -191,6 +195,16 @@ export class StrategyComponent implements OnInit {
} }
update(arr) { update(arr) {
//比较监控模版是否发生变化
const clearArr = [];
this.templatesResoure.forEach(res => {
if (this.validateForm.templates.indexOf(res) == -1) {
const d = {
templateid:res
}
clearArr.push(d);
}
});
const data = { const data = {
templateid: this.tempId, //模版id templateid: this.tempId, //模版id
host: this.validateForm.host, host: this.validateForm.host,
...@@ -202,7 +216,8 @@ export class StrategyComponent implements OnInit { ...@@ -202,7 +216,8 @@ export class StrategyComponent implements OnInit {
}; };
return d; return d;
}), }),
macros: [], templates_clear:clearArr,
macros: this.validateForm.macros,
hosts: [], hosts: [],
}; };
this.overAllSer.updateTemplates(data).subscribe( this.overAllSer.updateTemplates(data).subscribe(
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
<button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus-circle-o"></i>添加监控项原型</button> <button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus-circle-o"></i>添加监控项原型</button>
</div> </div>
<div nz-col nzSpan="18"></div> <div nz-col nzSpan="18"></div>
<div nz-col nzSpan="3"></div> <div nz-col nzSpan="3">
<button (click)="deleteBatchCheck()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>批量删除</button>
</div>
</div> </div>
<nz-table #nzTable [nzData]="checkList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading"> <nz-table #nzTable [nzData]="checkList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
...@@ -38,7 +40,6 @@ ...@@ -38,7 +40,6 @@
<th>名称</th> <th>名称</th>
<th>键值</th> <th>键值</th>
<th>间隔</th> <th>间隔</th>
<th>类型</th>
<th>状态</th> <th>状态</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
...@@ -49,11 +50,13 @@ ...@@ -49,11 +50,13 @@
<td class="round-tag tag-form">{{data.name}}</td> <td class="round-tag tag-form">{{data.name}}</td>
<td>{{data.key_}}</td> <td>{{data.key_}}</td>
<td>{{data.usedcount}}</td> <td>{{data.usedcount}}</td>
<td>{{data.type}}</td>
<td>{{data.status}}</td>
<td> <td>
<span>编辑</span> <span *ngIf="data.status == 0">启用</span>
<span>删除</span> <span *ngIf="data.status == 1">禁用</span>
</td>
<td class="main-color cursor">
<span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteCheck(data)">删除</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -110,7 +110,7 @@ export class CheckListComponent implements OnInit { ...@@ -110,7 +110,7 @@ export class CheckListComponent implements OnInit {
//单个删除 //单个删除
deleteCheck(item) { deleteCheck(item) {
this.commonSer.confirmThing('删除', '确定删除当前的自动发现', () => { this.commonSer.confirmThing('删除', '确定删除当前的监控项原型', () => {
const data = { const data = {
ids: [] ids: []
}; };
......
...@@ -105,12 +105,11 @@ ...@@ -105,12 +105,11 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="itemtype">监测点分类</nz-form-label> <nz-form-label [nzSpan]="6" nzFor="itemtype">监测点分类</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<nz-select style="width: 80%;display: inline-block" nzPlaceHolder="选择监测点分类" name="itemtype" <nz-select nzPlaceHolder="选择监测点分类" name="itemtype"
[nzSize]="nzSize" nzMode="tags" formControlName="applications"> [nzSize]="nzSize" nzMode="tags" formControlName="applications">
<nz-option *ngFor="let item of checkList" [nzValue]="item.applicationid" <nz-option *ngFor="let item of checkList" [nzValue]="item.applicationid"
[nzLabel]="item.name"></nz-option> [nzLabel]="item.name"></nz-option>
</nz-select> </nz-select>
<button nz-button nzType="primary" (click)="showTypeModal()">新建分类</button>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
......
...@@ -4,9 +4,9 @@ import {OverAllService} from '../../../overAll.service'; ...@@ -4,9 +4,9 @@ import {OverAllService} from '../../../overAll.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
@Component({ @Component({
selector: 'smart-trigger-prototype', selector: 'smart-trigger-prototype',
templateUrl: './trigger-prototype.component.html', templateUrl: './trigger-prototype.component.html',
styles: [] styles: []
}) })
export class TriggerPrototypeComponent implements OnInit { export class TriggerPrototypeComponent implements OnInit {
...@@ -31,10 +31,10 @@ export class TriggerPrototypeComponent implements OnInit { ...@@ -31,10 +31,10 @@ export class TriggerPrototypeComponent implements OnInit {
initForm() { initForm() {
this.triggerObj = { this.triggerObj = {
expression:"", expression: '',
priority:"2", priority: '2',
description:"" description: ''
} };
} }
//新增 //新增
...@@ -45,14 +45,17 @@ export class TriggerPrototypeComponent implements OnInit { ...@@ -45,14 +45,17 @@ export class TriggerPrototypeComponent implements OnInit {
} }
//编辑 //编辑
showEditModal(title,id, hostName) { showEditModal(title, id, hostName) {
this.title = title; this.title = title;
this.triggerId = id; this.triggerId = id;
this.isVisiable = true; this.isVisiable = true;
this.hostName = hostName; this.hostName = hostName;
this.overAllSer.findTriggerById(id).subscribe( this.overAllSer.findTriggerById(id).subscribe(
(res) => { (res) => {
const data = res.data[0];
this.triggerObj.expression = data.expression;
this.triggerObj.description = data.description;
this.triggerObj.priority = data.priority + '';
} }
); );
} }
...@@ -63,7 +66,7 @@ export class TriggerPrototypeComponent implements OnInit { ...@@ -63,7 +66,7 @@ export class TriggerPrototypeComponent implements OnInit {
this.message.error('请输入阈值'); this.message.error('请输入阈值');
return false; return false;
} }
if(this.title == "新增阈值原型"){ if (this.title == '新增阈值原型') {
this.createTrigger(); this.createTrigger();
} }
if (this.title == '编辑阈值原型') { if (this.title == '编辑阈值原型') {
...@@ -73,10 +76,10 @@ export class TriggerPrototypeComponent implements OnInit { ...@@ -73,10 +76,10 @@ export class TriggerPrototypeComponent implements OnInit {
//校验是否填值 //校验是否填值
checkFun() { checkFun() {
if(!this.triggerObj.expression){ if (!this.triggerObj.expression) {
this.message.error("请输入表达式"); this.message.error('请输入表达式');
return false; return false;
} }
return true; return true;
} }
...@@ -98,7 +101,13 @@ export class TriggerPrototypeComponent implements OnInit { ...@@ -98,7 +101,13 @@ export class TriggerPrototypeComponent implements OnInit {
//2.修改阈值 //2.修改阈值
updateTrigger() { updateTrigger() {
this.overAllSer.updateTriggerPrototype(this.triggerObj).subscribe(res => { const data = {
triggerid: this.triggerId,
expression: this.triggerObj.expression,
priority: this.triggerObj.priority,
description: this.triggerObj.description
};
this.overAllSer.updateTriggerPrototype(data).subscribe(res => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.success('修改阈值成功'); this.message.success('修改阈值成功');
this.initForm(); this.initForm();
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
<button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus-circle-o"></i>添加阈值原型</button> <button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus-circle-o"></i>添加阈值原型</button>
</div> </div>
<div nz-col nzSpan="18"></div> <div nz-col nzSpan="18"></div>
<div nz-col nzSpan="3"></div> <div nz-col nzSpan="3">
<button (click)="deleteBatchTrigger()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>批量删除</button>
</div>
</div> </div>
<nz-table #nzTable [nzData]="triggerList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading"> <nz-table #nzTable [nzData]="triggerList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
......
...@@ -104,7 +104,7 @@ export class TriggerListComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class TriggerListComponent implements OnInit {
} }
showEditModal(data) { showEditModal(data) {
this.smartTriggerPrototype.showEditModal('编辑阈值原型', data.id, this.tempName); this.smartTriggerPrototype.showEditModal('编辑阈值原型', data.triggerid, this.tempName);
} }
//单个删除 //单个删除
......
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