|
|
@ -1,4 +1,4 @@ |
|
|
|
import { Component, Input, OnInit } from '@angular/core'; |
|
|
|
import { Component, Input, OnInit, OnChanges, SimpleChanges } 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'; |
|
|
|
|
|
|
|
|
|
|
@ -7,10 +7,13 @@ import { NoticeService } from '../../../service/https/notice.service'; |
|
|
|
templateUrl: './path.component.html', |
|
|
|
templateUrl: './path.component.html', |
|
|
|
styleUrls: ['./path.component.styl'] |
|
|
|
styleUrls: ['./path.component.styl'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class PathComponent implements OnInit { |
|
|
|
export class PathComponent implements OnInit, OnChanges { |
|
|
|
@Input() detail_data: any; |
|
|
|
@Input() detail_data: any; |
|
|
|
data; |
|
|
|
data; |
|
|
|
viewType = 0; |
|
|
|
viewType = 0; |
|
|
|
|
|
|
|
whiteListParam = {}; |
|
|
|
|
|
|
|
greyListParam = {}; |
|
|
|
|
|
|
|
rules; |
|
|
|
|
|
|
|
|
|
|
|
constructor( |
|
|
|
constructor( |
|
|
|
private noticeService: NoticeService, |
|
|
|
private noticeService: NoticeService, |
|
|
@ -22,31 +25,144 @@ export class PathComponent implements OnInit { |
|
|
|
// if (this.detail_data == null) {
|
|
|
|
// if (this.detail_data == null) {
|
|
|
|
// this.detail_data = JSON.parse(jsonStr);
|
|
|
|
// this.detail_data = JSON.parse(jsonStr);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
this.parseData(this.detail_data); |
|
|
|
this.parseData(); |
|
|
|
|
|
|
|
if (this.rules == null) { |
|
|
|
|
|
|
|
this.noticeService.getDefaultRule().subscribe( |
|
|
|
|
|
|
|
resp => { |
|
|
|
|
|
|
|
if (resp.status === 200) { |
|
|
|
|
|
|
|
this.rules = resp.data; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.message.error(resp.msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
error => { |
|
|
|
|
|
|
|
this.message.error('服务器错误'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parseData(detail_data: any) { |
|
|
|
ngOnChanges(changes: SimpleChanges) { |
|
|
|
for (const dataKey in detail_data) { |
|
|
|
if ('detail_data' in changes) { |
|
|
|
if (detail_data.hasOwnProperty(dataKey)) { |
|
|
|
this.parseData(); |
|
|
|
|
|
|
|
// 在这里处理接收到的数据
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parseData() { |
|
|
|
|
|
|
|
for (const dataKey in this.detail_data) { |
|
|
|
|
|
|
|
if (this.detail_data.hasOwnProperty(dataKey)) { |
|
|
|
if (dataKey === 'type') { |
|
|
|
if (dataKey === 'type') { |
|
|
|
this.viewType = detail_data[dataKey]; |
|
|
|
this.viewType = this.detail_data[dataKey]; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.data = detail_data[dataKey]; |
|
|
|
this.data = this.detail_data[dataKey]; |
|
|
|
|
|
|
|
this.data.forEach(item => { |
|
|
|
|
|
|
|
item['is_in_white_list'] = 0;
|
|
|
|
|
|
|
|
item['is_in_grey_list'] = 0;
|
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clickWihteList(data) { |
|
|
|
clickWihteList(data) { |
|
|
|
alert("点击白名单"); |
|
|
|
let index = -1; |
|
|
|
|
|
|
|
// this.message.success('添加白名单成功!');
|
|
|
|
|
|
|
|
// this.data[index]['is_in_white_list'] = 1;
|
|
|
|
|
|
|
|
this.whiteListParam['range'] = ["ueba"]; |
|
|
|
|
|
|
|
this.whiteListParam['des'] = ""; |
|
|
|
|
|
|
|
this.whiteListParam['is_enable'] = 1; |
|
|
|
|
|
|
|
switch(this.viewType) { |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
this.whiteListParam['fields'] = ["sip"]; |
|
|
|
|
|
|
|
this.whiteListParam['name'] = data.req_ip + '-' + this.getCurrentTime(); |
|
|
|
|
|
|
|
this.whiteListParam['content'] = {"sip": data.req_ip}; |
|
|
|
|
|
|
|
this.whiteListParam['alert_rule_id'] = this.rules["white_list"]["ip"]; |
|
|
|
|
|
|
|
index = this.data.findIndex(item => item.req_ip === data.req_ip); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
this.whiteListParam['fields'] = ["url"]; |
|
|
|
|
|
|
|
this.whiteListParam['name'] = data.interface_addr + '-' + this.getCurrentTime(); |
|
|
|
|
|
|
|
this.whiteListParam['content'] = {"url": data.interface_addr}; |
|
|
|
|
|
|
|
this.whiteListParam['alert_rule_id'] = this.rules["white_list"]["interface"]; |
|
|
|
|
|
|
|
index = this.data.findIndex(item => item.interface_addr === data.interface_addr); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.noticeService.addWhitelist(this.whiteListParam).subscribe( |
|
|
|
|
|
|
|
resp => { |
|
|
|
|
|
|
|
if (resp.status === 200) { |
|
|
|
|
|
|
|
this.message.success('添加白名单成功!'); |
|
|
|
|
|
|
|
this.data[index]['is_in_white_list'] = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.message.error(resp.msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
error => { |
|
|
|
|
|
|
|
this.message.error('服务器错误'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clickGreyList(data) { |
|
|
|
clickGreyList(data) { |
|
|
|
alert("点击灰名单"); |
|
|
|
let index = -1; |
|
|
|
|
|
|
|
// this.message.success('添加灰名单成功!');
|
|
|
|
|
|
|
|
// this.data[index]['is_in_grey_list'] = 1;
|
|
|
|
|
|
|
|
this.greyListParam['des'] = ""; |
|
|
|
|
|
|
|
this.greyListParam['is_enable'] = 1; |
|
|
|
|
|
|
|
switch(this.viewType) { |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
this.greyListParam['fields'] = ["sip"]; |
|
|
|
|
|
|
|
this.greyListParam['name'] = data.req_ip + '-' + this.getCurrentTime(); |
|
|
|
|
|
|
|
this.greyListParam['content'] = {"sip": data.req_ip}; |
|
|
|
|
|
|
|
this.greyListParam['alert_rule_id'] = this.rules["grey_list"]["ip"]; |
|
|
|
|
|
|
|
index = this.data.findIndex(item => item.req_ip === data.req_ip); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
this.greyListParam['fields'] = ["url"]; |
|
|
|
|
|
|
|
this.greyListParam['name'] = data.interface_addr + '-' + this.getCurrentTime(); |
|
|
|
|
|
|
|
this.greyListParam['content'] = {"url": data.interface_addr}; |
|
|
|
|
|
|
|
this.greyListParam['alert_rule_id'] = this.rules["grey_list"]["interface"]; |
|
|
|
|
|
|
|
index = this.data.findIndex(item => item.interface_addr === data.interface_addr); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.noticeService.addGreyList(this.greyListParam).subscribe( |
|
|
|
|
|
|
|
resp => { |
|
|
|
|
|
|
|
if (resp.status === 200) { |
|
|
|
|
|
|
|
this.message.success('添加灰名单成功!'); |
|
|
|
|
|
|
|
this.data[index]['is_in_grey_list'] = 1; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.message.error(resp.msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
error => { |
|
|
|
|
|
|
|
this.message.error('服务器错误'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
clickFrequency(data) { |
|
|
|
clickFrequency(data) { |
|
|
|
alert("点击超链接"); |
|
|
|
alert("点击超链接"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在组件类中
|
|
|
|
|
|
|
|
getCurrentTime(): string { |
|
|
|
|
|
|
|
const now = new Date(); |
|
|
|
|
|
|
|
const year = now.getFullYear(); |
|
|
|
|
|
|
|
const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的
|
|
|
|
|
|
|
|
const day = String(now.getDate()).padStart(2, '0'); |
|
|
|
|
|
|
|
const hours = String(now.getHours()).padStart(2, '0'); |
|
|
|
|
|
|
|
const minutes = String(now.getMinutes()).padStart(2, '0'); |
|
|
|
|
|
|
|
const seconds = String(now.getSeconds()).padStart(2, '0'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|