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) {
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
ngOnInit() {
this.getList();
this.getGroupAlarm();
}
//获取推送设置列表
getList() {
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;
}
}
);
}
//添加告警组
showGroupModal() {
this.smartAlarmGroup.addModal();
}
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该告警组吗?</b>',
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.message.info('请选择需要编辑的分组');
return false;
}
let arr = [];
this.groupList.forEach(res => {
if (res.id == this.alertGroupId) {
arr = res;
}
});
this.smartAlarmGroup.editModal(arr);
}
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//启用或暂停告警组
changeStatus(title, status, item) {
this.modalService.confirm({
nzTitle: title,
nzContent: '<b style="color: red;">确定要' + title + '当前告警组吗</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
this.alarmSer.actionStatus(item.actionid, status).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info(title + '成功');
this.getList();
} 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('删除成功');
this.getList();
} else {
this.message.info(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}
);
}