@vgroup/dialbox 0.2.60 → 0.2.62
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 +239 -120
- package/fesm2015/vgroup-dialbox.mjs +250 -125
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +238 -119
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/call-progress.component.d.ts +3 -1
- package/package.json +1 -1
|
@@ -2102,6 +2102,7 @@ class CallProgressComponent {
|
|
|
2102
2102
|
});
|
|
2103
2103
|
}
|
|
2104
2104
|
startCall(callData) {
|
|
2105
|
+
var _a;
|
|
2105
2106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2106
2107
|
console.log(callData, 'callData');
|
|
2107
2108
|
try {
|
|
@@ -2114,6 +2115,7 @@ class CallProgressComponent {
|
|
|
2114
2115
|
scope: 'local',
|
|
2115
2116
|
};
|
|
2116
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;
|
|
2117
2119
|
if (response.status == 200) {
|
|
2118
2120
|
const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
|
|
2119
2121
|
this.getUserInformation(callAuthId);
|
|
@@ -2122,12 +2124,12 @@ class CallProgressComponent {
|
|
|
2122
2124
|
yield this.connectToDevice(tokenData.token, callData);
|
|
2123
2125
|
yield this.pollCallStatus(callAuthId);
|
|
2124
2126
|
setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
2125
|
-
var
|
|
2127
|
+
var _b;
|
|
2126
2128
|
yield this.addParticipantToCall({
|
|
2127
2129
|
from: callData === null || callData === void 0 ? void 0 : callData.from,
|
|
2128
2130
|
route: "OUTGOING",
|
|
2129
2131
|
participantNumber: callData === null || callData === void 0 ? void 0 : callData.phone,
|
|
2130
|
-
conferenceId: (
|
|
2132
|
+
conferenceId: (_b = response === null || response === void 0 ? void 0 : response.callauth) === null || _b === void 0 ? void 0 : _b.id
|
|
2131
2133
|
});
|
|
2132
2134
|
}), 1000);
|
|
2133
2135
|
// Poll the status for 30-45 seconds
|
|
@@ -2358,121 +2360,114 @@ class CallProgressComponent {
|
|
|
2358
2360
|
this.isAddRemoveParticipant = !this.isAddRemoveParticipant;
|
|
2359
2361
|
this.GetContactsList();
|
|
2360
2362
|
}
|
|
2361
|
-
callContact(contact) {
|
|
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
|
-
|
|
2468
|
-
|
|
2469
|
-
this.isCallOnHold = false;
|
|
2470
|
-
this.call.mute(false);
|
|
2471
|
-
}
|
|
2472
|
-
this.handleError(error);
|
|
2473
|
-
}
|
|
2474
|
-
});
|
|
2475
|
-
}
|
|
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
|
+
// }
|
|
2476
2471
|
// acceptConcurrentCall(incomingCall: any) {
|
|
2477
2472
|
// if (!incomingCall) return;
|
|
2478
2473
|
// // Put current call on hold instead of disconnecting
|
|
@@ -2495,6 +2490,104 @@ class CallProgressComponent {
|
|
|
2495
2490
|
// this.startTimer();
|
|
2496
2491
|
// this.cdr.detectChanges();
|
|
2497
2492
|
// }
|
|
2493
|
+
callContact(contact) {
|
|
2494
|
+
var _a, _b;
|
|
2495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2496
|
+
console.log("Starting second call:", contact);
|
|
2497
|
+
// Must have active Call A
|
|
2498
|
+
if (!this.call || this.call.status() !== "open") {
|
|
2499
|
+
console.error("No active call to start second call");
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
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;
|
|
2503
|
+
if (!phoneNumber) {
|
|
2504
|
+
console.error("No phone number found");
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
try {
|
|
2508
|
+
// ---- HOLD CALL A ----
|
|
2509
|
+
this.heldCall = this.call;
|
|
2510
|
+
this.isCallOnHold = true;
|
|
2511
|
+
this.heldCall.mute(true);
|
|
2512
|
+
console.log("Call A placed on hold");
|
|
2513
|
+
this.showContactsPanel = false;
|
|
2514
|
+
this.showRingAnimation = true;
|
|
2515
|
+
// ---- START CALL B ----
|
|
2516
|
+
yield this.startSecondOutboundCall(phoneNumber, contact);
|
|
2517
|
+
this.showRingAnimation = false;
|
|
2518
|
+
console.log("Second call started successfully");
|
|
2519
|
+
}
|
|
2520
|
+
catch (err) {
|
|
2521
|
+
console.error("Error starting second call:", err);
|
|
2522
|
+
// Restore call A
|
|
2523
|
+
if (this.heldCall) {
|
|
2524
|
+
this.call = this.heldCall;
|
|
2525
|
+
this.heldCall = undefined;
|
|
2526
|
+
this.isCallOnHold = false;
|
|
2527
|
+
this.call.mute(false);
|
|
2528
|
+
}
|
|
2529
|
+
this.showRingAnimation = false;
|
|
2530
|
+
swal("Error", "Failed to start second call", "error");
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
}
|
|
2534
|
+
startSecondOutboundCall(phoneNumber, contact) {
|
|
2535
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2536
|
+
console.log("Dialing second call to", phoneNumber);
|
|
2537
|
+
// 1️⃣ Prepare data for new call
|
|
2538
|
+
const payload = {
|
|
2539
|
+
channelId: environment.channelId,
|
|
2540
|
+
userId: localStorage.getItem("userId"),
|
|
2541
|
+
to: phoneNumber,
|
|
2542
|
+
scope: "local",
|
|
2543
|
+
fromNumber: this.callData.from
|
|
2544
|
+
};
|
|
2545
|
+
const response = yield this.initiateCall(payload);
|
|
2546
|
+
if (response.status !== 200) {
|
|
2547
|
+
throw new Error("Backend failed to initiate call");
|
|
2548
|
+
}
|
|
2549
|
+
const { id: callAuthId, recordCall } = yield this.getCallAuthId(response);
|
|
2550
|
+
this.recordCall = recordCall;
|
|
2551
|
+
const tokenData = yield this.getOutgoingCallToken(callAuthId);
|
|
2552
|
+
// 2️⃣ Setup Twilio Device (same as your current code)
|
|
2553
|
+
const options = {
|
|
2554
|
+
codecPreferences: ["opus", "pcmu"],
|
|
2555
|
+
closeProtection: true,
|
|
2556
|
+
};
|
|
2557
|
+
if (!this.device) {
|
|
2558
|
+
this.device = new Device(tokenData.token.value, options);
|
|
2559
|
+
yield this.device.register();
|
|
2560
|
+
}
|
|
2561
|
+
else if (this.device.updateToken) {
|
|
2562
|
+
yield this.device.updateToken(tokenData.token.value);
|
|
2563
|
+
}
|
|
2564
|
+
// 3️⃣ Start NEW CALL B
|
|
2565
|
+
const newCall = yield this.device.connect({
|
|
2566
|
+
params: {
|
|
2567
|
+
From: this.callData.from,
|
|
2568
|
+
To: phoneNumber,
|
|
2569
|
+
Env: environment.abb,
|
|
2570
|
+
Token: tokenData.token.id,
|
|
2571
|
+
Ext: this.callData.extNum
|
|
2572
|
+
},
|
|
2573
|
+
rtcConstraints: { audio: { deviceId: "default" } }
|
|
2574
|
+
});
|
|
2575
|
+
// 4️⃣ Set new call B as active call
|
|
2576
|
+
this.call = newCall;
|
|
2577
|
+
// Update call data UI
|
|
2578
|
+
this.callData = {
|
|
2579
|
+
phone: phoneNumber,
|
|
2580
|
+
from: this.callData.from,
|
|
2581
|
+
extNum: this.callData.extNum,
|
|
2582
|
+
name: `${contact.firstName} ${contact.middleName || ""} ${contact.lastName || ""}`.trim(),
|
|
2583
|
+
img: contact.img || "assets/images/user.jpg",
|
|
2584
|
+
displayNum: phoneNumber
|
|
2585
|
+
};
|
|
2586
|
+
this.setupEventListeners();
|
|
2587
|
+
this.pollCallStatus(callAuthId);
|
|
2588
|
+
console.log("Call B is now active");
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2498
2591
|
acceptConcurrentCall(incomingCall) {
|
|
2499
2592
|
var _a, _b;
|
|
2500
2593
|
if (!incomingCall)
|
|
@@ -2548,15 +2641,47 @@ class CallProgressComponent {
|
|
|
2548
2641
|
console.log('Updated callData:', this.callData);
|
|
2549
2642
|
this.cdr.detectChanges();
|
|
2550
2643
|
}
|
|
2644
|
+
// mergeCalls() {
|
|
2645
|
+
// // Merge functionality - unmute both calls for conference
|
|
2646
|
+
// if (this.heldCall && this.call) {
|
|
2647
|
+
// this.heldCall.mute(false);
|
|
2648
|
+
// this.call.mute(false);
|
|
2649
|
+
// this.isCallOnHold = false;
|
|
2650
|
+
// this.isConference = true;
|
|
2651
|
+
// this.cdr.detectChanges();
|
|
2652
|
+
// }
|
|
2653
|
+
// }
|
|
2551
2654
|
mergeCalls() {
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
this.
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
this.
|
|
2559
|
-
|
|
2655
|
+
var _a;
|
|
2656
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2657
|
+
if (!this.conferenceId) {
|
|
2658
|
+
swal("Error", "Unable to merge: conference ID missing", "error");
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
if (!((_a = this.callData) === null || _a === void 0 ? void 0 : _a.phone)) {
|
|
2662
|
+
swal("Error", "Second call number is missing", "error");
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
try {
|
|
2666
|
+
this.showRingAnimation = true;
|
|
2667
|
+
const payload = {
|
|
2668
|
+
from: this.callData.from,
|
|
2669
|
+
route: "OUTGOING",
|
|
2670
|
+
participantNumber: this.callData.phone,
|
|
2671
|
+
conferenceId: this.conferenceId
|
|
2672
|
+
};
|
|
2673
|
+
console.log("Calling addParticipant API:", payload);
|
|
2674
|
+
yield this.addParticipantToCall(payload);
|
|
2675
|
+
this.showRingAnimation = false;
|
|
2676
|
+
this.isConference = true;
|
|
2677
|
+
swal("Success", "Calls have been merged", "success");
|
|
2678
|
+
}
|
|
2679
|
+
catch (error) {
|
|
2680
|
+
console.error("Merge failed:", error);
|
|
2681
|
+
this.showRingAnimation = false;
|
|
2682
|
+
swal("Error", "Failed to merge calls", "error");
|
|
2683
|
+
}
|
|
2684
|
+
});
|
|
2560
2685
|
}
|
|
2561
2686
|
endHeldCall() {
|
|
2562
2687
|
if (this.heldCall) {
|