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