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} from 'ng-zorro-antd';
@Component({
selector: 'smart-alarm-log',
templateUrl: './alarm-log.component.html',
styles: [`
.tag-warn{
padding: 5px;
}
.tag-warn span{
border: 1px solid #ccc;
margin-right: 10px;
display: inline-block;
margin-bottom: 10px;
padding: 2px 4px;
border-radius: 4px;
}
:host ::ng-deep .tag-warn .ant-tag{
margin-right: 0px;
}
`]
@ViewChild('warnList') warnList: WarnListComponent;
logList = [];
warnCountList = [];
groupList = [];
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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
pageNum = 1;
pageCount = pageSize;
totalNum;
//条件
timeType;
obj = {
priorityName:null,
groupid:null,
equipmentType:null,
startTime:'',
endTime:'',
name:''
};
constructor(public alarmSer: AlarmService,public overAllSer:OverAllService,public message:NzMessageService,
public datePipe:DatePipe) {
}
ngOnInit() {
const obj = {};
this.getType();
this.getWarnGroup();
this.getList();
}
//
getList(){
const obj = {
"eventPage":this.pageNum,
"pageRecords":this.pageCount
}
this.alarmSer.alertFind(obj).subscribe(
(res)=>{
if(res.errCode == 10000){
this.logList = res.data.data;
this.totalNum = res.data.totalNum;
}else{
this.message.info(res.errMsg);
}
}
)
}
//获取分组
getWarnGroup(){
this.overAllSer.findGroup().subscribe(
(res)=>{
if(res.errCode == 10000){
this.groupList = res.data;
}
}
)
}
//获取资源类型
getType(){
this.overAllSer.findHostWarningCount().subscribe(
(res)=>{
if(res.errCode == 10000){
this.warnCountList = res.data;
}else{
this.message.info(res.errMsg);
}
}
)
}
//时间改变
changeType(){
const nowDate = new Date().getTime();
let day1,day2;
switch (this.timeType){
case'1':{
this.obj.startTime = this.datePipe.transform(nowDate,'yyyy-MM-dd') +' 00:00:00';
this.obj.endTime = this.datePipe.transform(nowDate,'yyyy-MM-dd') +' 23:59:59';
break;
};
case'2':{
day1 = nowDate - 1*24*60*60*1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 23:59:59';
break;
};
case'3':{
day1 = nowDate - 3*24*60*60*1000;
day2 = nowDate - 1*24*60*60*1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59';
break;
};
case'4':{
day1 = nowDate - 7*24*60*60*1000;
day2 = nowDate - 1*24*60*60*1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59';
break;
};
case'5':{
break;
};
}
}
//查询
searchValue(){
this.obj.startTime = this.datePipe.transform(this.obj.startTime,'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(this.obj.endTime,'yyyy-MM-dd HH:mm:ss');
this.warnList.getList(this.obj);
}