@vgroup/dialbox 0.2.59 → 0.2.61
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.
- package/esm2020/lib/components/call-progress/call-progress.component.mjs +170 -120
- package/fesm2015/vgroup-dialbox.mjs +174 -122
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +169 -119
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/call-progress.component.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2110,19 +2110,22 @@ class CallProgressComponent {
|
|
|
2110
2110
|
scope: 'local',
|
|
2111
2111
|
};
|
|
2112
2112
|
const response = await this.initiateCall(payload);
|
|
2113
|
+
this.conferenceId = response?.callauth?.id;
|
|
2113
2114
|
if (response.status == 200) {
|
|
2114
2115
|
const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2115
2116
|
this.getUserInformation(callAuthId);
|
|
2116
2117
|
this.recordCall = recordCall; // Store the recordCall value
|
|
2117
2118
|
const tokenData = await this.getOutgoingCallToken(callAuthId);
|
|
2118
2119
|
await this.connectToDevice(tokenData.token, callData);
|
|
2119
|
-
this.pollCallStatus(callAuthId);
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2120
|
+
await this.pollCallStatus(callAuthId);
|
|
2121
|
+
setTimeout(async () => {
|
|
2122
|
+
await this.addParticipantToCall({
|
|
2123
|
+
from: callData?.from,
|
|
2124
|
+
route: "OUTGOING",
|
|
2125
|
+
participantNumber: callData?.phone,
|
|
2126
|
+
conferenceId: response?.callauth?.id
|
|
2127
|
+
});
|
|
2128
|
+
}, 1000);
|
|
2126
2129
|
// Poll the status for 30-45 seconds
|
|
2127
2130
|
}
|
|
2128
2131
|
else if (response.status == 201) {
|
|
@@ -2335,118 +2338,114 @@ class CallProgressComponent {
|
|
|
2335
2338
|
this.isAddRemoveParticipant = !this.isAddRemoveParticipant;
|
|
2336
2339
|
this.GetContactsList();
|
|
2337
2340
|
}
|
|
2338
|
-
async callContact(contact) {
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
}
|
|
2447
|
-
this.handleError(error);
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2341
|
+
// async callContact(contact: any) {
|
|
2342
|
+
// console.log('Adding contact to call:', contact);
|
|
2343
|
+
// // Check if there's an active call
|
|
2344
|
+
// if (!this.call || this.call.status() !== 'open') {
|
|
2345
|
+
// console.error('No active call to add participant to');
|
|
2346
|
+
// return;
|
|
2347
|
+
// }
|
|
2348
|
+
// // Get the phone number from the contact
|
|
2349
|
+
// const phoneNumber = contact.numbersList && contact.numbersList[0]?.number;
|
|
2350
|
+
// if (!phoneNumber) {
|
|
2351
|
+
// console.error('No phone number found for contact');
|
|
2352
|
+
// return;
|
|
2353
|
+
// }
|
|
2354
|
+
// try {
|
|
2355
|
+
// // Put current call on hold
|
|
2356
|
+
// if (this.call) {
|
|
2357
|
+
// this.heldCall = this.call;
|
|
2358
|
+
// this.isCallOnHold = true;
|
|
2359
|
+
// this.heldCall.mute(true);
|
|
2360
|
+
// console.log('Current call put on hold');
|
|
2361
|
+
// }
|
|
2362
|
+
// // Close contacts panel
|
|
2363
|
+
// this.showContactsPanel = false;
|
|
2364
|
+
// // Prepare new call data
|
|
2365
|
+
// const newCallData = {
|
|
2366
|
+
// phone: phoneNumber,
|
|
2367
|
+
// from: this.callData.from,
|
|
2368
|
+
// extNum: this.callData.extNum,
|
|
2369
|
+
// name: `${contact.firstName} ${contact.middleName || ''} ${contact.lastName || ''}`.trim(),
|
|
2370
|
+
// img: contact.img || 'assets/images/user.jpg',
|
|
2371
|
+
// displayNum: phoneNumber
|
|
2372
|
+
// };
|
|
2373
|
+
// // Initiate new call
|
|
2374
|
+
// this.showRingAnimation = true;
|
|
2375
|
+
// const payload = {
|
|
2376
|
+
// channelId: environment.channelId,
|
|
2377
|
+
// userId: localStorage.getItem('userId'),
|
|
2378
|
+
// to: phoneNumber,
|
|
2379
|
+
// scope: 'local',
|
|
2380
|
+
// fromNumber: this.callData.from
|
|
2381
|
+
// };
|
|
2382
|
+
// const response = await this.initiateCall(payload);
|
|
2383
|
+
// if (response.status == 200) {
|
|
2384
|
+
// const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2385
|
+
// this.getUserInformation(callAuthId);
|
|
2386
|
+
// this.recordCall = recordCall;
|
|
2387
|
+
// const tokenData: any = await this.getOutgoingCallToken(callAuthId);
|
|
2388
|
+
// // Connect to new call
|
|
2389
|
+
// const options: any = {
|
|
2390
|
+
// codecPreferences: ['opus', 'pcmu'],
|
|
2391
|
+
// closeProtection: true,
|
|
2392
|
+
// };
|
|
2393
|
+
// // Reuse existing Device if available; otherwise create and register once
|
|
2394
|
+
// if (!this.device) {
|
|
2395
|
+
// this.device = new Device(tokenData.token.value, options);
|
|
2396
|
+
// await this.device.register();
|
|
2397
|
+
// } else {
|
|
2398
|
+
// // Update token if Device supports it and token changed/rotated
|
|
2399
|
+
// try {
|
|
2400
|
+
// if ((this.device as any).updateToken) {
|
|
2401
|
+
// await (this.device as any).updateToken(tokenData.token.value);
|
|
2402
|
+
// }
|
|
2403
|
+
// } catch (e) {
|
|
2404
|
+
// console.warn('Device updateToken failed, proceeding with existing token', e);
|
|
2405
|
+
// }
|
|
2406
|
+
// }
|
|
2407
|
+
// const newCall = await this.device.connect({
|
|
2408
|
+
// params: {
|
|
2409
|
+
// From: this.callData.from,
|
|
2410
|
+
// To: phoneNumber,
|
|
2411
|
+
// Env: environment.abb,
|
|
2412
|
+
// Token: tokenData.token.id,
|
|
2413
|
+
// Ext: this.callData.extNum
|
|
2414
|
+
// },
|
|
2415
|
+
// rtcConstraints: { audio: { deviceId: 'default' } },
|
|
2416
|
+
// });
|
|
2417
|
+
// // Set new call as active
|
|
2418
|
+
// this.call = newCall;
|
|
2419
|
+
// this.callData = newCallData;
|
|
2420
|
+
// // Setup event listeners for new call
|
|
2421
|
+
// this.setupEventListeners();
|
|
2422
|
+
// // Poll call status
|
|
2423
|
+
// this.pollCallStatus(callAuthId);
|
|
2424
|
+
// console.log('New call initiated to:', phoneNumber);
|
|
2425
|
+
// this.cdr.detectChanges();
|
|
2426
|
+
// } else if (response.status == 201) {
|
|
2427
|
+
// swal("Error", response.message.join("<br/>"), "error");
|
|
2428
|
+
// // Restore held call if new call fails
|
|
2429
|
+
// if (this.heldCall) {
|
|
2430
|
+
// this.call = this.heldCall;
|
|
2431
|
+
// this.heldCall = undefined;
|
|
2432
|
+
// this.isCallOnHold = false;
|
|
2433
|
+
// this.call.mute(false);
|
|
2434
|
+
// }
|
|
2435
|
+
// }
|
|
2436
|
+
// } catch (error) {
|
|
2437
|
+
// console.error('Error adding participant:', error);
|
|
2438
|
+
// this.showRingAnimation = false;
|
|
2439
|
+
// // Restore held call on error
|
|
2440
|
+
// if (this.heldCall) {
|
|
2441
|
+
// this.call = this.heldCall;
|
|
2442
|
+
// this.heldCall = undefined;
|
|
2443
|
+
// this.isCallOnHold = false;
|
|
2444
|
+
// this.call.mute(false);
|
|
2445
|
+
// }
|
|
2446
|
+
// this.handleError(error);
|
|
2447
|
+
// }
|
|
2448
|
+
// }
|
|
2450
2449
|
// acceptConcurrentCall(incomingCall: any) {
|
|
2451
2450
|
// if (!incomingCall) return;
|
|
2452
2451
|
// // Put current call on hold instead of disconnecting
|
|
@@ -2469,6 +2468,57 @@ class CallProgressComponent {
|
|
|
2469
2468
|
// this.startTimer();
|
|
2470
2469
|
// this.cdr.detectChanges();
|
|
2471
2470
|
// }
|
|
2471
|
+
async callContact(contact) {
|
|
2472
|
+
console.log("Adding participant:", contact);
|
|
2473
|
+
if (!this.call || this.call.status() !== 'open') {
|
|
2474
|
+
console.error('No active call');
|
|
2475
|
+
return;
|
|
2476
|
+
}
|
|
2477
|
+
const phoneNumber = contact?.numbersList?.[0]?.number;
|
|
2478
|
+
if (!phoneNumber) {
|
|
2479
|
+
console.error("No phone number found");
|
|
2480
|
+
return;
|
|
2481
|
+
}
|
|
2482
|
+
try {
|
|
2483
|
+
// ---- HOLD CURRENT CALL ----
|
|
2484
|
+
this.heldCall = this.call;
|
|
2485
|
+
this.isCallOnHold = true;
|
|
2486
|
+
this.heldCall.mute(true);
|
|
2487
|
+
this.showContactsPanel = false;
|
|
2488
|
+
this.showRingAnimation = true;
|
|
2489
|
+
if (!this.conferenceId) {
|
|
2490
|
+
console.error("No conferenceId found for active call");
|
|
2491
|
+
swal("Error", "Cannot add participant: conference not found", "error");
|
|
2492
|
+
this.showRingAnimation = false;
|
|
2493
|
+
return;
|
|
2494
|
+
}
|
|
2495
|
+
// ---- BUILD PAYLOAD ----
|
|
2496
|
+
setTimeout(async () => {
|
|
2497
|
+
await this.addParticipantToCall({
|
|
2498
|
+
from: this.callData?.from,
|
|
2499
|
+
route: "OUTGOING",
|
|
2500
|
+
participantNumber: this.callData?.phone,
|
|
2501
|
+
conferenceId: this.conferenceId
|
|
2502
|
+
});
|
|
2503
|
+
}, 1000);
|
|
2504
|
+
console.log("API Response:", this.conferenceId);
|
|
2505
|
+
this.showRingAnimation = false;
|
|
2506
|
+
swal("Success", "Participant is being added to your call", "success");
|
|
2507
|
+
// UI enters conference mode
|
|
2508
|
+
this.isConference = true;
|
|
2509
|
+
}
|
|
2510
|
+
catch (err) {
|
|
2511
|
+
console.error("Error adding participant:", err);
|
|
2512
|
+
swal("Error", "Failed to add participant", "error");
|
|
2513
|
+
this.showRingAnimation = false;
|
|
2514
|
+
if (this.heldCall) {
|
|
2515
|
+
this.call = this.heldCall;
|
|
2516
|
+
this.heldCall = undefined;
|
|
2517
|
+
this.call.mute(false);
|
|
2518
|
+
this.isCallOnHold = false;
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2472
2522
|
acceptConcurrentCall(incomingCall) {
|
|
2473
2523
|
if (!incomingCall)
|
|
2474
2524
|
return;
|