From b1ecd62cccbed9355fb0fae93f6fcc3b1d73b75d Mon Sep 17 00:00:00 2001 From: Eduard Klimenko Date: Fri, 3 May 2024 19:48:50 +0300 Subject: [PATCH] fix: transactions - HEP Logs --- .../detail-dialog/detail-dialog.component.ts | 1 + .../tab-hepsub/tab-hepsub.component.ts | 178 +++++++++--------- .../services/call/full-transaction.service.ts | 13 +- src/app/services/call/hep-log.service.ts | 24 +-- src/app/services/hepsub.service.ts | 9 +- src/app/services/index.ts | 4 +- 6 files changed, 116 insertions(+), 113 deletions(-) diff --git a/src/app/components/search-grid-call/detail-dialog/detail-dialog.component.ts b/src/app/components/search-grid-call/detail-dialog/detail-dialog.component.ts index 73cd2212..6e789b52 100644 --- a/src/app/components/search-grid-call/detail-dialog/detail-dialog.component.ts +++ b/src/app/components/search-grid-call/detail-dialog/detail-dialog.component.ts @@ -99,6 +99,7 @@ export class DetailDialogComponent implements OnInit, OnDestroy { _showLoader = false; set showLoader(val: boolean) { this._showLoader = val; + console.log({ val }); setInterval(() => { this.cdr.detectChanges(); }, 5); diff --git a/src/app/components/search-grid-call/detail-dialog/tab-hepsub/tab-hepsub.component.ts b/src/app/components/search-grid-call/detail-dialog/tab-hepsub/tab-hepsub.component.ts index d66717c7..f6425b1a 100644 --- a/src/app/components/search-grid-call/detail-dialog/tab-hepsub/tab-hepsub.component.ts +++ b/src/app/components/search-grid-call/detail-dialog/tab-hepsub/tab-hepsub.component.ts @@ -15,88 +15,88 @@ import { Functions } from '@app/helpers/functions'; import { MatTabGroup } from '@angular/material/tabs'; @Component({ - selector: 'app-tab-hepsub', - templateUrl: './tab-hepsub.component.html', - styleUrls: ['./tab-hepsub.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush + selector: 'app-tab-hepsub', + templateUrl: './tab-hepsub.component.html', + styleUrls: ['./tab-hepsub.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush }) export class TabHepsubComponent implements OnInit, OnDestroy, AfterViewInit { - _dataItem: any; + _dataItem: any; - @Input() id: any; - @Input() callid: any; - @Input() set dataItem(value: any) { - this._dataItem = value; + @Input() id: any; + @Input() callid: any; + @Input() set dataItem(value: any) { + this._dataItem = value; - if (this.dataItem.data.heplogs) { - this.dataLogs = this.dataItem.data.heplogs; - } - this.isLogs = this.dataLogs?.length > 0; - - const { agentCdr } = this._dataItem.data; - - if (agentCdr) { - this.subTabList.push({ - title: agentCdr.node - }); + if (this.dataItem.data.heplogs) { + this.dataLogs = this.dataItem.data.heplogs; + } + this.isLogs = this.dataLogs?.length > 0; - agentCdr.data.data = Functions.JSON_parse(agentCdr.data) || agentCdr.data; + const { agentCdr } = this._dataItem.data; + console.log({ value }); + if (agentCdr) { + this.subTabList.push({ + title: agentCdr.node + }); - this.jsonData = agentCdr.data; + agentCdr.data.data = Functions.JSON_parse(agentCdr.data) || agentCdr.data; - // extract agent node information - this.agentNode = agentCdr.node; - this.agentUuid = agentCdr.uuid; - } + this.jsonData = agentCdr.data; - this.cdr.detectChanges(); - } - get dataItem(): any { - return this._dataItem; - } - @Input() dataLogs: Array; - @Input() snapShotTimeRange: any; - @Output() haveData = new EventEmitter(); - @Output() ready: EventEmitter = new EventEmitter(); - @ViewChild('matTabGroup', { static: false }) matTabGroup: MatTabGroup; - indexTabPosition = 0; - - isLogs = true; - subTabList = []; - jsonData: any; - timestamp: any; // PCAP timestamp (unix time) - timestampString: string; // PCAP timestamp (UTC string) - agentPathPcap: string; - agentNode: string; - agentUuid: string; - _interval: any; - constructor( - private cdr: ChangeDetectorRef, - private _ass: AgentsubService - ) { } - - ngAfterViewInit() { - setTimeout(() => { - this.ready.emit({}); - }, 35) + // extract agent node information + this.agentNode = agentCdr.node; + this.agentUuid = agentCdr.uuid; } - ngOnInit() { - this._interval = setInterval(() => { - this.matTabGroup.realignInkBar(); - this.cdr.detectChanges(); - }, 2000); + this.cdr.detectChanges(); + } + get dataItem(): any { + return this._dataItem; + } + @Input() dataLogs: Array; + @Input() snapShotTimeRange: any; + @Output() haveData = new EventEmitter(); + @Output() ready: EventEmitter = new EventEmitter(); + @ViewChild('matTabGroup', { static: false }) matTabGroup: MatTabGroup; + indexTabPosition = 0; + + isLogs = true; + subTabList = []; + jsonData: any; + timestamp: any; // PCAP timestamp (unix time) + timestampString: string; // PCAP timestamp (UTC string) + agentPathPcap: string; + agentNode: string; + agentUuid: string; + _interval: any; + constructor( + private cdr: ChangeDetectorRef, + private _ass: AgentsubService + ) { } + + ngAfterViewInit() { + setTimeout(() => { + this.ready.emit({}); + }, 35) + } - this.agentPathPcap = this.jsonData[this.callid].pcap || 'not_set'; - this.timestamp = this.jsonData[this.callid].t_sec * 1000 || 0; - this.timestampString = new Date(this.timestamp ).toUTCString(); - } + ngOnInit() { + this._interval = setInterval(() => { + this.matTabGroup.realignInkBar(); + this.cdr.detectChanges(); + }, 2000); - ngOnDestroy() { - if (this._interval) { - clearInterval(this._interval); - } + this.agentPathPcap = this.jsonData[this.callid].pcap || 'not_set'; + this.timestamp = this.jsonData[this.callid].t_sec * 1000 || 0; + this.timestampString = new Date(this.timestamp).toUTCString(); + } + + ngOnDestroy() { + if (this._interval) { + clearInterval(this._interval); } + } async getPcap() { const request = this.getRequest() @@ -124,28 +124,28 @@ export class TabHepsubComponent implements OnInit, OnDestroy, AfterViewInit { // generate request as expected by AgentsubService private getRequest() { return { - param: { - location: {node: ["local"]}, - search: { - ['1_call']: { - id: 0, - ['callid']: [this.callid], - ['sid']: [this.callid], - ['source_ip']: [], - ['pcap']: [this.agentPathPcap], - ['__hep__']: [this.jsonData[this.callid].__hep__], - } - }, - transaction: { - call: true, - registration: false, - rest: false, + param: { + location: { node: ["local"] }, + search: { + ['1_call']: { + id: 0, + ['callid']: [this.callid], + ['sid']: [this.callid], + ['source_ip']: [], + ['pcap']: [this.agentPathPcap], + ['__hep__']: [this.jsonData[this.callid].__hep__], } }, - timestamp: { - from: this.timestamp, - to: this.timestamp, + transaction: { + call: true, + registration: false, + rest: false, } - }; + }, + timestamp: { + from: this.timestamp, + to: this.timestamp, + } + }; } } diff --git a/src/app/services/call/full-transaction.service.ts b/src/app/services/call/full-transaction.service.ts index 13982521..e0845bdd 100644 --- a/src/app/services/call/full-transaction.service.ts +++ b/src/app/services/call/full-transaction.service.ts @@ -1,3 +1,4 @@ +import { HepLogService } from './hep-log.service'; import { AgentsubService } from '@app/services/agentsub.service'; import { Injectable } from '@angular/core'; import { CallReportService } from '@app/services'; @@ -19,7 +20,7 @@ export class FullTransactionService { constructor( private callReportService: CallReportService, private callTransactionService: CallTransactionService, - // private hepLogService: HepLogService, + private hepLogService: HepLogService, private agentsubService: AgentsubService, private preferenceHepsubService: PreferenceHepsubService, private _pass: PreferenceAgentsubService, @@ -115,11 +116,11 @@ export class FullTransactionService { } } catch (err) { onError('agentCdr'); } - // try { - // const hepLogRes: any = await this.hepLogService.getLog(rt).toPromise(); - // tData = await _worker({ tData, logsData: hepLogRes.data, type: 'logs' }); - // tData.heplogs = hepLogRes.data; - // } catch (err) { onError('heplogs'); } + try { + const hepLogRes: any = await this.hepLogService.getLog(rt).toPromise(); + tData = await _worker({ tData, logsData: hepLogRes.data, type: 'logs' }); + tData.heplogs = hepLogRes.data; + } catch (err) { onError('heplogs'); } try { const callIdArr = tData?.data?.calldata.map(i => i.sid).sort().filter((i, k, a) => i !== a[k - 1]) || []; diff --git a/src/app/services/call/hep-log.service.ts b/src/app/services/call/hep-log.service.ts index 871fd2f6..f1946cd0 100644 --- a/src/app/services/call/hep-log.service.ts +++ b/src/app/services/call/hep-log.service.ts @@ -3,22 +3,22 @@ import { HttpClient } from '@angular/common/http'; import { environment } from '@environments/environment'; @Injectable({ - providedIn: 'root' + providedIn: 'root' }) export class HepLogService { - private url = `${environment.apiUrl}/call/report/log`; + private url = `${environment.apiUrl}/call/report/log`; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) { } - getLog(data: any) { - return this.http.post(`${this.url}`, data); - } + getLog(data: any) { + return this.http.post(`${this.url}`, data); + } } -/** - * TODO: - * transaction dialog / logs / HEPSUB:"test-endpoint"/ cdr - * as on HOMER [domain:port-1]/dashboard/home - * [domain:port-2]/api/v3/agent/type/cdr - */ \ No newline at end of file +// /** +// * TODO: +// * transaction dialog / logs / HEPSUB:"test-endpoint"/ cdr +// * as on HOMER [domain:port-1]/dashboard/home +// * [domain:port-2]/api/v3/agent/type/cdr +// */ diff --git a/src/app/services/hepsub.service.ts b/src/app/services/hepsub.service.ts index 0ee2091e..eda0036f 100644 --- a/src/app/services/hepsub.service.ts +++ b/src/app/services/hepsub.service.ts @@ -11,16 +11,17 @@ export class HepsubService { private url = `${environment.apiUrl}/hepsub`; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) { + console.log("HepsubService:super()"); + } // Hepsub protokols getProtokols(): Observable { - return this.http.get(`${this.url}/protocols`); + return this.http.get(`${this.url}/protocols`); } // Hepsub fields getFields(): Observable { - return this.http.get(`${this.url}/fields`); + return this.http.get(`${this.url}/fields`); } - } diff --git a/src/app/services/index.ts b/src/app/services/index.ts index f0120e07..4b2a1a61 100644 --- a/src/app/services/index.ts +++ b/src/app/services/index.ts @@ -19,7 +19,6 @@ export * from './message-details.service'; export * from './call/report.service'; export * from './call/transaction.service'; export * from './call/full-transaction.service'; -export * from './call/hep-log.service'; export * from './user-security.service'; export * from './export/call.service'; export * from './search/call.service'; @@ -32,4 +31,5 @@ export * from './search.service'; export * from './tooltip.service'; export * from './statistic.service'; export * from './time-formatting.service'; -export * from './copy.service'; \ No newline at end of file +export * from './copy.service'; +export * from './call/hep-log.service';