Commit f20ba31c authored by wangqinghua's avatar wangqinghua

重构 jtopo

parent 86b2b4c5
<nz-modal [nzWidth]="880" [nzFooter]="null" [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleCancel()"
(nzOnOk)="handleOk()">
<nz-tabset [nzSelectedIndex]="tabNum" (nzSelectedIndexChange)="tabsChange($event)"
style="padding-bottom: 25px;min-height: 500px">
<nz-tab nzTitle="模版">
<div nz-form>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="checkName">模版真实名称</nz-form-label>
<nz-form-control [nzSpan]="14">
<input name="checkName" type="text" nz-input [(ngModel)]="validateForm.host">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="checkName">模板显示名称</nz-form-label>
<nz-form-control [nzSpan]="14">
<input name="checkName" type="text" nz-input [(ngModel)]="validateForm.name">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="templateList">所在分组</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-checkbox-group [(ngModel)]="templateList" name="templateList"></nz-checkbox-group>
</nz-form-control>
</nz-form-item>
</div>
<div class="modal-footer-btn">
<button nz-button (click)="tabsChange(1)" nzType="primary">下一步</button>
</div>
</nz-tab>
<nz-tab nzTitle="链接的模版">
<div nz-form>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzFor="templates">需要链接的模板</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="templates" style="width: 100%" [(ngModel)]="validateForm.templates"
[nzSize]="nzSize" nzMode="tags" nzPlaceHolder="选择监控策略">
<nz-option *ngFor="let option of tempList" [nzLabel]="option.name"
[nzValue]="option.templateid"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
<div class="modal-footer-btn">
<button nz-button (click)="tabsChange(0)" nzType="primary">上一步</button>
<button nz-button (click)="tabsChange(2)" nzType="primary">下一步</button>
</div>
</nz-tab>
<nz-tab nzTitle="宏">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-control [nzOffset]="4" [nzSpan]="14">
<nz-radio-group [(ngModel)]="macroTYpe">
<label nz-radio-button nzValue="macro"><span>主机宏</span></label>
<!--<label nz-radio-button nzValue="macroExpand"><span>继承以及主机宏</span></label>-->
</nz-radio-group>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div *ngIf="macroTYpe == 'macro'">
<div nz-row [nzGutter]="24">
<div nz-col [nzOffset]="2" [nzSpan]="6">
</div>
<div nz-col [nzSpan]="6">
</div>
</div>
<div nz-row *ngFor="let item of macroList1;let i = index;" [nzGutter]="24">
<nz-form-control [nzOffset]="2" nz-col [nzSpan]="6">
<input nz-input [(ngModel)]="item.macro">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="1">
=>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="6">
<input nz-input [(ngModel)]="item.value">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="3">
<span (click)="deleteMacro1(i)">移除</span>
</nz-form-control>
</div>
<button nz-button (click)="addMacro1()" nzType="default">添加</button>
</div>
<div *ngIf="macroTYpe == 'macroExpand'">
<div nz-row [nzGutter]="24">
<div nz-col [nzOffset]="2" [nzSpan]="6">
</div>
<div nz-col [nzSpan]="1">
</div>
<div nz-col [nzSpan]="6">
</div>
<div nz-col [nzSpan]="3">
模版值
</div>
<div nz-col [nzSpan]="1">
</div>
<div nz-col [nzSpan]="3">
全局值(配置)
</div>
</div>
<div nz-row [nzGutter]="12" *ngFor="let item of macroList2">
<nz-form-control nz-col [nzOffset]="2" [nzSpan]="6">
<input nz-input placeholder="{$SNMP_COMMUNITY}" value="{{item.macro}}">
</nz-form-control>
<div nz-col [nzSpan]="1">
=>
</div>
<nz-form-control nz-col [nzSpan]="6">
<input nz-input placeholder="public" value="{{item.value}}">
</nz-form-control>
<div nz-col [nzSpan]="3">
<button nz-button nzType="default">更改</button>
</div>
<div nz-col [nzSpan]="1">
<span></span>
</div>
<div nz-col [nzSpan]="3">
<span>"public"</span>
</div>
<div nz-col [nzSpan]="2">
<span class="cursor" (click)="deleteMacro2(i)">移除</span>
</div>
</div>
<button nz-button (click)="addMacro2()" nzType="default">添加</button>
</div>
<div class="modal-footer-btn">
<button nz-button (click)="tabsChange(1)" nzType="primary">上一步</button>
<button nz-button (click)="handleOk()" nzType="primary">确定</button>
</div>
</nz-tab>
</nz-tabset>
</nz-modal>
import { Component, OnInit } from '@angular/core'; import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {FormBuilder} from '@angular/forms';
import {Router} from '@angular/router';
import {JhiMainComponent} from '../../layouts';
import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {OverAllService} from '../../overAll/overAll.service';
@Component({ @Component({
selector: 'smart-strategy', selector: 'smart-strategy',
templateUrl: './strategy.component.html', templateUrl: './strategy.component.html',
styles: [] styles: []
}) })
export class StrategyComponent implements OnInit { export class StrategyComponent implements OnInit {
constructor() { } @Output() done = new EventEmitter<any>();
isVisible = false;
title;
tabNum = 0;
nzSize = 'large';
ngOnInit() { validateForm;
} tempId; //模版Id
templateList = []; //模版组
tempList; //模版
//宏
macroTYpe = 'macro'; //宏tabs
mainHost = 'hostType1'; //主机tabs
macroList1: any[];
macroList2: any[]; //配置宏数组
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) {
}
ngOnInit() {
this.getTemplateGroup();
this.getTemplate();
this.initForm();
}
initForm() {
this.validateForm = {
host: null,
name: null,
groups: [],
templates: [],
macros: [],
hosts: [],
};
}
//获取模版组
getTemplateGroup() {
this.templateList = [];
this.overAllSer.getTemplateGroups().subscribe(
(res) => {
const list = res.data;
list.forEach(e => {
const gObj = {
label: e.name, value: e.groupid, checked: false
};
this.templateList.push(gObj);
});
}
);
}
//获取模版
getTemplate() {
this.tempList = [];
this.overAllSer.templates().subscribe(
(res) => {
this.tempList = res.data;
}
);
}
tabsChange(e){
this.tabNum = e;
}
showAddModal(title): void {
this.isVisible = true;
this.title = title;
}
showEditModal(title,id){
this.isVisible = true;
this.title = title;
this.tempId = id;
const data = {
templateids:[this.tempId]
}
this.overAllSer.findTemplates(data).subscribe(
(res)=>{
const data = res.data[0];
this.validateForm.host = data.host;
this.validateForm.name = data.name;
if(data.groups){
//所在组回显
this.templateList.forEach(e1=>{
data.groups.forEach(e2=>{
if(e1.value == e2.groupid){
e1.checked = true;
}
})
});
}
if(data.parentTemplates){
//模版回显
this.validateForm.templates = data.parentTemplates.map(e=>{
return e.templateid;
})
}
}
)
}
check(){
const han = /.*[\u4e00-\u9fa5]+.*$/;
if (han.test(this.validateForm.host)) {
this.message.error("模版真实名称不能输入中文");
return false;
};
return true;
}
handleOk() {
if(!this.check()){
return false;
}
const arr = [];
this.templateList.forEach(e=>{
if(e.checked){
const d = {
groupid:e.value
}
arr.push(d);
}
});
if(this.title == "添加模版"){
this.create(arr);
}
if(this.title == "编辑模版"){
this.update(arr);
}
}
create(arr){
const data = {
host: this.validateForm.host,
name: this.validateForm.name,
groups: arr,
templates: this.validateForm.templates.map(e=>{
const d = {
templateid:e
}
return d;
}),
macros: [],
hosts: [],
};
this.overAllSer.createTemplates(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("添加模版成功");
this.initForm();
this.done.emit();
this.isVisible = false;
}else{
this.message.error(res.errMsg);
}
}
)
}
update(arr){
const data = {
templateid:this.tempId, //模版id
host: this.validateForm.host,
name: this.validateForm.name,
groups: arr,
templates: this.validateForm.templates.map(e=>{
const d = {
templateid:e
}
return d;
}),
macros: [],
hosts: [],
}
this.overAllSer.updateTemplates(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("修改模版成功");
this.initForm();
this.done.emit();
this.isVisible = false;
}else{
this.message.error(res.errMsg);
}
}
)
}
handleCancel(): void {
this.isVisible = false;
this.initForm();
}
//新增宏
addMacro1() {
const data = {
macro: '{$SNMP_COMMUNITY}',
value: 'public',
};
this.macroList1.push(data);
}
//移除宏
deleteMacro1(index) {
this.macroList1.splice(index, 1);
}
//新增主机宏
addMacro2() {
const data = {
macro: '{$SNMP_COMMUNITY}',
value: 'public',
};
this.macroList2.push(data);
}
//移除主机宏
deleteMacro2(index) {
this.macroList2.splice(index, 1);
}
} }
...@@ -306,16 +306,12 @@ export class NeTopologyComponent implements OnInit, DoCheck, AfterViewInit, OnDe ...@@ -306,16 +306,12 @@ export class NeTopologyComponent implements OnInit, DoCheck, AfterViewInit, OnDe
arr.forEach(e2=>{ arr.forEach(e2=>{
if(e1.elementId == e2.hostId){ if(e1.elementId == e2.hostId){
if(e1.status == 0){ if(e1.status == 0){
e2.alarm = "正常";
e2.alarmColor = "50,205,50";
} }
if(e1.status == 1){ if(e1.status == 1){
e2.alarm = "告警"; e2.alarm = "告警";
e2.alarmColor = "255,182,193";
} }
if(e1.status == 2){ if(e1.status == 2){
e2.alarm = "严重"; // e2.alarm = "严重";
e2.alarmColor = "220,20,60";
} }
} }
}) })
......
...@@ -108,35 +108,35 @@ ...@@ -108,35 +108,35 @@
<div echarts [options]="secondOptionLeft" class="demo-chart"></div> <div echarts [options]="secondOptionLeft" class="demo-chart"></div>
</div> </div>
<div nz-col nzSpan="8"> <div nz-col nzSpan="8">
<div echarts [options]="secondOptionRight" class="demo-chart"></div> <!--<div echarts [options]="secondOptionRight" class="demo-chart"></div>-->
</div> </div>
</nz-collapse-panel> </nz-collapse-panel>
</nz-collapse> </nz-collapse>
</div> </div>
<div nz-row> <!--<div nz-row>-->
<nz-table #basicTable [nzData]="dataSet" [nzFrontPagination]="false" [nzTotal]="totalNumInOut" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="changeInoutInfo($event)" [nzLoading]="inOutLoading"> <!--<nz-table #basicTable [nzData]="dataSet" [nzFrontPagination]="false" [nzTotal]="totalNumInOut" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="changeInoutInfo($event)" [nzLoading]="inOutLoading">-->
<thead> <!--<thead>-->
<tr> <!--<tr>-->
<th>状态</th> <!--<th>状态</th>-->
<th>接口</th> <!--<th>接口</th>-->
<th>进流量</th> <!--<th>进流量</th>-->
<th>出流量</th> <!--<th>出流量</th>-->
<th>状态变更时间</th> <!--<th>状态变更时间</th>-->
<!--<th nzWidth="150px">图表</th>--> <!--&lt;!&ndash;<th nzWidth="150px">图表</th>&ndash;&gt;-->
</tr> <!--</tr>-->
</thead> <!--</thead>-->
<tbody> <!--<tbody>-->
<tr *ngFor="let data of basicTable.data"> <!--<tr *ngFor="let data of basicTable.data">-->
<td>{{data.state}}</td> <!--<td>{{data.state}}</td>-->
<td>{{data.name}}</td> <!--<td>{{data.name}}</td>-->
<td>{{data.in}}</td> <!--<td>{{data.in}}</td>-->
<td>{{data.out}}</td> <!--<td>{{data.out}}</td>-->
<td>{{data.changeState}}</td> <!--<td>{{data.changeState}}</td>-->
<!--<td>图表</td>--> <!--&lt;!&ndash;<td>图表</td>&ndash;&gt;-->
</tr> <!--</tr>-->
</tbody> <!--</tbody>-->
</nz-table> <!--</nz-table>-->
</div> <!--</div>-->
</section> </section>
</nz-tab> </nz-tab>
<nz-tab nzTitle="监测点列表"> <nz-tab nzTitle="监测点列表">
......
...@@ -53,7 +53,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -53,7 +53,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
hostName; hostName;
realName; realName;
size = 'default'; size = 'default';
hostType: string;
changeStates; changeStates;
chartOption1; chartOption1;
responseTimeStr; responseTimeStr;
...@@ -129,7 +128,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -129,7 +128,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
this.isSpinning = true; this.isSpinning = true;
this.routerInfo.queryParams.subscribe(queryParams => { this.routerInfo.queryParams.subscribe(queryParams => {
this.hostId = queryParams.hostId; this.hostId = queryParams.hostId;
this.hostType = queryParams.type;
this.hostName = queryParams.name; this.hostName = queryParams.name;
this.realName = queryParams.hostName; this.realName = queryParams.hostName;
}); });
...@@ -138,7 +136,7 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -138,7 +136,7 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
this.cpused(); this.cpused();
this.disks(); this.disks();
this.used(); this.used();
this.inOutInfo(); // this.inOutInfo();
//监测点 //监测点
this.getList(); this.getList();
...@@ -296,7 +294,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -296,7 +294,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
cpused() { cpused() {
const data = { const data = {
hostId: this.hostId, hostId: this.hostId,
hostType: this.hostType,
}; };
this.overAllSer.cupUsed(data).subscribe( this.overAllSer.cupUsed(data).subscribe(
(res) => { (res) => {
...@@ -370,7 +367,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -370,7 +367,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
used() { used() {
const data = { const data = {
hostId: this.hostId, hostId: this.hostId,
hostType: this.hostType,
}; };
this.overAllSer.used(data).subscribe( this.overAllSer.used(data).subscribe(
(res) => { (res) => {
...@@ -444,7 +440,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -444,7 +440,6 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
disks() { disks() {
const data = { const data = {
hostId: this.hostId, hostId: this.hostId,
hostType: this.hostType,
}; };
this.overAllSer.disks(data).subscribe( this.overAllSer.disks(data).subscribe(
(res) => { (res) => {
...@@ -626,7 +621,7 @@ export class BasicDetailComponent implements OnInit, AfterViewInit { ...@@ -626,7 +621,7 @@ export class BasicDetailComponent implements OnInit, AfterViewInit {
//进出口流量 翻页 //进出口流量 翻页
changeInoutInfo(e){ changeInoutInfo(e){
this.pageNum = e; this.pageNum = e;
this.inOutInfo(); // this.inOutInfo();
} }
//添加监测点 //添加监测点
......
...@@ -446,16 +446,9 @@ export class BasicComponent implements OnInit { ...@@ -446,16 +446,9 @@ export class BasicComponent implements OnInit {
//查看详情 //查看详情
goDetail(item) { goDetail(item) {
let type = 0;
if (item.hostExtend) {
if (item.hostExtend.equipmentType == '交换机') {
type = 1;
}
}
this.router.navigate(['app/main/basic-detail'], { this.router.navigate(['app/main/basic-detail'], {
queryParams: { queryParams: {
hostId: item.hostid, hostId: item.hostid,
type: type,
name: item.name, name: item.name,
hostName: item.host hostName: item.host
} }
......
...@@ -61,17 +61,17 @@ export class OverAllService { ...@@ -61,17 +61,17 @@ export class OverAllService {
//CPU使用率 //CPU使用率
cupUsed(data): Observable<any> { cupUsed(data): Observable<any> {
return this.http.get(SERVER_API_URL + '/host/cpuUsed/' + data.hostId + '/' + data.hostType); return this.http.get(SERVER_API_URL + '/host/cpuUsed/' + data.hostId);
} }
//内存使用率 //内存使用率
used(data): Observable<any> { used(data): Observable<any> {
return this.http.get(SERVER_API_URL + '/host/used/' + data.hostId + '/' + data.hostType); return this.http.get(SERVER_API_URL + '/host/used/' + data.hostId);
} }
//磁盘使用率 //磁盘使用率
disks(data): Observable<any> { disks(data): Observable<any> {
return this.http.get(SERVER_API_URL + '/host/disks/' + data.hostId + '/' + data.hostType); return this.http.get(SERVER_API_URL + '/host/disks/' + data.hostId);
} }
//进出口流量 --SNMP //进出口流量 --SNMP
...@@ -319,6 +319,11 @@ export class OverAllService { ...@@ -319,6 +319,11 @@ export class OverAllService {
return this.http.post(SERVER_API_URL + '/templates/create',data); return this.http.post(SERVER_API_URL + '/templates/create',data);
} }
//修改模板
updateTemplates(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/templates/update',data);
}
//删除模板(支持批量删除) //删除模板(支持批量删除)
deleteTemplates(data): Observable<any> { deleteTemplates(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/templates/delete',data); return this.http.post(SERVER_API_URL + '/templates/delete',data);
......
...@@ -15,12 +15,7 @@ ...@@ -15,12 +15,7 @@
</nz-breadcrumb-item> </nz-breadcrumb-item>
</nz-breadcrumb> </nz-breadcrumb>
</div> </div>
<div nz-col nzSpan="10" class="search-input text-right"> <div nz-col nzSpan="10" class="search-input text-right"></div>
<input (keyup.enter)="search('')" type="text" nz-input [(ngModel)]="searchName" placeholder="输入资源名称">
<button (click)="search('')" nz-button nzType="default"><i class="anticon anticon-search"
style="color: #6097b7"></i>搜索
</button>
</div>
<div nz-col nzSpan="2" class="text-right"> <div nz-col nzSpan="2" class="text-right">
<button (click)="ngOnInit()" nz-button nzType="primary"><i class="anticon anticon-sync"></i></button> <button (click)="ngOnInit()" nz-button nzType="primary"><i class="anticon anticon-sync"></i></button>
<smart-full-screen></smart-full-screen> <smart-full-screen></smart-full-screen>
...@@ -29,15 +24,12 @@ ...@@ -29,15 +24,12 @@
<div nz-row class="search-form tag-form"> <div nz-row class="search-form tag-form">
<div nz-col nzSpan="12"> <div nz-col nzSpan="12">
<input style="width: 250px" (keyup.enter)="search('')" type="text" nz-input [(ngModel)]="searchName" placeholder="输入资源名称">
<button (click)="search('')" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button>
</div> </div>
<div nz-col nzSpan="12" class="text-right"> <div nz-col nzSpan="12" class="text-right">
<button nz-button nzType="default" (click)="showGroupModal()"> <button nz-button nzType="default" (click)="showGroupModal()">
<i class="anticon anticon-plus-circle-o"></i>添加分组 <i class="anticon anticon-plus-circle-o"></i>添加模版组
</button>
<button (click)="openBatchHost(1,'停止')" nz-button nzType="default"><i
class="anticon anticon-pause-circle-o"></i>停止监控
</button>
<button (click)="openBatchHost(0,'开启')" nz-button nzType="default"><i class="anticon anticon-play-circle-o"></i>开启监控
</button> </button>
<button (click)="batchDeleteConfirm()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>删除模版 <button (click)="batchDeleteConfirm()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>删除模版
</button> </button>
...@@ -48,10 +40,7 @@ ...@@ -48,10 +40,7 @@
<tr> <tr>
<th [nzChecked]="allChecked"></th> <th [nzChecked]="allChecked"></th>
<th>名称</th> <th>名称</th>
<th>告警状态</th> <th>描述</th>
<th>关联资产</th>
<!--<th nzWidth="20%">主机启用状态</th>-->
<th>可用性</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
...@@ -69,84 +58,26 @@ ...@@ -69,84 +58,26 @@
(nzExpandChange)="getChildren(item)"> (nzExpandChange)="getChildren(item)">
<span>{{item.name}}</span> <span>{{item.name}}</span>
</td> </td>
<td>{{item.groupDescribe}}</td>
</ng-container> </ng-container>
<!--子集--> <!--子集-->
<ng-container *ngIf="item.level"> <ng-container *ngIf="item.level">
<td nzShowCheckbox [nzIndeterminate]="indeterminate" <td nzShowCheckbox [nzIndeterminate]="indeterminate"
(nzCheckedChange)="selectChecked($event,item)" [(nzChecked)]="item.checked"></td> (nzCheckedChange)="selectChecked($event,item)" [(nzChecked)]="item.checked"></td>
<td class="cursor" [nzIndentSize]="item.level*20"> <td class="cursor" [nzIndentSize]="item.level*20">
<span (click)="goDetail(item)">{{item.name}}</span> <span>{{item.name}}</span>
</td> </td>
<td></td>
</ng-container> </ng-container>
<td class="round-tag tag-form">
<ng-container *ngIf="item.status == 1">
<nz-tag [nzColor]="color.gray"></nz-tag>
</ng-container>
<ng-container *ngIf="item.status == 0">
<nz-tag *ngIf="item.maxLevel == 4 || item.maxLevel == 5" [nzColor]="color.red"></nz-tag>
<nz-tag *ngIf="item.maxLevel == 2 || item.maxLevel == 3"
[nzColor]="color.yellow"></nz-tag>
<nz-tag *ngIf="item.maxLevel < 2 " [nzColor]="color.green"></nz-tag>
</ng-container>
</td>
<td class="cursor">
<span (click)="goTOInventory(item?.inventory?.id)">{{item?.inventory?.name}}</span>
</td>
<!--<nz-tag *ngIf="item.status == 0" [nzColor]="color.green"></nz-tag>-->
<!--<nz-tag *ngIf="item.status == 1" [nzColor]="color.gray"></nz-tag>-->
<td class="default">
<ng-container *ngIf="item.level">
<ng-container *ngIf="item.available == 0">
<nz-tag>AGENT</nz-tag>
</ng-container>
<ng-container *ngIf="item.available == 1">
<nz-tag [nzColor]="'#3bae6a'">AGENT</nz-tag>
</ng-container>
<ng-container *ngIf="item.available == 2">
<nz-tag [nzColor]="'#d44f51'">AGENT</nz-tag>
</ng-container>
<ng-container *ngIf="item.snmp_available == 0">
<nz-tag>SNMP</nz-tag>
</ng-container>
<ng-container *ngIf="item.snmp_available == 1">
<nz-tag [nzColor]="'#3bae6a'">SNMP</nz-tag>
</ng-container>
<ng-container *ngIf="item.snmp_available == 2">
<nz-tag [nzColor]="'#d44f51'">SNMP</nz-tag>
</ng-container>
<ng-container *ngIf="item.jmx_available == 0">
<nz-tag>JMX</nz-tag>
</ng-container>
<ng-container *ngIf="item.jmx_available == 1">
<nz-tag [nzColor]="'#3bae6a'">JMX</nz-tag>
</ng-container>
<ng-container *ngIf="item.jmx_available == 2">
<nz-tag [nzColor]="'#d44f51'">JMX</nz-tag>
</ng-container>
<ng-container *ngIf="item.ipmi_available == 0">
<nz-tag>IPMI</nz-tag>
</ng-container>
<ng-container *ngIf="item.ipmi_available == 1">
<nz-tag [nzColor]="'#3bae6a'">IPMI</nz-tag>
</ng-container>
<ng-container *ngIf="item.ipmi_available == 2">
<nz-tag [nzColor]="'#d44f51'">IPMI</nz-tag>
</ng-container>
</ng-container>
</td>
<td class="handle main-color"> <td class="handle main-color">
<ng-container *ngIf="!item.level"> <ng-container *ngIf="!item.level">
<span (click)="showBasicEditModal(item)">添加资源</span> <span (click)="showTempAddModal(item)">添加模版</span>
<span (click)="updateGroup(item)">编辑</span> <span (click)="updateGroup(item)">编辑</span>
<span (click)="showDeleteGroupConfirm(item)">删除</span> <span (click)="showDeleteGroupConfirm(item)">删除</span>
</ng-container> </ng-container>
<ng-container *ngIf="item.level"> <ng-container *ngIf="item.level">
<span (click)="showBasicCheckModal(item.hostid,item.host)">添加监测点</span> <span (click)="showBasicCheckModal(item.hostid,item.host)">添加监测点</span>
<span (click)="editBasicModal(item)">编辑</span> <span (click)="showTempEditModal(item)">编辑</span>
<span (click)="showDeleteConfirm(item)">删除</span> <span (click)="showDeleteConfirm(item)">删除</span>
<nz-dropdown [nzTrigger]="'click'" class="table-dropdown"> <nz-dropdown [nzTrigger]="'click'" class="table-dropdown">
<a nz-dropdown>更多 <i class="anticon anticon-down"></i> <a nz-dropdown>更多 <i class="anticon anticon-down"></i>
......
...@@ -60,6 +60,9 @@ export class TemplateComponent implements OnInit { ...@@ -60,6 +60,9 @@ export class TemplateComponent implements OnInit {
searchName; searchName;
searchData; searchData;
//模版
templateList = [];
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router, constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) { private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) {
} }
...@@ -116,7 +119,22 @@ export class TemplateComponent implements OnInit { ...@@ -116,7 +119,22 @@ export class TemplateComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.select(); // this.select();
this.getTemplateGroup();
}
//获取模版组
getTemplateGroup(){
this.overAllSer.getTemplateGroups().subscribe(
(res)=>{
this.dataSet = res.data;
for (let i = 0; i < this.dataSet.length; i++) {
this.dataSet[i].host = i;
this.dataSet[i].checked = false;
}
this.toTree(null);
}
)
} }
//搜索 //搜索
...@@ -146,14 +164,14 @@ export class TemplateComponent implements OnInit { ...@@ -146,14 +164,14 @@ export class TemplateComponent implements OnInit {
this.frontPagination = true; this.frontPagination = true;
} }
//添加资源 //添加模版
showBasicEditModal() { showTempAddModal() {
this.basicEdit.showModal(); this.smartStrategy.showAddModal("添加模版");
} }
//编辑资源 name--分组名称,gId-当前分组的id //编辑模版
editBasicModal(item) { showTempEditModal(item) {
this.basicEdit.editModal(item.hostid, item.name, item.gId); this.smartStrategy.showEditModal("编辑模版", item.templateid);
} }
//添加监测点 //添加监测点
...@@ -161,21 +179,6 @@ export class TemplateComponent implements OnInit { ...@@ -161,21 +179,6 @@ export class TemplateComponent implements OnInit {
this.smartCheck.showAddModal(hostid, host); this.smartCheck.showAddModal(hostid, host);
} }
//列表
findList() {
const data = {};
this.overAllSer.find(data).subscribe(
(res) => {
if (res.data) {
this.dataSet = res.data;
} else {
this.message.info(res.errMsg);
}
}
);
}
//选择分组 //选择分组
select() { select() {
this.loading = true; this.loading = true;
...@@ -216,7 +219,6 @@ export class TemplateComponent implements OnInit { ...@@ -216,7 +219,6 @@ export class TemplateComponent implements OnInit {
} }
); );
} else if (this.selectedValue == 'all') { } else if (this.selectedValue == 'all') {
this.findList();
} }
} }
...@@ -288,7 +290,7 @@ export class TemplateComponent implements OnInit { ...@@ -288,7 +290,7 @@ export class TemplateComponent implements OnInit {
//添加分组 //添加分组
showGroupModal() { showGroupModal() {
this.smartCreateGroup.showModal('添加组'); this.smartCreateGroup.showModal('添加模版组');
} }
//编辑分组 //编辑分组
...@@ -329,6 +331,7 @@ export class TemplateComponent implements OnInit { ...@@ -329,6 +331,7 @@ export class TemplateComponent implements OnInit {
handleOk(e) { handleOk(e) {
this.select(); this.select();
this.smartStrategy.getTemplateGroup();
} }
//获取下级list //获取下级list
...@@ -344,11 +347,8 @@ export class TemplateComponent implements OnInit { ...@@ -344,11 +347,8 @@ export class TemplateComponent implements OnInit {
this.loading = true; this.loading = true;
const data = { const data = {
'groupids': [item.groupid], 'groupids': [item.groupid],
'hostExtend': {
'superiorHostid': null
}
}; };
this.overAllSer.findDetail(data).subscribe( this.overAllSer.findTemplates(data).subscribe(
(res) => { (res) => {
if (res.data) { if (res.data) {
this.dataSet[item.host].list = res.data; this.dataSet[item.host].list = res.data;
...@@ -388,24 +388,6 @@ export class TemplateComponent implements OnInit { ...@@ -388,24 +388,6 @@ export class TemplateComponent implements OnInit {
); );
} }
//查看详情
goDetail(item) {
let type = 0;
if (item.hostExtend) {
if (item.hostExtend.equipmentType == '交换机') {
type = 1;
}
}
this.router.navigate(['app/main/basic-detail'], {
queryParams: {
hostId: item.hostid,
type: type,
name: item.name,
hostName: item.host
}
});
}
//临时暂停 //临时暂停
showTempStop(item) { showTempStop(item) {
this.smartPause.showModal(item.hostid, '基础资源'); this.smartPause.showModal(item.hostid, '基础资源');
...@@ -453,37 +435,6 @@ export class TemplateComponent implements OnInit { ...@@ -453,37 +435,6 @@ export class TemplateComponent implements OnInit {
}); });
} }
//批量开启or停止监控
openBatchHost(status, operation) {
if (this.batchDelList.length == 0) {
this.message.info('请选择需要' + operation + '的设备');
return false;
}
this.modalService.confirm({
nzTitle: '监控',
nzContent: '确定批量' + operation + '监控设备?',
nzOkText: '确定',
nzCancelText: '取消',
nzOnOk: () => {
const data = {
status: status,
hostids: this.batchDelList
};
this.overAllSer.batchStopOrOpen(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('修改成功');
this.batchDelList = [];
this.select();
} else {
this.message.info(res.errMsg);
}
}
);
},
nzOnCancel: () => console.log('Cancel')
});
}
//资产页面 //资产页面
goTOInventory(id) { goTOInventory(id) {
......
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