Commit 81279855 authored by wangqinghua's avatar wangqinghua

监控项

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