@vgroup/dialbox 0.0.33 → 0.0.34

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.
@@ -2,9 +2,10 @@ import * as i0 from '@angular/core';
2
2
  import { Injectable, EventEmitter, Component, Input, Output, ViewChild, Inject, NgModule } from '@angular/core';
3
3
  import swal from 'sweetalert2';
4
4
  import { AsYouType } from 'libphonenumber-js';
5
- import { BehaviorSubject, throwError, interval, Subscription } from 'rxjs';
5
+ import { throwError, BehaviorSubject, interval, Subscription } from 'rxjs';
6
6
  import * as i1 from '@angular/common/http';
7
7
  import { HttpHeaders, HttpParams, HttpClientModule } from '@angular/common/http';
8
+ import { Device } from '@twilio/voice-sdk';
8
9
  import { catchError, switchMap, map } from 'rxjs/operators';
9
10
  import * as i3$1 from '@angular/material/dialog';
10
11
  import { MAT_DIALOG_DATA } from '@angular/material/dialog';
@@ -14,7 +15,6 @@ import * as i4 from '@angular/common';
14
15
  import { CommonModule } from '@angular/common';
15
16
  import * as i3 from '@angular/forms';
16
17
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
17
- import { Device } from '@twilio/voice-sdk';
18
18
  import { BrowserModule } from '@angular/platform-browser';
19
19
 
20
20
  const keypad = [
@@ -93,128 +93,6 @@ const environment = {
93
93
  perspectiveApiKey: 'AIzaSyClf32lvLH4QOy-vOnzLzwSNntKIgapH8s'
94
94
  };
95
95
 
96
- class TwilioService {
97
- constructor(http) {
98
- this.http = http;
99
- this.openInProgressDialpad = new BehaviorSubject(false);
100
- this.currentCall = new BehaviorSubject(null);
101
- this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
102
- this.callType = new BehaviorSubject('NIL');
103
- this.isIncomingCallPicked = new BehaviorSubject(false); // for both incoming and outgoing
104
- this.token = localStorage.getItem('ext_token');
105
- this.isNewContactAdded = new BehaviorSubject(false);
106
- this.updateRecentCall = new BehaviorSubject(false);
107
- this.callhandleFromNotification = new BehaviorSubject({});
108
- this.endCall = new BehaviorSubject(false);
109
- this.dialNumberFromOtherModule = new BehaviorSubject({ number: '', name: '', img: '', callerId: '', isDialFromHistory: false, from: '' });
110
- this.toggleCallerIdAlert = new BehaviorSubject(true);
111
- this.isTrialOver = new BehaviorSubject(false);
112
- this.isPaymentDue = new BehaviorSubject(false);
113
- this.isAvailableNumber = new BehaviorSubject(false);
114
- this.callerIdList = new BehaviorSubject([]);
115
- this.triggerSMSReload = new BehaviorSubject(false);
116
- }
117
- // onIncomingCall(){
118
- // this.device.on('incoming', (call:any) => {
119
- // console.log(call);
120
- // //call.accept();
121
- // });
122
- // }
123
- saveContact(payload) {
124
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
125
- return this.http.post(environment.apiUrl + '/utilities/phonebook/add/contacts/manually', payload, httpOptions);
126
- }
127
- updateContact(payload) {
128
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + this.token }) };
129
- return this.http.post(environment.apiUrl + '/utilities/phonebook/update/contact', payload, httpOptions);
130
- }
131
- deleteContact(id) {
132
- let payload = {
133
- phonebookid: id
134
- };
135
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
136
- return this.http.post(environment.apiUrl + '/utilities/phonebook/delete/contact/' + id, payload, httpOptions);
137
- }
138
- getContactList() {
139
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
140
- return this.http.get(environment.apiUrl + '/utilities/phonebook/read/contacts', httpOptions);
141
- }
142
- addContactToFavourite(payload) {
143
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
144
- return this.http.post(environment.apiUrl + '/utilities/phonebook/update/favourite', payload, httpOptions);
145
- }
146
- getFavouritContacts() {
147
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
148
- return this.http.get(environment.apiUrl + '/utilities/phonebook/favourite/contacts', httpOptions);
149
- }
150
- getRecentCalls(pageIndex, pageSize) {
151
- // let params = new HttpParams();
152
- // params = params.set('size', pageSize);
153
- // params = params.set('page', pageIndex);
154
- const headers = { 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') };
155
- const httpOptions = { headers };
156
- return this.http.get(environment.apiUrl + '/utilities/phonebook/recent/calls', httpOptions);
157
- }
158
- deleteRecentCallLog(id) {
159
- let payload = {
160
- recordId: id
161
- };
162
- const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
163
- return this.http.post(environment.apiUrl + '/utilities/phonebook/delete/calls/' + id, payload, httpOptions);
164
- }
165
- uploadPhoto(payload) {
166
- let httpOptions = {
167
- headers: new HttpHeaders({
168
- 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
169
- })
170
- };
171
- return this.http.post(environment.apiUrl + '/utilities/phonebook/upload/photo', payload, httpOptions);
172
- }
173
- deletePhoto(id) {
174
- let payload = {
175
- phonebookid: id
176
- };
177
- let httpOptions = {
178
- headers: new HttpHeaders({
179
- 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
180
- })
181
- };
182
- return this.http.post(environment.apiUrl + '/utilities/phonebook/delete/photo/' + id, payload, httpOptions);
183
- }
184
- // toggleCallerIdAlertFn(val: any) {
185
- // let httpOptions = {
186
- // headers: new HttpHeaders({
187
- // 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
188
- // })
189
- // };
190
- // return this.http.put<[]>(environment.apiUrl + '/utilities/softphone/callerid/alert/' + val, {}, httpOptions);
191
- // }
192
- toggleCoutryCodeToast(val) {
193
- let httpOptions = {
194
- headers: new HttpHeaders({
195
- 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
196
- })
197
- };
198
- return this.http.put(environment.apiUrl + '/utilities/softphone/countrycode/alert/' + val, {}, httpOptions);
199
- }
200
- getToNumber(dialledNo, isoCode) {
201
- const httpOptions = {
202
- headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }),
203
- params: new HttpParams().set('isoCode', isoCode)
204
- };
205
- const params = new HttpParams().set('isoCode', isoCode);
206
- return this.http.get(environment.apiUrl + '/utilities/softphone/check/countryCode/' + dialledNo, httpOptions);
207
- }
208
- }
209
- TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
210
- TwilioService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, providedIn: 'root' });
211
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, decorators: [{
212
- type: Injectable,
213
- args: [{
214
- providedIn: 'root'
215
- }]
216
- }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
217
-
218
96
  class IpAddressService {
219
97
  constructor(http) {
220
98
  this.http = http;
@@ -1416,6 +1294,152 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
1416
1294
  }]
1417
1295
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: IpAddressService }]; } });
1418
1296
 
1297
+ class TwilioService {
1298
+ constructor(http, extensionService) {
1299
+ this.http = http;
1300
+ this.extensionService = extensionService;
1301
+ this.openInProgressDialpad = new BehaviorSubject(false);
1302
+ this.currentCall = new BehaviorSubject(null);
1303
+ this.currentCallState = new BehaviorSubject('none'); //in-progress, out-progress, none
1304
+ this.callType = new BehaviorSubject('NIL');
1305
+ this.isIncomingCallPicked = new BehaviorSubject(false); // for both incoming and outgoing
1306
+ this.token = localStorage.getItem('ext_token');
1307
+ this.isNewContactAdded = new BehaviorSubject(false);
1308
+ this.updateRecentCall = new BehaviorSubject(false);
1309
+ this.callhandleFromNotification = new BehaviorSubject({});
1310
+ this.endCall = new BehaviorSubject(false);
1311
+ this.dialNumberFromOtherModule = new BehaviorSubject({ number: '', name: '', img: '', callerId: '', isDialFromHistory: false, from: '' });
1312
+ this.toggleCallerIdAlert = new BehaviorSubject(true);
1313
+ this.isTrialOver = new BehaviorSubject(false);
1314
+ this.isPaymentDue = new BehaviorSubject(false);
1315
+ this.isAvailableNumber = new BehaviorSubject(false);
1316
+ this.callerIdList = new BehaviorSubject([]);
1317
+ this.triggerSMSReload = new BehaviorSubject(false);
1318
+ this.initializeTwilioDevice();
1319
+ }
1320
+ initializeTwilioDevice() {
1321
+ if (this.token) {
1322
+ this.extensionService.getIncomingCallToken().subscribe((data) => {
1323
+ this.incomingCallToken = data.token;
1324
+ localStorage.setItem('in-token', data.token);
1325
+ this.device = new Device(this.incomingCallToken, {
1326
+ allowIncomingWhileBusy: true,
1327
+ // Add any other necessary options
1328
+ });
1329
+ this.device.register();
1330
+ this.device.on('incoming', (call) => {
1331
+ this.currentCall.next(call);
1332
+ this.callType.next('INCOMING');
1333
+ this.currentCallState.next('incoming');
1334
+ });
1335
+ this.device.on('error', (error) => {
1336
+ console.error('Twilio Device Error:', error);
1337
+ // Add error handling and reconnection logic
1338
+ });
1339
+ });
1340
+ }
1341
+ }
1342
+ // onIncomingCall(){
1343
+ // this.device.on('incoming', (call:any) => {
1344
+ // console.log(call);
1345
+ // //call.accept();
1346
+ // });
1347
+ // }
1348
+ saveContact(payload) {
1349
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
1350
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/add/contacts/manually', payload, httpOptions);
1351
+ }
1352
+ updateContact(payload) {
1353
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + this.token }) };
1354
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/update/contact', payload, httpOptions);
1355
+ }
1356
+ deleteContact(id) {
1357
+ let payload = {
1358
+ phonebookid: id
1359
+ };
1360
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
1361
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/delete/contact/' + id, payload, httpOptions);
1362
+ }
1363
+ getContactList() {
1364
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
1365
+ return this.http.get(environment.apiUrl + '/utilities/phonebook/read/contacts', httpOptions);
1366
+ }
1367
+ addContactToFavourite(payload) {
1368
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
1369
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/update/favourite', payload, httpOptions);
1370
+ }
1371
+ getFavouritContacts() {
1372
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
1373
+ return this.http.get(environment.apiUrl + '/utilities/phonebook/favourite/contacts', httpOptions);
1374
+ }
1375
+ getRecentCalls(pageIndex, pageSize) {
1376
+ // let params = new HttpParams();
1377
+ // params = params.set('size', pageSize);
1378
+ // params = params.set('page', pageIndex);
1379
+ const headers = { 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') };
1380
+ const httpOptions = { headers };
1381
+ return this.http.get(environment.apiUrl + '/utilities/phonebook/recent/calls', httpOptions);
1382
+ }
1383
+ deleteRecentCallLog(id) {
1384
+ let payload = {
1385
+ recordId: id
1386
+ };
1387
+ const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }) };
1388
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/delete/calls/' + id, payload, httpOptions);
1389
+ }
1390
+ uploadPhoto(payload) {
1391
+ let httpOptions = {
1392
+ headers: new HttpHeaders({
1393
+ 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
1394
+ })
1395
+ };
1396
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/upload/photo', payload, httpOptions);
1397
+ }
1398
+ deletePhoto(id) {
1399
+ let payload = {
1400
+ phonebookid: id
1401
+ };
1402
+ let httpOptions = {
1403
+ headers: new HttpHeaders({
1404
+ 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
1405
+ })
1406
+ };
1407
+ return this.http.post(environment.apiUrl + '/utilities/phonebook/delete/photo/' + id, payload, httpOptions);
1408
+ }
1409
+ // toggleCallerIdAlertFn(val: any) {
1410
+ // let httpOptions = {
1411
+ // headers: new HttpHeaders({
1412
+ // 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
1413
+ // })
1414
+ // };
1415
+ // return this.http.put<[]>(environment.apiUrl + '/utilities/softphone/callerid/alert/' + val, {}, httpOptions);
1416
+ // }
1417
+ toggleCoutryCodeToast(val) {
1418
+ let httpOptions = {
1419
+ headers: new HttpHeaders({
1420
+ 'Auth-Key': "Bearer " + localStorage.getItem('ext_token')
1421
+ })
1422
+ };
1423
+ return this.http.put(environment.apiUrl + '/utilities/softphone/countrycode/alert/' + val, {}, httpOptions);
1424
+ }
1425
+ getToNumber(dialledNo, isoCode) {
1426
+ const httpOptions = {
1427
+ headers: new HttpHeaders({ 'Content-Type': 'application/json', 'Auth-Key': "Bearer " + localStorage.getItem('ext_token') }),
1428
+ params: new HttpParams().set('isoCode', isoCode)
1429
+ };
1430
+ const params = new HttpParams().set('isoCode', isoCode);
1431
+ return this.http.get(environment.apiUrl + '/utilities/softphone/check/countryCode/' + dialledNo, httpOptions);
1432
+ }
1433
+ }
1434
+ TwilioService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, deps: [{ token: i1.HttpClient }, { token: ExtensionService }], target: i0.ɵɵFactoryTarget.Injectable });
1435
+ TwilioService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, providedIn: 'root' });
1436
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImport: i0, type: TwilioService, decorators: [{
1437
+ type: Injectable,
1438
+ args: [{
1439
+ providedIn: 'root'
1440
+ }]
1441
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ExtensionService }]; } });
1442
+
1419
1443
  const GlobalConstant = {
1420
1444
  ErrorMsg500: "Unable to process request. Please try again later.",
1421
1445
  isSMSVisible: true,
@@ -1509,24 +1533,15 @@ class IncomingCallComponent {
1509
1533
  this.selectedIncomingCallInfo = new EventEmitter();
1510
1534
  }
1511
1535
  ngOnInit() {
1512
- this.extensionService.getIncomingCallToken().subscribe((data) => {
1513
- this.twilioService.incomingCallToken = data.token;
1514
- localStorage.setItem('in-token', data.token);
1515
- this.isTwilioConnected = true;
1516
- this.twilioService.device = new Device(this.twilioService.incomingCallToken, { allowIncomingWhileBusy: true });
1517
- this.twilioService.device.register();
1518
- this.twilioService.device.on('incoming', (call) => {
1519
- this.twilioService.currentCall.next(call);
1520
- this.twilioService.callType.next('INCOMING');
1536
+ this.twilioService.currentCall.subscribe((call) => {
1537
+ if (call) {
1538
+ this.twilioCallData = call;
1521
1539
  this.notificationSerivce.showNotification(call);
1522
- //this.twilioService.openInProgressDialpad.next(true);
1523
- });
1524
- this.twilioService.device.on('error', (err) => {
1525
- console.log(err);
1526
- });
1540
+ // Handle the call UI
1541
+ }
1527
1542
  });
1528
1543
  try {
1529
- this.twilioService.currentCall.subscribe(call => {
1544
+ this.twilioService.currentCall.subscribe((call) => {
1530
1545
  if (call) {
1531
1546
  this.twilioCallData = call;
1532
1547
  this.twilioAuthId = call.customParameters.get('twilioAuthId');