@vgroup/dialbox 0.0.76 → 0.0.78
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/dialbox.component.mjs +181 -7
- package/esm2020/lib/service/twilio.service.mjs +32 -2
- package/fesm2015/vgroup-dialbox.mjs +204 -7
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +211 -7
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/dialbox.component.d.ts +1 -0
- package/lib/service/twilio.service.d.ts +10 -1
- package/package.json +1 -1
|
@@ -1372,7 +1372,8 @@ class TwilioService {
|
|
|
1372
1372
|
this.notificationSerivce = notificationSerivce;
|
|
1373
1373
|
this.openInProgressDialpad = new BehaviorSubject(false);
|
|
1374
1374
|
this.currentCall = new BehaviorSubject(null);
|
|
1375
|
-
this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
|
|
1375
|
+
this.currentCallState = new BehaviorSubject('none'); // 'incoming', 'in-progress', 'out-progress', 'none'
|
|
1376
|
+
this._currentCall = null;
|
|
1376
1377
|
this.callType = new BehaviorSubject('NIL');
|
|
1377
1378
|
this.isIncomingCallPicked = new BehaviorSubject(false); // for both incoming and outgoing
|
|
1378
1379
|
this.token = localStorage.getItem('ext_token');
|
|
@@ -1400,10 +1401,27 @@ class TwilioService {
|
|
|
1400
1401
|
});
|
|
1401
1402
|
this.device.register();
|
|
1402
1403
|
this.device.on('incoming', (call) => {
|
|
1404
|
+
this._currentCall = call;
|
|
1403
1405
|
this.currentCall.next(call);
|
|
1404
1406
|
this.callType.next('INCOMING');
|
|
1405
1407
|
this.currentCallState.next('incoming');
|
|
1406
1408
|
this.notificationSerivce.showNotification(call);
|
|
1409
|
+
// Set up call event handlers
|
|
1410
|
+
call.on('accept', () => {
|
|
1411
|
+
this.currentCallState.next('in-progress');
|
|
1412
|
+
});
|
|
1413
|
+
call.on('disconnect', () => {
|
|
1414
|
+
this._currentCall = null;
|
|
1415
|
+
this.currentCall.next(null);
|
|
1416
|
+
this.currentCallState.next('none');
|
|
1417
|
+
this.callType.next('NIL');
|
|
1418
|
+
});
|
|
1419
|
+
call.on('cancel', () => {
|
|
1420
|
+
this._currentCall = null;
|
|
1421
|
+
this.currentCall.next(null);
|
|
1422
|
+
this.currentCallState.next('none');
|
|
1423
|
+
this.callType.next('NIL');
|
|
1424
|
+
});
|
|
1407
1425
|
});
|
|
1408
1426
|
this.device.on('error', (error) => {
|
|
1409
1427
|
console.error('Twilio Device Error:', error);
|
|
@@ -1503,6 +1521,18 @@ class TwilioService {
|
|
|
1503
1521
|
const params = new HttpParams().set('isoCode', isoCode);
|
|
1504
1522
|
return this.http.get(environment.apiUrl + '/utilities/softphone/check/countryCode/' + dialledNo, httpOptions);
|
|
1505
1523
|
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Get the current active call
|
|
1526
|
+
*/
|
|
1527
|
+
getCurrentCall() {
|
|
1528
|
+
return this._currentCall;
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Check if there's an active call
|
|
1532
|
+
*/
|
|
1533
|
+
hasActiveCall() {
|
|
1534
|
+
return this._currentCall !== null;
|
|
1535
|
+
}
|
|
1506
1536
|
}
|
|
1507
1537
|
TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }, { token: ExtensionService }, { token: NotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1508
1538
|
TwilioService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, providedIn: 'root' });
|
|
@@ -2212,24 +2242,198 @@ class DialboxComponent {
|
|
|
2212
2242
|
this.isInitialized = true;
|
|
2213
2243
|
// Initialize Twilio service
|
|
2214
2244
|
this.twilioService.initializeTwilioDevice();
|
|
2245
|
+
// Check for any existing call first
|
|
2246
|
+
const currentCall = this.twilioService.getCurrentCall();
|
|
2247
|
+
if (currentCall) {
|
|
2248
|
+
this.handleIncomingCall(currentCall);
|
|
2249
|
+
}
|
|
2215
2250
|
// Subscribe to incoming calls to show dialpad when call comes in
|
|
2216
2251
|
const callSub = this.twilioService.currentCall.subscribe(call => {
|
|
2217
2252
|
if (call) {
|
|
2218
|
-
console.log('Incoming call received:', call);
|
|
2253
|
+
console.log('Incoming call received in component:', call);
|
|
2254
|
+
this.handleIncomingCall(call);
|
|
2255
|
+
}
|
|
2256
|
+
});
|
|
2257
|
+
// Subscribe to call state changes
|
|
2258
|
+
const callStateSub = this.twilioService.currentCallState.subscribe(state => {
|
|
2259
|
+
console.log('Call state changed to:', state);
|
|
2260
|
+
if (state === 'incoming' || state === 'in-progress') {
|
|
2219
2261
|
this.isCallInProgress = true;
|
|
2220
|
-
this.
|
|
2262
|
+
this._isDialpadHidden = false; // Force show the dialpad for incoming/active calls
|
|
2263
|
+
}
|
|
2264
|
+
else if (state === 'none') {
|
|
2265
|
+
this.isCallInProgress = false;
|
|
2221
2266
|
}
|
|
2222
2267
|
});
|
|
2223
2268
|
this.subscriptions.add(callSub);
|
|
2269
|
+
this.subscriptions.add(callStateSub);
|
|
2270
|
+
}
|
|
2271
|
+
handleIncomingCall(call) {
|
|
2272
|
+
console.log('Handling incoming call:', call);
|
|
2273
|
+
// Update call state
|
|
2274
|
+
this.isCallInProgress = true;
|
|
2275
|
+
// Force show the dialpad by directly setting the private field
|
|
2276
|
+
// to bypass any setter logic that might prevent showing it
|
|
2277
|
+
this._isDialpadHidden = false;
|
|
2278
|
+
// Update call data
|
|
2279
|
+
const callerNumber = call.parameters['From'] || 'Unknown';
|
|
2280
|
+
const callerName = call.parameters['CallerName'] || 'Unknown Caller';
|
|
2281
|
+
this.callData = {
|
|
2282
|
+
...this.callData,
|
|
2283
|
+
phone: callerNumber,
|
|
2284
|
+
name: callerName,
|
|
2285
|
+
img: 'assets/images/user.jpg',
|
|
2286
|
+
isIncomingCall: true,
|
|
2287
|
+
dial: true
|
|
2288
|
+
};
|
|
2289
|
+
// Add to incoming calls list if not already present
|
|
2290
|
+
const callExists = this.newIncomingCalls.some((c) => c.parameters['CallSid'] === call.parameters['CallSid']);
|
|
2291
|
+
if (!callExists) {
|
|
2292
|
+
this.newIncomingCalls = [...this.newIncomingCalls, call];
|
|
2293
|
+
this.incomingCallsList = [...this.newIncomingCalls];
|
|
2294
|
+
}
|
|
2295
|
+
// Emit event to notify parent components
|
|
2296
|
+
this.incomingCallInitiated.emit();
|
|
2297
|
+
// Set up call event handlers if not already set
|
|
2298
|
+
if (!call.listenerCount('accept')) {
|
|
2299
|
+
call.on('accept', () => {
|
|
2300
|
+
console.log('Call accepted:', call.parameters['CallSid']);
|
|
2301
|
+
this.isCallInProgress = true;
|
|
2302
|
+
this._isDialpadHidden = false; // Ensure dialpad stays open
|
|
2303
|
+
});
|
|
2304
|
+
}
|
|
2305
|
+
if (!call.listenerCount('disconnect')) {
|
|
2306
|
+
call.on('disconnect', () => {
|
|
2307
|
+
console.log('Call disconnected:', call.parameters['CallSid']);
|
|
2308
|
+
this.isCallInProgress = false;
|
|
2309
|
+
// Remove from incoming calls list
|
|
2310
|
+
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
|
|
2311
|
+
this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
|
|
2312
|
+
// If no more calls, reset the state
|
|
2313
|
+
if (this.incomingCallsList.length === 0) {
|
|
2314
|
+
this.isCallInProgress = false;
|
|
2315
|
+
// Don't hide the dialpad if there are no more calls
|
|
2316
|
+
// Let the user decide when to close it
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
if (!call.listenerCount('cancel')) {
|
|
2321
|
+
call.on('cancel', () => {
|
|
2322
|
+
console.log('Call cancelled by caller:', call.parameters['CallSid']);
|
|
2323
|
+
this.isCallInProgress = false;
|
|
2324
|
+
// Remove from incoming calls list
|
|
2325
|
+
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
|
|
2326
|
+
this.newIncomingCalls = this.newIncomingCalls.filter((item) => item.parameters['CallSid'] !== call.parameters['CallSid']);
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2224
2329
|
}
|
|
2225
2330
|
// ngOnChange() {
|
|
2226
2331
|
// this.initializeTwilio();
|
|
2227
2332
|
// }
|
|
2333
|
+
// ngOnInit() {
|
|
2334
|
+
// try {
|
|
2335
|
+
// this.getContactList();
|
|
2336
|
+
// this.getUserCallSetting();
|
|
2337
|
+
// // Subscribe to dial number events
|
|
2338
|
+
// const sub1 = this.twilioService.dialNumberFromOtherModule.subscribe((contact: any) => {
|
|
2339
|
+
// if (contact.number) {
|
|
2340
|
+
// this.isSmartDialCall = false;
|
|
2341
|
+
// if (contact.isDialFromHistory) {
|
|
2342
|
+
// //handle dialing from history page
|
|
2343
|
+
// if(contact.callerId == 'smartDialing'){
|
|
2344
|
+
// this.selectedCallerId = { number: contact.from };
|
|
2345
|
+
// this.isSmartDialCall = true;
|
|
2346
|
+
// setTimeout(() => {
|
|
2347
|
+
// this.isDialpadHidden = false;
|
|
2348
|
+
// }, 2000);
|
|
2349
|
+
// this.callData.phone = contact.number;
|
|
2350
|
+
// this.callData.name = contact.name;
|
|
2351
|
+
// this.callData.img = contact.img;
|
|
2352
|
+
// this.callData.from = contact.from;
|
|
2353
|
+
// this.sanitizedNum = contact.number;
|
|
2354
|
+
// this.getUserInformation(contact);
|
|
2355
|
+
// // this.incomingCallsList.push(contact)
|
|
2356
|
+
// this.initiateCall();
|
|
2357
|
+
// }else{
|
|
2358
|
+
// this.getUserCallSetting();
|
|
2359
|
+
// setTimeout(() => {
|
|
2360
|
+
// this.isDialpadHidden = false;
|
|
2361
|
+
// }, 1000);
|
|
2362
|
+
// this.getUserInformation(contact);
|
|
2363
|
+
// // this.incomingCallsList.push(contact)
|
|
2364
|
+
// this.dialedNumber = contact.number;
|
|
2365
|
+
// this.sanitizedNum = contact.number;
|
|
2366
|
+
// }
|
|
2367
|
+
// } else {
|
|
2368
|
+
// if (contact.callerId == 'alwaysAsk' || contact.callerId == 'smartDialing') {
|
|
2369
|
+
// this.getUserCallSetting();
|
|
2370
|
+
// setTimeout(() => {
|
|
2371
|
+
// this.isDialpadHidden = false;
|
|
2372
|
+
// }, 1000);
|
|
2373
|
+
// this.dialedNumber = contact.number;
|
|
2374
|
+
// this.sanitizedNum = contact.number;
|
|
2375
|
+
// } else {
|
|
2376
|
+
// setTimeout(() => {
|
|
2377
|
+
// this.isDialpadHidden = false;
|
|
2378
|
+
// }, 2000);
|
|
2379
|
+
// this.callData.phone = contact.number;
|
|
2380
|
+
// this.callData.name = contact.name;
|
|
2381
|
+
// this.callData.img = contact.img;
|
|
2382
|
+
// this.sanitizedNum = contact.number;
|
|
2383
|
+
// this.initiateCall();
|
|
2384
|
+
// }
|
|
2385
|
+
// }
|
|
2386
|
+
// }
|
|
2387
|
+
// })
|
|
2388
|
+
// // handle incoming call
|
|
2389
|
+
// const sub2 = this.twilioService.currentCall.subscribe(incomingCallData => {
|
|
2390
|
+
// // if (incomingCallData) {
|
|
2391
|
+
// // this.isCallInProgress = true;
|
|
2392
|
+
// // this.isDialpadHidden = false;
|
|
2393
|
+
// // this.callData.phone = incomingCallData.parameters.From;
|
|
2394
|
+
// // this.callData.name = incomingCallData.customParameters.get('name');
|
|
2395
|
+
// // this.callData.img = incomingCallData.customParameters.get('image');
|
|
2396
|
+
// // this.callData.isIncomingCall = true;
|
|
2397
|
+
// // }
|
|
2398
|
+
// if (incomingCallData) {
|
|
2399
|
+
// if (this.isCallInProgress) {
|
|
2400
|
+
// this.newIncomingCalls.push(incomingCallData);
|
|
2401
|
+
// this.getUserInformation(incomingCallData);
|
|
2402
|
+
// } else {
|
|
2403
|
+
// this.isCallInProgress = true;
|
|
2404
|
+
// this.isDialpadHidden = false;
|
|
2405
|
+
// this.callData.phone = incomingCallData.parameters['From'];
|
|
2406
|
+
// this.getUserInformation(incomingCallData);
|
|
2407
|
+
// this.callData.name = incomingCallData.customParameters.get('name');
|
|
2408
|
+
// this.callData.img = incomingCallData.customParameters.get('image') || 'assets/images/user.jpg';
|
|
2409
|
+
// this.callData.isIncomingCall = true;
|
|
2410
|
+
// }
|
|
2411
|
+
// incomingCallData.on('cancel', () => {
|
|
2412
|
+
// this.incomingCallsList = this.incomingCallsList.filter((item: any) => item.parameters.CallSid !== incomingCallData.parameters['CallSid']);
|
|
2413
|
+
// if(this.incomingCallsList.length == 0){
|
|
2414
|
+
// this.isCallInProgress = false;
|
|
2415
|
+
// }
|
|
2416
|
+
// });
|
|
2417
|
+
// incomingCallData.on('disconnect', () => {
|
|
2418
|
+
// this.incomingCallsList = this.incomingCallsList.filter((item: any) => item.parameters.CallSid !== incomingCallData.parameters['CallSid']);
|
|
2419
|
+
// if(this.incomingCallsList.length == 0){
|
|
2420
|
+
// this.isCallInProgress = false;
|
|
2421
|
+
// }
|
|
2422
|
+
// });
|
|
2423
|
+
// }
|
|
2424
|
+
// });
|
|
2425
|
+
// this.subscriptions.add(sub1);
|
|
2426
|
+
// this.subscriptions.add(sub2);
|
|
2427
|
+
// }catch(e){
|
|
2428
|
+
// console.log(e)
|
|
2429
|
+
// }
|
|
2430
|
+
// }
|
|
2228
2431
|
ngOnInit() {
|
|
2229
2432
|
try {
|
|
2433
|
+
this.token = localStorage.getItem('ext_token') || '';
|
|
2434
|
+
//this.isCallInProgress = true;
|
|
2230
2435
|
this.getContactList();
|
|
2231
2436
|
this.getUserCallSetting();
|
|
2232
|
-
// Subscribe to dial number events
|
|
2233
2437
|
const sub1 = this.twilioService.dialNumberFromOtherModule.subscribe((contact) => {
|
|
2234
2438
|
if (contact.number) {
|
|
2235
2439
|
this.isSmartDialCall = false;
|
|
@@ -2300,7 +2504,7 @@ class DialboxComponent {
|
|
|
2300
2504
|
}
|
|
2301
2505
|
else {
|
|
2302
2506
|
this.isCallInProgress = true;
|
|
2303
|
-
this.isDialpadHidden =
|
|
2507
|
+
this.isDialpadHidden = false;
|
|
2304
2508
|
this.callData.phone = incomingCallData.parameters['From'];
|
|
2305
2509
|
this.getUserInformation(incomingCallData);
|
|
2306
2510
|
this.callData.name = incomingCallData.customParameters.get('name');
|
|
@@ -2308,13 +2512,13 @@ class DialboxComponent {
|
|
|
2308
2512
|
this.callData.isIncomingCall = true;
|
|
2309
2513
|
}
|
|
2310
2514
|
incomingCallData.on('cancel', () => {
|
|
2311
|
-
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters
|
|
2515
|
+
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters['CallSid'] !== incomingCallData.parameters['CallSid']);
|
|
2312
2516
|
if (this.incomingCallsList.length == 0) {
|
|
2313
2517
|
this.isCallInProgress = false;
|
|
2314
2518
|
}
|
|
2315
2519
|
});
|
|
2316
2520
|
incomingCallData.on('disconnect', () => {
|
|
2317
|
-
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters
|
|
2521
|
+
this.incomingCallsList = this.incomingCallsList.filter((item) => item.parameters['CallSid'] !== incomingCallData.parameters['CallSid']);
|
|
2318
2522
|
if (this.incomingCallsList.length == 0) {
|
|
2319
2523
|
this.isCallInProgress = false;
|
|
2320
2524
|
}
|