Commit 4c6d4711 authored by wangqinghua's avatar wangqinghua

download

parent a075be7e
...@@ -59,8 +59,13 @@ ...@@ -59,8 +59,13 @@
</div> </div>
</div> </div>
<div nz-row class="search-form" style="border-top: none;padding: 0 0 15px 0;"> <div nz-row class="search-form" style="border-top: none;padding: 0 0 15px 0;">
<input style="width: 15%;" [(ngModel)]="obj.name" nz-input placeholder="告警信息"> <div nz-col nzSpan="16">
<button (click)="searchValue()" nz-button nzType="default"><i class="anticon anticon-search"></i>搜索</button> <input style="width: 15%;" [(ngModel)]="obj.name" nz-input placeholder="告警信息">
<button (click)="searchValue()" nz-button nzType="default"><i class="anticon anticon-search"></i>搜索</button>
</div>
<div nz-col nzSpan="8" class="text-right">
<button [nzLoading]="isDownload" (click)="downLoadExcel()" nz-button nzType="default"><i class="anticon anticon-download"></i>下载</button>
</div>
</div> </div>
<smart-warn-list #warnList></smart-warn-list> <smart-warn-list #warnList></smart-warn-list>
\ No newline at end of file
...@@ -5,6 +5,8 @@ import {WarnListComponent} from '../../modal/warn-list/warn-list.component'; ...@@ -5,6 +5,8 @@ import {WarnListComponent} from '../../modal/warn-list/warn-list.component';
import {OverAllService} from '../../overAll/overAll.service'; import {OverAllService} from '../../overAll/overAll.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {DatePipe} from '@angular/common'; import {DatePipe} from '@angular/common';
import {CommonService} from '../../shared/common/common.service';
import {WorkService} from '../../work/work.service';
@Component({ @Component({
selector: 'smart-alarm-list', selector: 'smart-alarm-list',
...@@ -50,9 +52,10 @@ export class AlarmListComponent implements OnInit { ...@@ -50,9 +52,10 @@ export class AlarmListComponent implements OnInit {
dateBegin = null; dateBegin = null;
dateEnd = null; dateEnd = null;
isDownload;
constructor(public alarmSer: AlarmService, public overAllSer: OverAllService, public message: NzMessageService, constructor(public alarmSer: AlarmService, public overAllSer: OverAllService, public message: NzMessageService,
public datePipe: DatePipe) { public datePipe: DatePipe,private commonSer:CommonService,private workSer:WorkService) {
this.changeType(); this.changeType();
} }
...@@ -62,10 +65,6 @@ export class AlarmListComponent implements OnInit { ...@@ -62,10 +65,6 @@ export class AlarmListComponent implements OnInit {
this.searchValue(); this.searchValue();
} }
// ngAfterViewInit(){
// this.searchValue();
// }
//获取分组 //获取分组
getWarnGroup() { getWarnGroup() {
this.overAllSer.findGroup().subscribe( this.overAllSer.findGroup().subscribe(
...@@ -134,4 +133,24 @@ export class AlarmListComponent implements OnInit { ...@@ -134,4 +133,24 @@ export class AlarmListComponent implements OnInit {
} }
this.warnList.getList(this.obj); this.warnList.getList(this.obj);
} }
//导出文件
downLoadExcel(){
this.isDownload = true;
this.alarmSer.getExportUrlEvent(this.obj).subscribe(
(res)=>{
if(res.errCode == 10000){
this.workSer.downloadTemplate('alarm',res.data).subscribe(
(data)=>{
this.isDownload = false;
this.commonSer.downloadFile('告警记录.xlsx',data)
}
)
}else{
this.message.error(res.errMsg);
}
this.isDownload = false;
}
)
}
} }
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<label nz-radio-button nzValue="5">自定义</label> <label nz-radio-button nzValue="5">自定义</label>
</nz-radio-group> </nz-radio-group>
</div> </div>
<div nz-col nzSpan="8"> <div nz-col nzSpan="7">
<ng-container *ngIf="timeType == '5'"> <ng-container *ngIf="timeType == '5'">
<nz-date-picker <nz-date-picker
nzFormat="yyyy-MM-dd" nzFormat="yyyy-MM-dd"
...@@ -56,7 +56,8 @@ ...@@ -56,7 +56,8 @@
></nz-date-picker> ></nz-date-picker>
</ng-container> </ng-container>
</div> </div>
<div nz-col nzSpan="3" class="text-right"> <div nz-col nzSpan="4" class="text-right">
<button [nzLoading]="isDownload" (click)="downLoadExcel()" nz-button nzType="default"><i class="anticon anticon-download"></i>下载</button>
<button (click)="search()" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button> <button (click)="search()" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button>
</div> </div>
</div> </div>
......
...@@ -6,6 +6,8 @@ import {AlarmService} from '../alarm.service'; ...@@ -6,6 +6,8 @@ import {AlarmService} from '../alarm.service';
import {pageSize} from '../../app.constants'; import {pageSize} from '../../app.constants';
import {NzMessageService, NzModalService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService} from 'ng-zorro-antd';
import {AlarmTargetComponent} from '../modal/alarm-target/alarm-target.component'; import {AlarmTargetComponent} from '../modal/alarm-target/alarm-target.component';
import {CommonService} from '../../shared/common/common.service';
import {WorkService} from '../../work/work.service';
@Component({ @Component({
selector: 'smart-alarm-log', selector: 'smart-alarm-log',
...@@ -60,8 +62,10 @@ export class AlarmLogComponent implements OnInit { ...@@ -60,8 +62,10 @@ export class AlarmLogComponent implements OnInit {
title; title;
content; content;
loading = false; loading = false;
isDownload;
constructor(public alarmSer: AlarmService,public overAllSer:OverAllService,public message:NzMessageService, constructor(public alarmSer: AlarmService,public overAllSer:OverAllService,public message:NzMessageService,
public datePipe:DatePipe,public modalSer:NzModalService) { public datePipe:DatePipe,public modalSer:NzModalService,private commonSer:CommonService,
private workSer:WorkService) {
const today = new Date(); const today = new Date();
this.obj.time_from = this.datePipe.transform(today,"yyyy-MM-dd") +" 00:00:00"; 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"; this.obj.time_till = this.datePipe.transform(today,"yyyy-MM-dd") +" 23:59:59";
...@@ -222,4 +226,31 @@ export class AlarmLogComponent implements OnInit { ...@@ -222,4 +226,31 @@ export class AlarmLogComponent implements OnInit {
this.smartAlarmTarget.showModal(); this.smartAlarmTarget.showModal();
} }
//导出文件
downLoadExcel(){
this.isDownload = true;
const data = {
"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.alarmSer.getExportUrlAlert(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.workSer.downloadTemplate('alert',res.data).subscribe(
(data)=>{
this.isDownload = false;
this.commonSer.downloadFile('告警推送日志.xlsx',data);
}
)
}else{
this.message.error(res.errMsg);
}
this.isDownload = false;
}
)
}
} }
...@@ -123,4 +123,14 @@ export class AlarmService { ...@@ -123,4 +123,14 @@ export class AlarmService {
findAlertTarget(): Observable<any>{ findAlertTarget(): Observable<any>{
return this.http.get(SERVER_API_URL + '/action/findAlertTarget'); return this.http.get(SERVER_API_URL + '/action/findAlertTarget');
} }
}
\ No newline at end of file //导出当前告警列表
getExportUrlEvent(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/event/getExportUrl',data);
}
//告警推送日志导出
getExportUrlAlert(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/alert/getExportUrl',data);
}
}
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
style="font-size: 15px;"></i>{{alarmTotal}} style="font-size: 15px;"></i>{{alarmTotal}}
</span> </span>
</div> </div>
<div nz-col nzSpan="8" class="text-right">
<button [nzLoading]="isDownload" (click)="downLoadExcel()" nz-button nzType="default"><i class="anticon anticon-download"></i>下载</button>
</div>
</div> </div>
<div class="tag-warn tag-form handle"> <div class="tag-warn tag-form handle">
<ng-container *ngFor="let item of warnCountList"> <ng-container *ngFor="let item of warnCountList">
......
...@@ -5,6 +5,8 @@ import {SendLogComponent} from '../modal/send-log/send-log.component'; ...@@ -5,6 +5,8 @@ import {SendLogComponent} from '../modal/send-log/send-log.component';
import {color, pageSize} from '../../app.constants'; import {color, pageSize} from '../../app.constants';
import {WarnListComponent} from '../../modal/warn-list/warn-list.component'; import {WarnListComponent} from '../../modal/warn-list/warn-list.component';
import {OverAllService} from '../../overAll/overAll.service'; import {OverAllService} from '../../overAll/overAll.service';
import {CommonService} from '../../shared/common/common.service';
import {WorkService} from '../../work/work.service';
@Component({ @Component({
selector: 'smart-now-alarm', selector: 'smart-now-alarm',
...@@ -48,9 +50,10 @@ export class NowAlarmComponent implements OnInit, OnDestroy { ...@@ -48,9 +50,10 @@ export class NowAlarmComponent implements OnInit, OnDestroy {
time_; time_;
selectHostId; selectHostId;
isDownload;
constructor(public alarmSer: AlarmService, public message: NzMessageService, constructor(public alarmSer: AlarmService, public message: NzMessageService,private workSer:WorkService,
public overAllSer:OverAllService) { public overAllSer:OverAllService,private commonSer:CommonService) {
} }
ngOnInit() { ngOnInit() {
...@@ -98,4 +101,28 @@ export class NowAlarmComponent implements OnInit, OnDestroy { ...@@ -98,4 +101,28 @@ export class NowAlarmComponent implements OnInit, OnDestroy {
getTotal(num){ getTotal(num){
this.alarmTotal = num; this.alarmTotal = num;
} }
//导出文件
downLoadExcel(){
this.isDownload = true;
const data = {
isWaring:'yes',
hostid:this.selectHostId,
};
this.alarmSer.getExportUrlEvent(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.workSer.downloadTemplate('alarm',res.data).subscribe(
(data)=>{
this.isDownload = false;
this.commonSer.downloadFile('当前告警.xlsx',data);
}
)
}else{
this.message.error(res.errMsg);
}
this.isDownload = false;
}
)
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment