@chat21/chat21-ionic 3.4.13-rc2 → 3.4.13-rc4

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 (44) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/src/app/app.component.ts +7 -6
  4. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +3 -28
  5. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +12 -7
  6. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +2 -1
  7. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +5 -30
  8. package/src/app/chatlib/conversation-detail/message/options/options.component.html +4 -1
  9. package/src/app/chatlib/conversation-detail/message/options/options.component.scss +7 -0
  10. package/src/app/chatlib/conversation-detail/message/options/options.component.ts +41 -8
  11. package/src/app/components/canned-response/canned-response.component.html +8 -3
  12. package/src/app/components/canned-response/canned-response.component.scss +26 -0
  13. package/src/app/components/canned-response/canned-response.component.ts +8 -28
  14. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -4
  15. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +11 -0
  16. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +1 -0
  17. package/src/app/components/conversation-info/info-content/info-content.component.ts +9 -11
  18. package/src/app/components/conversation-info/info-group/info-group.component.ts +2 -10
  19. package/src/app/components/copilot-popover/copilot-popover.component.html +25 -0
  20. package/src/app/components/copilot-popover/copilot-popover.component.scss +101 -0
  21. package/src/app/components/copilot-popover/copilot-popover.component.spec.ts +24 -0
  22. package/src/app/components/copilot-popover/copilot-popover.component.ts +81 -0
  23. package/src/app/components/copilot-suggestions/copilot-suggestions.component.ts +37 -18
  24. package/src/app/components/navbar/navbar.component.ts +4 -4
  25. package/src/app/components/project-item/project-item.component.ts +3 -4
  26. package/src/app/modals/create-canned-response/create-canned-response.page.ts +1 -1
  27. package/src/app/pages/contacts-directory/contacts-directory.page.ts +5 -4
  28. package/src/app/pages/conversation-detail/conversation-detail.module.ts +3 -1
  29. package/src/app/pages/conversation-detail/conversation-detail.page.html +6 -3
  30. package/src/app/pages/conversation-detail/conversation-detail.page.ts +29 -28
  31. package/src/app/pages/conversations-list/conversations-list.page.ts +1 -1
  32. package/src/app/services/canned-responses/canned-responses.service.ts +22 -16
  33. package/src/app/services/contacts/contacts.service.ts +23 -20
  34. package/src/app/services/copilot/copilot.service.ts +46 -19
  35. package/src/app/services/projects/{projects.service.spec.ts → project.service.spec.ts} +2 -2
  36. package/src/app/services/projects/project.service.ts +68 -0
  37. package/src/app/services/tiledesk/tiledesk.service.ts +0 -35
  38. package/src/app/utils/project-utils.ts +140 -0
  39. package/src/assets/i18n/en.json +4 -1
  40. package/src/assets/i18n/it.json +4 -1
  41. package/src/chat21-core/utils/constants.ts +3 -0
  42. package/src/global.scss +6 -0
  43. package/src/variables.scss +1 -0
  44. package/src/app/services/projects/projects.service.ts +0 -43
@@ -0,0 +1,101 @@
1
+ #copilot-container{
2
+ margin: 10px;
3
+ display: flex;
4
+ flex-direction: column;
5
+ gap: 15px;
6
+
7
+
8
+ ion-header{
9
+ display: flex;
10
+ flex-direction: column;
11
+ gap: 5px;
12
+
13
+ .main-title{
14
+ background: linear-gradient(135deg, #217bfe 0, #078efb 33%, #ac87eb 100%);
15
+ background-clip: text;
16
+ inline-size: fit-content;
17
+ color: transparent;
18
+ font-weight: 500;
19
+ }
20
+
21
+ .title{
22
+ font-weight: 500;
23
+ }
24
+ }
25
+
26
+ ion-content{
27
+
28
+
29
+ .content-container{
30
+
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ gap: 10px;
35
+ }
36
+
37
+
38
+ .text-message {
39
+ position: relative;
40
+ // margin: 0 35px;
41
+ // width: calc(100% - 70px);
42
+ // ----- new after adding canned open /close canned responses
43
+ // margin: 0 70px;
44
+ // width: calc(100% - 100px);
45
+ // ----- new after adding emoji picker
46
+ // margin: 0 108px;
47
+ width: 100%; //calc(100% - 140px);
48
+ ion-textarea {
49
+ // border-radius: 4px;
50
+ border-radius: 20px; // NK edited
51
+ padding: 0;
52
+ margin: 0;
53
+ height: auto;
54
+ overflow: auto;
55
+ // min-height: 30px;
56
+ min-height: 74px; // NK edited
57
+ max-height: 184px;
58
+ background-color: var(--textarea-background);
59
+ color: var(--textarea-color);
60
+ --placeholder-color: var(--textarea-placeholder-color);
61
+ // --padding-top: 5px; // NK edited
62
+ --padding-top: 8px;
63
+ --padding-bottom: 5px;
64
+ --padding-end: 5px;
65
+ // --padding-start: 5px; // NK edited
66
+ --padding-start: 10px;
67
+ line-height: 1.34;
68
+ font-size: 13px;
69
+ }
70
+ }
71
+ }
72
+
73
+
74
+ ion-footer{
75
+ display: flex;
76
+ justify-content: center;
77
+
78
+ ion-button{
79
+ background-color: var(--icon-color);
80
+ color: var(--bacis-white);
81
+ font-size: 11px;
82
+ margin: 2px;
83
+ padding-bottom: 0px;
84
+ --padding-start: 0px;
85
+ --ripple-color: transparent;
86
+ text-transform: unset;
87
+ height: 25px;
88
+ border-radius: 4px;
89
+ &.active{
90
+ color: var(--basic-blue);
91
+ fill: var(--basic-blue);
92
+ }
93
+ ion-icon{
94
+ margin-right: 4px;
95
+ margin-left: 4px;
96
+ }
97
+ }
98
+ }
99
+
100
+
101
+ }
@@ -0,0 +1,24 @@
1
+ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+ import { IonicModule } from '@ionic/angular';
3
+
4
+ import { CopilotPopoverComponent } from './copilot-popover.component';
5
+
6
+ describe('CopilotPopoverComponent', () => {
7
+ let component: CopilotPopoverComponent;
8
+ let fixture: ComponentFixture<CopilotPopoverComponent>;
9
+
10
+ beforeEach(waitForAsync(() => {
11
+ TestBed.configureTestingModule({
12
+ declarations: [ CopilotPopoverComponent ],
13
+ imports: [IonicModule.forRoot()]
14
+ }).compileComponents();
15
+
16
+ fixture = TestBed.createComponent(CopilotPopoverComponent);
17
+ component = fixture.componentInstance;
18
+ fixture.detectChanges();
19
+ }));
20
+
21
+ it('should create', () => {
22
+ expect(component).toBeTruthy();
23
+ });
24
+ });
@@ -0,0 +1,81 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { PopoverController } from '@ionic/angular';
3
+ import { MessageModel } from 'src/chat21-core/models/message';
4
+ import { UserModel } from 'src/chat21-core/models/user';
5
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
6
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
7
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
8
+ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
9
+
10
+ @Component({
11
+ selector: 'app-copilot-popover',
12
+ templateUrl: './copilot-popover.component.html',
13
+ styleUrls: ['./copilot-popover.component.scss'],
14
+ })
15
+ export class CopilotPopoverComponent implements OnInit {
16
+
17
+ @Input() message: MessageModel
18
+
19
+ text: string;
20
+ loggedUser: UserModel
21
+
22
+ public translationsMap: Map<string, string>;
23
+ private logger: LoggerService = LoggerInstance.getInstance()
24
+
25
+ constructor(
26
+ private ctr: PopoverController,
27
+ private tiledeskAuthService: TiledeskAuthService,
28
+ private customTranslateService: CustomTranslateService,
29
+ ) { }
30
+
31
+ ngOnInit() {
32
+ this.logger.debug('[COPILOT-POPOVER] ngOnInit message data:', this.message)
33
+ this.loggedUser = this.tiledeskAuthService.getCurrentUser();
34
+ this.text = this.message.text
35
+ this.initTranslations();
36
+ }
37
+
38
+ onClose(){
39
+ this.ctr.dismiss()
40
+ }
41
+
42
+ initTranslations(){
43
+ let keys= [
44
+ "HELLO",
45
+ "COPILOT.ASK_AI",
46
+ "COPILOT.INSERT_PROMPT_HERE",
47
+ "COPILOT.HOW_CAN_I_HELP_YOU"
48
+ ]
49
+ this.translationsMap = this.customTranslateService.translateLanguage(keys)
50
+ }
51
+
52
+ onClickCopilot(){
53
+ this.logger.debug('[COPILOT-POPOVER] onClickCopilot')
54
+ this.ctr.dismiss({text: this.text})
55
+ }
56
+
57
+
58
+ ionChange(e: any) {
59
+ this.logger.log("[COPILOT-POPOVER] ionChange event ", e);
60
+ // this.logger.log("[CONVS-DETAIL][MSG-TEXT-AREA] ionChange detail.value ", e.detail.value);
61
+
62
+ const message = e.detail.value
63
+ this.logger.log("[COPILOT-POPOVER] [MSG-TEXT-AREA] ionChange message ", message);
64
+ // this.logger.log("[CONVS-DETAIL] [MSG-TEXT-AREA] ionChange this.messageString ", this.messageString);
65
+ const footerSelectionHeight = 33
66
+ const height = e.target.offsetHeight + footerSelectionHeight + 20; // nk added +20
67
+
68
+ // this.eventChangeTextArea.emit({ msg: message, offsetHeight: height });
69
+ }
70
+
71
+ ionFocus(){
72
+ this.logger.log("[CONVS-DETAIL][MSG-TEXT-AREA] ionFocus event ");
73
+ }
74
+
75
+ onKeydown(e: any, text: string) {
76
+ this.logger.log("[COPILOT-POPOVER] - returnChangeTextArea - onKeydown in MSG-TEXT-AREA event", e)
77
+ this.logger.log("[COPILOT-POPOVER] - returnChangeTextArea - onKeydown in MSG-TEXT-AREA text", text)
78
+ }
79
+
80
+
81
+ }
@@ -1,3 +1,4 @@
1
+ import { AppConfigProvider } from 'src/app/services/app-config';
1
2
  import { filter } from 'rxjs/operators';
2
3
  import { Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output, SimpleChange } from '@angular/core';
3
4
  import { CopilotService } from 'src/app/services/copilot/copilot.service';
@@ -16,6 +17,7 @@ import { getProjectIdSelectedConversation } from 'src/chat21-core/utils/utils';
16
17
  export class CopilotSuggestionsComponent implements OnInit {
17
18
 
18
19
  // @Input() tagsCannedFilter: any = []
20
+ @Input() question: string;
19
21
  @Input() conversationWith: string;
20
22
  @Input() conversationWithFullname: string;
21
23
  @Input() currentString: string;
@@ -38,19 +40,23 @@ export class CopilotSuggestionsComponent implements OnInit {
38
40
  public tiledeskAuthService: TiledeskAuthService,
39
41
  public tiledeskService: TiledeskService,
40
42
  public copilotService: CopilotService,
43
+ public appConfigProvider: AppConfigProvider,
41
44
  public el: ElementRef
42
- ) { }
45
+ ) {
46
+ const serverBaseUrl = this.appConfigProvider.getConfig().apiUrl
47
+ this.copilotService.initialize(serverBaseUrl)
48
+ }
43
49
 
44
50
  ngOnInit() {
45
51
  this.loggedUser = this.tiledeskAuthService.getCurrentUser()
46
52
  }
47
53
 
48
54
  ngOnChanges(changes: SimpleChange){
49
- this.logger.debug('[COPILOT] - loadTagsCanned strSearch ', this.currentString)
50
- if(changes && changes['conversationWith'] && (changes['conversationWith'].previousValue !== changes['conversationWith'].currentValue)){
51
- this.projectID = getProjectIdSelectedConversation(this.conversationWith)
52
- }
53
- this.loadSuggestions(this.conversationWith)
55
+ this.logger.debug('[COPILOT] - loadTagsCanned strSearch ', this.currentString)
56
+ if(changes && changes['conversationWith'] && (changes['conversationWith'].previousValue !== changes['conversationWith'].currentValue)){
57
+ this.projectID = getProjectIdSelectedConversation(this.conversationWith)
58
+ }
59
+ this.loadSuggestions(this.conversationWith)
54
60
  }
55
61
 
56
62
 
@@ -89,22 +95,35 @@ export class CopilotSuggestionsComponent implements OnInit {
89
95
 
90
96
 
91
97
  getAndShowSuggestions(projectId) {
92
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
93
98
  this.logger.log('[COPILOT] - loadTagsCanned tagsCanned.length', this.suggestions.length)
94
99
  //if(this.tagsCanned.length <= 0 ){
95
100
  this.suggestions = []
96
101
  this.showLoading = true;
97
- this.copilotService.getAll(tiledeskToken, projectId, this.conversationWith).subscribe((res) => {
98
- this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses RES', res)
99
- this.suggestions = res.map(el => ({ ...el, disabled : true }))
100
- this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses tagsCannedCount', this.suggestions)
101
- }, (error) => {
102
- this.logger.error('[COPILOT] - loadTagsCanned getCannedResponses - ERROR ', error)
103
- }, () => {
104
- this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses * COMPLETE *')
105
- this.showLoading = false
106
- this.onLoadedSuggestions.emit(this.suggestions)
107
- })
102
+ if(this.question && this.question !== ''){
103
+ this.copilotService.getAllFromQuestion(this.question, projectId, this.conversationWith).subscribe((res) => {
104
+ this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses RES', res)
105
+ this.suggestions = res.map(el => ({ ...el, disabled : true }))
106
+ this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses tagsCannedCount', this.suggestions)
107
+ }, (error) => {
108
+ this.logger.error('[COPILOT] - loadTagsCanned getCannedResponses - ERROR ', error)
109
+ }, () => {
110
+ this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses * COMPLETE *')
111
+ this.showLoading = false
112
+ this.onLoadedSuggestions.emit(this.suggestions)
113
+ })
114
+ } else {
115
+ this.copilotService.getAll(projectId, this.conversationWith).subscribe((res) => {
116
+ this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses RES', res)
117
+ this.suggestions = res.map(el => ({ ...el, disabled : true }))
118
+ this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses tagsCannedCount', this.suggestions)
119
+ }, (error) => {
120
+ this.logger.error('[COPILOT] - loadTagsCanned getCannedResponses - ERROR ', error)
121
+ }, () => {
122
+ this.logger.log('[COPILOT] - loadTagsCanned getCannedResponses * COMPLETE *')
123
+ this.showLoading = false
124
+ this.onLoadedSuggestions.emit(this.suggestions)
125
+ })
126
+ }
108
127
  }
109
128
 
110
129
 
@@ -1,7 +1,7 @@
1
1
  import { AppConfigProvider } from 'src/app/services/app-config';
2
2
  import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
3
3
  import { EventsService } from 'src/app/services/events-service';
4
- import { ProjectsService } from './../../services/projects/projects.service';
4
+ import { ProjectService } from '../../services/projects/project.service';
5
5
  import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
6
6
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
7
7
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
@@ -33,7 +33,7 @@ export class NavbarComponent implements OnInit {
33
33
  public MT: boolean;
34
34
 
35
35
  constructor(
36
- private projectsService: ProjectsService,
36
+ private projectService: ProjectService,
37
37
  private tiledeskAuthService: TiledeskAuthService,
38
38
  private appConfigProvider: AppConfigProvider,
39
39
  private translateService: CustomTranslateService,
@@ -78,7 +78,7 @@ export class NavbarComponent implements OnInit {
78
78
 
79
79
  getProjects() {
80
80
  this.logger.log('[NAVBAR] calling getProjects ... ');
81
- this.projectsService.getProjects(this.tiledeskToken).subscribe((projects: any) => {
81
+ this.projectService.getProjects().subscribe((projects: any) => {
82
82
  this.logger.log('[NAVBAR] getProjects PROJECTS ', projects);
83
83
  if (projects) {
84
84
  // this.projects = projects;
@@ -170,7 +170,7 @@ export class NavbarComponent implements OnInit {
170
170
  url = baseUrl + '#/project/' + this.project.id_project.id + '/project-settings/general' + '?token=' + this.tiledeskToken
171
171
  }else if(event ==='allProjects'){
172
172
  url = baseUrl + '#/projects/' + '?token=' + this.tiledeskToken
173
- }else if('addProject'){
173
+ }else if(event === 'addProject'){
174
174
  url = baseUrl + '#/create-new-project/' + '?token=' + this.tiledeskToken
175
175
  }
176
176
  console.log('onClickDropdownOption-->', url)
@@ -14,6 +14,7 @@ import { WebSocketJs } from 'src/app/services/websocket/websocket-js';
14
14
  import { AppConfigProvider } from 'src/app/services/app-config';
15
15
  import { ConvertRequestToConversation } from 'src/chat21-core/utils/convertRequestToConversation';
16
16
  import { compareValues } from 'src/chat21-core/utils/utils';
17
+ import { ProjectService } from 'src/app/services/projects/project.service';
17
18
 
18
19
  @Component({
19
20
  selector: 'app-project-item',
@@ -46,7 +47,7 @@ export class ProjectItemComponent implements OnInit {
46
47
  public appStorageService: AppStorageService,
47
48
  private translateService: CustomTranslateService,
48
49
  public tiledeskAuthService: TiledeskAuthService,
49
- public tiledeskService: TiledeskService,
50
+ public projectService: ProjectService,
50
51
  public webSocketJs: WebSocketJs,
51
52
  private appConfigProvider: AppConfigProvider,
52
53
  public events: EventsService,
@@ -174,9 +175,7 @@ export class ProjectItemComponent implements OnInit {
174
175
 
175
176
  if (!stored_project || stored_project === 'undefined') {
176
177
  this.logger.log('PROJECT-ITEM - THERE IS NOT STORED LAST PROJECT OR IS UNDEFINED ', stored_project)
177
- const tiledeskToken = this.appStorageService.getItem('tiledeskToken');
178
- this.logger.log('[PROJECT-ITEM] - GET PROJECTS - tiledeskToken', tiledeskToken);
179
- this.tiledeskService.getProjects(tiledeskToken).subscribe(projects => {
178
+ this.projectService.getProjects().subscribe(projects => {
180
179
  this.logger.log('[PROJECT-ITEM - GET PROJECTS - RES', projects);
181
180
 
182
181
  this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTS - RES this.project', this.project);
@@ -177,7 +177,7 @@ export class CreateCannedResponsePage implements OnInit {
177
177
  this.logger.log('[CREATE-CANNED-RES] - CREATE CANNED RESP - MSG ', message);
178
178
  this.logger.log('[CREATE-CANNED-RES] - CREATE CANNED RESP - TITLE ', title);
179
179
 
180
- this.cannedResponsesService.add(this.tiledeskToken, this.prjctID, title.trim(), message.trim()).subscribe((responses: any) => {
180
+ this.cannedResponsesService.add(this.prjctID, title.trim(), message.trim()).subscribe((responses: any) => {
181
181
  this.logger.log('[CREATE-CANNED-RES] - CREATE CANNED RESP - RES ', responses);
182
182
  }, (error) => {
183
183
  this.logger.error('[CREATE-CANNED-RES]- CREATE CANNED RESP - ERROR ', error);
@@ -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;
@@ -31,22 +31,23 @@ export class ContactsDirectoryPage implements OnInit {
31
31
  private navService: NavProxyService,
32
32
  // private contactsDirectoryService: ContactsDirectoryService,
33
33
  private contactsService: ContactsService,
34
+ private appConfigProvider: AppConfigProvider,
34
35
  public events: EventsService
35
36
  ) {
37
+ const serverBaseUrl = this.appConfigProvider.getConfig().apiUrl
38
+ this.contactsService.initialize(serverBaseUrl)
36
39
  }
37
40
 
38
41
  ngOnInit() {
39
- this.logger.log('[CONTACT-DIRECTORY-PAGE] - TOKEN (ngOnInit)', this.token);
40
42
  this.initialize();
41
43
  }
42
44
 
43
45
  /** */
44
46
  initialize() {
45
47
  this.logger.log('[CONTACT-DIRECTORY-PAGE] - initialize');
46
- this.logger.log('[CONTACT-DIRECTORY-PAGE] - token: ', this.token);
47
48
  this.contacts = [];
48
49
  this.initSubscriptions();
49
- this.contactsService.loadContactsFromUrl(this.token);
50
+ this.contactsService.loadContactsFromUrl();
50
51
  }
51
52
 
52
53
  /**
@@ -44,6 +44,7 @@ import { OptionsComponent } from 'src/app/chatlib/conversation-detail/message/op
44
44
  import { UserTypingComponent } from 'src/chat21-core/utils/user-typing/user-typing.component';
45
45
  import { AvatarProfileComponent } from 'src/app/components/utils/avatar-profile/avatar-profile.component';
46
46
  import { CopilotSuggestionsComponent } from 'src/app/components/copilot-suggestions/copilot-suggestions.component';
47
+ import { CopilotPopoverComponent } from 'src/app/components/copilot-popover/copilot-popover.component';
47
48
 
48
49
 
49
50
  @NgModule({
@@ -66,7 +67,7 @@ import { CopilotSuggestionsComponent } from 'src/app/components/copilot-suggesti
66
67
  MomentModule
67
68
  ],
68
69
  // entryComponents: [MessageTextAreaComponent],
69
- entryComponents: [ BubbleInfoPopoverComponent],
70
+ entryComponents: [ BubbleInfoPopoverComponent, CopilotPopoverComponent],
70
71
  declarations: [
71
72
  ConversationDetailPage,
72
73
  //******** COMPONENTS - init ********//
@@ -90,6 +91,7 @@ import { CopilotSuggestionsComponent } from 'src/app/components/copilot-suggesti
90
91
  ReturnReceiptComponent,
91
92
  OptionsComponent,
92
93
  BubbleInfoPopoverComponent,
94
+ CopilotPopoverComponent,
93
95
  UserTypingComponent,
94
96
  // --------- footer --------- //
95
97
  MessageTextAreaComponent,
@@ -61,7 +61,7 @@
61
61
  here is ignored
62
62
  </span>
63
63
 
64
- <div class="overlay" *ngIf="SHOW_CANNED_RESPONSES || SHOW_COPILOT_SUGGESTIONS" (click)="this.SHOW_COPILOT_SUGGESTIONS=!this.SHOW_COPILOT_SUGGESTIONS; this.SHOW_CANNED_RESPONSES = !this.SHOW_CANNED_RESPONSES"></div>
64
+ <div class="overlay" *ngIf="SHOW_CANNED_RESPONSES || SHOW_COPILOT_SUGGESTIONS" (click)="this.SHOW_COPILOT_SUGGESTIONS=false; this.SHOW_CANNED_RESPONSES=false"></div>
65
65
 
66
66
  <ng-template #content_welcome>
67
67
  <!-- <div class="messageFirst">
@@ -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"
@@ -183,6 +184,7 @@
183
184
 
184
185
  <copilot-suggestions *ngIf="SHOW_COPILOT_SUGGESTIONS"
185
186
  id="copilot"
187
+ [question]="copilotQuestion"
186
188
  [conversationWith]="conversationWith"
187
189
  [conversationWithFullname]="conversationWithFullname"
188
190
  [currentString]="messageStr"
@@ -202,7 +204,8 @@
202
204
  [channelType]="channelType"
203
205
  [channel]="conversation?.attributes?.request_channel"
204
206
  [tagsCannedFilter]="tagsCannedFilter"
205
- [areVisibleCAR]="areVisibleCAR"
207
+ [areVisibleCAR]="areVisibleCAR"
208
+ [isCopilotEnabled]="isCopilotEnabled"
206
209
  [supportMode]="supportMode"
207
210
  [leadInfo]="leadInfo"
208
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;
@@ -162,6 +165,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
162
165
  conversation: ConversationModel;
163
166
  USER_ROLE: string;
164
167
 
168
+ /**COPILOT : start */
169
+ copilotQuestion: string = '';
170
+ /**COPILOT : end */
171
+
165
172
  isMine = isMine
166
173
  isInfo = isInfo
167
174
  isFirstMessage = isFirstMessage
@@ -230,10 +237,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
230
237
  public presenceService: PresenceService,
231
238
  public toastController: ToastController,
232
239
  public tiledeskService: TiledeskService,
240
+ public projectService: ProjectService,
233
241
  private networkService: NetworkService,
234
242
  private events: EventsService,
235
243
  private webSocketService: WebsocketService,
236
- private sanitizer: DomSanitizer,
244
+ public projectPlanUtils: ProjectPlanUtils,
237
245
  private g: Globals,
238
246
  ) {
239
247
  // Change list on date change
@@ -258,7 +266,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
258
266
  this.getConversations();
259
267
  this.watchToConnectionStatus();
260
268
  this.getOSCODE();
261
- this.getStoredProjectAndUserRole();
269
+ this.listenToEventServiceEvents();
262
270
  this.listenToDsbrdPostMsgs();
263
271
  }
264
272
 
@@ -297,7 +305,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
297
305
  }
298
306
 
299
307
 
300
- getStoredProjectAndUserRole() {
308
+ listenToEventServiceEvents() {
301
309
  this.events.subscribe('storage:last_project', project => {
302
310
  this.logger.log('[CONVS-DETAIL] stored_project ', project)
303
311
  if (project && project !== 'undefined') {
@@ -305,6 +313,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
305
313
  this.logger.log('[CONVS-DETAIL] USER_ROLE ', this.USER_ROLE)
306
314
  }
307
315
  });
316
+
317
+ this.events.subscribe('copilot:new_question', data => {
318
+ this.logger.log('[CONVS-DETAIL] copilot:new_question ', data)
319
+ if(data?.text){
320
+ this.copilotQuestion = data.text
321
+ this.SHOW_COPILOT_SUGGESTIONS = !this.SHOW_COPILOT_SUGGESTIONS
322
+ }
323
+ })
308
324
  }
309
325
 
310
326
  getConversations() {
@@ -486,6 +502,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
486
502
  this.isEmailEnabled = (this.appConfigProvider.getConfig().emailSection === 'true' || this.appConfigProvider.getConfig().emailSection === true) ? true : false;
487
503
  this.isWhatsappTemplatesEnabled = (this.appConfigProvider.getConfig().whatsappTemplatesSection === 'true' || this.appConfigProvider.getConfig().whatsappTemplatesSection === true) ? true : false;
488
504
 
505
+ this.cannedResponsesService.initialize(appconfig.apiUrl)
506
+
489
507
  if (checkPlatformIsMobile()) {
490
508
  this.isMobile = true
491
509
  // this.openInfoConversation = false; // indica se è aperto il box info conversazione
@@ -532,7 +550,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
532
550
  this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES + projectId', res, res.id_project)
533
551
  if (res) {
534
552
  const projectId = res.id_project
535
- this.getProjectById(tiledeskToken, projectId)
553
+ this.getProjectById(projectId)
536
554
  }
537
555
  }, (error) => {
538
556
  this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',conversationWith, error)
@@ -546,13 +564,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
546
564
 
547
565
  }
548
566
 
549
- getProjectById(tiledeskToken, projectId) {
550
- this.tiledeskService.getProjectById(tiledeskToken, projectId).subscribe((project) => {
567
+ getProjectById(projectId) {
568
+ this.projectService.getProjectById(projectId).subscribe(async (project) => {
551
569
  this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', project)
552
570
  if (project) {
553
571
  const projectId = project.id_project
554
- this.canShowCanned = this.checkPlanIsExpired(project)
572
+ this.canShowCanned = this.projectPlanUtils.checkPlanIsExpired(project)
555
573
  this.offlineMsgEmail = this.checkOfflineMsgEmailIsEnabled(project)
574
+ this.isCopilotEnabled = this.projectPlanUtils.checkProjectProfileFeature(project, 'copilot')
556
575
  }
557
576
  }, (error) => {
558
577
  this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
@@ -565,27 +584,6 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
565
584
  }
566
585
 
567
586
 
568
- checkPlanIsExpired(project: Project): boolean {
569
- let check: boolean = false
570
-
571
- //case FREE plan
572
- if(project && project.trialExpired && project.profile.type=== 'trial'){
573
- check = true
574
- }else if(project && !project.trialExpired && project.profile.type=== 'trial'){
575
- check = false
576
- }
577
-
578
- //case PAYMENT plan
579
- if(project && project.isActiveSubscription && project.profile.type=== 'payment'){
580
- check = true
581
- }else if(project && !project.isActiveSubscription && project.profile.type=== 'payment'){
582
- check = false
583
- }
584
-
585
- return check
586
- }
587
-
588
-
589
587
  checkOfflineMsgEmailIsEnabled(project: Project): boolean {
590
588
  let check: boolean = true
591
589
 
@@ -1641,6 +1639,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1641
1639
  onClickOpenCannedResponses($event) {
1642
1640
  this.logger.log('[CONVS-DETAIL] - onClickOpenCannedResponses ', $event)
1643
1641
  this.SHOW_CANNED_RESPONSES = !this.SHOW_CANNED_RESPONSES
1642
+ this.SHOW_COPILOT_SUGGESTIONS = false;
1644
1643
 
1645
1644
  //HIDE_CANNED_RESPONSES: true --> not show CANNED component
1646
1645
  //HIDE_CANNED_RESPONSES: false --> show CANNED component and place '/' char in textarea
@@ -1886,6 +1885,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1886
1885
  }
1887
1886
  if(event === 'copilot'){
1888
1887
  this.SHOW_COPILOT_SUGGESTIONS = !this.SHOW_COPILOT_SUGGESTIONS
1888
+ this.SHOW_CANNED_RESPONSES = false
1889
+ this.copilotQuestion = ''
1889
1890
  }
1890
1891
  }
1891
1892
 
@@ -911,7 +911,7 @@ export class ConversationListPage implements OnInit {
911
911
  isMobile: this.isMobile
912
912
  })
913
913
  } else {
914
- this.navService.push(ContactsDirectoryPage, { token: TOKEN })
914
+ this.navService.push(ContactsDirectoryPage, {})
915
915
  }
916
916
  }
917
917