From b17724ea27ff0104d4651a5b3e12fa12dfcc6be7 Mon Sep 17 00:00:00 2001 From: TANGWY Date: Thu, 13 Jun 2024 18:25:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E9=9D=A2=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- angular.json | 18 +- extra-webpack.config.js | 2 +- package-lock.json | 2 +- package.json | 6 +- src/app/app-routing.module.ts | 2 +- src/app/app.component.ts | 2 +- .../layout/manage/manage.component.html | 59 +- .../layout/manage/manage.component.styl | 2 +- .../config/layout/manage/manage.component.ts | 1048 ++++++++++++++++- .../config/layout/manage/manage.module.ts | 4 +- .../layout/manage/path/path.component.html | 4 +- .../layout/manage/path/path.component.ts | 52 +- .../manage/process/process.component.html | 18 + .../manage/process/process.component.spec.ts | 28 + .../manage/process/process.component.styl | 0 .../manage/process/process.component.ts | 88 ++ .../config/service/https/notice.service.ts | 203 +++- src/environments/environment.prod.ts | 2 +- src/environments/environment.ts | 2 +- 19 files changed, 1407 insertions(+), 135 deletions(-) create mode 100644 src/app/routes/config/layout/manage/process/process.component.html create mode 100644 src/app/routes/config/layout/manage/process/process.component.spec.ts create mode 100644 src/app/routes/config/layout/manage/process/process.component.styl create mode 100644 src/app/routes/config/layout/manage/process/process.component.ts diff --git a/angular.json b/angular.json index 0e5f196..d739638 100644 --- a/angular.json +++ b/angular.json @@ -3,7 +3,7 @@ "version": 1, "newProjectRoot": "projects", "projects": { - "notice": { + "uebaMetricsAnalysis": { "root": "", "sourceRoot": "src", "projectType": "application", @@ -21,7 +21,7 @@ "build": { "builder": "@angular-builders/custom-webpack:browser", "options": { - "outputPath": "dist/notice", + "outputPath": "dist/uebaMetricsAnalysis", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", @@ -82,18 +82,18 @@ "serve": { "builder": "@angular-builders/dev-server:generic", "options": { - "browserTarget": "notice:build" + "browserTarget": "uebaMetricsAnalysis:build" }, "configurations": { "production": { - "browserTarget": "notice:build:production" + "browserTarget": "uebaMetricsAnalysis:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { - "browserTarget": "notice:build" + "browserTarget": "uebaMetricsAnalysis:build" } }, "test": { @@ -127,7 +127,7 @@ } } }, - "notice-e2e": { + "uebaMetricsAnalysis-e2e": { "root": "e2e/", "projectType": "application", "prefix": "", @@ -136,11 +136,11 @@ "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", - "devServerTarget": "notice:serve" + "devServerTarget": "uebaMetricsAnalysis:serve" }, "configurations": { "production": { - "devServerTarget": "notice:serve:production" + "devServerTarget": "uebaMetricsAnalysis:serve:production" } } }, @@ -156,5 +156,5 @@ } } }, - "defaultProject": "notice" + "defaultProject": "uebaMetricsAnalysis" } \ No newline at end of file diff --git a/extra-webpack.config.js b/extra-webpack.config.js index b2b457b..a404e62 100644 --- a/extra-webpack.config.js +++ b/extra-webpack.config.js @@ -7,7 +7,7 @@ module.exports = (angularWebpackConfig, options) => { output: { library: `${name}-[name]`, libraryTarget: 'umd', - publicPath: process.env.NODE_ENV == 'prod' ? '/WebApi/notice/static/dist/' : 'http://localhost:4203/' + publicPath: process.env.NODE_ENV == 'prod' ? '/WebApi/uebaMetricsAnalysis/static/dist/' : 'http://localhost:4203/' }, diff --git a/package-lock.json b/package-lock.json index 1fb66dc..4ce0ffe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "notice", + "name": "uebaMetricsAnalysis", "version": "0.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index c24716f..c77f533 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "notice", + "name": "uebaMetricsAnalysis", "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve notice --host 0.0.0.0 --disable-host-check --port 4203 --open --proxy-config proxy.conf.js", - "build": "set NODE_ENV=prod&& ng build notice --aot --output-path dist/ --deploy-url /WebApi/notice/static/dist/ --base-href /WebApi/notice/static/dist/ --prod", + "start": "ng serve uebaMetricsAnalysis --host 0.0.0.0 --disable-host-check --port 4203 --open --proxy-config proxy.conf.js", + "build": "set NODE_ENV=prod&& ng build uebaMetricsAnalysis --aot --output-path dist/ --deploy-url /WebApi/uebaMetricsAnalysis/static/dist/ --base-href /WebApi/uebaMetricsAnalysis/static/dist/ --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index fc9c1d4..03b3233 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -13,7 +13,7 @@ const routes: Routes = [ imports: [RouterModule.forRoot(routes, { useHash: true })], exports: [RouterModule], providers: [ - { provide: APP_BASE_HREF, useValue: (window as any).__POWERED_BY_QIANKUN__ ? '/notice' : '/' }, + { provide: APP_BASE_HREF, useValue: (window as any).__POWERED_BY_QIANKUN__ ? '/uebaMetricsAnalysis' : '/' }, ] }) export class AppRoutingModule { } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d8841e9..abf4eab 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -28,7 +28,7 @@ export class AppComponent implements OnInit { if (!this.prefixRouter) { this.prefixRouter = await this.configService.translatePrefix(); } - const appName = '/notice'; + const appName = '/uebaMetricsAnalysis'; const prefix = this.configService.getUrlPrefix(this.prefixRouter, appName); document.title = prefix ? prefix : '绿盟智能安全运营平台'; } diff --git a/src/app/routes/config/layout/manage/manage.component.html b/src/app/routes/config/layout/manage/manage.component.html index 84409e3..d435318 100644 --- a/src/app/routes/config/layout/manage/manage.component.html +++ b/src/app/routes/config/layout/manage/manage.component.html @@ -1,4 +1,5 @@
+

接口访问统计

时间选择:
@@ -7,7 +8,7 @@
统计维度:
- + @@ -20,9 +21,10 @@
- -
- +
+
+ + 归属单位 @@ -43,18 +45,18 @@ "ip_reat": 0.3, "ip_avg": 0.43, "trend": 0.3 --> - {{ data.company }} + {{data.company}} {{ data.req_frequency }} - {{ data.frequency_rate }} + {{ data.frequency_rate| percent: '1.1-2' }} {{ data.ip_count }} - {{ data.ip_reat }} - {{ data.ip_avg }} - {{ data.trend }} + {{ data.ip_rate| percent: '1.1-2' }} + {{ data.ip_avg| number: '1.2-2' }} + {{ data.trend| percent: '1.1-2' }} - + 归属单位 @@ -75,18 +77,18 @@ "account_reat": 0.3, "account_avg": 0.43, "trend": 0.3 --> - {{ data.company }} + {{data.company}} {{ data.req_frequency }} - {{ data.frequency_rate }} + {{ data.frequency_rate| percent: '1.1-2' }} {{ data.account_count }} - {{ data.account_reat }} - {{ data.account_avg }} - {{ data.trend }} + {{ data.account_rate| percent: '1.1-2' }} + {{ data.account_avg| number: '1.2-2' }} + {{ data.trend| percent: '1.1-2' }} - + 接口地址 @@ -103,15 +105,16 @@ "frequency_rate": 0.160727824109174, "frequency_avg": 0, "trend": 0.07 --> - {{ data.interface_addr }} + {{ data.interface_addr }} {{ data.req_frequency }} - {{ data.frequency_avg }} - {{ data.trend }} + {{ data.frequency_rate | percent: '1.1-2' }} + {{ data.frequency_avg| number: '1.2-2' }} + {{ data.trend| percent: '1.1-2' }} - + 菜单名称 @@ -128,18 +131,22 @@ "frequency_rate": 0.263449367088608, "frequency_avg": 111, "trend": 0.09 --> - {{ data.menu_name }} + {{ data.menu_name }} {{ data.req_frequency }} - {{ data.frequency_avg }} - {{ data.trend }} + {{ data.frequency_rate| percent: '1.1-2' }} + {{ data.frequency_avg| number: '1.2-2'}} + {{ data.trend| percent: '1.1-2' }}
- - - + + + + + +
\ No newline at end of file diff --git a/src/app/routes/config/layout/manage/manage.component.styl b/src/app/routes/config/layout/manage/manage.component.styl index a68a1f5..ab1c4c7 100644 --- a/src/app/routes/config/layout/manage/manage.component.styl +++ b/src/app/routes/config/layout/manage/manage.component.styl @@ -32,4 +32,4 @@ .ant-select{ width 100px } -} \ No newline at end of file +} diff --git a/src/app/routes/config/layout/manage/manage.component.ts b/src/app/routes/config/layout/manage/manage.component.ts index 60839ca..6a2a4d6 100644 --- a/src/app/routes/config/layout/manage/manage.component.ts +++ b/src/app/routes/config/layout/manage/manage.component.ts @@ -1,55 +1,168 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit,Injectable } from '@angular/core'; import { NzMessageService } from 'ng-zorro-antd'; import { NoticeService } from '../../service/https/notice.service'; import { CacheService } from '../../service/cache/cache.service'; +import { PathComponent } from './path/path.component'; +import { ProcessComponent } from './process/process.component'; +import { Subscription } from 'rxjs'; +import * as XLSX from 'xlsx'; +import { saveAs } from 'file-saver'; +const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8'; +const EXCEL_EXTENSION = '.xlsx'; +// data mapping +// IP +const ipKeyMaps = { + 'company': '归属单位', + 'req_frequency': '访问频次', + 'frequency_rate': '频次占比', + 'ip_count': 'IP计数', + 'ip_rate': 'IP占比', + 'ip_avg': 'IP均值', + 'trend': '访问趋势', +}; +const accountKeyMaps = { + 'company': '归属单位', + 'req_frequency': '访问频次', + 'frequency_rate': '频次占比', + 'account_count': 'IP计数', + 'account_rate': 'IP占比', + 'account_avg': 'IP均值', + 'trend': '访问趋势', +}; + +const interfaceKeyMaps = { + 'interface_addr': '接口地址', + 'req_frequency': '访问频次', + 'frequency_rate': '频次占比', + 'frequency_avg': '频次均值', + 'trend': '访问趋势', +}; + +const menuKeyMaps = { + 'menu_name': '菜单名称', + 'req_frequency': '访问频次', + 'frequency_rate': '频次占比', + 'frequency_avg': '频次均值', + 'trend': '访问趋势', +}; @Component({ selector: 'app-manage', templateUrl: './manage.component.html', styleUrls: ['./manage.component.styl'] }) + +@Injectable({ + providedIn: 'root' + }) + export class ManageComponent implements OnInit { + summary_detal_data :any; + tableisShow :any; dateFormat = 'yyyy/MM/dd HH:mm:ss' + submitLoading = false; + logLoading = false; dateRange = [] listOfData = [] iphead = [] dimension = '1' isVisible = false + detail_data : any; + destroySubscriptions: Subscription[] = []; + constructor( private noticeService: NoticeService, public message: NzMessageService, public cache: CacheService ) { } + exportAsExcelFile(json: any[], excelFileName: string): void { + const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json); + const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] }; + const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); + this.saveAsExcelFile(excelBuffer, excelFileName); + } + private saveAsExcelFile(buffer: any, fileName: string): void { + const data: Blob = new Blob([buffer], { + type: EXCEL_TYPE + }); + saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION); + } + onSubmit(){ - this.isVisible = true - console.log(123) - - console.log(this.dimension) - console.log("Selected Date Range: ", this.dateRange); + // 日期校验 + this.submitLoading = true; + this.tableisShow = this.dimension; if (this.dateRange.length === 2) { const startDate = this.dateRange[0]; const endDate = this.dateRange[1]; console.log(startDate); - alert(`Selected Date Range: ${startDate.toLocaleDateString()} - ${endDate.toLocaleDateString()}`); + //alert(`Selected Date Range: ${startDate.toLocaleDateString()} - ${endDate.toLocaleDateString()}`); } else { alert('Please select a date range.'); } + // 获取es的查询最大日期范围 + // this.noticeService.getQueryRange().subscribe(resp => { + // if (resp.status === 200) { + // console.log(resp.data); + // } else { + // this.message.error(resp.msg); + // } + // }, + // error => { + // this.message.error('服务器错误'); + // }) - this.noticeService.getQueryRange().subscribe(resp => { - if (resp.status === 200) { - console.log(resp.data); - } else { - this.message.error(resp.msg); + // 获取es数据 暂时mock数据 + this.summary_detal_data = this.mockData + this.listOfData=[] + if (this.summary_detal_data.code === 0) { + switch(this.dimension.toString()){ + case "1": + this.listOfData = this.summary_detal_data.data.summary.ip; + console.log("1"+this.dimension.toString()) + break; + case "2": + this.listOfData = this.summary_detal_data.data.summary.account; + console.log("2"+this.dimension.toString()) + break; + case "3": + this.listOfData = this.summary_detal_data.data.summary.interface; + console.log("3"+this.dimension.toString()) + break; + case "4": + this.listOfData = this.summary_detal_data.data.summary.menu; + console.log("4"+this.dimension.toString()) + break; } - }, - error => { - this.message.error('服务器错误'); - }) + } else { + this.message.error("error"); + } + + // this.listOfData = resp.data.summary.ip; + // this.noticeService.getUebaResult({"type":eventVal}).subscribe(resp => { + // if (resp.code === 200) { + // switch(this.dimension.toString()){ + // case "1": + // this.listOfData = resp.summary.ip; + // case "2": + // this.listOfData = resp.summary.account; + // case "3": + // this.listOfData = resp.summary.interface; + // case "4": + // this.listOfData = resp.summary.menu; + // } + // } else { + // this.message.error(resp.msg); + // } + // }, + // error => { + // this.message.error('服务器错误'); + // }) } ngOnInit() { const now = new Date(); @@ -57,32 +170,895 @@ export class ManageComponent implements OnInit { oneWeekAgo.setDate(now.getDate() - 7); this.dateRange = [oneWeekAgo, now]; + + this.onSubmit() } getMenuItem(e) { console.log(e.el.dataset.id); // this.key = e.el.dataset.id; } - selectValChange(){ - console.log("xxxx"+this.dimension) - - this.noticeService.getUebaResult(this.dimension).subscribe(resp => { - if (resp.status === 200) { - switch(this.dimension.toString()){ - case "1": - this.listOfData = resp["summary"]["ip"]; - case "2": - this.listOfData = resp["summary"]["account"]; - case "3": - this.listOfData = resp["summary"]["interface"]; - case "4": - this.listOfData = resp["summary"]["menu"]; + + exportExcel(){ + var keysMap :any; + var fileName = ""; + switch(this.dimension){ + 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 =this.convertKeys(this.listOfData,keysMap) + this.exportAsExcelFile(data,fileName); + } + + showModel(data){ + var tmpdata :any; + switch(data.type){ + case 1: + tmpdata=this.summary_detal_data.data.detail.ip[data.key]; + break; + case 2 : + tmpdata=this.summary_detal_data.data.detail.account[data.key]; + break; + case 3 : + tmpdata=this.summary_detal_data.data.detail.interface[data.key]; + break; + case 4 : + tmpdata=this.summary_detal_data.data.detail.menu[data.key]; + break; + } + var diagData = { + "type": data.type, + [data.key]: tmpdata + } + + this.detail_data =diagData; + console.log(JSON.stringify(this.detail_data)); + this.isVisible=true; + } + cancelSearch(): void { + this.submitLoading = false; + this.logLoading = false; + + this.destroySubscriptions.forEach(subscription => { + if (subscription) { + subscription.unsubscribe(); } - } else { - this.message.error(resp.msg); - } - }, - error => { - this.message.error('服务器错误'); + }); +} +convertKeys(excelData: Raw[], keysMap: Record): Target[] { + return excelData.map(excelItem => { + return Object.entries(excelItem).reduce((prev: any, curt) => { + const [curtKey, curtValue] = curt; + // 更新 key + const mappedKey = keysMap[curtKey]; + if (mappedKey) { + prev[mappedKey] = curtValue; + } else { + prev[curtKey] = curtValue; + } + + return prev; + }, {}); }) } + +mockData={ + "message": "success", + "code": 0, + "data": { + "detail": { + "interface": { + "http://190.89.233.2:8909/getUser": [ + { + "req_ip": "192.156.3.12", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 54411, + "req_frequency": 23, + "req_account": "zhangq" + }, + { + "req_ip": "192.156.3.12", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 54412, + "req_frequency": 24, + "req_account": "huqx" + }, + { + "req_ip": "192.156.3.13", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 54413, + "req_frequency": 25, + "req_account": "zhangsf" + }, + { + "req_ip": "192.156.3.14", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 54414, + "req_frequency": 26, + "req_account": "zhaoj" + }, + { + "req_ip": "192.156.3.15", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 54415, + "req_frequency": 27, + "req_account": "sangdq" + }, + { + "req_ip": "192.156.3.16", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 54416, + "req_frequency": 28, + "req_account": "hujt" + }, + { + "req_ip": "192.156.3.17", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 43325, + "req_frequency": 29, + "req_account": "zhangs" + }, + { + "req_ip": "192.156.3.18", + "interface_addr": "http://190.89.233.2:8909/getUser", + "req_jobnum": 43326, + "req_frequency": 30, + "req_account": "lin" + } + ], + "http://190.89.233.2:8909/update/sysconfig": [ + { + "req_ip": "192.106.3.35", + "interface_addr": "http://190.89.233.2:8909/update/sysconfig", + "req_jobnum": 54415, + "req_frequency": 34, + "req_account": "zhangsf" + }, + { + "req_ip": "192.106.3.36", + "interface_addr": "http://190.89.233.2:8909/update/sysconfig", + "req_jobnum": 54416, + "req_frequency": 23, + "req_account": "zhaoj" + }, + { + "req_ip": "192.106.3.37", + "interface_addr": "http://190.89.233.2:8909/update/sysconfig", + "req_jobnum": 43325, + "req_frequency": 78, + "req_account": "sangdq" + }, + { + "req_ip": "192.146.3.38", + "interface_addr": "http://190.89.233.2:8910/update/sysconfig", + "req_jobnum": 43326, + "req_frequency": 79, + "req_account": "hujt" + }, + { + "req_ip": "192.146.3.39", + "interface_addr": "http://190.89.233.2:8911/update/sysconfig", + "req_jobnum": 43327, + "req_frequency": 80, + "req_account": "zhangs" + }, + { + "req_ip": "192.146.3.40", + "interface_addr": "http://190.89.233.2:8912/update/sysconfig", + "req_jobnum": 43328, + "req_frequency": 81, + "req_account": "lin" + }, + { + "req_ip": "192.146.3.41", + "interface_addr": "http://190.89.233.2:8913/update/sysconfig", + "req_jobnum": 65341, + "req_frequency": 82, + "req_account": "liuhr" + }, + { + "req_ip": "192.146.3.42", + "interface_addr": "http://190.89.233.2:8914/update/sysconfig", + "req_jobnum": 65342, + "req_frequency": 83, + "req_account": "sunxq01" + }, + { + "req_ip": "192.146.3.43", + "interface_addr": "http://190.89.233.2:8915/update/sysconfig", + "req_jobnum": 65343, + "req_frequency": 84, + "req_account": "xiaod01" + }, + { + "req_ip": "192.146.3.44", + "interface_addr": "http://190.89.233.2:8916/update/sysconfig", + "req_jobnum": 98761, + "req_frequency": 85, + "req_account": "qingsx" + }, + { + "req_ip": "192.146.3.45", + "interface_addr": "http://190.89.233.2:8917/update/sysconfig", + "req_jobnum": 98761, + "req_frequency": 86, + "req_account": "guobg" + }, + { + "req_ip": "192.146.3.46", + "interface_addr": "http://190.89.233.2:8918/update/sysconfig", + "req_jobnum": 98761, + "req_frequency": 87, + "req_account": "zhangq" + } + ], + "http://190.89.233.2:8909/getpublicconfig": [ + { + "req_ip": "192.156.3.12", + "interface_addr": "http://190.89.233.2:8909/getpublicconfig", + "req_jobnum": 43327, + "req_frequency": 43, + "req_account": "liuhr" + }, + { + "req_ip": "192.156.3.12", + "interface_addr": "http://190.89.233.2:8909/getpublicconfig", + "req_jobnum": 43328, + "req_frequency": 44, + "req_account": "sunxq01" + }, + { + "req_ip": "192.156.3.18", + "interface_addr": "http://190.89.233.2:8909/getpublicconfig", + "req_jobnum": 65341, + "req_frequency": 45, + "req_account": "shicl" + }, + { + "req_ip": "192.106.3.33", + "interface_addr": "http://190.89.233.2:8909/getpublicconfig", + "req_jobnum": 65342, + "req_frequency": 46, + "req_account": "gongxs" + }, + { + "req_ip": "192.106.3.34", + "interface_addr": "http://190.89.233.2:8909/getpublicconfig", + "req_jobnum": 65343, + "req_frequency": 47, + "req_account": "sunzs" + } + ] + }, + "ip": { + "省公司": [ + { + "req_ip": "192.146.3.38", + "req_frequency": 123 + }, + { + "req_ip": "192.146.3.39", + "req_frequency": 124 + }, + { + "req_ip": "192.146.3.40", + "req_frequency": 125 + }, + { + "req_ip": "192.146.3.41", + "req_frequency": 126 + }, + { + "req_ip": "192.146.3.42", + "req_frequency": 127 + }, + { + "req_ip": "192.146.3.43", + "req_frequency": 128 + }, + { + "req_ip": "192.146.3.44", + "req_frequency": 129 + }, + { + "req_ip": "192.146.3.45", + "req_frequency": 130 + }, + { + "req_ip": "192.146.3.46", + "req_frequency": 131 + }, + { + "req_ip": "192.146.3.47", + "req_frequency": 132 + } + ], + "孝感分公司": [ + { + "req_ip": "192.126.3.24", + "req_frequency": 54 + }, + { + "req_ip": "192.126.3.25", + "req_frequency": 55 + }, + { + "req_ip": "192.126.3.26", + "req_frequency": 56 + }, + { + "req_ip": "192.126.3.27", + "req_frequency": 57 + }, + { + "req_ip": "192.126.3.28", + "req_frequency": 58 + }, + { + "req_ip": "192.126.3.29", + "req_frequency": 59 + }, + { + "req_ip": "192.106.3.30", + "req_frequency": 60 + } + ], + "黄冈分公司": [ + { + "req_ip": "192.106.3.30", + "req_frequency": 51 + }, + { + "req_ip": "192.106.3.31", + "req_frequency": 52 + }, + { + "req_ip": "192.106.3.32", + "req_frequency": 53 + }, + { + "req_ip": "192.106.3.33", + "req_frequency": 54 + }, + { + "req_ip": "192.106.3.34", + "req_frequency": 55 + }, + { + "req_ip": "192.106.3.35", + "req_frequency": 56 + }, + { + "req_ip": "192.106.3.36", + "req_frequency": 57 + }, + { + "req_ip": "192.106.3.37", + "req_frequency": 58 + }, + { + "req_ip": "192.106.3.38", + "req_frequency": 59 + } + ], + "随州分公司": [ + { + "req_ip": "192.116.3.24", + "req_frequency": 44 + }, + { + "req_ip": "192.116.3.25", + "req_frequency": 45 + }, + { + "req_ip": "192.116.3.26", + "req_frequency": 46 + }, + { + "req_ip": "192.116.3.27", + "req_frequency": 47 + }, + { + "req_ip": "192.116.3.28", + "req_frequency": 48 + }, + { + "req_ip": "192.116.3.29", + "req_frequency": 49 + }, + { + "req_ip": "192.116.3.30", + "req_frequency": 50 + } + ], + "宜昌分公司": [ + { + "req_ip": "192.156.3.11", + "req_frequency": 22 + }, + { + "req_ip": "192.156.3.12", + "req_frequency": 12 + }, + { + "req_ip": "192.156.3.19", + "req_frequency": 78 + }, + { + "req_ip": "192.156.3.20", + "req_frequency": 79 + }, + { + "req_ip": "192.156.3.21", + "req_frequency": 80 + }, + { + "req_ip": "192.156.3.22", + "req_frequency": 81 + }, + { + "req_ip": "192.156.3.23", + "req_frequency": 82 + }, + { + "req_ip": "192.156.3.24", + "req_frequency": 83 + } + ] + }, + "account": { + "省公司": [ + { + "req_jobnum": 98761, + "req_frequency": 37, + "req_account": "maoxt" + }, + { + "req_jobnum": 98761, + "req_frequency": 29, + "req_account": "xiaod01" + }, + { + "req_jobnum": 98761, + "req_frequency": 71, + "req_account": "qingsx" + }, + { + "req_jobnum": 98761, + "req_frequency": 79, + "req_account": "guobg" + } + ], + "孝感分公司": [ + { + "req_jobnum": 43325, + "req_frequency": 98, + "req_account": "zhangs" + }, + { + "req_jobnum": 43326, + "req_frequency": 43, + "req_account": "lin" + }, + { + "req_jobnum": 43327, + "req_frequency": 33, + "req_account": "liuhr" + }, + { + "req_jobnum": 43328, + "req_frequency": 51, + "req_account": "sunxq01" + } + ], + "黄冈分公司": [ + { + "req_jobnum": 65341, + "req_frequency": 47, + "req_account": "shicl" + }, + { + "req_jobnum": 65342, + "req_frequency": 65, + "req_account": "gongxs" + }, + { + "req_jobnum": 65343, + "req_frequency": 54, + "req_account": "sunzs" + } + ], + "随州分公司": [ + { + "req_jobnum": 54415, + "req_frequency": 36, + "req_account": "sangdq" + }, + { + "req_jobnum": 54416, + "req_frequency": 37, + "req_account": "hujt" + } + ], + "宜昌分公司": [ + { + "req_jobnum": 54412, + "req_frequency": 33, + "req_account": "huqx" + }, + { + "req_jobnum": 54413, + "req_frequency": 34, + "req_account": "zhangsf" + }, + { + "req_jobnum": 54414, + "req_frequency": 35, + "req_account": "zhaoj" + } + ] + }, + "menu": { + "菜单1": [ + { + "menu_name": "菜单1", + "req_ip": "192.106.3.32", + "req_jobnum": "43326", + "req_frequency": 53, + "req_account": "lin" + }, + { + "menu_name": "菜单1", + "req_ip": "192.106.3.33", + "req_jobnum": "43327", + "req_frequency": 54, + "req_account": "liuhr" + }, + { + "menu_name": "菜单1", + "req_ip": "192.106.3.34", + "req_jobnum": "43328", + "req_frequency": 55, + "req_account": "sunxq01" + }, + { + "menu_name": "菜单1", + "req_ip": "192.106.3.35", + "req_jobnum": "65341", + "req_frequency": 56, + "req_account": "shicl" + }, + { + "menu_name": "菜单1", + "req_ip": "192.106.3.36", + "req_jobnum": "65342", + "req_frequency": 57, + "req_account": "gongxs" + }, + { + "menu_name": "菜单1", + "req_ip": "192.106.3.37", + "req_jobnum": "65343", + "req_frequency": 58, + "req_account": "sunzs" + } + ], + "菜单2": [ + { + "menu_name": "菜单2", + "req_ip": "192.156.3.12", + "req_jobnum": "54411", + "req_frequency": 31, + "req_account": "zhangq" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.12", + "req_jobnum": "54412", + "req_frequency": 32, + "req_account": "huqx" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.13", + "req_jobnum": "54413", + "req_frequency": 33, + "req_account": "zhangsf" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.14", + "req_jobnum": "54414", + "req_frequency": 34, + "req_account": "zhaoj" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.15", + "req_jobnum": "54415", + "req_frequency": 35, + "req_account": "sangdq" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.16", + "req_jobnum": "54416", + "req_frequency": 36, + "req_account": "hujt" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.17", + "req_jobnum": "43325", + "req_frequency": 37, + "req_account": "zhangs" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.18", + "req_jobnum": "43326", + "req_frequency": 38, + "req_account": "lin" + }, + { + "menu_name": "菜单2", + "req_ip": "192.156.3.12", + "req_jobnum": "43327", + "req_frequency": 39, + "req_account": "liuhr" + } + ], + "菜单3": [ + { + "menu_name": "菜单3", + "req_ip": "192.106.3.33", + "req_jobnum": "65342", + "req_frequency": 51, + "req_account": "gongxs" + }, + { + "menu_name": "菜单3", + "req_ip": "192.106.3.34", + "req_jobnum": "65343", + "req_frequency": 52, + "req_account": "sunzs" + }, + { + "menu_name": "菜单3", + "req_ip": "192.106.3.35", + "req_jobnum": "54415", + "req_frequency": 53, + "req_account": "zhangsf" + }, + { + "menu_name": "菜单3", + "req_ip": "192.106.3.36", + "req_jobnum": "54416", + "req_frequency": 54, + "req_account": "zhaoj" + }, + { + "menu_name": "菜单3", + "req_ip": "192.106.3.37", + "req_jobnum": "43325", + "req_frequency": 55, + "req_account": "sangdq" + }, + { + "menu_name": "菜单3", + "req_ip": "192.146.3.38", + "req_jobnum": "43326", + "req_frequency": 56, + "req_account": "hujt" + }, + { + "menu_name": "菜单3", + "req_ip": "192.146.3.39", + "req_jobnum": "43327", + "req_frequency": 57, + "req_account": "zhangs" + }, + { + "menu_name": "菜单3", + "req_ip": "192.146.3.40", + "req_jobnum": "43328", + "req_frequency": 58, + "req_account": "lin" + }, + { + "menu_name": "菜单3", + "req_ip": "192.146.3.41", + "req_jobnum": "65341", + "req_frequency": 59, + "req_account": "liuhr" + }, + { + "menu_name": "菜单3", + "req_ip": "192.146.3.42", + "req_jobnum": "65342", + "req_frequency": 60, + "req_account": "sunxq01" + }, + { + "menu_name": "菜单3", + "req_ip": "192.146.3.43", + "req_jobnum": "65343", + "req_frequency": 61, + "req_account": "xiaod01" + } + ] + } + }, + "summary": { + "interface": [ + { + "trend": 0.07, + "frequency_avg": 0, + "interface_addr": "http://190.89.233.2:8909/getUser", + "frequency_rate": 0.160727824109174, + "req_frequency": 212 + }, + { + "trend": 0.02, + "frequency_avg": 0, + "interface_addr": "http://190.89.233.2:8909/getpublicconfig", + "frequency_rate": 0.170583775587566, + "req_frequency": 225 + }, + { + "trend": -0.09, + "frequency_avg": 0, + "interface_addr": "http://190.89.233.2:8909/update/sysconfig", + "frequency_rate": 0.66868840030326, + "req_frequency": 882 + } + ], + "ip": [ + { + "trend": 0.09, + "company": "宜昌分公司", + "ip_rate": 0.195121951219512, + "ip_count": 8, + "ip_avg": 2.14344941956882, + "req_frequency": 517, + "frequency_rate": 17.1475953565506 + }, + { + "trend": 0.1, + "company": "随州分公司", + "ip_rate": 0.170731707317073, + "ip_count": 7, + "ip_avg": 1.55887230514096, + "req_frequency": 329, + "frequency_rate": 10.9121061359867 + }, + { + "trend": -0.07, + "company": "孝感分公司", + "ip_rate": 0.170731707317073, + "ip_count": 7, + "ip_avg": 1.89054726368159, + "req_frequency": 399, + "frequency_rate": 13.2338308457711 + }, + { + "trend": -0.02, + "company": "黄冈分公司", + "ip_rate": 0.219512195121951, + "ip_count": 9, + "ip_avg": 1.82421227197347, + "req_frequency": 495, + "frequency_rate": 16.4179104477612 + }, + { + "trend": 0.1, + "company": "省公司", + "ip_rate": 0.24390243902439, + "ip_count": 10, + "ip_avg": 4.22885572139304, + "req_frequency": 1275, + "frequency_rate": 42.2885572139304 + } + ], + "account": [ + { + "account_rate": 0.242424242424242, + "account_avg": 2.46323529411765, + "trend": 0.09, + "company": "宜昌分公司", + "req_frequency": 134, + "account_count": 8, + "frequency_rate": 19.7058823529412 + }, + { + "account_rate": 0.212121212121212, + "account_avg": 1.53361344537815, + "trend": 0.1, + "company": "随州分公司", + "req_frequency": 73, + "account_count": 7, + "frequency_rate": 10.7352941176471 + }, + { + "account_rate": 0.212121212121212, + "account_avg": 4.72689075630252, + "trend": -0.07, + "company": "孝感分公司", + "req_frequency": 225, + "account_count": 7, + "frequency_rate": 33.0882352941176 + }, + { + "account_rate": 0.272727272727273, + "account_avg": 2.71241830065359, + "trend": -0.02, + "company": "黄冈分公司", + "req_frequency": 166, + "account_count": 9, + "frequency_rate": 24.4117647058824 + }, + { + "account_rate": 0.303030303030303, + "account_avg": 3.17647058823529, + "trend": 0.1, + "company": "省公司", + "req_frequency": 216, + "account_count": 10, + "frequency_rate": 31.7647058823529 + } + ], + "menu": [ + { + "menu_name": "菜单1", + "trend": 0.09, + "frequency_avg": 111, + "frequency_rate": 0.263449367088608, + "req_frequency": 333 + }, + { + "menu_name": "菜单2", + "trend": -0.01, + "frequency_avg": 105, + "frequency_rate": 0.249208860759494, + "req_frequency": 315 + }, + { + "menu_name": "菜单3", + "trend": 0.02, + "frequency_avg": 205.333333333333, + "frequency_rate": 0.487341772151899, + "req_frequency": 616 + } + ] + } + } +} + + + + + + + + + + + + + + } diff --git a/src/app/routes/config/layout/manage/manage.module.ts b/src/app/routes/config/layout/manage/manage.module.ts index 5d736b7..31179db 100644 --- a/src/app/routes/config/layout/manage/manage.module.ts +++ b/src/app/routes/config/layout/manage/manage.module.ts @@ -4,13 +4,13 @@ import { CommonModule } from '@angular/common'; import { ManageComponent } from './manage.component'; import { SharedModule } from 'src/app/common-ui'; import { PathComponent } from './path/path.component'; - +import { ProcessComponent } from './process/process.component'; @NgModule({ imports: [ CommonModule, SharedModule ], - declarations: [PathComponent, ManageComponent] + declarations: [PathComponent, ManageComponent,ProcessComponent] }) export class ManageModule {} diff --git a/src/app/routes/config/layout/manage/path/path.component.html b/src/app/routes/config/layout/manage/path/path.component.html index cd913ac..9460a35 100644 --- a/src/app/routes/config/layout/manage/path/path.component.html +++ b/src/app/routes/config/layout/manage/path/path.component.html @@ -1,4 +1,6 @@ -
cdfddffff
\ No newline at end of file +
+

Name: {{ detail_data.type }}

+
\ No newline at end of file diff --git a/src/app/routes/config/layout/manage/path/path.component.ts b/src/app/routes/config/layout/manage/path/path.component.ts index dc645e2..568ba5c 100644 --- a/src/app/routes/config/layout/manage/path/path.component.ts +++ b/src/app/routes/config/layout/manage/path/path.component.ts @@ -8,14 +8,7 @@ import { NoticeService } from '../../../service/https/notice.service'; styleUrls: ['./path.component.styl'] }) export class PathComponent implements OnInit { - @Input() datas: any; - data; - mailData: any; - messageData: any; - qywechatData: any; - dingtalkData: any; - wechartRobotData: any; - dingdingRobotData: any; + @Input() detail_data: any; constructor( private noticeService: NoticeService, @@ -23,47 +16,6 @@ export class PathComponent implements OnInit { ) {} ngOnInit() { - this.queryData(); + } - - queryData() { - this.noticeService.queryConfig().subscribe( - resp => { - if (resp.status === 200) { - // console.log(resp.data); - this.data = resp.data; - this.processData(this.data); - } else { - this.message.error(resp.msg); - } - }, - error => { - this.message.error('服务器错误'); - } - ); - } - - processData(allData) { - allData.forEach((item) => { - if (item.type === 'mail') { - this.mailData = item; - } - if (item.type === 'message') { - this.messageData = item; - } - if (item.type === 'qywechat') { - this.qywechatData = item; - } - if (item.type === 'dingtalk') { - this.dingtalkData = item; - } - if (item.type === 'webhook') { - this.wechartRobotData = item; - } - if (item.type === 'robot') { - this.dingdingRobotData = item; - } - }); - } - } diff --git a/src/app/routes/config/layout/manage/process/process.component.html b/src/app/routes/config/layout/manage/process/process.component.html new file mode 100644 index 0000000..7e6bde0 --- /dev/null +++ b/src/app/routes/config/layout/manage/process/process.component.html @@ -0,0 +1,18 @@ + + + 查询进度 + + + + + + + + + + \ No newline at end of file diff --git a/src/app/routes/config/layout/manage/process/process.component.spec.ts b/src/app/routes/config/layout/manage/process/process.component.spec.ts new file mode 100644 index 0000000..558cf4a --- /dev/null +++ b/src/app/routes/config/layout/manage/process/process.component.spec.ts @@ -0,0 +1,28 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { PathComponent } from './process.component'; + +describe('PathComponent', () => { + let component: PathComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PathComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(PathComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/routes/config/layout/manage/process/process.component.styl b/src/app/routes/config/layout/manage/process/process.component.styl new file mode 100644 index 0000000..e69de29 diff --git a/src/app/routes/config/layout/manage/process/process.component.ts b/src/app/routes/config/layout/manage/process/process.component.ts new file mode 100644 index 0000000..80c640f --- /dev/null +++ b/src/app/routes/config/layout/manage/process/process.component.ts @@ -0,0 +1,88 @@ +import { + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + EventEmitter, + Input, + OnChanges, + Output, + SimpleChanges +} from '@angular/core'; + +@Component({ + selector: 'app-process', + templateUrl: './process.component.html', + styleUrls: ['./process.component.styl'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +// @ts-ignore +export class ProcessComponent implements OnChanges { + // @ts-ignore + @Input() visible = false; + // @ts-ignore + // tslint:disable-next-line:no-output-on-prefix + @Output() onCancel = new EventEmitter(); + + open = false; + process = 0; + intervalId = -1; + + constructor( + private cdr: ChangeDetectorRef + ) {} + + ngOnChanges(changes: SimpleChanges): void { + const visible = changes['visible']; + + if (visible.currentValue !== null) { + if (visible.currentValue) { + this.start(); + } + } + } + + random() { + const acc = Math.ceil(Math.random() * 10); + const added = this.process + acc; + this.process = added >= 99 ? 99 : added; + } + + start() { + this.open = true; + this.process = 0; + clearTimeout(this.intervalId); + this.ticker(); + } + + ticker() { + this.intervalId = setTimeout(() => { + if (this.visible) { + this.random(); + this.ticker(); + } else { + this.process = 100; + this.autoClose(); + } + this.cdr.markForCheck(); + }, 1000); + } + + cancel() { + this.open = false; + clearTimeout(this.intervalId); + this.onCancel.emit(); + } + + autoClose() { + clearTimeout(this.intervalId); + setTimeout(() => { + this.open = false; + this.cdr.markForCheck(); + }, 300); + } + + justClose() { + this.open = false; + clearTimeout(this.intervalId); + } +} \ No newline at end of file diff --git a/src/app/routes/config/service/https/notice.service.ts b/src/app/routes/config/service/https/notice.service.ts index c30a987..0ff13e1 100644 --- a/src/app/routes/config/service/https/notice.service.ts +++ b/src/app/routes/config/service/https/notice.service.ts @@ -35,7 +35,208 @@ export class NoticeService { } getUebaResult(params:any) { - const url = '/UebaMetricsAnalysis/ueba_metrics/get_summary_data_list'; + const url = '/uebaMetricsAnalysis/ueba_metrics/get_summary_data_list'; return this.httpService.get(url, params,30000); } + + // 引擎接口 + // 获取已有的白名单 + whiteListQuery(params){ + // { + // "message": "success", + // "code": 200, + // "data": { + // "total": 3, + // "data": [ + // { + // "white_content": { + // "sip": "128.3.212.3" + // }, + // "update_time": 1717731552, + // "alert_rule_id": [ + // 400000 + // ], + // "name": "test2", + // "white_rule": { + // "url": [ + // "http://baid.com" + // ], + // "sip": { + // "ip_range_list": [], + // "single_ip_list": [ + // "128.3.212.3" + // ] + // } + // }, + // "des": "\u63cf\u8ff0\u4fe1\u606f", + // "event_rule_id": [], + // "range": [ + // "ueba" + // ], + // "is_enable": 1, + // "create_time": 1717731479, + // "is_gray": 0, + // "id": 5 + // }, + // { + // "white_content": { + // "url": "http://baid.com", + // "sip": "128.3.212.3" + // }, + // "update_time": 1717730831, + // "alert_rule_id": [ + // 400000 + // ], + // "name": "test2", + // "white_rule": { + // "url": [ + // "http://baid.com" + // ], + // "sip": { + // "ip_range_list": [], + // "single_ip_list": [ + // "128.3.212.3" + // ] + // } + // }, + // "des": "\u63cf\u8ff0\u4fe1\u606f", + // "event_rule_id": [], + // "range": [ + // "ueba" + // ], + // "is_enable": 1, + // "create_time": 1717730546, + // "is_gray": 0, + // "id": 2 + // }, + // { + // "white_content": { + // "dport": "123", + // "sip": "0.0.0.0", + // "dip": "0.0.0.0", + // "sport": "111" + // }, + // "update_time": 1717399034, + // "alert_rule_id": [], + // "name": "test", + // "white_rule": { + // "dport": [ + // 123 + // ], + // "sip": { + // "ip_range_list": [], + // "single_ip_list": [ + // "0.0.0.0" + // ] + // }, + // "dip": { + // "ip_range_list": [], + // "single_ip_list": [ + // "0.0.0.0" + // ] + // }, + // "sport": [ + // 111 + // ] + // }, + // "des": "", + // "event_rule_id": [ + // 490002 + // ], + // "range": [ + // "cep" + // ], + // "is_enable": 1, + // "create_time": 1713409218, + // "is_gray": 0, + // "id": 1 + // } + // ] + // } + // } + //pageIndex,pageSize + //const url = '/ditingEngine/diting/global/whitelist_query/?pageIndex=1&pageSize=10000'; + const url = '/ditingEngine/diting/global/whitelist_query'; + return this.httpService.get(url, params); + } + + // 获取已有的灰名单 + greyListQyery(param){ + // { + // "message": "\u8c1b\u542c\u5f15\u64ce-\u540d\u5355\u67e5\u8be2\u6210\u529f", + // "code": 200, + // "data": { + // "total": 1, + // "data": [ + // { + // "white_content": { + // "url": "http://baid.com", + // "sip": "187.23.23.4" + // }, + // "update_time": 1717730747, + // "alert_rule_id": [ + // 400000 + // ], + // "name": "\u7070\u540d\u5355-\u540d\u79f0", + // "des": "\u7070\u540d\u5355-\u63cf\u8ff0", + // "range": "ueba", + // "is_enable": 1, + // "create_time": 1717730747, + // "is_gray": 1, + // "id": 3 + // } + // ] + // } + // } + // const url = 'https://10.65.74.3/ditingEngine/ueba/engine_name_list/query/?pageIndex=1&pageSize=10&type=0'; + const url = '/ditingEngine/ueba/engine_name_list/query'; + return this.httpService.get(url,param); + } + + // 添加白名单 + addWhitelist(params){ + // { + // "range": [ + // "ueba" + // ], + // "fields": [ + // "sip", + // ], + // "name": "test2",//ip+加入时间 + // "des": "", + // "is_enable": 1, + // "content": { + // "sip": "128.3.212.3", + // }, + // "alert_rule_id": [ + // 400000, + // 400000 + // ] + // } + const url = '/ditingEngine/diting/global/whitelist_add'; + return this.httpService.post(url,{}, params); + } + + // 添加灰名单 + addGreyList(params){ + // { + // "fields": [ + // "sip", + // "url" + // ], + // "name": "灰名单-名称",//ip+加入时间 + // "alert_rule_id": [ + // 400000 + // ], + // "des": "灰名单-描述", + // "is_enable": 1, + // "content": { + // "sip": "187.23.23.4", + // "url": "http://baid.com" + // }, + // "type": 0 + // } + const url = '/ditingEngine/diting/global/whitelist_add'; + return this.httpService.post(url,{}, params); + } } diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 5122b4d..2254fe9 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,5 +1,5 @@ export const environment = { production: true, - productionUrls: '/WebApi/notice/static/dist/', + productionUrls: '/WebApi/uebaMetricsAnalysis/static/dist/', hashPrefx: '' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 613a9a8..d0a51af 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -5,7 +5,7 @@ export const environment = { production: false, productionUrls: '', - hashPrefx: '/WebApi/notice/static/dist/' + hashPrefx: '/WebApi/uebaMetricsAnalysis/static/dist/' }; /*