@vgroup/dialbox 0.1.98 → 0.1.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import * as i0 from '@angular/core';
3
3
  import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, NgModule } from '@angular/core';
4
4
  import swal from 'sweetalert2';
5
5
  import { AsYouType } from 'libphonenumber-js';
6
- import { throwError, BehaviorSubject, of, interval, Subscription } from 'rxjs';
6
+ import { throwError, BehaviorSubject, forkJoin, of, interval, Subscription } from 'rxjs';
7
7
  import * as i1 from '@angular/common/http';
8
8
  import { HttpHeaders, HttpParams, HttpClientModule } from '@angular/common/http';
9
9
  import { catchError, switchMap, map, tap, shareReplay } from 'rxjs/operators';
@@ -536,6 +536,38 @@ class ExtensionService {
536
536
  const httpOptions = { headers: new HttpHeaders(params) };
537
537
  return this.http.put(environment.apiUrl + '/utilities/softphone/update/callerid/label', dtModel, httpOptions);
538
538
  }
539
+ // initiateCall(payload: any): Observable<any> {
540
+ // return this.fetchBlockedCountries().pipe(
541
+ // switchMap(blockedCountries => {
542
+ // return this.ipAddressService.getIpAddressInfo().pipe(
543
+ // switchMap(ipAddressInfo => {
544
+ // const params = {
545
+ // 'Content-Type': 'application/json',
546
+ // 'Auth-Key': 'Bearer ' + localStorage.getItem('ext_token'),
547
+ // 'ip-address': ipAddressInfo.ip,
548
+ // 'ip-country': ipAddressInfo.address.country,
549
+ // };
550
+ // payload = {...payload, proxy:ipAddressInfo.proxy.toString()}
551
+ // const httpOptions = { headers: new HttpHeaders(params) };
552
+ // return this.http.post<[]>(environment.apiUrl + '/utilities/ext/ur/initiate/call', payload, httpOptions).pipe(
553
+ // catchError(error => {
554
+ // return throwError(error);
555
+ // }),
556
+ // );
557
+ // return this.http.post<[]>(environment.apiUrl + '/ur/initiate/conference/call', payload, httpOptions).pipe(
558
+ // catchError(error => {
559
+ // return throwError(error);
560
+ // }),
561
+ // );
562
+ // }),
563
+ // catchError(error => {
564
+ // // Catch error from getIpAddressInfo
565
+ // return throwError(error);
566
+ // })
567
+ // );
568
+ // })
569
+ // );
570
+ // }
539
571
  initiateCall(payload) {
540
572
  return this.fetchBlockedCountries().pipe(switchMap(blockedCountries => {
541
573
  return this.ipAddressService.getIpAddressInfo().pipe(switchMap(ipAddressInfo => {
@@ -545,15 +577,18 @@ class ExtensionService {
545
577
  'ip-address': ipAddressInfo.ip,
546
578
  'ip-country': ipAddressInfo.address.country,
547
579
  };
580
+ const params1 = {
581
+ "from": payload.from,
582
+ "to": payload.to,
583
+ "userId": payload.userId
584
+ };
548
585
  payload = Object.assign(Object.assign({}, payload), { proxy: ipAddressInfo.proxy.toString() });
549
586
  const httpOptions = { headers: new HttpHeaders(params) };
550
- return this.http.post(environment.apiUrl + '/utilities/ext/ur/initiate/call', payload, httpOptions).pipe(catchError(error => {
551
- return throwError(error);
552
- }));
553
- }), catchError(error => {
554
- // Catch error from getIpAddressInfo
555
- return throwError(error);
556
- }));
587
+ const api1$ = this.http.post(`${environment.apiUrl}/utilities/ext/ur/initiate/call`, payload, httpOptions);
588
+ const api2$ = this.http.post(`${environment.apiUrl}/ur/initiate/conference/call`, params1, httpOptions);
589
+ // Run both requests in parallel
590
+ return forkJoin([api1$, api2$]).pipe(catchError(error => throwError(() => error)));
591
+ }), catchError(error => throwError(() => error)));
557
592
  }));
558
593
  }
559
594
  fetchBlockedCountries() {
@@ -2147,10 +2182,6 @@ class CallProgressComponent {
2147
2182
  const callerName = ((_b = this.call.customParameters) === null || _b === void 0 ? void 0 : _b.get('name')) || '-';
2148
2183
  const callerImg = ((_c = this.call.customParameters) === null || _c === void 0 ? void 0 : _c.get('image')) || 'assets/images/user.jpg';
2149
2184
  this.callData = Object.assign(Object.assign({}, this.callData), { phone: fromNumber, displayNum: fromNumber, name: callerName, img: callerImg });
2150
- // Ensure UI flags are properly set
2151
- this.isConcurrentIncoming = false;
2152
- this.incomingCallDiv = false;
2153
- this.showRingAnimation = false;
2154
2185
  // Restart timer for the resumed call
2155
2186
  this.startTimer();
2156
2187
  this.disbaleEndCallBtn = false;
@@ -2293,7 +2324,6 @@ class CallProgressComponent {
2293
2324
  }
2294
2325
  }
2295
2326
  closeIncomingCall(data) {
2296
- var _a, _b, _c, _d;
2297
2327
  // this.incomingCallDiv = false;
2298
2328
  if (data.show) {
2299
2329
  //this.showCallProgressEvent.emit()
@@ -2305,7 +2335,6 @@ class CallProgressComponent {
2305
2335
  this.incomingCallDiv = false;
2306
2336
  const incomingDetail = this.extensionService.getCallSid();
2307
2337
  this.incomingRecordCall = incomingDetail.recordCall;
2308
- // Start recording if the call is answered and recording is enabled
2309
2338
  if (this.incomingRecordCall) {
2310
2339
  this.startRecording();
2311
2340
  }
@@ -2316,43 +2345,12 @@ class CallProgressComponent {
2316
2345
  }
2317
2346
  else {
2318
2347
  // incoming call rejected or auto-cancelled
2319
- console.log('Incoming call rejected/cancelled');
2320
- console.log('Current call status:', (_a = this.call) === null || _a === void 0 ? void 0 : _a.status());
2321
- console.log('Held call status:', (_b = this.heldCall) === null || _b === void 0 ? void 0 : _b.status());
2322
2348
  this.isConcurrentIncoming = false;
2323
2349
  this.incomingCallDiv = false;
2324
- // Check if there's a held call that needs to be restored
2325
- if (this.heldCall && this.heldCall.status() === 'open') {
2326
- console.log('Restoring held call to active');
2327
- // Make held call the active call
2328
- this.call = this.heldCall;
2329
- this.heldCall = undefined;
2330
- this.isCallOnHold = false;
2331
- // Unmute the resumed call
2332
- this.call.mute(false);
2333
- this.isMute = false;
2334
- // Update UI with the resumed call info
2335
- const fromNumber = this.call.parameters['From'];
2336
- const callerName = ((_c = this.call.customParameters) === null || _c === void 0 ? void 0 : _c.get('name')) || '-';
2337
- const callerImg = ((_d = this.call.customParameters) === null || _d === void 0 ? void 0 : _d.get('image')) || 'assets/images/user.jpg';
2338
- this.callData = Object.assign(Object.assign({}, this.callData), { phone: fromNumber, displayNum: fromNumber, name: callerName, img: callerImg });
2339
- this.disbaleEndCallBtn = false;
2340
- this.showRingAnimation = false;
2341
- console.log('Held call restored successfully');
2342
- }
2343
- // Check if there's an active call (for cases where incoming was rejected before being answered)
2344
- else if (this.call && this.call.status() === 'open') {
2345
- console.log('Active call exists, keeping UI visible');
2346
- // Just ensure UI flags are correct to show the active call
2347
- this.disbaleEndCallBtn = false;
2348
- this.showRingAnimation = false;
2349
- }
2350
- // No active or held call - completely end
2351
- else {
2352
- console.log('No active or held call, ending completely');
2350
+ // If there is NO active call, then propagate end. Otherwise keep ongoing UI.
2351
+ if (!this.call || this.call.status() !== 'open') {
2353
2352
  this.endCallEvent.emit();
2354
2353
  }
2355
- this.cdr.detectChanges();
2356
2354
  }
2357
2355
  }
2358
2356
  clearInputs() {
@@ -2413,7 +2411,7 @@ class CallProgressComponent {
2413
2411
  this.extensionService.pauseOrResumeRecording(sid, 'pause').subscribe(response => {
2414
2412
  this.stopRecordingTimer();
2415
2413
  this.isPaused = true;
2416
- }, error => {
2414
+ }, (error) => {
2417
2415
  console.error('Error pausing recording:', error);
2418
2416
  // Consider updating the UI to show the error state
2419
2417
  });