Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {WarnListComponent} from '../../modal/warn-list/warn-list.component';
import {OverAllService} from '../../overAll/overAll.service';
import {DatePipe} from '@angular/common';
import {AlarmService} from '../alarm.service';
import {pageSize} from '../../app.constants';
import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {AlarmTargetComponent} from '../modal/alarm-target/alarm-target.component';
import {CommonService} from '../../shared/common/common.service';
import {WorkService} from '../../work/work.service';
selector: 'smart-alarm-log',
templateUrl: './alarm-log.component.html',
styles: [`
.tag-warn {
border: 1px solid #ccc;
margin-right: 10px;
display: inline-block;
margin-bottom: 10px;
padding: 2px 4px;
border-radius: 4px;
}
@ViewChild('smartAlarmTarget') smartAlarmTarget: AlarmTargetComponent;
time_from: <any>'',
time_till: <any>'',
alertGroupId: null,
mediatypeids: null,
hostids: null,
constructor(public alarmSer: AlarmService, public overAllSer: OverAllService, public message: NzMessageService,
public datePipe: DatePipe, public modalSer: NzModalService, private commonSer: CommonService,
private workSer: WorkService) {
this.obj.time_from = this.datePipe.transform(today, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.time_till = this.datePipe.transform(today, 'yyyy-MM-dd') + ' 23:59:59';
'eventPage': this.pageNum,
'pageRecords': this.pageCount,
'alertGroupId': this.obj.alertGroupId,
'time_from': new Date(this.obj.time_from).getTime(),
'time_till': new Date(this.obj.time_till).getTime(),
'mediatypeids': [this.obj.mediatypeids],
'hostids': [this.obj.hostids]
this.logList = res.data.data;
this.totalNum = res.data.totalNum;
}
//获取告警组
getGroupAlarm() {
this.alarmSer.alertGroupFind().subscribe(
(res) => {
if (res.errCode == 10000) {
let day1, day2;
switch (this.timeType) {
case'1': {
this.obj.time_from = this.datePipe.transform(nowDate, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.time_till = this.datePipe.transform(nowDate, 'yyyy-MM-dd') + ' 23:59:59';
case'2': {
day1 = nowDate - 1 * 24 * 60 * 60 * 1000;
this.obj.time_from = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.time_till = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 23:59:59';
case'3': {
this.obj.time_from = nowDate - 3 * 24 * 60 * 60 * 1000;
case'4': {
this.obj.time_from = nowDate - 7 * 24 * 60 * 60 * 1000;
this.obj.time_from = new Date(this.startTime).getTime();
this.obj.time_till = new Date(this.endTime).getTime();
}
change(e) {
if (e > 0) {
this.pageNum = e;
this.getList();
}
this.isVisible = true;
this.title = data.subject;
this.content = data.message;
}
//modal取消
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该告警组吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const arr = {
};
arr.ids.push(data.alertid);
this.alarmSer.alertDelete(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel'),
'alertGroupId': this.obj.alertGroupId,
'time_from': new Date(this.obj.time_from).getTime(),
'time_till': new Date(this.obj.time_till).getTime(),
'mediatypeids': [],
'hostids': []
(res) => {
if (res.errCode == 10000) {
this.workSer.downloadTemplate('alert', res.data).subscribe(
(data) => {