@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
|
@@ -2115,19 +2115,23 @@ class CallProgressComponent {
|
|
|
2115
2115
|
scope: 'local',
|
|
2116
2116
|
};
|
|
2117
2117
|
const response = yield this.initiateCall(payload);
|
|
2118
|
+
this.conferenceId = (_a = response === null || response === void 0 ? void 0 : response.callauth) === null || _a === void 0 ? void 0 : _a.id;
|
|
2118
2119
|
if (response.status == 200) {
|
|
2119
2120
|
const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
|
|
2120
2121
|
this.getUserInformation(callAuthId);
|
|
2121
2122
|
this.recordCall = recordCall; // Store the recordCall value
|
|
2122
2123
|
const tokenData = yield this.getOutgoingCallToken(callAuthId);
|
|
2123
2124
|
yield this.connectToDevice(tokenData.token, callData);
|
|
2124
|
-
this.pollCallStatus(callAuthId);
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2125
|
+
yield this.pollCallStatus(callAuthId);
|
|
2126
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
2127
|
+
var _b;
|
|
2128
|
+
yield this.addParticipantToCall({
|
|
2129
|
+
from: callData === null || callData === void 0 ? void 0 : callData.from,
|
|
2130
|
+
route: "OUTGOING",
|
|
2131
|
+
participantNumber: callData === null || callData === void 0 ? void 0 : callData.phone,
|
|
2132
|
+
conferenceId: (_b = response === null || response === void 0 ? void 0 : response.callauth) === null || _b === void 0 ? void 0 : _b.id
|
|
2133
|
+
});
|
|
2134
|
+
}), 1000);
|
|
2131
2135
|
// Poll the status for 30-45 seconds
|
|
2132
2136
|
}
|
|
2133
2137
|
else if (response.status == 201) {
|
|
@@ -2356,121 +2360,114 @@ class CallProgressComponent {
|
|
|
2356
2360
|
this.isAddRemoveParticipant = !this.isAddRemoveParticipant;
|
|
2357
2361
|
this.GetContactsList();
|
|
2358
2362
|
}
|
|
2359
|
-
callContact(contact) {
|
|
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
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
this.isCallOnHold = false;
|
|
2468
|
-
this.call.mute(false);
|
|
2469
|
-
}
|
|
2470
|
-
this.handleError(error);
|
|
2471
|
-
}
|
|
2472
|
-
});
|
|
2473
|
-
}
|
|
2363
|
+
// async callContact(contact: any) {
|
|
2364
|
+
// console.log('Adding contact to call:', contact);
|
|
2365
|
+
// // Check if there's an active call
|
|
2366
|
+
// if (!this.call || this.call.status() !== 'open') {
|
|
2367
|
+
// console.error('No active call to add participant to');
|
|
2368
|
+
// return;
|
|
2369
|
+
// }
|
|
2370
|
+
// // Get the phone number from the contact
|
|
2371
|
+
// const phoneNumber = contact.numbersList && contact.numbersList[0]?.number;
|
|
2372
|
+
// if (!phoneNumber) {
|
|
2373
|
+
// console.error('No phone number found for contact');
|
|
2374
|
+
// return;
|
|
2375
|
+
// }
|
|
2376
|
+
// try {
|
|
2377
|
+
// // Put current call on hold
|
|
2378
|
+
// if (this.call) {
|
|
2379
|
+
// this.heldCall = this.call;
|
|
2380
|
+
// this.isCallOnHold = true;
|
|
2381
|
+
// this.heldCall.mute(true);
|
|
2382
|
+
// console.log('Current call put on hold');
|
|
2383
|
+
// }
|
|
2384
|
+
// // Close contacts panel
|
|
2385
|
+
// this.showContactsPanel = false;
|
|
2386
|
+
// // Prepare new call data
|
|
2387
|
+
// const newCallData = {
|
|
2388
|
+
// phone: phoneNumber,
|
|
2389
|
+
// from: this.callData.from,
|
|
2390
|
+
// extNum: this.callData.extNum,
|
|
2391
|
+
// name: `${contact.firstName} ${contact.middleName || ''} ${contact.lastName || ''}`.trim(),
|
|
2392
|
+
// img: contact.img || 'assets/images/user.jpg',
|
|
2393
|
+
// displayNum: phoneNumber
|
|
2394
|
+
// };
|
|
2395
|
+
// // Initiate new call
|
|
2396
|
+
// this.showRingAnimation = true;
|
|
2397
|
+
// const payload = {
|
|
2398
|
+
// channelId: environment.channelId,
|
|
2399
|
+
// userId: localStorage.getItem('userId'),
|
|
2400
|
+
// to: phoneNumber,
|
|
2401
|
+
// scope: 'local',
|
|
2402
|
+
// fromNumber: this.callData.from
|
|
2403
|
+
// };
|
|
2404
|
+
// const response = await this.initiateCall(payload);
|
|
2405
|
+
// if (response.status == 200) {
|
|
2406
|
+
// const { id: callAuthId, recordCall } = await this.getCallAuthId(response);
|
|
2407
|
+
// this.getUserInformation(callAuthId);
|
|
2408
|
+
// this.recordCall = recordCall;
|
|
2409
|
+
// const tokenData: any = await this.getOutgoingCallToken(callAuthId);
|
|
2410
|
+
// // Connect to new call
|
|
2411
|
+
// const options: any = {
|
|
2412
|
+
// codecPreferences: ['opus', 'pcmu'],
|
|
2413
|
+
// closeProtection: true,
|
|
2414
|
+
// };
|
|
2415
|
+
// // Reuse existing Device if available; otherwise create and register once
|
|
2416
|
+
// if (!this.device) {
|
|
2417
|
+
// this.device = new Device(tokenData.token.value, options);
|
|
2418
|
+
// await this.device.register();
|
|
2419
|
+
// } else {
|
|
2420
|
+
// // Update token if Device supports it and token changed/rotated
|
|
2421
|
+
// try {
|
|
2422
|
+
// if ((this.device as any).updateToken) {
|
|
2423
|
+
// await (this.device as any).updateToken(tokenData.token.value);
|
|
2424
|
+
// }
|
|
2425
|
+
// } catch (e) {
|
|
2426
|
+
// console.warn('Device updateToken failed, proceeding with existing token', e);
|
|
2427
|
+
// }
|
|
2428
|
+
// }
|
|
2429
|
+
// const newCall = await this.device.connect({
|
|
2430
|
+
// params: {
|
|
2431
|
+
// From: this.callData.from,
|
|
2432
|
+
// To: phoneNumber,
|
|
2433
|
+
// Env: environment.abb,
|
|
2434
|
+
// Token: tokenData.token.id,
|
|
2435
|
+
// Ext: this.callData.extNum
|
|
2436
|
+
// },
|
|
2437
|
+
// rtcConstraints: { audio: { deviceId: 'default' } },
|
|
2438
|
+
// });
|
|
2439
|
+
// // Set new call as active
|
|
2440
|
+
// this.call = newCall;
|
|
2441
|
+
// this.callData = newCallData;
|
|
2442
|
+
// // Setup event listeners for new call
|
|
2443
|
+
// this.setupEventListeners();
|
|
2444
|
+
// // Poll call status
|
|
2445
|
+
// this.pollCallStatus(callAuthId);
|
|
2446
|
+
// console.log('New call initiated to:', phoneNumber);
|
|
2447
|
+
// this.cdr.detectChanges();
|
|
2448
|
+
// } else if (response.status == 201) {
|
|
2449
|
+
// swal("Error", response.message.join("<br/>"), "error");
|
|
2450
|
+
// // Restore held call if new call fails
|
|
2451
|
+
// if (this.heldCall) {
|
|
2452
|
+
// this.call = this.heldCall;
|
|
2453
|
+
// this.heldCall = undefined;
|
|
2454
|
+
// this.isCallOnHold = false;
|
|
2455
|
+
// this.call.mute(false);
|
|
2456
|
+
// }
|
|
2457
|
+
// }
|
|
2458
|
+
// } catch (error) {
|
|
2459
|
+
// console.error('Error adding participant:', error);
|
|
2460
|
+
// this.showRingAnimation = false;
|
|
2461
|
+
// // Restore held call on error
|
|
2462
|
+
// if (this.heldCall) {
|
|
2463
|
+
// this.call = this.heldCall;
|
|
2464
|
+
// this.heldCall = undefined;
|
|
2465
|
+
// this.isCallOnHold = false;
|
|
2466
|
+
// this.call.mute(false);
|
|
2467
|
+
// }
|
|
2468
|
+
// this.handleError(error);
|
|
2469
|
+
// }
|
|
2470
|
+
// }
|
|
2474
2471
|
// acceptConcurrentCall(incomingCall: any) {
|
|
2475
2472
|
// if (!incomingCall) return;
|
|
2476
2473
|
// // Put current call on hold instead of disconnecting
|
|
@@ -2493,6 +2490,61 @@ class CallProgressComponent {
|
|
|
2493
2490
|
// this.startTimer();
|
|
2494
2491
|
// this.cdr.detectChanges();
|
|
2495
2492
|
// }
|
|
2493
|
+
callContact(contact) {
|
|
2494
|
+
var _a, _b;
|
|
2495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2496
|
+
console.log("Adding participant:", contact);
|
|
2497
|
+
if (!this.call || this.call.status() !== 'open') {
|
|
2498
|
+
console.error('No active call');
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2501
|
+
const phoneNumber = (_b = (_a = contact === null || contact === void 0 ? void 0 : contact.numbersList) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.number;
|
|
2502
|
+
if (!phoneNumber) {
|
|
2503
|
+
console.error("No phone number found");
|
|
2504
|
+
return;
|
|
2505
|
+
}
|
|
2506
|
+
try {
|
|
2507
|
+
// ---- HOLD CURRENT CALL ----
|
|
2508
|
+
this.heldCall = this.call;
|
|
2509
|
+
this.isCallOnHold = true;
|
|
2510
|
+
this.heldCall.mute(true);
|
|
2511
|
+
this.showContactsPanel = false;
|
|
2512
|
+
this.showRingAnimation = true;
|
|
2513
|
+
if (!this.conferenceId) {
|
|
2514
|
+
console.error("No conferenceId found for active call");
|
|
2515
|
+
swal("Error", "Cannot add participant: conference not found", "error");
|
|
2516
|
+
this.showRingAnimation = false;
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
// ---- BUILD PAYLOAD ----
|
|
2520
|
+
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
2521
|
+
var _c, _d;
|
|
2522
|
+
yield this.addParticipantToCall({
|
|
2523
|
+
from: (_c = this.callData) === null || _c === void 0 ? void 0 : _c.from,
|
|
2524
|
+
route: "OUTGOING",
|
|
2525
|
+
participantNumber: (_d = this.callData) === null || _d === void 0 ? void 0 : _d.phone,
|
|
2526
|
+
conferenceId: this.conferenceId
|
|
2527
|
+
});
|
|
2528
|
+
}), 1000);
|
|
2529
|
+
console.log("API Response:", this.conferenceId);
|
|
2530
|
+
this.showRingAnimation = false;
|
|
2531
|
+
swal("Success", "Participant is being added to your call", "success");
|
|
2532
|
+
// UI enters conference mode
|
|
2533
|
+
this.isConference = true;
|
|
2534
|
+
}
|
|
2535
|
+
catch (err) {
|
|
2536
|
+
console.error("Error adding participant:", err);
|
|
2537
|
+
swal("Error", "Failed to add participant", "error");
|
|
2538
|
+
this.showRingAnimation = false;
|
|
2539
|
+
if (this.heldCall) {
|
|
2540
|
+
this.call = this.heldCall;
|
|
2541
|
+
this.heldCall = undefined;
|
|
2542
|
+
this.call.mute(false);
|
|
2543
|
+
this.isCallOnHold = false;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2496
2548
|
acceptConcurrentCall(incomingCall) {
|
|
2497
2549
|
var _a, _b;
|
|
2498
2550
|
if (!incomingCall)
|