Commit 81279855 authored by wangqinghua's avatar wangqinghua

监控项

parent c0063fd5
......@@ -413,4 +413,24 @@ export class OverAllService {
findItemById(params): Observable<any> {
return this.http.get(SERVER_API_URL + '/itemprototype/find/'+ params);
}
//创建触发器
createTri(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/trigger/create', data);
}
//修改触发器
updateTri(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/trigger/update', data);
}
//查询触发器
findTri(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/trigger/findTrigger', data);
}
//删除触发器
deleteTri(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/trigger/delete', data);
}
}
......@@ -6,6 +6,7 @@ import {CheckPrototypeComponent} from '../../modal/check-prototype/check-prototy
import {SystemService} from '../../../../system/system.service';
import {CommonService} from '../../../../shared/common/common.service';
import {NzMessageService} from 'ng-zorro-antd';
import {TriModalComponent} from '../tri-modal/tri-modal.component';
@Component({
selector: 'smart-item-list',
......@@ -37,7 +38,7 @@ import {NzMessageService} from 'ng-zorro-antd';
]
})
export class ItemListComponent implements OnInit {
@ViewChild('smartCheckProtoType') smartCheckProtoType: CheckPrototypeComponent;
@ViewChild('smartTriModal') smartTriModal: TriModalComponent;
tempName;
disName;
......
......@@ -14,9 +14,6 @@
<nz-breadcrumb-item>
模版:{{tempName}}
</nz-breadcrumb-item>
<nz-breadcrumb-item>
自动发现:{{disName}}
</nz-breadcrumb-item>
</nz-breadcrumb>
</div>
<div nz-col nzSpan="8" class="text-right">
......@@ -26,15 +23,19 @@
</div>
<div nz-row [nzGutter]="4" class="search-form">
<div nz-col nzSpan="3">
<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 nz-col nzSpan="18"></div>
<div nz-col nzSpan="3">
<div nz-col nzSpan="15">
<button (click)="deleteBatchTrigger()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>批量删除</button>
</div>
<div nz-col nzSpan="6">
<input (keyup.enter)="getList()" style="width: 200px;" type="text" nz-input [(ngModel)]="queryName" placeholder="输入阈值名称">
<button (click)="getList()" nz-button nzType="default"><i class="anticon anticon-search"
style="color: #6097b7"></i>搜索</button>
</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" [nzLoading]="loading">
<thead>
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked"
......@@ -47,12 +48,12 @@
</thead>
<tbody>
<tr *ngFor="let data of triggerList">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="selectItem(data,$event)"></td>
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="refreshStatus()"></td>
<td class="round-tag tag-form">
<nz-tag *ngIf="data.priority == 4 || data.priority == 5" [nzColor]="color.red"></nz-tag>
<nz-tag *ngIf="data.priority == 2 || data.priority == 3" [nzColor]="color.yellow"></nz-tag>
</td>
<td>{{data.comments}}</td>
<td>{{data.description}}</td>
<td>{{data.expression}}</td>
<td class="cursor main-color">
<span (click)="showEditModal(data)">编辑</span>
......@@ -61,5 +62,5 @@
</tr>
</tbody>
</nz-table>
<!--触发器原型-->
<smart-trigger-prototype #smartTriggerPrototype (done)="getList()"></smart-trigger-prototype>
\ No newline at end of file
<!--阈值-->
<smart-tri-modal #smartTriModal (done)="getList()"></smart-tri-modal>
......@@ -6,6 +6,7 @@ import {TriggerPrototypeComponent} from '../../modal/trigger-prototype/trigger-p
import {SystemService} from '../../../../system/system.service';
import {CommonService} from '../../../../shared/common/common.service';
import {NzMessageService} from 'ng-zorro-antd';
import {TriModalComponent} from '../tri-modal/tri-modal.component';
@Component({
selector: 'smart-tri-list',
......@@ -13,11 +14,11 @@ import {NzMessageService} from 'ng-zorro-antd';
styles: []
})
export class TriListComponent implements OnInit {
@ViewChild('smartTriggerPrototype') smartTriggerPrototype: TriggerPrototypeComponent;
@ViewChild('smartTriModal') smartTriModal: TriModalComponent;
tempName;
disName;
hostId;
discoveryids;
templateid;
queryName;
color = color;
loading = false;
......@@ -36,9 +37,8 @@ export class TriListComponent implements OnInit {
private commonSer: CommonService) {
this.routerInfo.queryParams.subscribe(
(res) => {
this.discoveryids = res.id;
this.tempName = res.name;
this.hostId = res.hostId;
this.templateid = res.templateid;
}
);
}
......@@ -52,19 +52,6 @@ export class TriListComponent implements OnInit {
this.triggerList = $event;
}
selectItem(item, e) {
if (e) {
this.selectList.push(item);
} else {
this.selectList.forEach((value, index) => {
if (value.id == item.id) {
this.selectList.splice(index, 1);
}
});
}
this.refreshStatus();
}
refreshStatus(): void {
const allChecked = this.triggerList.every(value => value.checked === true);
const allUnChecked = this.triggerList.every(value => !value.checked);
......@@ -85,35 +72,33 @@ export class TriListComponent implements OnInit {
getList() {
this.loading = true;
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount,
discoveryids: [this.discoveryids]
queryName:this.queryName,
templateids: [this.templateid]
};
this.overAllSer.findPageTrigger(data).subscribe(
this.overAllSer.findTri(data).subscribe(
(res) => {
this.triggerList = res.data.data;
this.totalNum = res.data.totalNum;
this.triggerList = res.data;
this.loading = false;
}
);
}
showAddModal() {
this.smartTriggerPrototype.showAddModal('新增阈值原型', this.tempName);
this.smartTriModal.showAddModal('新增阈值', this.tempName);
}
showEditModal(data) {
this.smartTriggerPrototype.showEditModal('编辑阈值原型', data.triggerid, this.tempName);
this.smartTriModal.showEditModal('编辑阈值', data.triggerid, this.tempName);
}
//单个删除
deleteTrigger(item) {
this.commonSer.confirmThing('删除', '确定删除当前的阈值原型', () => {
this.commonSer.confirmThing('删除', '确定删除当前的阈值', () => {
const data = {
ids: []
};
data.ids.push(item.triggerid);
this.overAllSer.deleteTrigger(data).subscribe(
this.overAllSer.deleteTri(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
......@@ -128,17 +113,21 @@ export class TriListComponent implements OnInit {
//批量删除
deleteBatchTrigger() {
if (this.selectList.length == 0) {
this.message.warning('请选择需要删除的阈值原型');
let arr = [];
this.triggerList.forEach(e => {
if (e.checked) {
arr.push(e.triggerid);
}
});
if (arr.length == 0) {
this.message.warning('请选择需要删除的阈值');
return false;
}
this.commonSer.confirmThing('删除', '确定删除选择的阈值原型', () => {
this.commonSer.confirmThing('删除', '确定删除选择的阈值', () => {
const data = {
ids: this.selectList.map(e => {
return e.triggerid;
})
ids: arr
};
this.overAllSer.deleteTrigger(data).subscribe(
this.overAllSer.deleteTri(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
......
......@@ -2,6 +2,13 @@
(nzOnOk)="saveTrigger()">
<div nz-form class="ant-advanced-search-form form-select">
<nz-form-item nzFlex>
<nz-form-label [nzSpan]="6" nzRequired nzFor="description">名称</nz-form-label>
<nz-form-control [nzSpan]="14">
<input name="description" type="text" nz-input [(ngModel)]="triggerObj.description">
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item nzFlex>
<nz-form-label [nzSpan]="6" nzRequired nzFor="priority">严重性</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-radio-group [(ngModel)]="triggerObj.priority">
......@@ -19,9 +26,9 @@
</nz-form-control>
</nz-form-item>
<nz-form-item nzFlex>
<nz-form-label [nzSpan]="6" nzRequired nzFor="priority">描述</nz-form-label>
<nz-form-label [nzSpan]="6" nzFor="comments">描述</nz-form-label>
<nz-form-control [nzSpan]="14">
<textarea nz-input name="description" [(ngModel)]="triggerObj.description" placeholder="描述"
<textarea nz-input name="comments" [(ngModel)]="triggerObj.comments" placeholder="描述"
[nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
</nz-form-control>
</nz-form-item>
......
......@@ -32,7 +32,8 @@ export class TriModalComponent implements OnInit {
this.triggerObj = {
expression: '',
priority: '2',
description: ''
description: '',
comments:''
};
}
......@@ -54,6 +55,7 @@ export class TriModalComponent implements OnInit {
const data = res.data[0];
this.triggerObj.expression = data.expression;
this.triggerObj.description = data.description;
this.triggerObj.comments = data.comments;
this.triggerObj.priority = data.priority + '';
}
);
......@@ -65,10 +67,10 @@ export class TriModalComponent implements OnInit {
this.message.error('请输入阈值');
return false;
}
if (this.title == '新增阈值原型') {
if (this.title == '新增阈值') {
this.createTrigger();
}
if (this.title == '编辑阈值原型') {
if (this.title == '编辑阈值') {
this.updateTrigger();
}
}
......@@ -79,12 +81,16 @@ export class TriModalComponent implements OnInit {
this.message.error('请输入表达式');
return false;
}
if (!this.triggerObj.description) {
this.message.error('请输入名称');
return false;
}
return true;
}
//1.创建阈值
createTrigger() {
this.overAllSer.createTriggerPrototype(this.triggerObj).subscribe(
this.overAllSer.createTri(this.triggerObj).subscribe(
(response) => {
if (response.errCode == 10000) {
this.message.success('创建阈值成功');
......@@ -104,9 +110,10 @@ export class TriModalComponent implements OnInit {
triggerid: this.triggerId,
expression: this.triggerObj.expression,
priority: this.triggerObj.priority,
description: this.triggerObj.description
description: this.triggerObj.description,
comments: this.triggerObj.comments
};
this.overAllSer.updateTriggerPrototype(data).subscribe(res => {
this.overAllSer.updateTri(data).subscribe(res => {
if (res.errCode == 10000) {
this.message.success('修改阈值成功');
this.initForm();
......
......@@ -52,7 +52,7 @@
<nz-tag *ngIf="data.priority == 4 || data.priority == 5" [nzColor]="color.red"></nz-tag>
<nz-tag *ngIf="data.priority == 2 || data.priority == 3" [nzColor]="color.yellow"></nz-tag>
</td>
<td>{{data.comments}}</td>
<td>{{data.description}}</td>
<td>{{data.expression}}</td>
<td class="cursor main-color">
<span (click)="showEditModal(data)">编辑</span>
......
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