Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {AlarmService} from '../alarm.service';
import {pageSize} from '../../app.constants';
import {AlarmGroupComponent} from '../modal/alarm-group/alarm-group.component';
import {AlarmModalComponent} from '../../modal/alarm-modal/alarm-modal.component';
selector: 'smart-alarm-set',
templateUrl: './alarm-set.component.html',
styles: []
constructor(private alarmSer: AlarmService, private modalSer: NzModalService,
private message: NzMessageService, private modalService: NzModalService) {
const data = {
eventPage: this.pageNum,
pageRecords: this.pageCount,
alertGroupId: this.alertGroupId
};
this.alarmSer.actionFind(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.setList = res.data.data;
this.totalNum = res.data.totalNum;
}
}
);
}
//获取告警组
getGroupAlarm() {
this.alarmSer.alertGroupFind().subscribe(
(res) => {
if (res.errCode == 10000) {
this.groupList = res.data;
this.alertGroupId = this.groupList[0].id;
this.getList();
}
}
);
}
//添加告警组
showGroupModal() {
this.smartAlarmGroup.addModal();
}
if (!this.alertGroupId) {
this.message.info('请选择需要删除的告警组');
return false;
}
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const arr = {
};
arr.ids.push(this.alertGroupId);
this.alarmSer.alertGroupDelete(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
} else {
this.message.info(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel'),
this.groupList.forEach(res => {
if (res.id == this.alertGroupId) {
arr = res;
}
});
this.smartAlarmGroup.editModal(arr);
}
this.smartAlarmModal.showAddModal("添加告警");
}
//编辑告警推送
showEditModal(item){
changeStatus(title, status, item) {
this.modalService.confirm({
nzTitle: title,
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
this.alarmSer.actionStatus(item.actionid, status).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info(title + '成功');
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
} else {
this.message.info(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
});
}
//删除告警
deleteAlarm(item) {
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该告警吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const arr = {
params: []
};
arr.params.push(item.actionid);
this.alarmSer.actionDelete(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
} else {
this.message.info(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}
);
}