@chat21/chat21-ionic 3.4.13-rc3 → 3.4.13-rc5

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/src/app/app.component.ts +15 -6
  4. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +1 -26
  5. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +1 -1
  6. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +1 -0
  7. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +1 -0
  8. package/src/app/chatlib/conversation-detail/message/options/options.component.html +1 -1
  9. package/src/app/chatlib/conversation-detail/message/options/options.component.ts +1 -0
  10. package/src/app/components/canned-response/canned-response.component.ts +4 -9
  11. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -3
  12. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +1 -0
  13. package/src/app/components/conversation-info/info-content/info-content.component.ts +10 -14
  14. package/src/app/components/conversation-info/info-group/info-group.component.ts +2 -10
  15. package/src/app/components/copilot-popover/copilot-popover.component.html +1 -1
  16. package/src/app/components/copilot-popover/copilot-popover.component.ts +1 -2
  17. package/src/app/components/copilot-suggestions/copilot-suggestions.component.ts +14 -12
  18. package/src/app/components/navbar/navbar.component.ts +4 -4
  19. package/src/app/components/project-item/project-item.component.ts +3 -4
  20. package/src/app/modals/create-canned-response/create-canned-response.page.ts +6 -12
  21. package/src/app/modals/create-ticket/create-ticket.page.ts +10 -23
  22. package/src/app/modals/send-email/send-email.page.ts +1 -3
  23. package/src/app/pages/contacts-directory/contacts-directory.page.ts +3 -5
  24. package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -2
  25. package/src/app/pages/conversation-detail/conversation-detail.page.ts +15 -32
  26. package/src/app/pages/conversations-list/conversations-list.page.ts +8 -16
  27. package/src/app/pages/create-requester/create-requester.page.ts +5 -10
  28. package/src/app/services/canned-responses/canned-responses.service.ts +25 -19
  29. package/src/app/services/contacts/contacts.service.ts +23 -20
  30. package/src/app/services/copilot/copilot.service.ts +27 -23
  31. package/src/app/services/projects/{projects.service.spec.ts → project.service.spec.ts} +2 -2
  32. package/src/app/services/projects/project.service.ts +68 -0
  33. package/src/app/services/tiledesk/tiledesk.service.ts +48 -82
  34. package/src/app/utils/project-utils.ts +140 -0
  35. package/src/chat21-core/utils/constants.ts +3 -0
  36. package/src/app/services/projects/projects.service.ts +0 -43
@@ -23,7 +23,6 @@ export class CreateTicketPage implements OnInit {
23
23
  loadingAssignee: boolean = true;
24
24
  loadingRequesters: boolean = true;
25
25
  prjctID: string;
26
- tiledeskToken: string;
27
26
  selectedRequester: any;
28
27
  storageBucket: string;
29
28
  baseUrl: string;
@@ -66,7 +65,6 @@ export class CreateTicketPage implements OnInit {
66
65
  constructor(
67
66
  public modalController: ModalController,
68
67
  public tiledeskService: TiledeskService,
69
- public tiledeskAuthService: TiledeskAuthService,
70
68
  public appConfigProvider: AppConfigProvider,
71
69
  public events: EventsService
72
70
  ) {}
@@ -85,11 +83,8 @@ export class CreateTicketPage implements OnInit {
85
83
  this.prjctID = storedPrjctObjct.id_project.id
86
84
  this.logger.log('[CREATE-TICKET] this.prjctID ', this.prjctID)
87
85
  }
88
- this.tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
89
- this.logger.log('[CREATE-TICKET] tiledeskToken ', this.tiledeskToken)
90
-
91
- this.getProjectUsersAndContacts(this.prjctID, this.tiledeskToken)
92
- this.getProjectUserBotsAndDepts(this.prjctID, this.tiledeskToken)
86
+ this.getProjectUsersAndContacts(this.prjctID)
87
+ this.getProjectUserBotsAndDepts(this.prjctID)
93
88
  }
94
89
 
95
90
  getUploadEngine() {
@@ -108,16 +103,9 @@ export class CreateTicketPage implements OnInit {
108
103
  // -------------------------------------------------------------------------------------------
109
104
  // Create the array of the project-users and contacts displayed in the combo box "Requester"
110
105
  // -------------------------------------------------------------------------------------------
111
- getProjectUsersAndContacts(projctid: string, tiledesktoken: string) {
112
- const projectUsers = this.tiledeskService.getProjectUsersByProjectId(
113
- projctid,
114
- tiledesktoken,
115
- )
116
- const leads = this.tiledeskService.getAllLeadsActiveWithLimit(
117
- projctid,
118
- tiledesktoken,
119
- 10000,
120
- )
106
+ getProjectUsersAndContacts(projctid: string) {
107
+ const projectUsers = this.tiledeskService.getProjectUsersByProjectId(projctid)
108
+ const leads = this.tiledeskService.getAllLeadsActiveWithLimit(projctid,10000)
121
109
 
122
110
  zip(projectUsers, leads).subscribe(
123
111
  ([_prjctUsers, _leads]) => {
@@ -253,11 +241,11 @@ export class CreateTicketPage implements OnInit {
253
241
  // -------------------------------------------------------------------------------------------------------------------
254
242
  // Create the array of the project-users, the bots and of the departments displayed in the combo box "Select Assignee"
255
243
  // -------------------------------------------------------------------------------------------------------------------
256
- getProjectUserBotsAndDepts(projctid: string, tiledesktoken: string) {
244
+ getProjectUserBotsAndDepts(projctid: string) {
257
245
  // this.loadingAssignee = true;
258
- const projectUsers = this.tiledeskService.getProjectUsersByProjectId( projctid, tiledesktoken)
259
- const bots = this.tiledeskService.getAllBotByProjectId(projctid, tiledesktoken)
260
- const depts = this.tiledeskService.getDeptsByProjectId(projctid, tiledesktoken)
246
+ const projectUsers = this.tiledeskService.getProjectUsersByProjectId( projctid)
247
+ const bots = this.tiledeskService.getAllBotByProjectId(projctid)
248
+ const depts = this.tiledeskService.getDeptsByProjectId(projctid)
261
249
 
262
250
  zip(projectUsers, bots, depts).subscribe(
263
251
  ([_prjctUsers, _bots, _depts]) => {
@@ -361,8 +349,7 @@ export class CreateTicketPage implements OnInit {
361
349
  this.assignee_dept_id,
362
350
  this.assignee_participants_id,
363
351
  this.selectedPriority,
364
- this.prjctID,
365
- this.tiledeskToken
352
+ this.prjctID
366
353
  ).subscribe((newticket: any) => {
367
354
  this.logger.log('[WS-REQUESTS-LIST] create internalRequest - RES ', newticket);
368
355
 
@@ -34,7 +34,6 @@ export class SendEmailModal implements OnInit {
34
34
  public viewCtrl: ModalController,
35
35
  private formBuilder: FormBuilder,
36
36
  private tiledeskService: TiledeskService,
37
- private tiledeskAuthService: TiledeskAuthService,
38
37
  private toastController: ToastController
39
38
  ) { }
40
39
 
@@ -81,8 +80,7 @@ export class SendEmailModal implements OnInit {
81
80
 
82
81
  onSubmit(){
83
82
  this.logger.log('[SEND-EMAIL-MODAL] onSubmit -->',this.emailFormGroup)
84
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
85
- this.tiledeskService.sendEmail(tiledeskToken, this.projectId, this.conversationWith, this.emailFormGroup.value).subscribe((res)=> {
83
+ this.tiledeskService.sendEmail(this.projectId, this.conversationWith, this.emailFormGroup.value).subscribe((res)=> {
86
84
  this.logger.debug('[SEND-EMAIL-MODAL] subscribe to sendEmail API response -->', res)
87
85
  if(res && res.queued){
88
86
  this.viewCtrl.dismiss({form: this.emailFormGroup.value})
@@ -10,6 +10,7 @@ import { EventsService } from '../../services/events-service';
10
10
  // Logger
11
11
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
12
12
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
13
+ import { AppConfigProvider } from 'src/app/services/app-config';
13
14
 
14
15
  @Component({
15
16
  selector: 'app-contacts-directory',
@@ -18,7 +19,6 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
18
19
  })
19
20
  export class ContactsDirectoryPage implements OnInit {
20
21
 
21
- @Input() token: string;
22
22
  @Input() isMobile: boolean;
23
23
  @Input() stylesMap: Map<string, string>;
24
24
  // @Input() user: string;
@@ -32,21 +32,19 @@ export class ContactsDirectoryPage implements OnInit {
32
32
  // private contactsDirectoryService: ContactsDirectoryService,
33
33
  private contactsService: ContactsService,
34
34
  public events: EventsService
35
- ) {
35
+ ) {
36
36
  }
37
37
 
38
38
  ngOnInit() {
39
- this.logger.log('[CONTACT-DIRECTORY-PAGE] - TOKEN (ngOnInit)', this.token);
40
39
  this.initialize();
41
40
  }
42
41
 
43
42
  /** */
44
43
  initialize() {
45
44
  this.logger.log('[CONTACT-DIRECTORY-PAGE] - initialize');
46
- this.logger.log('[CONTACT-DIRECTORY-PAGE] - token: ', this.token);
47
45
  this.contacts = [];
48
46
  this.initSubscriptions();
49
- this.contactsService.loadContactsFromUrl(this.token);
47
+ this.contactsService.loadContactsFromUrl();
50
48
  }
51
49
 
52
50
  /**
@@ -135,7 +135,8 @@
135
135
  [messages]="messages"
136
136
  [senderId]="loggedUser.uid"
137
137
  [baseLocation]="window?.location?.origin"
138
- [areVisibleCAR]="areVisibleCAR"
138
+ [areVisibleCAR]="areVisibleCAR"
139
+ [isCopilotEnabled]="isCopilotEnabled"
139
140
  [supportMode]= "supportMode"
140
141
  [isMobile]="isMobile"
141
142
  [isTypings]="isTypings"
@@ -203,7 +204,8 @@
203
204
  [channelType]="channelType"
204
205
  [channel]="conversation?.attributes?.request_channel"
205
206
  [tagsCannedFilter]="tagsCannedFilter"
206
- [areVisibleCAR]="areVisibleCAR"
207
+ [areVisibleCAR]="areVisibleCAR"
208
+ [isCopilotEnabled]="isCopilotEnabled"
207
209
  [supportMode]="supportMode"
208
210
  [leadInfo]="leadInfo"
209
211
  [fileUploadAccept]="appConfigProvider.getConfig().fileUploadAccept"
@@ -1,3 +1,4 @@
1
+ import { ProjectPlanUtils } from './../../utils/project-utils';
1
2
  import { DomSanitizer } from '@angular/platform-browser';
2
3
  import {
3
4
  Component,
@@ -81,6 +82,7 @@ import { EventsService } from '../../services/events-service'
81
82
  import { WebsocketService } from 'src/app/services/websocket/websocket.service';
82
83
  import { Project } from 'src/chat21-core/models/projects';
83
84
  import { Globals } from 'src/app/utils/globals';
85
+ import { ProjectService } from 'src/app/services/projects/project.service';
84
86
 
85
87
  @Component({
86
88
  selector: 'app-conversation-detail',
@@ -147,6 +149,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
147
149
 
148
150
  public_Key: any;
149
151
  areVisibleCAR: boolean;
152
+ isCopilotEnabled: boolean;
150
153
  supportMode: boolean;
151
154
  isEmailEnabled: boolean;
152
155
  offlineMsgEmail: boolean;
@@ -234,10 +237,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
234
237
  public presenceService: PresenceService,
235
238
  public toastController: ToastController,
236
239
  public tiledeskService: TiledeskService,
240
+ public projectService: ProjectService,
237
241
  private networkService: NetworkService,
238
242
  private events: EventsService,
239
243
  private webSocketService: WebsocketService,
240
- private sanitizer: DomSanitizer,
244
+ public projectPlanUtils: ProjectPlanUtils,
241
245
  private g: Globals,
242
246
  ) {
243
247
  // Change list on date change
@@ -498,6 +502,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
498
502
  this.isEmailEnabled = (this.appConfigProvider.getConfig().emailSection === 'true' || this.appConfigProvider.getConfig().emailSection === true) ? true : false;
499
503
  this.isWhatsappTemplatesEnabled = (this.appConfigProvider.getConfig().whatsappTemplatesSection === 'true' || this.appConfigProvider.getConfig().whatsappTemplatesSection === true) ? true : false;
500
504
 
505
+ this.cannedResponsesService.initialize(appconfig.apiUrl)
506
+
501
507
  if (checkPlatformIsMobile()) {
502
508
  this.isMobile = true
503
509
  // this.openInfoConversation = false; // indica se è aperto il box info conversazione
@@ -538,13 +544,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
538
544
  }
539
545
 
540
546
  _getProjectIdByConversationWith(conversationWith: string) {
541
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
542
547
  if (this.channelType !== TYPE_DIRECT && !this.conversationWith.startsWith('group-')) {
543
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
548
+ this.tiledeskService.getProjectIdByConvRecipient(conversationWith).subscribe((res) => {
544
549
  this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES + projectId', res, res.id_project)
545
550
  if (res) {
546
551
  const projectId = res.id_project
547
- this.getProjectById(tiledeskToken, projectId)
552
+ this.getProjectById(projectId)
548
553
  }
549
554
  }, (error) => {
550
555
  this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',conversationWith, error)
@@ -558,13 +563,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
558
563
 
559
564
  }
560
565
 
561
- getProjectById(tiledeskToken, projectId) {
562
- this.tiledeskService.getProjectById(tiledeskToken, projectId).subscribe((project) => {
566
+ getProjectById(projectId) {
567
+ this.projectService.getProjectById(projectId).subscribe(async (project) => {
563
568
  this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', project)
564
569
  if (project) {
565
570
  const projectId = project.id_project
566
- this.canShowCanned = this.checkPlanIsExpired(project)
571
+ this.canShowCanned = this.projectPlanUtils.checkPlanIsExpired(project)
567
572
  this.offlineMsgEmail = this.checkOfflineMsgEmailIsEnabled(project)
573
+ this.isCopilotEnabled = this.projectPlanUtils.checkProjectProfileFeature(project, 'copilot')
568
574
  }
569
575
  }, (error) => {
570
576
  this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
@@ -577,27 +583,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
577
583
  }
578
584
 
579
585
 
580
- checkPlanIsExpired(project: Project): boolean {
581
- let check: boolean = false
582
-
583
- //case FREE plan
584
- if(project && project.trialExpired && project.profile.type=== 'trial'){
585
- check = true
586
- }else if(project && !project.trialExpired && project.profile.type=== 'trial'){
587
- check = false
588
- }
589
-
590
- //case PAYMENT plan
591
- if(project && project.isActiveSubscription && project.profile.type=== 'payment'){
592
- check = true
593
- }else if(project && !project.isActiveSubscription && project.profile.type=== 'payment'){
594
- check = false
595
- }
596
-
597
- return check
598
- }
599
-
600
-
601
586
  checkOfflineMsgEmailIsEnabled(project: Project): boolean {
602
587
  let check: boolean = true
603
588
 
@@ -982,10 +967,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
982
967
  getLeadDetail() {
983
968
  const that = this;
984
969
  if (this.channelType !== TYPE_DIRECT && !this.conversationWith.startsWith('group-')) {
985
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
986
970
  const projectId = getProjectIdSelectedConversation(this.conversationWith)
987
971
  this.logger.debug('[CONVS-DETAIL] getLeadDetail - section ', projectId)
988
- this.tiledeskService.getRequest(this.conversationWith, projectId, tiledeskToken).subscribe((request: any) => {
972
+ this.tiledeskService.getRequest(this.conversationWith, projectId).subscribe((request: any) => {
989
973
  that.logger.debug('[CONVS-DETAIL] getLeadDetail - selected REQUEST detail', request)
990
974
  if(request && request.channel){
991
975
  this.conversation.attributes['request_channel'] = request.channel.name
@@ -1051,13 +1035,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1051
1035
  }
1052
1036
 
1053
1037
  sendEmail(message: string): Observable<boolean> {
1054
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
1055
1038
  const emailFormGroup = {
1056
1039
  subject: this.translationsMap.get('EMAIL.SUBJECT_OFFLINE_MESSAGE'),
1057
1040
  text: message
1058
1041
  }
1059
1042
  let status = new Subject<boolean>();
1060
- this.tiledeskService.sendEmail(tiledeskToken, this.leadInfo.projectId, this.conversationWith, emailFormGroup).subscribe((res) => {
1043
+ this.tiledeskService.sendEmail(this.leadInfo.projectId, this.conversationWith, emailFormGroup).subscribe((res) => {
1061
1044
  this.logger.debug('[SEND-EMAIL-MODAL] subscribe to sendEmail API response -->', res)
1062
1045
  if (res && res.queued) {
1063
1046
  this.presentToast(this.translationsMap.get('EMAIL.SEND_EMAIL_SUCCESS_OFFLINE_MESSAGE'), 'success', '', 2000)
@@ -903,15 +903,11 @@ export class ConversationListPage implements OnInit {
903
903
  // Opens the list of contacts for direct convs
904
904
  // ---------------------------------------------------------
905
905
  openContactsDirectory(event: any) {
906
- const TOKEN = this.tiledeskAuthService.getTiledeskToken()
907
- this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory', TOKEN)
906
+ this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory')
908
907
  if (checkPlatformIsMobile()) {
909
- presentModal(this.modalController, ContactsDirectoryPage, {
910
- token: TOKEN,
911
- isMobile: this.isMobile
912
- })
908
+ presentModal(this.modalController, ContactsDirectoryPage, { isMobile: this.isMobile })
913
909
  } else {
914
- this.navService.push(ContactsDirectoryPage, { token: TOKEN })
910
+ this.navService.push(ContactsDirectoryPage, { isMobile: this.isMobile })
915
911
  }
916
912
  }
917
913
 
@@ -1003,9 +999,7 @@ export class ConversationListPage implements OnInit {
1003
999
  let project_id = ''
1004
1000
  if (conversationWith_segments.length === 4) {
1005
1001
  project_id = conversationWith_segments[2]
1006
-
1007
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1008
- this.archiveSupportGroupConv(tiledeskToken,project_id,conversationId,)
1002
+ this.archiveSupportGroupConv(project_id,conversationId)
1009
1003
  } else {
1010
1004
  this.getProjectIdByConversationWith(conversationId)
1011
1005
  }
@@ -1016,15 +1010,13 @@ export class ConversationListPage implements OnInit {
1016
1010
  }
1017
1011
 
1018
1012
  getProjectIdByConversationWith(conversationId: string) {
1019
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1020
-
1021
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationId).subscribe((res) => {
1013
+ this.tiledeskService.getProjectIdByConvRecipient(conversationId).subscribe((res) => {
1022
1014
  this.logger.log('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT RES',res)
1023
1015
 
1024
1016
  if (res) {
1025
1017
  const project_id = res.id_project
1026
1018
  this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id',project_id)
1027
- this.archiveSupportGroupConv(tiledeskToken,project_id,conversationId)
1019
+ this.archiveSupportGroupConv(project_id,conversationId)
1028
1020
  }
1029
1021
  },(error) => {
1030
1022
  this.logger.error('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT - ERROR ',error)
@@ -1033,9 +1025,9 @@ export class ConversationListPage implements OnInit {
1033
1025
  })
1034
1026
  }
1035
1027
 
1036
- archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
1028
+ archiveSupportGroupConv(project_id, conversationId) {
1037
1029
  this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ',project_id)
1038
- this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe((res) => {
1030
+ this.tiledeskService.closeSupportGroup(project_id, conversationId).subscribe((res) => {
1039
1031
  this.archiveActionNotAllowed = false
1040
1032
  this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES',res)
1041
1033
  if(res.status === REQUEST_ARCHIVED)
@@ -3,7 +3,6 @@ import { Validators, FormBuilder, FormGroup, FormControl} from '@angular/forms';
3
3
  import { ModalController } from '@ionic/angular'
4
4
  import { TranslateService } from '@ngx-translate/core';
5
5
  import { TiledeskService } from 'src/app/services/tiledesk/tiledesk.service';
6
- import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
7
6
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
7
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
8
  @Component({
@@ -19,7 +18,6 @@ export class CreateRequesterPage implements OnInit {
19
18
  @Input() projectUserAndLeadsArray: any
20
19
 
21
20
  prjctID: string;
22
- tiledeskToken: string;
23
21
  showSpinnerCreateRequester: boolean = false;
24
22
  requester_id: string;
25
23
  logger: LoggerService = LoggerInstance.getInstance();
@@ -28,7 +26,6 @@ export class CreateRequesterPage implements OnInit {
28
26
  public modalController: ModalController,
29
27
  private formBuilder: FormBuilder,
30
28
  public tiledeskService: TiledeskService,
31
- public tiledeskAuthService: TiledeskAuthService,
32
29
  private translate: TranslateService,
33
30
  ) { }
34
31
 
@@ -42,9 +39,7 @@ export class CreateRequesterPage implements OnInit {
42
39
  this.prjctID = storedPrjctObjct.id_project.id
43
40
  this.logger.log('[CREATE-REQUESTER] this.prjctID ', this.prjctID)
44
41
  }
45
- this.tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
46
- this.logger.log('[CREATE-REQUESTER] tiledeskToken ', this.tiledeskToken)
47
-
42
+
48
43
  this.buildForm()
49
44
 
50
45
  }
@@ -84,13 +79,13 @@ export class CreateRequesterPage implements OnInit {
84
79
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER email ', new_user_email);
85
80
 
86
81
 
87
- this.tiledeskService.createNewProjectUserToGetNewLeadID(this.prjctID, this.tiledeskToken).subscribe(res => {
82
+ this.tiledeskService.createNewProjectUserToGetNewLeadID(this.prjctID).subscribe(res => {
88
83
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER - CREATE-PROJECT-USER ', res);
89
84
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER - CREATE-PROJECT-USER UUID ', res.uuid_user);
90
85
  if (res) {
91
86
  if (res.uuid_user) {
92
87
  let new_lead_id = res.uuid_user
93
- this.createNewContact(new_lead_id, new_user_name, new_user_email, this.prjctID, this.tiledeskToken)
88
+ this.createNewContact(new_lead_id, new_user_name, new_user_email, this.prjctID)
94
89
  }
95
90
  }
96
91
  }, error => {
@@ -103,8 +98,8 @@ export class CreateRequesterPage implements OnInit {
103
98
  }
104
99
 
105
100
 
106
- createNewContact(lead_id: string, lead_name: string, lead_email: string, projecId: string, tiledeskToken: string) {
107
- this.tiledeskService.createNewLead(lead_id, lead_name, lead_email, projecId, tiledeskToken ).subscribe(lead => {
101
+ createNewContact(lead_id: string, lead_name: string, lead_email: string, projecId: string) {
102
+ this.tiledeskService.createNewLead(lead_id, lead_name, lead_email, projecId ).subscribe(lead => {
108
103
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER - CREATE-NEW-LEAD - RES ', lead);
109
104
  this.projectUserAndLeadsArray.push({ id: lead.lead_id, name: lead.fullname, role: 'lead', email: lead_email, requestertype: 'lead', requester_id: lead._id});
110
105
  this.requester_id = lead._id
@@ -6,38 +6,44 @@ import { map } from 'rxjs/operators';
6
6
  // Logger
7
7
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
8
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
9
10
 
10
11
  @Injectable({
11
12
  providedIn: 'root'
12
13
  })
13
14
  export class CannedResponsesService {
14
15
 
15
- private apiUrl: string;
16
+ private SERVER_BASE_URL: string;
17
+ private tiledeskToken: string;
18
+
16
19
  private logger: LoggerService = LoggerInstance.getInstance();
17
20
 
18
21
  constructor(
19
22
  public http: HttpClient,
20
- public appConfigProvider: AppConfigProvider
23
+ public appStorageService: AppStorageService
21
24
  ) {
22
-
23
25
  this.logger.log('[CANNED-RESPONSES-SERVICE] HELLO !');
24
- this.apiUrl = appConfigProvider.getConfig().apiUrl;
25
- this.logger.log('[CANNED-RESPONSES-SERVICE] apiUrl ', this.apiUrl);
26
+ }
27
+
28
+ initialize(serverBaseUrl: string) {
29
+ this.logger.log('[CANNED-RESPONSES-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
30
+ this.SERVER_BASE_URL = serverBaseUrl;
31
+ this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
26
32
  }
27
33
 
28
34
 
29
- public getAll(token: string, projectid: string) {
30
- const cannedResponsesURL = this.apiUrl + projectid + "/canned/";
31
- this.logger.log('[CANNED-RESPONSES-SERVICE] getCannedResponses - URL ', cannedResponsesURL);
35
+ public getAll(projectid: string) {
36
+ const url = this.SERVER_BASE_URL + projectid + "/canned/";
37
+ this.logger.log('[CANNED-RESPONSES-SERVICE] getCannedResponses - URL ', url);
32
38
 
33
39
  const httpOptions = {
34
40
  headers: new HttpHeaders({
35
41
  'Content-Type': 'application/json',
36
- Authorization: token
42
+ Authorization: this.tiledeskToken
37
43
  })
38
44
  };
39
45
 
40
- return this.http.get(cannedResponsesURL, httpOptions).pipe(map((res: any) => {
46
+ return this.http.get(url, httpOptions).pipe(map((res: any) => {
41
47
  this.logger.log('[CANNED-RESPONSES-SERVICE] getCannedResponses - RES ', res);
42
48
  return res
43
49
  }))
@@ -46,14 +52,14 @@ export class CannedResponsesService {
46
52
  // -------------------------------------------------------------------------------------
47
53
  // @ Create - Save (POST) new canned response
48
54
  // -------------------------------------------------------------------------------------
49
- public add(token: string, projectid: string, title: string, message: string) {
50
- const url = this.apiUrl + projectid + '/canned/'
55
+ public add(projectid: string, title: string, message: string) {
56
+ const url = this.SERVER_BASE_URL + projectid + '/canned/'
51
57
  this.logger.log('[TILEDESK-SERVICE] - CREATE CANNED-RES - URL', url);
52
58
 
53
59
  const httpOptions = {
54
60
  headers: new HttpHeaders({
55
61
  'Content-Type': 'application/json',
56
- Authorization: token
62
+ Authorization: this.tiledeskToken
57
63
  })
58
64
  };
59
65
 
@@ -69,14 +75,14 @@ export class CannedResponsesService {
69
75
 
70
76
  }
71
77
 
72
- public edit(token: string, projectid: string, canned: any){
73
- const cannedResponsesURL = this.apiUrl + projectid + "/canned/"+ canned._id;
78
+ public edit(projectid: string, canned: any){
79
+ const cannedResponsesURL = this.SERVER_BASE_URL + projectid + "/canned/"+ canned._id;
74
80
  this.logger.log('[CANNED-RESPONSES-SERVICE] editCannedResponses - URL ', cannedResponsesURL);
75
81
 
76
82
  const httpOptions = {
77
83
  headers: new HttpHeaders({
78
84
  'Content-Type': 'application/json',
79
- Authorization: token
85
+ Authorization: this.tiledeskToken
80
86
  })
81
87
  };
82
88
 
@@ -91,14 +97,14 @@ export class CannedResponsesService {
91
97
  }))
92
98
  }
93
99
 
94
- public delete(token: string, projectid: string, cannedID: string){
95
- const cannedResponsesURL = this.apiUrl + projectid + "/canned/"+cannedID;
100
+ public delete(projectid: string, cannedID: string){
101
+ const cannedResponsesURL = this.SERVER_BASE_URL + projectid + "/canned/"+cannedID;
96
102
  this.logger.log('[CANNED-RESPONSES-SERVICE] deleteCannedResponses - URL ', cannedResponsesURL);
97
103
 
98
104
  const httpOptions = {
99
105
  headers: new HttpHeaders({
100
106
  'Content-Type': 'application/json',
101
- Authorization: token
107
+ Authorization: this.tiledeskToken
102
108
  })
103
109
  };
104
110
 
@@ -14,6 +14,7 @@ import { map } from 'rxjs/operators';
14
14
  // Logger
15
15
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
16
16
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
17
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
17
18
 
18
19
  @Injectable({
19
20
  providedIn: 'root'
@@ -26,36 +27,41 @@ export class ContactsService {
26
27
  BScontactDetail: BehaviorSubject<UserModel> = new BehaviorSubject<UserModel>(null);
27
28
 
28
29
  // private
29
- private urlRemoteContacts: string;
30
+ private SERVER_BASE_URL: string;
31
+ private tiledeskToken: string;
32
+
30
33
  private contacts: UserModel[];
31
34
  private logger: LoggerService = LoggerInstance.getInstance();
32
35
 
33
36
  constructor(
34
37
  public http: HttpClient,
35
- public appConfigProvider: AppConfigProvider
38
+ public appStorageService: AppStorageService
36
39
  ) {
37
- this.urlRemoteContacts = appConfigProvider.getConfig().apiUrl + 'chat21/contacts';
40
+ this.logger.log('[COPILOT-SERVICE] HELLO !');
38
41
  }
39
42
 
43
+ initialize(serverBaseUrl: string) {
44
+ this.logger.log('[COPILOT-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
45
+ this.SERVER_BASE_URL = serverBaseUrl;
46
+ this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
47
+ }
40
48
 
41
- // initialize() {}
42
49
 
43
50
  /** */
44
- public loadContactsFromUrl(token: string) {
45
- this.contacts = [];
46
- this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl token', token);
47
- this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl urlRemoteContacts', this.urlRemoteContacts)
51
+ public loadContactsFromUrl() {
52
+ const url = this.SERVER_BASE_URL + 'chat21/contacts';
53
+ this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl urlRemoteContacts', url)
48
54
  // if (this.urlRemoteContacts.startsWith('http') && token) {
49
55
  const that = this;
50
56
  const httpOptions = {
51
57
  headers: new HttpHeaders({
52
58
  'Content-Type': 'application/json',
53
- Authorization: token
59
+ Authorization: this.tiledeskToken
54
60
  })
55
61
  };
56
-
57
-
58
- this.http.get<any[]>(this.urlRemoteContacts, httpOptions).subscribe(users => {
62
+
63
+ this.contacts = [];
64
+ this.http.get<any[]>(url, httpOptions).subscribe(users => {
59
65
  this.logger.log('[CONTACT-SERVICE] loadContactsFromUrl users ', users);
60
66
  users.forEach(user => {
61
67
  const member = that.createCompleteUser(user);
@@ -103,24 +109,21 @@ export class ContactsService {
103
109
  * @param token
104
110
  * @param uid
105
111
  */
106
- public loadContactDetail(token: string, uid: string) {
112
+ public loadContactDetail(uid: string) {
107
113
  this.contacts = [];
114
+ const url = this.SERVER_BASE_URL + 'chat21/contacts/' + uid;
108
115
  this.logger.log('[CONTACT-SERVICE] - loadContactDetail - uid ', uid);
109
- this.logger.log('[CONTACT-SERVICE] - loadContactDetail - token ', token);
110
- const urlRemoteContactDetail = this.urlRemoteContacts + '/' + uid;
111
116
  // if (urlRemoteContactDetail.startsWith('http') && token) {
112
117
 
113
118
  const httpOptions = {
114
119
  headers: new HttpHeaders({
115
120
  'Content-Type': 'application/json',
116
- Authorization: token
121
+ Authorization: this.tiledeskToken
117
122
  })
118
123
  };
119
124
  // const postData = {};
120
- this.logger.log('[CONTACT-SERVICE] - loadContactDetail url ', urlRemoteContactDetail);
121
- return this.http
122
- .get(urlRemoteContactDetail, httpOptions)
123
- .pipe(map((res: any) => {
125
+ this.logger.log('[CONTACT-SERVICE] - loadContactDetail url ', url);
126
+ return this.http.get(url, httpOptions).pipe(map((res: any) => {
124
127
  this.logger.log('[CONTACT-SERVICE] - loadContactDetail - loadContactDetail RES ', res);
125
128
  if (res.uid) {
126
129
  let user = this.createCompleteUser(res)