[webapp] 批量处理eslint格式告警

This commit is contained in:
tomsun28
2021-12-23 15:59:49 +08:00
parent 1469e85443
commit 7e41f64491
72 changed files with 1724 additions and 2170 deletions

View File

@@ -17,7 +17,7 @@
<i nz-icon nzType="appstore-add" nzTheme="outline"></i>
新增阈值
</button>
<button nz-button nzType="primary" (click)="onEditAlertDefine()" >
<button nz-button nzType="primary" (click)="onEditAlertDefine()">
<i nz-icon nzType="edit" nzTheme="outline"></i>
编辑
</button>
@@ -29,110 +29,110 @@
<i nz-icon nzType="sync" nzTheme="outline"></i>
</button>
<nz-table #fixedTable [nzData]="defines"
[nzPageIndex]="pageIndex" [nzPageSize]="pageSize" [nzTotal]="total"
nzFrontPagination ="false"
[nzLoading] = "tableLoading"
nzShowSizeChanger
[nzShowTotal]="rangeTemplate"
[nzPageSizeOptions]="[8,15,25]"
(nzQueryParams)="onTablePageChange($event)"
nzShowPagination = "true" [nzScroll]="{ x: '1150px', y: '1240px' }">
<nz-table
#fixedTable
[nzData]="defines"
[nzPageIndex]="pageIndex"
[nzPageSize]="pageSize"
[nzTotal]="total"
nzFrontPagination="false"
[nzLoading]="tableLoading"
nzShowSizeChanger
[nzShowTotal]="rangeTemplate"
[nzPageSizeOptions]="[8, 15, 25]"
(nzQueryParams)="onTablePageChange($event)"
nzShowPagination="true"
[nzScroll]="{ x: '1150px', y: '1240px' }"
>
<thead>
<tr>
<th nzAlign="center" nzLeft nzWidth="60px" [(nzChecked)]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
<th nzAlign="center">指标对象</th>
<th nzAlign="center">阈值触发表达式</th>
<th nzAlign="center">告警级别</th>
<th nzAlign="center">触发次数</th>
<th nzAlign="center">通知模版</th>
<th nzAlign="center">全局默认</th>
<th nzAlign="center">最新修改时间</th>
<th nzAlign="center" nzRight>操作</th>
</tr>
<tr>
<th nzAlign="center" nzLeft nzWidth="60px" [(nzChecked)]="checkedAll" (nzCheckedChange)="onAllChecked($event)"></th>
<th nzAlign="center">指标对象</th>
<th nzAlign="center">阈值触发表达式</th>
<th nzAlign="center">告警级别</th>
<th nzAlign="center">触发次数</th>
<th nzAlign="center">通知模版</th>
<th nzAlign="center">全局默认</th>
<th nzAlign="center">最新修改时间</th>
<th nzAlign="center" nzRight>操作</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of fixedTable.data">
<td nzAlign="center" nzLeft [nzChecked]="checkedDefineIds.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td>
<td nzAlign="center">
<span>{{ data.app + '.' + data.metric + '.' + data.field }}</span>
</td>
<td nzAlign="center">
<span>{{ data.expr}}</span>
</td>
<td nzAlign="center">
<nz-tag *ngIf="data.priority == 0" nzColor="red">
<i nz-icon nzType="bell" nzTheme="outline"></i>
<span>紧急告警</span>
</nz-tag>
<nz-tag *ngIf="data.priority == 1" nzColor="orange">
<i nz-icon nzType="bell" nzTheme="outline"></i>
<span>严重告警</span>
</nz-tag>
<nz-tag *ngIf="data.priority == 2" nzColor="yellow">
<i nz-icon nzType="bell" nzTheme="outline"></i>
<span>警告告警</span>
</nz-tag>
</td>
<td nzAlign="center">{{ data.times }}</td>
<td nzAlign="center">{{ data.template }}</td>
<td nzAlign="center">
<nz-tag *ngIf="data.preset" nzColor="green">
<span></span>
</nz-tag>
<nz-tag *ngIf="!data.preset" nzColor="orange">
<span></span>
</nz-tag>
</td>
<td nzAlign="center">{{ data.gmtUpdate? data.gmtUpdate : data.gmtCreate }}</td>
<td nzAlign="center" nzRight>
<button nz-button nzType="primary" (click)="onOpenConnectModal(data.id, data.app)" nz-tooltip nzTooltipTitle="配置关联监控">
<i nz-icon nzType="link" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onEditOneAlertDefine(data.id)" nz-tooltip nzTooltipTitle="修改告警配置">
<i nz-icon nzType="edit" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onDeleteOneAlertDefine(data.id)" nz-tooltip nzTooltipTitle="删除告警配置">
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
</td>
</tr>
<tr *ngFor="let data of fixedTable.data">
<td nzAlign="center" nzLeft [nzChecked]="checkedDefineIds.has(data.id)" (nzCheckedChange)="onItemChecked(data.id, $event)"></td>
<td nzAlign="center">
<span>{{ data.app + '.' + data.metric + '.' + data.field }}</span>
</td>
<td nzAlign="center">
<span>{{ data.expr }}</span>
</td>
<td nzAlign="center">
<nz-tag *ngIf="data.priority == 0" nzColor="red">
<i nz-icon nzType="bell" nzTheme="outline"></i>
<span>紧急告警</span>
</nz-tag>
<nz-tag *ngIf="data.priority == 1" nzColor="orange">
<i nz-icon nzType="bell" nzTheme="outline"></i>
<span>严重告警</span>
</nz-tag>
<nz-tag *ngIf="data.priority == 2" nzColor="yellow">
<i nz-icon nzType="bell" nzTheme="outline"></i>
<span>警告告警</span>
</nz-tag>
</td>
<td nzAlign="center">{{ data.times }}</td>
<td nzAlign="center">{{ data.template }}</td>
<td nzAlign="center">
<nz-tag *ngIf="data.preset" nzColor="green">
<span></span>
</nz-tag>
<nz-tag *ngIf="!data.preset" nzColor="orange">
<span></span>
</nz-tag>
</td>
<td nzAlign="center">{{ data.gmtUpdate ? data.gmtUpdate : data.gmtCreate }}</td>
<td nzAlign="center" nzRight>
<button nz-button nzType="primary" (click)="onOpenConnectModal(data.id, data.app)" nz-tooltip nzTooltipTitle="配置关联监控">
<i nz-icon nzType="link" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onEditOneAlertDefine(data.id)" nz-tooltip nzTooltipTitle="修改告警配置">
<i nz-icon nzType="edit" nzTheme="outline"></i>
</button>
<button nz-button nzType="primary" (click)="onDeleteOneAlertDefine(data.id)" nz-tooltip nzTooltipTitle="删除告警配置">
<i nz-icon nzType="delete" nzTheme="outline"></i>
</button>
</td>
</tr>
</tbody>
</nz-table>
<ng-template #rangeTemplate>
总量 {{ total }}
</ng-template>
<ng-template #rangeTemplate> 总量 {{ total }} </ng-template>
<!-- 新增或修改告警定义弹出框 -->
<nz-modal
[(nzVisible)]="isManageModalVisible"
[nzTitle]="isManageModalAdd?'新增告警阈值' : '修改告警阈值'"
[nzTitle]="isManageModalAdd ? '新增告警阈值' : '修改告警阈值'"
(nzOnCancel)="onManageModalCancel()"
(nzOnOk)="onManageModalOk()"
nzMaskClosable="false"
nzWidth="60%"
[nzOkLoading]="isManageModalOkLoading"
>
<div *nzModalContent class = "-inner-content">
<div *nzModalContent class="-inner-content">
<form nz-form>
<nz-form-item>
<nz-form-label [nzSpan]="7" nzFor= 'target' nzRequired="true">指标对象</nz-form-label>
<nz-form-label [nzSpan]="7" nzFor="target" nzRequired="true">指标对象</nz-form-label>
<nz-form-control [nzSpan]="8">
<nz-cascader name="target" id="target" [nzOptions]="appHierarchies" [(ngModel)]="cascadeValues">
</nz-cascader>
<nz-cascader name="target" id="target" [nzOptions]="appHierarchies" [(ngModel)]="cascadeValues"> </nz-cascader>
</nz-form-control>
</nz-form-item >
</nz-form-item>
<nz-form-item>
<nz-col [nzSpan]="8" nzOffset="7">
<nz-collapse>
<nz-collapse-panel
[nzActive] = "isManageModalAdd"
nzHeader="支持的阈值触发表达式环境变量与操作符"
>
<nz-collapse-panel [nzActive]="isManageModalAdd" nzHeader="支持的阈值触发表达式环境变量与操作符">
<nz-list nzSize="small" nzSplit="false">
<nz-list-item *ngIf="cascadeValues.length == 3">
<code>{{cascadeValues[2]}} : 选中的指标对象</code>
<code>{{ cascadeValues[2] }} : 选中的指标对象</code>
</nz-list-item>
<nz-list-item>
<code>instance : 所属行实例值</code>
@@ -146,29 +146,39 @@
</nz-col>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="7" nzFor= 'expr' nzRequired="true" nzTooltipTitle="根据此表达式来计算判断是否触发阈值,表达式环境变量和操作符见上方">
<nz-form-label
[nzSpan]="7"
nzFor="expr"
nzRequired="true"
nzTooltipTitle="根据此表达式来计算判断是否触发阈值,表达式环境变量和操作符见上方"
>
阈值触发表达式
</nz-form-label>
<nz-form-control [nzSpan]="8">
<nz-textarea-count [nzMaxCharacterCount]="100">
<textarea [(ngModel)]="define.expr" rows="3" nz-input
name="expr" id="expr" placeholder="根据此表达式计算判断是否触发阈值.&#10;示例: equals&#40;instance,&quot;cpu1&quot;&#41; &amp;&amp; usage&gt;40">
<textarea
[(ngModel)]="define.expr"
rows="3"
nz-input
name="expr"
id="expr"
placeholder='根据此表达式计算判断是否触发阈值.&#10;示例: equals&#40;instance,"cpu1"&#41; &amp;&amp; usage&gt;40'
>
</textarea>
</nz-textarea-count>
</nz-form-control>
</nz-form-item >
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "priority"
nzTooltipTitle="触发阈值的告警级别,从低到高依次为:警告-warning严重-critical紧急-emergency">
<nz-form-label
nzSpan="7"
nzRequired="true"
nzFor="priority"
nzTooltipTitle="触发阈值的告警级别,从低到高依次为:警告-warning严重-critical紧急-emergency"
>
告警级别
</nz-form-label>
<nz-form-control nzSpan="8">
<nz-select
[(ngModel)]="define.priority"
nzAllowClear
nzPlaceHolder="Choose"
name="priority" id="priority"
>
<nz-select [(ngModel)]="define.priority" nzAllowClear nzPlaceHolder="Choose" name="priority" id="priority">
<nz-option [nzValue]="0" nzLabel="紧急告警"></nz-option>
<nz-option [nzValue]="1" nzLabel="严重告警"></nz-option>
<nz-option [nzValue]="2" nzLabel="警告告警"></nz-option>
@@ -176,28 +186,24 @@
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "duration" nzTooltipTitle="设置触发阈值多少次之后才会发送告警">
<nz-form-label nzSpan="7" nzRequired="true" nzFor="duration" nzTooltipTitle="设置触发阈值多少次之后才会发送告警">
触发次数
</nz-form-label>
<nz-form-control nzSpan="8">
<nz-input-number [(ngModel)]="define.times" [nzMin]="1" [nzMax]="10" [nzStep]="1"
name="duration" id="duration">
<nz-input-number [(ngModel)]="define.times" [nzMin]="1" [nzMax]="10" [nzStep]="1" name="duration" id="duration">
</nz-input-number>
</nz-form-control>
</nz-form-item >
</nz-form-item>
<nz-form-item>
<nz-col [nzSpan]="8" nzOffset="7">
<nz-collapse>
<nz-collapse-panel
[nzActive] = "isManageModalAdd"
nzHeader="支持的通知模版环境变量"
>
<nz-collapse-panel [nzActive]="isManageModalAdd" nzHeader="支持的通知模版环境变量">
<nz-list nzSize="small" nzSplit="false">
<nz-list-item *ngIf="cascadeValues.length == 3">
<code>&#36;&#40;metric&#41; : 选中的指标对象名称</code>
</nz-list-item>
<nz-list-item *ngIf="cascadeValues.length == 3">
<code>&#36;&#40;{{cascadeValues[2]}}&#41; : 选中的指标对象值</code>
<code>&#36;&#40;{{ cascadeValues[2] }}&#41; : 选中的指标对象值</code>
</nz-list-item>
<nz-list-item>
<code>&#36;&#40;instance&#41; : 所在行实例值</code>
@@ -214,33 +220,37 @@
</nz-col>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="7" nzFor= 'template' nzRequired="true" nzTooltipTitle="告警触发后发送的通知信息模版,模版环境变量见上方">
<nz-form-label [nzSpan]="7" nzFor="template" nzRequired="true" nzTooltipTitle="告警触发后发送的通知信息模版,模版环境变量见上方">
通知模版
</nz-form-label>
<nz-form-control [nzSpan]="8">
<nz-textarea-count [nzMaxCharacterCount]="200">
<textarea [(ngModel)]="define.template" rows="3" nz-input
name="template" id="template" placeholder="请输入告警的通知模版.&#10;示例: ${app}.${metrics}.${metric}'s value is too high">
<textarea
[(ngModel)]="define.template"
rows="3"
nz-input
name="template"
id="template"
placeholder="请输入告警的通知模版.&#10;示例: ${app}.${metrics}.${metric}'s value is too high"
>
</textarea>
</nz-textarea-count>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "preset" nzTooltipTitle="此告警阈值配置是否应用于全局所有此类型监控">
<nz-form-label nzSpan="7" nzRequired="true" nzFor="preset" nzTooltipTitle="此告警阈值配置是否应用于全局所有此类型监控">
全局默认
</nz-form-label>
<nz-form-control nzSpan="8">
<nz-switch [(ngModel)]="define.preset" name="preset" id="preset"></nz-switch>
</nz-form-control>
</nz-form-item >
</nz-form-item>
<nz-form-item>
<nz-form-label nzSpan="7" nzRequired="true" nzFor= "enable" nzTooltipTitle="此告警阈值配置开启生效或关闭">
启用告警
</nz-form-label>
<nz-form-label nzSpan="7" nzRequired="true" nzFor="enable" nzTooltipTitle="此告警阈值配置开启生效或关闭"> 启用告警 </nz-form-label>
<nz-form-control nzSpan="8">
<nz-switch [(ngModel)]="define.enable" name="enable" id="enable"></nz-switch>
</nz-form-control>
</nz-form-item >
</nz-form-item>
</form>
</div>
</nz-modal>
@@ -274,21 +284,17 @@
>
<nz-table #t [nzData]="$asTransferItems(items)" nzSize="small">
<thead>
<tr>
<th [nzChecked]="stat.checkAll" [nzIndeterminate]="stat.checkHalf"
(nzCheckedChange)="onItemSelectAll($event)"></th>
<th *ngIf="direction=='left'">关联监控</th>
<th *ngIf="direction=='right'">已关联监控</th>
</tr>
<tr>
<th [nzChecked]="stat.checkAll" [nzIndeterminate]="stat.checkHalf" (nzCheckedChange)="onItemSelectAll($event)"></th>
<th *ngIf="direction == 'left'">未关联监控</th>
<th *ngIf="direction == 'right'">关联监控</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of t.data" (click)="onItemSelect(data)">
<td
[nzChecked]="!!data.checked"
(nzCheckedChange)="onItemSelect(data)"
></td>
<td>{{ data.name }}</td>
</tr>
<tr *ngFor="let data of t.data" (click)="onItemSelect(data)">
<td [nzChecked]="!!data.checked" (nzCheckedChange)="onItemSelect(data)"></td>
<td>{{ data.name }}</td>
</tr>
</tbody>
</nz-table>
</ng-template>

View File

@@ -8,9 +8,8 @@ describe('AlertSettingComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AlertSettingComponent ]
})
.compileComponents();
declarations: [AlertSettingComponent]
}).compileComponents();
});
beforeEach(() => {

View File

@@ -1,31 +1,32 @@
import { Component, OnInit } from '@angular/core';
import {NzTableQueryParams} from "ng-zorro-antd/table";
import {NzModalService} from "ng-zorro-antd/modal";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {AlertDefineService} from "../../../service/alert-define.service";
import {AlertDefine} from "../../../pojo/AlertDefine";
import {finalize, map} from "rxjs/operators";
import {AppDefineService} from "../../../service/app-define.service";
import {TransferChange, TransferItem} from "ng-zorro-antd/transfer";
import {zip} from "rxjs";
import {MonitorService} from "../../../service/monitor.service";
import {Message} from "../../../pojo/Message";
import {AlertDefineBind} from "../../../pojo/AlertDefineBind";
import {Monitor} from "../../../pojo/Monitor";
import { NzModalService } from 'ng-zorro-antd/modal';
import { NzNotificationService } from 'ng-zorro-antd/notification';
import { NzTableQueryParams } from 'ng-zorro-antd/table';
import { TransferChange, TransferItem } from 'ng-zorro-antd/transfer';
import { zip } from 'rxjs';
import { finalize, map } from 'rxjs/operators';
import { AlertDefine } from '../../../pojo/AlertDefine';
import { AlertDefineBind } from '../../../pojo/AlertDefineBind';
import { Message } from '../../../pojo/Message';
import { Monitor } from '../../../pojo/Monitor';
import { AlertDefineService } from '../../../service/alert-define.service';
import { AppDefineService } from '../../../service/app-define.service';
import { MonitorService } from '../../../service/monitor.service';
@Component({
selector: 'app-alert-setting',
templateUrl: './alert-setting.component.html',
styles: [
]
styles: []
})
export class AlertSettingComponent implements OnInit {
constructor(private modal: NzModalService,
private notifySvc: NzNotificationService,
private appDefineSvc: AppDefineService,
private monitorSvc: MonitorService,
private alertDefineSvc: AlertDefineService) { }
constructor(
private modal: NzModalService,
private notifySvc: NzNotificationService,
private appDefineSvc: AppDefineService,
private monitorSvc: MonitorService,
private alertDefineSvc: AlertDefineService
) {}
pageIndex: number = 1;
pageSize: number = 8;
@@ -39,19 +40,25 @@ export class AlertSettingComponent implements OnInit {
ngOnInit(): void {
this.loadAlertDefineTable();
// 查询监控层级
const getHierarchy$ = this.appDefineSvc.getAppHierarchy()
.pipe(finalize(() => {
getHierarchy$.unsubscribe();
}))
.subscribe(message => {
if (message.code === 0) {
this.appHierarchies = message.data;
} else {
console.warn(message.msg);
const getHierarchy$ = this.appDefineSvc
.getAppHierarchy()
.pipe(
finalize(() => {
getHierarchy$.unsubscribe();
})
)
.subscribe(
message => {
if (message.code === 0) {
this.appHierarchies = message.data;
} else {
console.warn(message.msg);
}
},
error => {
console.warn(error.msg);
}
}, error => {
console.warn(error.msg);
})
);
}
sync() {
@@ -60,8 +67,8 @@ export class AlertSettingComponent implements OnInit {
loadAlertDefineTable() {
this.tableLoading = true;
let alertDefineInit$ = this.alertDefineSvc.getAlertDefines(this.pageIndex - 1, this.pageSize)
.subscribe(message => {
let alertDefineInit$ = this.alertDefineSvc.getAlertDefines(this.pageIndex - 1, this.pageSize).subscribe(
message => {
this.tableLoading = false;
this.checkedAll = false;
this.checkedDefineIds.clear();
@@ -74,10 +81,12 @@ export class AlertSettingComponent implements OnInit {
console.warn(message.msg);
}
alertDefineInit$.unsubscribe();
}, error => {
},
error => {
this.tableLoading = false;
alertDefineInit$.unsubscribe();
});
}
);
}
onNewAlertDefine() {
@@ -89,7 +98,7 @@ export class AlertSettingComponent implements OnInit {
onEditOneAlertDefine(alertDefineId: number) {
if (alertDefineId == null) {
this.notifySvc.warning("未选中任何待编辑项!","");
this.notifySvc.warning('未选中任何待编辑项!', '');
return;
}
this.editAlertDefine(alertDefineId);
@@ -98,15 +107,15 @@ export class AlertSettingComponent implements OnInit {
onEditAlertDefine() {
// 编辑时只能选中一个
if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) {
this.notifySvc.warning("未选中任何待编辑项!","");
this.notifySvc.warning('未选中任何待编辑项!', '');
return;
}
if (this.checkedDefineIds.size > 1) {
this.notifySvc.warning("只能对一个选中项进行编辑!","");
this.notifySvc.warning('只能对一个选中项进行编辑!', '');
return;
}
let alertDefineId = 0;
this.checkedDefineIds.forEach(item => alertDefineId = item);
this.checkedDefineIds.forEach(item => (alertDefineId = item));
this.editAlertDefine(alertDefineId);
}
@@ -115,25 +124,31 @@ export class AlertSettingComponent implements OnInit {
this.isManageModalVisible = true;
this.isManageModalOkLoading = false;
// 查询告警定义信息
const getDefine$ = this.alertDefineSvc.getAlertDefine(alertDefineId)
.pipe(finalize(() => {
getDefine$.unsubscribe();
}))
.subscribe(message => {
if (message.code === 0) {
this.define = message.data;
this.cascadeValues = [this.define.app, this.define.metric, this.define.field];
} else {
this.notifySvc.error("查询此监控定义详情失败!",message.msg);
const getDefine$ = this.alertDefineSvc
.getAlertDefine(alertDefineId)
.pipe(
finalize(() => {
getDefine$.unsubscribe();
})
)
.subscribe(
message => {
if (message.code === 0) {
this.define = message.data;
this.cascadeValues = [this.define.app, this.define.metric, this.define.field];
} else {
this.notifySvc.error('查询此监控定义详情失败!', message.msg);
}
},
error => {
this.notifySvc.error('查询此监控定义详情失败!', error.msg);
}
}, error => {
this.notifySvc.error("查询此监控定义详情失败!",error.msg);
})
);
}
onDeleteAlertDefines() {
if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) {
this.notifySvc.warning("未选中任何待删除项!","");
this.notifySvc.warning('未选中任何待删除项!', '');
return;
}
this.modal.confirm({
@@ -141,7 +156,7 @@ export class AlertSettingComponent implements OnInit {
nzOkText: '确定',
nzCancelText: '取消',
nzOkDanger: true,
nzOkType: "primary",
nzOkType: 'primary',
nzOnOk: () => this.deleteAlertDefines(this.checkedDefineIds)
});
}
@@ -154,33 +169,34 @@ export class AlertSettingComponent implements OnInit {
nzOkText: '确定',
nzCancelText: '取消',
nzOkDanger: true,
nzOkType: "primary",
nzOkType: 'primary',
nzOnOk: () => this.deleteAlertDefines(defineIds)
});
}
deleteAlertDefines(defineIds: Set<number>) {
if (defineIds == null || defineIds.size == 0) {
this.notifySvc.warning("未选中任何待删除项!","");
this.notifySvc.warning('未选中任何待删除项!', '');
return;
}
this.tableLoading = true;
const deleteDefines$ = this.alertDefineSvc.deleteAlertDefines(defineIds)
.subscribe(message => {
const deleteDefines$ = this.alertDefineSvc.deleteAlertDefines(defineIds).subscribe(
message => {
deleteDefines$.unsubscribe();
if (message.code === 0) {
this.notifySvc.success("删除成功!", "");
this.notifySvc.success('删除成功!', '');
this.loadAlertDefineTable();
} else {
this.tableLoading = false;
this.notifySvc.error("删除失败!", message.msg);
this.notifySvc.error('删除失败!', message.msg);
}
}, error => {
},
error => {
this.tableLoading = false;
deleteDefines$.unsubscribe();
this.notifySvc.error("删除失败!", error.msg)
})
this.notifySvc.error('删除失败!', error.msg);
}
);
}
// begin: 列表多选分页逻辑
@@ -201,6 +217,7 @@ export class AlertSettingComponent implements OnInit {
}
/**
* 分页回调
*
* @param params 页码信息
*/
onTablePageChange(params: NzTableQueryParams) {
@@ -211,7 +228,6 @@ export class AlertSettingComponent implements OnInit {
}
// end: 列表多选逻辑
// start 新增修改告警定义model
isManageModalVisible = false;
isManageModalOkLoading = false;
@@ -227,39 +243,51 @@ export class AlertSettingComponent implements OnInit {
this.define.metric = this.cascadeValues[1];
this.define.field = this.cascadeValues[2];
if (this.isManageModalAdd) {
const modalOk$ = this.alertDefineSvc.newAlertDefine(this.define)
.pipe(finalize(() => {
modalOk$.unsubscribe();
this.isManageModalOkLoading = false;
}))
.subscribe(message => {
if (message.code === 0) {
this.isManageModalVisible = false;
this.notifySvc.success("新增成功!", "");
this.loadAlertDefineTable();
} else {
this.notifySvc.error("新增失败!", message.msg);
const modalOk$ = this.alertDefineSvc
.newAlertDefine(this.define)
.pipe(
finalize(() => {
modalOk$.unsubscribe();
this.isManageModalOkLoading = false;
})
)
.subscribe(
message => {
if (message.code === 0) {
this.isManageModalVisible = false;
this.notifySvc.success('新增成功!', '');
this.loadAlertDefineTable();
} else {
this.notifySvc.error('新增失败!', message.msg);
}
},
error => {
this.notifySvc.error('新增失败!', error.msg);
}
}, error => {
this.notifySvc.error("新增失败!", error.msg);
})
);
} else {
const modalOk$ = this.alertDefineSvc.editAlertDefine(this.define)
.pipe(finalize(() => {
modalOk$.unsubscribe();
this.isManageModalOkLoading = false;
}))
.subscribe(message => {
if (message.code === 0) {
this.isManageModalVisible = false;
this.notifySvc.success("修改成功!", "");
this.loadAlertDefineTable();
} else {
this.notifySvc.error("修改失败!", message.msg);
const modalOk$ = this.alertDefineSvc
.editAlertDefine(this.define)
.pipe(
finalize(() => {
modalOk$.unsubscribe();
this.isManageModalOkLoading = false;
})
)
.subscribe(
message => {
if (message.code === 0) {
this.isManageModalVisible = false;
this.notifySvc.success('修改成功!', '');
this.loadAlertDefineTable();
} else {
this.notifySvc.error('修改失败!', message.msg);
}
},
error => {
this.notifySvc.error('修改失败!', error.msg);
}
}, error => {
this.notifySvc.error("修改失败!", error.msg);
})
);
}
}
// end 新增修改告警定义model
@@ -280,7 +308,7 @@ export class AlertSettingComponent implements OnInit {
if (defineBindData.data != undefined) {
defineBindData.data.forEach(bind => {
bindRecode[bind.monitorId] = bind.monitorName;
})
});
}
let listTmp: any[] = [];
if (monitorData.data != undefined) {
@@ -290,12 +318,13 @@ export class AlertSettingComponent implements OnInit {
name: monitor.name,
key: monitor.id,
direction: bindRecode[monitor.id] == undefined ? 'left' : 'right'
})
})
});
});
}
return listTmp;
})
).subscribe(list => this.transferData = list);
)
.subscribe(list => (this.transferData = list));
}
onConnectModalCancel() {
this.isConnectModalVisible = false;
@@ -311,23 +340,29 @@ export class AlertSettingComponent implements OnInit {
bind.monitorName = item.name;
defineBinds.push(bind);
}
})
const applyBind$ = this.alertDefineSvc.applyAlertDefineMonitorsBind(this.currentAlertDefineId, defineBinds)
.pipe(finalize(() => {
applyBind$.unsubscribe();
}))
.subscribe(message => {
this.isConnectModalOkLoading = false;
if (message.code === 0) {
this.notifySvc.success("应用成功!", "");
this.isConnectModalVisible = false;
this.loadAlertDefineTable();
} else {
this.notifySvc.error("应用失败!", message.msg);
});
const applyBind$ = this.alertDefineSvc
.applyAlertDefineMonitorsBind(this.currentAlertDefineId, defineBinds)
.pipe(
finalize(() => {
applyBind$.unsubscribe();
})
)
.subscribe(
message => {
this.isConnectModalOkLoading = false;
if (message.code === 0) {
this.notifySvc.success('应用成功!', '');
this.isConnectModalVisible = false;
this.loadAlertDefineTable();
} else {
this.notifySvc.error('应用失败!', message.msg);
}
},
error => {
this.notifySvc.error('应用失败!', error.msg);
}
}, error => {
this.notifySvc.error("应用失败!", error.msg);
})
);
}
change(ret: TransferChange): void {
const listKeys = ret.list.map(l => l.key);
@@ -344,5 +379,4 @@ export class AlertSettingComponent implements OnInit {
});
}
// end 告警定义与监控关联model
}