@vgroup/dialbox 0.0.61 → 0.0.63
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.module.mjs +29 -3
- package/esm2020/lib/service/app-initializer.service.mjs +76 -0
- package/esm2020/lib/service/twilio.service.mjs +18 -45
- package/fesm2015/vgroup-dialbox.mjs +123 -47
- package/fesm2015/vgroup-dialbox.mjs.map +1 -1
- package/fesm2020/vgroup-dialbox.mjs +115 -47
- package/fesm2020/vgroup-dialbox.mjs.map +1 -1
- package/lib/service/app-initializer.service.d.ts +17 -0
- package/lib/service/twilio.service.d.ts +1 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, NgModule } from '@angular/core';
|
|
2
|
+
import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, PLATFORM_ID, APP_INITIALIZER, Injector, NgModule } from '@angular/core';
|
|
3
3
|
import swal from 'sweetalert2';
|
|
4
4
|
import { AsYouType } from 'libphonenumber-js';
|
|
5
5
|
import { throwError, BehaviorSubject, interval, Subscription } from 'rxjs';
|
|
@@ -12,7 +12,7 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
|
12
12
|
import * as i5 from '@angular/router';
|
|
13
13
|
import { RouterLink, RouterModule } from '@angular/router';
|
|
14
14
|
import * as i4 from '@angular/common';
|
|
15
|
-
import { CommonModule } from '@angular/common';
|
|
15
|
+
import { isPlatformBrowser, CommonModule } from '@angular/common';
|
|
16
16
|
import * as i3 from '@angular/forms';
|
|
17
17
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
18
18
|
import { BrowserModule } from '@angular/platform-browser';
|
|
@@ -1366,11 +1366,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
1366
1366
|
}], ctorParameters: function () { return [{ type: TwilioService }]; } });
|
|
1367
1367
|
|
|
1368
1368
|
class TwilioService {
|
|
1369
|
-
constructor(http, extensionService, notificationSerivce
|
|
1369
|
+
constructor(http, extensionService, notificationSerivce) {
|
|
1370
1370
|
this.http = http;
|
|
1371
1371
|
this.extensionService = extensionService;
|
|
1372
1372
|
this.notificationSerivce = notificationSerivce;
|
|
1373
|
-
this.twilioService = twilioService;
|
|
1374
1373
|
this.openInProgressDialpad = new BehaviorSubject(false);
|
|
1375
1374
|
this.currentCall = new BehaviorSubject(null);
|
|
1376
1375
|
this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
|
|
@@ -1388,53 +1387,27 @@ class TwilioService {
|
|
|
1388
1387
|
this.isAvailableNumber = new BehaviorSubject(false);
|
|
1389
1388
|
this.callerIdList = new BehaviorSubject([]);
|
|
1390
1389
|
this.triggerSMSReload = new BehaviorSubject(false);
|
|
1391
|
-
this.isTwilioConnected = false;
|
|
1392
|
-
this.doNotDisturb = true;
|
|
1393
1390
|
this.initializeTwilioDevice();
|
|
1394
1391
|
}
|
|
1395
1392
|
initializeTwilioDevice() {
|
|
1396
|
-
|
|
1397
|
-
// this.extensionService.getIncomingCallToken().subscribe((data: any) => {
|
|
1398
|
-
// this.incomingCallToken = data.token;
|
|
1399
|
-
// localStorage.setItem('in-token', data.token);
|
|
1400
|
-
// this.device = new Device(this.incomingCallToken!, {
|
|
1401
|
-
// allowIncomingWhileBusy: true,
|
|
1402
|
-
// // Add any other necessary options
|
|
1403
|
-
// });
|
|
1404
|
-
// this.device.register();
|
|
1405
|
-
// this.device.on('incoming', (call: Call) => {
|
|
1406
|
-
// this.currentCall.next(call);
|
|
1407
|
-
// this.callType.next('INCOMING');
|
|
1408
|
-
// this.currentCallState.next('incoming');
|
|
1409
|
-
// this.notificationSerivce.showNotification(call);
|
|
1410
|
-
// });
|
|
1411
|
-
// this.device.on('error', (error: any) => {
|
|
1412
|
-
// console.error('Twilio Device Error:', error);
|
|
1413
|
-
// // Add error handling and reconnection logic
|
|
1414
|
-
// });
|
|
1415
|
-
// });
|
|
1416
|
-
// }
|
|
1417
|
-
if (localStorage.getItem('in-token')) {
|
|
1418
|
-
this.isTwilioConnected = true;
|
|
1419
|
-
this.doNotDisturb = false;
|
|
1393
|
+
if (this.token) {
|
|
1420
1394
|
this.extensionService.getIncomingCallToken().subscribe((data) => {
|
|
1421
|
-
this.
|
|
1395
|
+
this.incomingCallToken = data.token;
|
|
1422
1396
|
localStorage.setItem('in-token', data.token);
|
|
1423
|
-
this.
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
this.
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
this.
|
|
1432
|
-
this.twilioService.callType.next('INCOMING');
|
|
1397
|
+
this.device = new Device(this.incomingCallToken, {
|
|
1398
|
+
allowIncomingWhileBusy: true,
|
|
1399
|
+
// Add any other necessary options
|
|
1400
|
+
});
|
|
1401
|
+
this.device.register();
|
|
1402
|
+
this.device.on('incoming', (call) => {
|
|
1403
|
+
this.currentCall.next(call);
|
|
1404
|
+
this.callType.next('INCOMING');
|
|
1405
|
+
this.currentCallState.next('incoming');
|
|
1433
1406
|
this.notificationSerivce.showNotification(call);
|
|
1434
|
-
//this.twilioService.openInProgressDialpad.next(true);
|
|
1435
1407
|
});
|
|
1436
|
-
this.
|
|
1437
|
-
console.
|
|
1408
|
+
this.device.on('error', (error) => {
|
|
1409
|
+
console.error('Twilio Device Error:', error);
|
|
1410
|
+
// Add error handling and reconnection logic
|
|
1438
1411
|
});
|
|
1439
1412
|
});
|
|
1440
1413
|
}
|
|
@@ -1531,14 +1504,14 @@ class TwilioService {
|
|
|
1531
1504
|
return this.http.get(environment.apiUrl + '/utilities/softphone/check/countryCode/' + dialledNo, httpOptions);
|
|
1532
1505
|
}
|
|
1533
1506
|
}
|
|
1534
|
-
TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }, { token: ExtensionService }, { token: NotificationService }
|
|
1507
|
+
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 });
|
|
1535
1508
|
TwilioService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, providedIn: 'root' });
|
|
1536
1509
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, decorators: [{
|
|
1537
1510
|
type: Injectable,
|
|
1538
1511
|
args: [{
|
|
1539
1512
|
providedIn: 'root'
|
|
1540
1513
|
}]
|
|
1541
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ExtensionService }, { type: NotificationService }
|
|
1514
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ExtensionService }, { type: NotificationService }]; } });
|
|
1542
1515
|
|
|
1543
1516
|
const GlobalConstant = {
|
|
1544
1517
|
ErrorMsg500: "Unable to process request. Please try again later.",
|
|
@@ -3203,6 +3176,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
3203
3176
|
args: [MAT_DIALOG_DATA]
|
|
3204
3177
|
}] }]; } });
|
|
3205
3178
|
|
|
3179
|
+
class AppInitializerService {
|
|
3180
|
+
constructor(twilioService, extensionService, router, platformId) {
|
|
3181
|
+
this.twilioService = twilioService;
|
|
3182
|
+
this.extensionService = extensionService;
|
|
3183
|
+
this.router = router;
|
|
3184
|
+
this.platformId = platformId;
|
|
3185
|
+
}
|
|
3186
|
+
initializeApp() {
|
|
3187
|
+
return new Promise((resolve) => {
|
|
3188
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
3189
|
+
this.initializeServices().then(() => {
|
|
3190
|
+
resolve();
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
else {
|
|
3194
|
+
resolve();
|
|
3195
|
+
}
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
async initializeServices() {
|
|
3199
|
+
try {
|
|
3200
|
+
// Initialize Twilio device
|
|
3201
|
+
await this.initializeTwilio();
|
|
3202
|
+
// Fetch initial data
|
|
3203
|
+
await this.fetchInitialData();
|
|
3204
|
+
console.log('App initialization complete');
|
|
3205
|
+
}
|
|
3206
|
+
catch (error) {
|
|
3207
|
+
console.error('Error during app initialization:', error);
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
async initializeTwilio() {
|
|
3211
|
+
const token = localStorage.getItem('ext_token');
|
|
3212
|
+
if (token) {
|
|
3213
|
+
await this.twilioService.initializeTwilioDevice();
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
async fetchInitialData() {
|
|
3217
|
+
const token = localStorage.getItem('ext_token');
|
|
3218
|
+
if (token) {
|
|
3219
|
+
try {
|
|
3220
|
+
// Fetch caller ID
|
|
3221
|
+
const response = await this.extensionService.fetchCallerId(token).toPromise();
|
|
3222
|
+
if (response && typeof response === 'object' && 'status' in response) {
|
|
3223
|
+
const callerIdRes = response;
|
|
3224
|
+
if (callerIdRes.status === 200) {
|
|
3225
|
+
const callerId = callerIdRes.callerid || 'Not set';
|
|
3226
|
+
localStorage.setItem('callerID', callerId);
|
|
3227
|
+
this.extensionService.changeMessage(callerId);
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
catch (error) {
|
|
3232
|
+
console.error('Error fetching initial data:', error);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
AppInitializerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AppInitializerService, deps: [{ token: TwilioService }, { token: ExtensionService }, { token: i5.Router }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3238
|
+
AppInitializerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AppInitializerService, providedIn: 'root' });
|
|
3239
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: AppInitializerService, decorators: [{
|
|
3240
|
+
type: Injectable,
|
|
3241
|
+
args: [{
|
|
3242
|
+
providedIn: 'root'
|
|
3243
|
+
}]
|
|
3244
|
+
}], ctorParameters: function () { return [{ type: TwilioService }, { type: ExtensionService }, { type: i5.Router }, { type: Object, decorators: [{
|
|
3245
|
+
type: Inject,
|
|
3246
|
+
args: [PLATFORM_ID]
|
|
3247
|
+
}] }]; } });
|
|
3248
|
+
|
|
3206
3249
|
class DialboxModule {
|
|
3207
3250
|
}
|
|
3208
3251
|
DialboxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DialboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -3219,7 +3262,19 @@ DialboxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version:
|
|
|
3219
3262
|
IncomingCallComponent,
|
|
3220
3263
|
CallProgressComponent,
|
|
3221
3264
|
CallerIdDialogComponent] });
|
|
3222
|
-
DialboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DialboxModule,
|
|
3265
|
+
DialboxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: DialboxModule, providers: [
|
|
3266
|
+
{
|
|
3267
|
+
provide: APP_INITIALIZER,
|
|
3268
|
+
useFactory: (injector) => {
|
|
3269
|
+
return () => {
|
|
3270
|
+
const appInitializer = injector.get(AppInitializerService);
|
|
3271
|
+
return appInitializer.initializeApp();
|
|
3272
|
+
};
|
|
3273
|
+
},
|
|
3274
|
+
deps: [Injector],
|
|
3275
|
+
multi: true
|
|
3276
|
+
}
|
|
3277
|
+
], imports: [CommonModule,
|
|
3223
3278
|
FormsModule,
|
|
3224
3279
|
ReactiveFormsModule,
|
|
3225
3280
|
HttpClientModule,
|
|
@@ -3248,6 +3303,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
3248
3303
|
IncomingCallComponent,
|
|
3249
3304
|
CallProgressComponent,
|
|
3250
3305
|
CallerIdDialogComponent,
|
|
3306
|
+
],
|
|
3307
|
+
providers: [
|
|
3308
|
+
{
|
|
3309
|
+
provide: APP_INITIALIZER,
|
|
3310
|
+
useFactory: (injector) => {
|
|
3311
|
+
return () => {
|
|
3312
|
+
const appInitializer = injector.get(AppInitializerService);
|
|
3313
|
+
return appInitializer.initializeApp();
|
|
3314
|
+
};
|
|
3315
|
+
},
|
|
3316
|
+
deps: [Injector],
|
|
3317
|
+
multi: true
|
|
3318
|
+
}
|
|
3251
3319
|
]
|
|
3252
3320
|
}]
|
|
3253
3321
|
}] });
|