|
|
@ -1,14 +1,46 @@ |
|
|
|
import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core'; |
|
|
|
import { Component, Input, OnInit, OnChanges, SimpleChanges, Output } from '@angular/core'; |
|
|
|
import { NzMessageService } from 'ng-zorro-antd'; |
|
|
|
import { NzMessageService } from 'ng-zorro-antd'; |
|
|
|
import { NoticeService } from '../../../service/https/notice.service'; |
|
|
|
import { NoticeService } from '../../../service/https/notice.service'; |
|
|
|
|
|
|
|
import { exportAsExcelFile, convertKeys } from '../utils/utils'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// data mapping
|
|
|
|
|
|
|
|
// IP
|
|
|
|
|
|
|
|
const ipKeyMaps = { |
|
|
|
|
|
|
|
'req_ip': '访问源IP', |
|
|
|
|
|
|
|
'req_frequency': '访问频次' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const accountKeyMaps = { |
|
|
|
|
|
|
|
'req_account': '账号', |
|
|
|
|
|
|
|
'req_frequency': '访问频次', |
|
|
|
|
|
|
|
'req_jobnum': '工号' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const interfaceKeyMaps = { |
|
|
|
|
|
|
|
'interface_addr': '接口地址', |
|
|
|
|
|
|
|
'req_ip': '访问IP', |
|
|
|
|
|
|
|
'req_account': '访问账号', |
|
|
|
|
|
|
|
'req_frequency': '访问频次' , |
|
|
|
|
|
|
|
'req_jobnum': '工号' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const menuKeyMaps = { |
|
|
|
|
|
|
|
'menu_name': '菜单名称', |
|
|
|
|
|
|
|
'req_ip': '访问IP', |
|
|
|
|
|
|
|
'req_account': '访问账号', |
|
|
|
|
|
|
|
'req_frequency': '访问频次' , |
|
|
|
|
|
|
|
'req_jobnum': '工号' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-path', |
|
|
|
selector: 'app-path', |
|
|
|
templateUrl: './path.component.html', |
|
|
|
templateUrl: './path.component.html', |
|
|
|
styleUrls: ['./path.component.styl'] |
|
|
|
styleUrls: ['./path.component.styl'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
export class PathComponent implements OnInit, OnChanges { |
|
|
|
export class PathComponent implements OnInit, OnChanges { |
|
|
|
@Input() detail_data: any; |
|
|
|
@Input() detail_data: any; |
|
|
|
|
|
|
|
// @Output() detailDataChange = new EventEmitter();
|
|
|
|
data; |
|
|
|
data; |
|
|
|
viewType = 0; |
|
|
|
viewType = 0; |
|
|
|
whiteListParam = {}; |
|
|
|
whiteListParam = {}; |
|
|
@ -29,7 +61,7 @@ export class PathComponent implements OnInit, OnChanges { |
|
|
|
// if (this.detail_data == null) {
|
|
|
|
// if (this.detail_data == null) {
|
|
|
|
// this.detail_data = JSON.parse(jsonStr);
|
|
|
|
// this.detail_data = JSON.parse(jsonStr);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
this.parseData(); |
|
|
|
|
|
|
|
if (this.rules === undefined) { |
|
|
|
if (this.rules === undefined) { |
|
|
|
this.noticeService.getDefaultRule().subscribe( |
|
|
|
this.noticeService.getDefaultRule().subscribe( |
|
|
|
resp => { |
|
|
|
resp => { |
|
|
@ -107,7 +139,7 @@ export class PathComponent implements OnInit, OnChanges { |
|
|
|
} |
|
|
|
} |
|
|
|
this.noticeService.addWhitelist(this.whiteListParam).subscribe( |
|
|
|
this.noticeService.addWhitelist(this.whiteListParam).subscribe( |
|
|
|
resp => { |
|
|
|
resp => { |
|
|
|
if (resp.status === 200) { |
|
|
|
if (resp.code === 200) { |
|
|
|
this.message.success('添加白名单成功!'); |
|
|
|
this.message.success('添加白名单成功!'); |
|
|
|
this.data[index]['is_in_white_list'] = 1; |
|
|
|
this.data[index]['is_in_white_list'] = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -118,6 +150,19 @@ export class PathComponent implements OnInit, OnChanges { |
|
|
|
this.message.error('服务器错误'); |
|
|
|
this.message.error('服务器错误'); |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
var log_params = { |
|
|
|
|
|
|
|
"action":"add wihte list", |
|
|
|
|
|
|
|
"params":this.whiteListParam |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.noticeService.writeAuditlog(log_params).subscribe(resp => { |
|
|
|
|
|
|
|
if (resp.code !== 200) { |
|
|
|
|
|
|
|
this.message.error("审计日志记录失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
error => { |
|
|
|
|
|
|
|
this.message.error('服务器错误'); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clickGreyList(data) { |
|
|
|
clickGreyList(data) { |
|
|
@ -149,7 +194,7 @@ export class PathComponent implements OnInit, OnChanges { |
|
|
|
this.greyListParam["type"]=0; |
|
|
|
this.greyListParam["type"]=0; |
|
|
|
this.noticeService.addGreyList(this.greyListParam).subscribe( |
|
|
|
this.noticeService.addGreyList(this.greyListParam).subscribe( |
|
|
|
resp => { |
|
|
|
resp => { |
|
|
|
if (resp.status === 200) { |
|
|
|
if (resp.code === 200) { |
|
|
|
this.message.success('添加灰名单成功!'); |
|
|
|
this.message.success('添加灰名单成功!'); |
|
|
|
this.data[index]['is_in_grey_list'] = 1; |
|
|
|
this.data[index]['is_in_grey_list'] = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -160,6 +205,20 @@ export class PathComponent implements OnInit, OnChanges { |
|
|
|
this.message.error('服务器错误'); |
|
|
|
this.message.error('服务器错误'); |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var log_params = { |
|
|
|
|
|
|
|
"action":"add greyList", |
|
|
|
|
|
|
|
"params":this.greyListParam |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.noticeService.writeAuditlog(log_params).subscribe(resp => { |
|
|
|
|
|
|
|
if (resp.code!== 200) { |
|
|
|
|
|
|
|
this.message.error("审计日志记录失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
error => { |
|
|
|
|
|
|
|
this.message.error('服务器错误'); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clickFrequency(data) { |
|
|
|
clickFrequency(data) { |
|
|
@ -196,5 +255,43 @@ export class PathComponent implements OnInit, OnChanges { |
|
|
|
|
|
|
|
|
|
|
|
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
exportExcel(){ |
|
|
|
|
|
|
|
var keysMap :any; |
|
|
|
|
|
|
|
var fileName = ""; |
|
|
|
|
|
|
|
switch(this.viewType){ |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
keysMap= ipKeyMaps; |
|
|
|
|
|
|
|
fileName="ip维度" |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
keysMap= accountKeyMaps; |
|
|
|
|
|
|
|
fileName="账号维度" |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
keysMap= interfaceKeyMaps; |
|
|
|
|
|
|
|
fileName="接口维度" |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
keysMap= menuKeyMaps; |
|
|
|
|
|
|
|
fileName="菜单维度" |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(JSON.stringify(keysMap)); |
|
|
|
|
|
|
|
var data =convertKeys(this.data,keysMap) |
|
|
|
|
|
|
|
exportAsExcelFile(data,fileName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// async getval(){
|
|
|
|
|
|
|
|
// const [ewAssetDetailsRes, assetTypeRes] = await Promise.all([
|
|
|
|
|
|
|
|
// this.noticeService.getUebaResult(this.di),
|
|
|
|
|
|
|
|
// this.noticeService.getQueryRange(this.di)
|
|
|
|
|
|
|
|
// ]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(ewAssetDetailsRes && assetTypeRes){
|
|
|
|
|
|
|
|
// this.ewAssetDetails = ewAssetDetailsRes.data;
|
|
|
|
|
|
|
|
// this.assetType = assetTypeRes.data;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|