Skip to content

Commit

Permalink
fix: transactions - HEP Logs
Browse files Browse the repository at this point in the history
  • Loading branch information
RFbkak37y3kIY committed May 3, 2024
1 parent 8f68505 commit b1ecd62
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
@Input() snapShotTimeRange: any;
@Output() haveData = new EventEmitter();
@Output() ready: EventEmitter<any> = 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<any>;
@Input() snapShotTimeRange: any;
@Output() haveData = new EventEmitter();
@Output() ready: EventEmitter<any> = 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()
Expand Down Expand Up @@ -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,
}
};
}
}
13 changes: 7 additions & 6 deletions src/app/services/call/full-transaction.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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]) || [];
Expand Down
24 changes: 12 additions & 12 deletions src/app/services/call/hep-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>(`${this.url}`, data);
}
getLog(data: any) {
return this.http.post<any>(`${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
*/
// /**
// * TODO:
// * transaction dialog / logs / HEPSUB:"test-endpoint"/ cdr
// * as on HOMER [domain:port-1]/dashboard/home
// * [domain:port-2]/api/v3/agent/type/cdr
// */
9 changes: 5 additions & 4 deletions src/app/services/hepsub.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PreferenceHepsub> {
return this.http.get<PreferenceHepsub>(`${this.url}/protocols`);
return this.http.get<PreferenceHepsub>(`${this.url}/protocols`);
}

// Hepsub fields
getFields(): Observable<PreferenceHepsub> {
return this.http.get<PreferenceHepsub>(`${this.url}/fields`);
return this.http.get<PreferenceHepsub>(`${this.url}/fields`);
}

}
4 changes: 2 additions & 2 deletions src/app/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
export * from './copy.service';
export * from './call/hep-log.service';

0 comments on commit b1ecd62

Please sign in to comment.