@vgroup/dialbox 0.2.61 → 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 +106 -35
- package/fesm2015/vgroup-dialbox.mjs +111 -36
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +105 -34
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/components/call-progress/call-progress.component.d.ts +2 -1
- package/package.json +1 -1
|
@@ -2493,9 +2493,10 @@ class CallProgressComponent {
|
|
|
2493
2493
|
callContact(contact) {
|
|
2494
2494
|
var _a, _b;
|
|
2495
2495
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2496
|
-
console.log("
|
|
2497
|
-
|
|
2498
|
-
|
|
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");
|
|
2499
2500
|
return;
|
|
2500
2501
|
}
|
|
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;
|
|
@@ -2504,45 +2505,87 @@ class CallProgressComponent {
|
|
|
2504
2505
|
return;
|
|
2505
2506
|
}
|
|
2506
2507
|
try {
|
|
2507
|
-
// ---- HOLD
|
|
2508
|
+
// ---- HOLD CALL A ----
|
|
2508
2509
|
this.heldCall = this.call;
|
|
2509
2510
|
this.isCallOnHold = true;
|
|
2510
2511
|
this.heldCall.mute(true);
|
|
2512
|
+
console.log("Call A placed on hold");
|
|
2511
2513
|
this.showContactsPanel = false;
|
|
2512
2514
|
this.showRingAnimation = true;
|
|
2513
|
-
|
|
2514
|
-
|
|
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);
|
|
2515
|
+
// ---- START CALL B ----
|
|
2516
|
+
yield this.startSecondOutboundCall(phoneNumber, contact);
|
|
2530
2517
|
this.showRingAnimation = false;
|
|
2531
|
-
|
|
2532
|
-
// UI enters conference mode
|
|
2533
|
-
this.isConference = true;
|
|
2518
|
+
console.log("Second call started successfully");
|
|
2534
2519
|
}
|
|
2535
2520
|
catch (err) {
|
|
2536
|
-
console.error("Error
|
|
2537
|
-
|
|
2538
|
-
this.showRingAnimation = false;
|
|
2521
|
+
console.error("Error starting second call:", err);
|
|
2522
|
+
// Restore call A
|
|
2539
2523
|
if (this.heldCall) {
|
|
2540
2524
|
this.call = this.heldCall;
|
|
2541
2525
|
this.heldCall = undefined;
|
|
2542
|
-
this.call.mute(false);
|
|
2543
2526
|
this.isCallOnHold = false;
|
|
2527
|
+
this.call.mute(false);
|
|
2544
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");
|
|
2545
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");
|
|
2546
2589
|
});
|
|
2547
2590
|
}
|
|
2548
2591
|
acceptConcurrentCall(incomingCall) {
|
|
@@ -2598,15 +2641,47 @@ class CallProgressComponent {
|
|
|
2598
2641
|
console.log('Updated callData:', this.callData);
|
|
2599
2642
|
this.cdr.detectChanges();
|
|
2600
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
|
+
// }
|
|
2601
2654
|
mergeCalls() {
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
this.
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
this.
|
|
2609
|
-
|
|
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
|
+
});
|
|
2610
2685
|
}
|
|
2611
2686
|
endHeldCall() {
|
|
2612
2687
|
if (this.heldCall) {
|