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';
@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;
}
`]
constructor(public alarmSer: AlarmService,public overAllSer:OverAllService,public message:NzMessageService,
"mediatypeids":[this.obj.mediatypeids],
"hostids":[this.obj.hostids]
if(!this.obj.mediatypeids){
data.mediatypeids = []
}
if(!this.obj.hostids){
data.hostids = []
}
(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;
}
}
)
}
//时间改变
changeType(){
const nowDate = new Date().getTime();
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';
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':{
day1 = nowDate - 3*24*60*60*1000;
day2 = 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(day2,'yyyy-MM-dd') + ' 23:59:59';
case'4':{
day1 = nowDate - 7*24*60*60*1000;
day2 = 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(day2,'yyyy-MM-dd') + ' 23:59:59';
this.obj.time_from = new Date(this.obj.time_from).getTime();
this.obj.time_till = new Date(this.obj.time_till).getTime();
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
}
//查看消息内容
showDeleteModal(data){
this.isVisible = true;
this.title = data.subject;
this.content = data.message;
}
//modal取消
handleCancel(){
this.isVisible = false;
}
//删除告警日志
deleteLog(data){
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该告警组吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const arr = {
ids:[]
};
arr.ids.push(data.alertid);
this.alarmSer.alertDelete(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
} else {
this.message.info(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel'),
})
}
//选择告警目标--主机
showTargetModal(){
this.smartAlarmTarget.showModal();