Commit d43ca8df authored by wangqinghua's avatar wangqinghua

template

parent c7ab0af1
......@@ -104,6 +104,8 @@ import {StrategyComponent} from './modal/strategy/strategy.component';
import {DiscoveryListComponent} from './overAll/template/discovery-list/discovery-list.component';
import {CheckListComponent} from './overAll/template/check-list/check-list.component';
import {TriggerListComponent} from './overAll/template/trigger-list/trigger-list.component';
import {TriggerPrototypeComponent} from './overAll/template/modal/trigger-prototype/trigger-prototype.component';
import {CheckPrototypeComponent} from './overAll/template/modal/check-prototype/check-prototype.component';
@NgModule({
imports: [
......@@ -210,6 +212,8 @@ import {TriggerListComponent} from './overAll/template/trigger-list/trigger-list
DiscoveryListComponent,
CheckListComponent,
TriggerListComponent,
TriggerPrototypeComponent,
CheckPrototypeComponent,
],
providers:[
OverAllService,
......
......@@ -70,7 +70,14 @@ export class AlarmModalComponent implements OnInit {
mediaTypeIds:[],
def_longdata:null,
r_longdata:null,
r_shortdata:null,
r_shortdata:'' +
'问题 {TRIGGER.NAME} 恢复于: {EVENT.TIME} {EVENT.DATE} \n' +
'主机: {HOST.NAME}\n' +
'严重程度: {TRIGGER.SEVERITY}\n' +
'\n' +
'原始问题ID: {EVENT.ID}\n' +
'{TRIGGER.URL}'
,
sendInfos:null,
event:{
eventTypeId:null, //事件分类id
......
......@@ -69,12 +69,12 @@ export class DiscoveryComponent implements OnInit {
}
//编辑
showEditModal(hostId, id) {
this.title = '编辑监测点';
showEditModal(hostId, discoveryid,title) {
this.title = title;
this.hostId = hostId;
this.isVisiable = true;
this.itemId = id;
this.overAllSer.findItemDetail(id).subscribe(
this.itemId = discoveryid;
this.overAllSer.findItemDetail(discoveryid).subscribe(
(res) => {
const data = res.data[0];
data.type += '';
......
......@@ -57,14 +57,15 @@ export class SelectRoleComponent implements OnInit {
ngOnInit() {
}
initForm(){
this.allChecked = false;
}
showModal(title,id) {
this.title = title;
this.isVisible = true;
this.userId = id;
const data = {
userId:this.userId
}
this.systemSer.getRoleByUserId(data).subscribe(
this.systemSer.getRoleByUserId(this.userId).subscribe(
(res)=>{
this.userRoleList = res.data;
this.getRole();
......@@ -91,6 +92,7 @@ export class SelectRoleComponent implements OnInit {
handEditleOk(){
this.done.emit(this.selectList);
this.allChecked = false;
this.isVisible = false;
}
......
......@@ -25,7 +25,7 @@
</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>
......@@ -36,24 +36,28 @@
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked" (nzCheckedChange)="checkAll($event)"></th>
<th>名称</th>
<th>监控项</th>
<th>阈值</th>
<th>键值</th>
<th>间隔</th>
<th>类型</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of checkList">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="selectItem(data,$event)"></td>
<td class="round-tag tag-form">{{data.inventoryNo}}</td>
<td>{{data.name}}</td>
<td>{{data.inventorycount}}</td>
<td>{{data.stock}}</td>
<td>{{data.usedcount}}</td>
<td>{{data.lendcount}}</td>
<td>{{data.repaircount}}</td>
<td>
<span>编辑</span>
<span>删除</span>
</td>
</tr>
</tbody>
</nz-table>
<!--监控项原型-->
<smart-check-prototype #smartCheckProtoType></smart-check-prototype>
\ No newline at end of file
import { Component, OnInit } from '@angular/core';
import {Component, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service';
import {SystemService} from '../../../system/system.service';
import {OverAllService} from '../../overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
import {pageSize} from '../../../app.constants';
import {CheckPrototypeComponent} from '../modal/check-prototype/check-prototype.component';
@Component({
selector: 'smart-check-list',
......@@ -12,9 +13,11 @@ import {pageSize} from '../../../app.constants';
styles: []
})
export class CheckListComponent implements OnInit {
@ViewChild('smartCheckProtoType') smartCheckProtoType:CheckPrototypeComponent;
tempName;
disName;
hostId;
discoveryids;
pageNum = 1;
......@@ -33,7 +36,8 @@ export class CheckListComponent implements OnInit {
this.routerInfo.queryParams.subscribe(
(res) => {
this.discoveryids = res.id;
this.tempName = res.name
this.tempName = res.name;
this.hostId = res.hostId;
}
);
}
......@@ -85,7 +89,58 @@ export class CheckListComponent implements OnInit {
);
}
//新增监控项原型
showAddModal(){
this.smartCheckProtoType.showAddModal(this.hostId,this.tempName,"添加监控项原型")
}
//编辑监控项原型
showEditModal(data){
this.smartCheckProtoType.showEditModal(this.hostId,data.id,this.tempName,"编辑监控项原型")
}
//单个删除
deleteCheck(item){
this.commonSer.confirmThing("删除","确定删除当前的自动发现",()=>{
const data ={
ids:[]
};
data.ids.push(item.itemid);
this.overAllSer.deleteItemPrototype(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList();
}else{
this.message.error(res.errMsg);
}
}
)
})
}
//批量删除
deleteBatchCheck(){
if(this.selectList.length == 0){
this.message.warning("请选择需要删除的监控项原型");
return false;
}
this.commonSer.confirmThing("删除","确定删除选择的监控项原型",()=>{
const data ={
ids:this.selectList.map(e=>{
return e.itemid;
})
};
this.overAllSer.deleteItemPrototype(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList();
}else{
this.message.error(res.errMsg);
}
}
)
})
}
}
......@@ -39,6 +39,7 @@
<th>间隔</th>
<th>类型</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
......@@ -55,6 +56,13 @@
<td>{{data.usedcount}}</td>
<td>{{data.lendcount}}</td>
<td>{{data.repaircount}}</td>
<td class="main-color cursor">
<span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteDiscovery(data)">删除</span>
</td>
</tr>
</tbody>
</nz-table>
<!--自动发现-->
<smart-discovery #smartDiscovery></smart-discovery>
\ No newline at end of file
import {Component, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service';
import {WorkService} from '../../../work/work.service';
import {SystemService} from '../../../system/system.service';
import {AssetsComponent} from '../../../work/modal/assets/assets.component';
import {pageSize, SERVER_API_URL} from '../../../app.constants';
import {UploadComponent} from '../../../work/modal/upload/upload.component';
import {NzMessageService} from 'ng-zorro-antd';
import {OverAllService} from '../../overAll.service';
import {DiscoveryComponent} from '../../../modal/discovery/discovery.component';
@Component({
selector: 'smart-discovery-list',
......@@ -15,11 +13,9 @@ import {OverAllService} from '../../overAll.service';
styles: []
})
export class DiscoveryListComponent implements OnInit {
@ViewChild('smartDiscovery') smartDiscovery: DiscoveryComponent;
@ViewChild('smartAssets') smartAssets:AssetsComponent;
@ViewChild('smartUpload') smartUpload:UploadComponent;
hostId;
templateid;
discoveryList;
tempName;
......@@ -37,7 +33,7 @@ export class DiscoveryListComponent implements OnInit {
private commonSer:CommonService) {
this.routerInfo.queryParams.subscribe(
(res) => {
this.hostId = res.hostId;
this.templateid = res.templateid;
this.tempName = res.name
}
);
......@@ -80,7 +76,7 @@ export class DiscoveryListComponent implements OnInit {
const data = {
pageNum:this.pageNum,
pageCount:this.pageCount,
hostIds:[this.hostId]
hostIds:[this.templateid]
};
this.overAllSer.findPageLldrule(data).subscribe(
(res) => {
......@@ -90,18 +86,50 @@ export class DiscoveryListComponent implements OnInit {
);
}
//删除资产--单个
deleteInVentory(item){
const data = {
inventoryIds:[]
//添加自动发现
showAddModal() {
this.smartDiscovery.showAddModal(this.templateid,"添加自动发现")
}
//编辑自动发现
showEditModal(data){
this.smartDiscovery.showEditModal(this.templateid,data.itemid,"编辑自动发现");
}
//goto 监测项原型
goToCheck(data){
this.router.navigate(['app/main/checkList'],{
queryParams:{
id:data.itemid,
name:data.name,
tempName : this.tempName
}
})
}
//goto 阈值原型
goToTrigger(data){
this.router.navigate(['app/main/triggerList'],{
queryParams:{
id:data.itemid,
name:data.name,
tempName : this.tempName
}
})
}
//单个删除
deleteDiscovery(item){
this.commonSer.confirmThing("删除","确定删除当前的自动发现",()=>{
const data ={
ids:[]
};
data.inventoryIds.push(item.id);
this.commonSer.confirmThing("删除","确定删除该资产?",()=>{
data.ids.push(item.itemid);
this.overAllSer.deleteLldrule(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList();
this.message.success("删除资产成功");
}else{
this.message.error(res.errMsg);
}
......@@ -111,22 +139,22 @@ export class DiscoveryListComponent implements OnInit {
}
//批量删除
batchDeleteInventory(){
deleteBatchDiscovery(){
if(this.selectList.length == 0){
this.message.warning("请选择需要删除的资产");
this.message.warning("请选择需要删除的自动发现");
return false;
}
const data = {
inventoryIds:this.selectList.map(e=>{
return e.id;
this.commonSer.confirmThing("删除","确定删除选择的自动发现",()=>{
const data ={
ids:this.selectList.map(e=>{
return e.itemid;
})
};
this.commonSer.confirmThing("批量删除","确定删除选择的资产?",()=>{
this.overAllSer.deleteLldrule(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList();
this.message.success("删除资产成功");
}else{
this.message.error(res.errMsg);
}
......@@ -134,36 +162,4 @@ export class DiscoveryListComponent implements OnInit {
)
})
}
//添加资产
showAddModal() {
this.smartAssets.showAddModal("添加资产");
}
//编辑资产
showEditModal(id){
this.smartAssets.showEditModal("编辑资产",id);
}
//goto 监测项原型
goToCheck(data){
this.router.navigate(['app/main/checkList'],{
queryParams:{
id:data.itemid,
name:data.name,
tempName : this.tempName
}
})
}
//goto 阈值原型
goToTrigger(data){
this.router.navigate(['app/main/triggerList'],{
queryParams:{
id:data.itemid,
name:data.name,
tempName : this.tempName
}
})
}
}
<nz-modal [nzWidth]="880" [(nzVisible)]="isCheck" [nzTitle]="title" (nzOnCancel)="handleCheckCancel()"
(nzOnOk)="handleCheckOk()">
<form [formGroup]="validateForm" nz-form>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="checkName">监测点名称</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="checkName" name="checkName" type="text" nz-input formControlName="name">
<nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').errors">请输入监测点名称!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="type">类型</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="type" name="type" nzPlaceHolder="选择类型" formControlName="type">
<nz-option nzValue="0" nzLabel="Agent客户端"></nz-option>
<nz-option nzValue="7" nzLabel="Agent客户端(主动式)"></nz-option>
<nz-option nzValue="3" nzLabel="简单检查"></nz-option>
<nz-option nzValue="1" nzLabel="SNMPv1 客户端"></nz-option>
<nz-option nzValue="4" nzLabel="SNMPv2 客户端"></nz-option>
<nz-option nzValue="6" nzLabel="SNMPv3 客户端"></nz-option>
<nz-option nzValue="5" nzLabel="Agent内部"></nz-option>
<nz-option nzValue="2" nzLabel="Agent采集器"></nz-option>
<nz-option nzValue="8" nzLabel="Agent整合"></nz-option>
<nz-option nzValue="10" nzLabel="外部检查"></nz-option>
<nz-option nzValue="11" nzLabel="数据库监控"></nz-option>
<nz-option nzValue="12" nzLabel="IPMI客户端"></nz-option>
<nz-option nzValue="13" nzLabel="SSH 客户端"></nz-option>
<nz-option nzValue="14" nzLabel="TELNET客户端"></nz-option>
<nz-option nzValue="16" nzLabel="JMX agent代理程序"></nz-option>
<nz-option nzValue="15" nzLabel="可计算的"></nz-option>
<nz-option nzValue="18" nzLabel="相关项目"></nz-option>
</nz-select>
<nz-form-explain *ngIf="validateForm.get('type').dirty && validateForm.get('type').errors">请选择监测点类型!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<ng-container *ngIf="isInterface">
<ng-container *ngIf=" validateForm.value.type == '0' || validateForm.value.type == '1' || validateForm.value.type == '3' ||
validateForm.value.type == '4' || validateForm.value.type == '6' || validateForm.value.type == '10' || validateForm.value.type == '12' ||
validateForm.value.type == '13' || validateForm.value.type == '14' || validateForm.value.type == '16' || validateForm.value.type == '17'">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="interfaceid">主机接口</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="interfaceid" formControlName="interfaceid" nzPlaceHolder="选择主机接口">
<nz-option *ngFor="let item of interfaceList" nzValue="{{item.interfaceid}}"
nzLabel="{{item.ip}}:{{item.port}}"></nz-option>
</nz-select>
<nz-form-explain *ngIf="validateForm.get('interfaceid').dirty && validateForm.get('interfaceid').errors">请选择主机接口!</nz-form-explain>
</nz-form-control>
</nz-form-item>
</ng-container>
</ng-container>
<ng-container *ngIf="validateForm.value.type == 1 || validateForm.value.type == 4 || validateForm.value.type == 6">
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="snmp_oid">SNMP OID</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="snmp_oid" name="snmp_oid" type="text" nz-input formControlName="snmp_oid">
<!--<nz-form-explain *ngIf="validateForm.get('note').dirty && validateForm.get('note').errors">Please input your username!</nz-form-explain>-->
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="snmp_community">SNMP community</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="snmp_community" name="units" type="text" nz-input
formControlName="snmp_community">
<!--<nz-form-explain *ngIf="validateForm.get('note').dirty && validateForm.get('note').errors">Please input your username!</nz-form-explain>-->
</nz-form-control>
</nz-form-item>
</ng-container>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="key_">键值</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="key_" style="width: 85%;display: inline-block" placeholder="输入键值" type="text" name="key_"
nz-input formControlName="key_">
<button nz-button nzType="primary" (click)="showKeymodal()">选择</button>
<nz-form-explain *ngIf="validateForm.get('key_').dirty && validateForm.get('key_').errors">请选择键值!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="value_type">信息类型</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="value_type" formControlName="value_type" nzPlaceHolder="请选择信息类型">
<nz-option nzValue="0" nzLabel="浮点数"></nz-option>
<nz-option nzValue="1" nzLabel="字符"></nz-option>
<nz-option nzValue="2" nzLabel="日志"></nz-option>
<nz-option nzValue="3" nzLabel="整数"></nz-option>
<nz-option nzValue="4" nzLabel="文本"></nz-option>
</nz-select>
<nz-form-explain *ngIf="validateForm.get('value_type').dirty && validateForm.get('value_type').errors">请选择信息类型!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="units">单位</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="units" name="units" type="text" nz-input formControlName="units">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzFor="itemtype">监测点分类</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select style="width: 80%;display: inline-block" nzPlaceHolder="选择监测点分类" name="itemtype" [nzSize]="nzSize" nzMode="tags" formControlName="applications">
<nz-option *ngFor="let item of checkList" [nzValue]="item.applicationid"
[nzLabel]="item.name"></nz-option>
</nz-select>
<button nz-button nzType="primary" (click)="showTypeModal()">新建分类</button>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6" nzRequired nzFor="delay">数据更新间隔</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="delay" name="delay" type="text" placeholder="输入数据更新间隔" nz-input
formControlName="delay">
<nz-form-explain *ngIf="validateForm.get('delay').dirty && validateForm.get('delay').errors">请输入数据更新间隔!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6">历史数据保留时长(单位天)</nz-form-label>
<nz-form-control [nzSpan]="14" nzFor="history">
<input type="text" name="history" id="history" placeholder="输入历史数据保留时长" nz-input
formControlName="history">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6">趋势数据存储周期(单位天)</nz-form-label>
<nz-form-control [nzSpan]="14">
<input type="text" name="trends" nz-input formControlName="trends">
</nz-form-control>
</nz-form-item>
</form>
</nz-modal>
<!--键值查询-->
<smart-basic-key (keyValue)="getKey($event)" #basicKey></smart-basic-key>
<!--新建分类-->
<smart-new-type (data)="addItemType($event)" #newType></smart-new-type>
import {Component, EventEmitter, OnInit, Output, ViewChild} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {OverAllService} from '../../../overAll.service';
import {BasicKeyComponent} from '../../../../modal/basic-key/basic-key.component';
import {NewTypeComponent} from '../../../../modal/new-type/new-type.component';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
selector: 'smart-check-prototype',
templateUrl: './check-prototype.component.html',
styles: []
})
export class CheckPrototypeComponent implements OnInit {
@ViewChild('basicKey') basicKey: BasicKeyComponent;
@ViewChild('newType') newType: NewTypeComponent;
@Output() done = new EventEmitter<any>();
title;
isCheck = false;
isInterface = true; //添加模版监测点的时候不需要主机接口
nzSize = 'large';
hostId; //主机ID
hostName; //主机name
itemId; //监控项id
interfaceList: any[];
valueMapList = [];
validateForm: FormGroup;
checkList; //监测点分类
interval; //间隔时长
tabNum: number;
triggerObj = {
condition: '',
faultCondition: '',
itemName: ''
};
constructor(private overAllSer: OverAllService, private fb: FormBuilder,
private message: NzMessageService) {
}
ngOnInit() {
this.initForm();
this.getValuemap();
}
initForm() {
this.tabNum = 0;
this.validateForm = this.fb.group({
hostid: [this.hostId],
name: [null, [Validators.required]],
interfaceid: [null],
key_: [null, [Validators.required]],
value_type: [null, [Validators.required]],
type: [null, [Validators.required]],
units: [null],
history: ['3600'],
trends: [null],
delay: [null, [Validators.required]],
snmp_oid: ['interfaces.ifTable.ifEntry.ifInOctets.1'],
snmp_community: ['public'],
applications: [null],
});
this.triggerObj = {
condition: '',
faultCondition: '',
itemName: ''
};
}
//新增
showAddModal(hostId, hostName,title) {
this.title = title;
this.isCheck = true;
this.hostId = hostId;
this.hostName = hostName;
if(this.title == '添加监测点'){
//主机接口
this.overAllSer.findInterface(this.hostId).subscribe(
(res) => {
this.interfaceList = res.data;
}
);
this.isInterface = true;
}
if(this.title == '添加模版监测点'){
this.isInterface = false;
this.validateForm.get('interfaceid').clearValidators();
}
this.getItemType();
}
//映射值
getValuemap() {
// this.overAllSer.findValuemap().subscribe(
// (res) => {
// if (res.errCode == 10000) {
// this.valueMapList = res.data;
// } else {
// this.message.error(res.errMsg);
// }
// }
// );
}
//编辑
showEditModal(hostId, id, hostName,title) {
this.title = title;
this.hostId = hostId;
this.isCheck = true;
this.itemId = id;
this.hostName = hostName;
this.overAllSer.findItemDetail(id).subscribe(
(res) => {
const data = res.data[0];
data.type += '';
data.interfaceid += '';
data.value_type += '';
if(data.applications){
data.applications = data.applications.map(e=>{
return e.applicationid;
});
}
this.validateForm.patchValue(data);
}
);
//主机接口
this.overAllSer.findInterface(this.hostId).subscribe(
(res) => {
this.interfaceList = res.data;
}
);
this.getItemType();
}
//获取监测点分类
getItemType() {
//监测点分类
const data = {
'hostids': [this.hostId]
};
this.overAllSer.findItemType(data).subscribe(
(res) => {
this.checkList = res.data;
}
);
}
//添加
handleCheckOk() {
const list = ['0','1','3','4','6','10','12','13','14','16','17'];
if(list.indexOf(this.validateForm.value.type) > -1){
this.validateForm.get('type').setValidators(Validators.required);
}
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
if (this.validateForm.invalid) {
this.message.error('请输入必填信息');
return false;
}
this.validateForm.value.applications = [this.validateForm.value.applications];
this.validateForm.value.hostid = this.hostId;
if (this.title == '添加监测点原型') {
this.create();
}
if (this.title == '编辑监测点原型') {
this.update();
}
}
create() {
this.overAllSer.create(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('创建监测点成功');
this.done.emit();
this.tabNum = 1;
this.isCheck = false;
} else {
this.message.error(res.errMsg);
}
},
(err) => {
this.message.error('系统错误');
}
);
}
//修改监控项
update() {
this.validateForm.addControl('itemid', new FormControl(this.itemId));
this.overAllSer.itemUpdata(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('修改监测点成功');
this.done.emit();
this.tabNum = 1;
this.isCheck = false;
} else {
this.message.error(res.errMsg);
}
},
(err) => {
this.message.error('系统错误');
}
);
}
handleCheckCancel(): void {
this.isCheck = false;
this.initForm();
}
//键值查询
showKeymodal() {
this.basicKey.showKeyModal();
}
//新增分类
showTypeModal() {
this.newType.showModal('新建分类');
}
//添加分类
addItemType(data) {
const obj = {
hostid: this.hostId,
name: data
};
this.overAllSer.createItemType(obj).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('添加成功');
this.getItemType();
} else {
this.message.error(res.errMsg);
}
}
);
}
getKey(keyValue): void {
const d = {
key_: keyValue
};
this.validateForm.patchValue(d);
}
}
<nz-modal [nzWidth]="880" [(nzVisible)]="isVisiable" [nzTitle]="title" (nzOnCancel)="handleCheckCancel()"
(nzOnOk)="saveTrigger()">
<div nz-form class="ant-advanced-search-form form-select">
<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">
<label nz-radio-button nzValue="2">危险</label>
<label nz-radio-button nzValue="3">故障</label>
</nz-radio-group>
</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">
<textarea nz-input name="description" [(ngModel)]="triggerObj.expression" placeholder="描述"
[nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
</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">
<textarea nz-input name="description" [(ngModel)]="triggerObj.description" placeholder="描述"
[nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
</nz-form-control>
</nz-form-item>
</div>
</nz-modal>
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {FormBuilder} from '@angular/forms';
import {OverAllService} from '../../../overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
selector: 'smart-trigger-prototype',
templateUrl: './trigger-prototype.component.html',
styles: []
})
export class TriggerPrototypeComponent implements OnInit {
@Output() done = new EventEmitter<any>();
isVisiable = false;
title;
triggerId; //阈值id
itemId; //监控项ID
hostName; //主机name
itemObj; //监控项对象
triggerObj;
constructor(private overAllSer: OverAllService, private fb: FormBuilder,
private message: NzMessageService) {
}
ngOnInit() {
this.initForm();
}
initForm() {
this.triggerObj = {
expression:"",
priority:"2",
description:""
}
}
//新增
showAddModal(title, hostName) {
this.title = title;
this.isVisiable = true;
this.hostName = hostName;
}
//编辑
showEditModal(title,id, hostName) {
this.title = title;
this.triggerId = id;
this.isVisiable = true;
this.hostName = hostName;
this.overAllSer.findTriggerById(id).subscribe(
(res) => {
}
);
}
//阈值--start
saveTrigger() {
if (!this.checkFun()) {
this.message.error('请输入阈值');
return false;
}
if(this.title == "新增阈值原型"){
this.createTrigger();
}
if (this.title == '编辑阈值原型') {
this.updateTrigger();
}
}
//校验是否填值
checkFun() {
if(!this.triggerObj.expression){
this.message.error("请输入表达式");
return false;
}
return true;
}
//1.创建阈值
createTrigger() {
this.overAllSer.createTriggerPrototype(this.triggerObj).subscribe(
(response) => {
if (response.errCode == 10000) {
this.message.success('创建阈值成功');
this.initForm();
this.done.emit();
this.isVisiable = false;
} else {
this.message.error(response.errMsg);
}
}
);
}
//2.修改阈值
updateTrigger() {
this.overAllSer.updateTriggerPrototype(this.triggerObj).subscribe(res => {
if (res.errCode == 10000) {
this.message.success('修改阈值成功');
this.initForm();
this.done.emit();
this.isVisiable = false;
} else {
this.message.error(res.errMsg);
}
});
}
//取消
handleCheckCancel() {
this.isVisiable = false;
this.initForm();
}
}
......@@ -42,6 +42,8 @@
<th>名称</th>
<th>描述</th>
<th>自动发现</th>
<th>监控项</th>
<th>触发器</th>
<th>操作</th>
</tr>
</thead>
......@@ -61,6 +63,8 @@
</td>
<td>{{item.description}}</td>
<td></td>
<td></td>
<td></td>
</ng-container>
<!--子集-->
<ng-container *ngIf="item.level">
......@@ -73,6 +77,8 @@
<td class="main-color cursor">
<span (click)="goToDiscovery(item)">{{item.discoveriesCount}}</span>
</td>
<td>{{item.itemCount}}</td>
<td>{{item.triggersCount}}</td>
</ng-container>
<td class="handle main-color">
......@@ -83,7 +89,7 @@
</ng-container>
<ng-container *ngIf="item.level">
<span (click)="showBasicCheckModal(item.templateid,item.host)">添加监测点</span>
<span (click)="showDiscoveryAddModal(item)">添加自动发现</span>
<!--<span (click)="showDiscoveryAddModal(item)">添加自动发现</span>-->
<span (click)="showTempEditModal(item)">编辑</span>
<span (click)="showDeleteConfirm(item)">删除</span>
<span (click)="showAlarm(item)">添加告警</span>
......
......@@ -20,7 +20,6 @@ import {StrategyComponent} from '../../modal/strategy/strategy.component';
styles: []
})
export class TemplateComponent implements OnInit {
//组件
@ViewChild('basicEdit') basicEdit: BasicEditComponent;
@ViewChild('smartCheck') smartCheck: BasiCheckComponent;
......@@ -187,7 +186,7 @@ export class TemplateComponent implements OnInit {
goToDiscovery(item){
this.router.navigate(['app/main/discoveryList'], {
queryParams: {
hostId: item.templateid,
templateid: item.templateid,
name: item.name,
hostName: item.host
}
......
......@@ -25,8 +25,7 @@
</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>
......@@ -37,25 +36,27 @@
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked"
(nzCheckedChange)="checkAll($event)"></th>
<th>名称</th>
<th>监控项</th>
<th>阈值</th>
<th>键值</th>
<th>间隔</th>
<th>类型</th>
<th>状态</th>
<th>严重性</th>
<th nzWidth="35%">名称</th>
<th nzWidth="35%">表达式</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of triggerList">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="selectItem(data,$event)"></td>
<td class="round-tag tag-form">{{data.inventoryNo}}</td>
<td>{{data.name}}</td>
<td>{{data.inventorycount}}</td>
<td>{{data.stock}}</td>
<td>{{data.usedcount}}</td>
<td>{{data.lendcount}}</td>
<td>{{data.repaircount}}</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.expression}}</td>
<td class="cursor main-color">
<span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteTrigger(data)">删除</span>
</td>
</tr>
</tbody>
</nz-table>
<!--触发器原型-->
<smart-trigger-prototype #smartTriggerPrototype></smart-trigger-prototype>
\ No newline at end of file
import {Component, OnInit} from '@angular/core';
import {pageSize} from '../../../app.constants';
import {Component, OnInit, ViewChild} from '@angular/core';
import {color, pageSize} from '../../../app.constants';
import {ActivatedRoute, Router} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service';
import {SystemService} from '../../../system/system.service';
import {OverAllService} from '../../overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
import {TriggerPrototypeComponent} from '../modal/trigger-prototype/trigger-prototype.component';
@Component({
selector: 'smart-trigger-list',
......@@ -13,9 +14,12 @@ import {NzMessageService} from 'ng-zorro-antd';
})
export class TriggerListComponent implements OnInit {
@ViewChild('smartTriggerPrototype') smartTriggerPrototype:TriggerPrototypeComponent;
tempName;
disName;
hostId;
discoveryids;
color = color;
pageNum = 1;
pageCount = pageSize;
......@@ -34,6 +38,7 @@ export class TriggerListComponent implements OnInit {
(res) => {
this.discoveryids = res.id;
this.tempName = res.name;
this.hostId = res.hostId;
}
);
}
......@@ -77,7 +82,7 @@ export class TriggerListComponent implements OnInit {
pageCount: this.pageCount,
hostIds: [this.discoveryids]
};
this.overAllSer.findItemPrototype(data).subscribe(
this.overAllSer.findPageTrigger(data).subscribe(
(res) => {
this.triggerList = res.data.data;
this.totalNum = res.data.totalNum;
......@@ -86,7 +91,56 @@ export class TriggerListComponent implements OnInit {
}
showAddModal() {
this.smartTriggerPrototype.showAddModal("新增阈值原型",this.tempName);
}
showEditModal(data) {
this.smartTriggerPrototype.showEditModal("编辑阈值原型",data.id,this.tempName);
}
//单个删除
deleteTrigger(item){
this.commonSer.confirmThing("删除","确定删除当前的阈值原型",()=>{
const data ={
ids:[]
};
data.ids.push(item.triggerid);
this.overAllSer.deleteTrigger(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList();
}else{
this.message.error(res.errMsg);
}
}
)
})
}
//批量删除
deleteBatchTrigger(){
if(this.selectList.length == 0){
this.message.warning("请选择需要删除的阈值原型");
return false;
}
this.commonSer.confirmThing("删除","确定删除选择的阈值原型",()=>{
const data ={
ids:this.selectList.map(e=>{
return e.triggerid;
})
};
this.overAllSer.deleteTrigger(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList();
}else{
this.message.error(res.errMsg);
}
}
)
})
}
}
import {Component, OnInit} from '@angular/core';
import {SystemService} from '../../system.service';
import {NzMessageService} from 'ng-zorro-antd';
import {SidebarComponent} from '../../../layouts';
@Component({
selector: 'smart-separation',
......@@ -32,7 +33,8 @@ export class SeparationComponent implements OnInit {
comment:"",
};
constructor(private systemSer: SystemService,private message:NzMessageService) {
constructor(private systemSer: SystemService,private message:NzMessageService,
) {
}
ngOnInit() {}
......
......@@ -61,8 +61,8 @@ export class SystemService {
}
//查找用户角色
getRoleByUserId(data): Observable<any>{
return this.http.get(SERVER_API_URL_COMS + '/user/getRoleByUserId?'+ this.commonSer.toQuery(data) );
getRoleByUserId(params): Observable<any>{
return this.http.get(SERVER_API_URL_COMS + '/user/getRoleByUserId/'+ params );
}
//删除用户
......
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