@chat21/chat21-ionic 3.0.61-rc2 → 3.0.61-rc24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +101 -0
- package/README.md +6 -0
- package/angular.json +2 -0
- package/config.xml +4 -5
- package/deploy_pre.sh +27 -27
- package/deploy_prod.sh +5 -1
- package/env.sample +2 -2
- package/package.json +8 -8
- package/resources/{Android → android}/icon/drawable-hdpi-icon.png +0 -0
- package/resources/{Android → android}/icon/drawable-ldpi-icon.png +0 -0
- package/resources/{Android → android}/icon/drawable-mdpi-icon.png +0 -0
- package/resources/{Android → android}/icon/drawable-xhdpi-icon.png +0 -0
- package/resources/{Android → android}/icon/drawable-xxhdpi-icon.png +0 -0
- package/resources/{Android → android}/icon/drawable-xxxhdpi-icon.png +0 -0
- package/resources/{Android → android}/icon.png +0 -0
- package/resources/{Android → android}/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/{Android → android}/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/{Android → android}/splash.png +0 -0
- package/src/app/app-routing.module.ts +15 -0
- package/src/app/app.component.html +4 -3
- package/src/app/app.component.scss +6 -1
- package/src/app/app.component.ts +36 -22
- package/src/app/app.module.ts +11 -3
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +36 -25
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +160 -50
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +108 -18
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +21 -36
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.scss +19 -7
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +35 -40
- package/src/app/chatlib/conversation-detail/message/message-attachment/message-attachment.component.scss +1 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +6 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +89 -21
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +37 -33
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +7 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +148 -63
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +59 -22
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +32 -9
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +107 -23
- package/src/app/components/conversation-info/info-content/info-content.component.html +2 -2
- package/src/app/components/ddp-header/ddp-header.component.html +11 -4
- package/src/app/components/ddp-header/ddp-header.component.ts +94 -19
- package/src/app/components/project-item/project-item.component.html +2 -2
- package/src/app/components/project-item/project-item.component.scss +1 -1
- package/src/app/components/project-item/project-item.component.ts +1 -1
- package/src/app/components/sidebar/sidebar.component.html +151 -86
- package/src/app/components/sidebar/sidebar.component.scss +72 -4
- package/src/app/components/sidebar/sidebar.component.ts +211 -72
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +29 -10
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +54 -29
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +176 -97
- package/src/app/pages/conversation-detail/conversation-detail.module.ts +6 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +20 -10
- package/src/app/pages/conversation-detail/conversation-detail.page.scss +28 -0
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +1131 -777
- package/src/app/pages/conversations-list/conversations-list.module.ts +2 -1
- package/src/app/pages/conversations-list/conversations-list.page.html +9 -6
- package/src/app/pages/conversations-list/conversations-list.page.scss +9 -1
- package/src/app/pages/conversations-list/conversations-list.page.ts +740 -440
- package/src/app/pages/create-canned-response/create-canned-response-routing.module.ts +17 -0
- package/src/app/pages/create-canned-response/create-canned-response.module.ts +30 -0
- package/src/app/pages/create-canned-response/create-canned-response.page.html +150 -0
- package/src/app/pages/create-canned-response/create-canned-response.page.scss +55 -0
- package/src/app/pages/create-canned-response/create-canned-response.page.spec.ts +24 -0
- package/src/app/pages/create-canned-response/create-canned-response.page.ts +319 -0
- package/src/app/pages/create-requester/create-requester-routing.module.ts +17 -0
- package/src/app/pages/create-requester/create-requester.module.ts +28 -0
- package/src/app/pages/create-requester/create-requester.page.html +67 -0
- package/src/app/pages/create-requester/create-requester.page.scss +30 -0
- package/src/app/pages/create-requester/create-requester.page.spec.ts +24 -0
- package/src/app/pages/create-requester/create-requester.page.ts +138 -0
- package/src/app/pages/create-ticket/create-ticket-routing.module.ts +17 -0
- package/src/app/pages/create-ticket/create-ticket.module.ts +28 -0
- package/src/app/pages/create-ticket/create-ticket.page.html +171 -0
- package/src/app/pages/create-ticket/create-ticket.page.scss +52 -0
- package/src/app/pages/create-ticket/create-ticket.page.spec.ts +24 -0
- package/src/app/pages/create-ticket/create-ticket.page.ts +432 -0
- package/src/app/pages/loader-preview/loader-preview.page.ts +226 -166
- package/src/app/pages/profile-info/profile-info.page.html +2 -2
- package/src/app/pages/profile-info/profile-info.page.scss +13 -2
- package/src/app/services/tiledesk/tiledesk.service.ts +209 -0
- package/src/app/shared/shared.module.ts +1 -1
- package/src/app/utils/scrollbar-theme.directive.ts +58 -24
- package/src/assets/i18n/de.json +46 -7
- package/src/assets/i18n/en.json +42 -3
- package/src/assets/i18n/es.json +42 -3
- package/src/assets/i18n/fr.json +45 -6
- package/src/assets/i18n/it.json +42 -3
- package/src/assets/i18n/pt.json +42 -3
- package/src/assets/i18n/ru.json +43 -4
- package/src/assets/i18n/sr.json +265 -0
- package/src/assets/i18n/tr.json +42 -4
- package/src/assets/images/default-avatar-x-select.png +0 -0
- package/src/assets/images/language_flag/hr.png +0 -0
- package/src/assets/images/language_flag/sr.png +0 -0
- package/src/assets/images/priority_icons/high.svg +3 -0
- package/src/assets/images/priority_icons/high_v2.svg +14 -0
- package/src/assets/images/priority_icons/low.svg +10 -0
- package/src/assets/images/priority_icons/low_v2.svg +14 -0
- package/src/assets/images/priority_icons/medium.svg +16 -0
- package/src/assets/images/priority_icons/medium_v2.svg +11 -0
- package/src/assets/images/priority_icons/urgent.svg +4 -0
- package/src/assets/images/priority_icons/urgent_v2.svg +16 -0
- package/src/chat-config-pre-test.json +1 -1
- package/src/chat-config-template.json +5 -4
- package/src/chat-config.json +2 -1
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +8 -3
- package/src/chat21-core/utils/constants.ts +6 -1
- package/src/chat21-core/utils/utils-message.ts +19 -0
- package/src/global.scss +65 -111
- package/publish_pre.sh +0 -33
- package/publish_prod.sh +0 -33
|
@@ -1,155 +1,195 @@
|
|
|
1
|
-
import { URL_SOUND_LIST_CONVERSATION } from './../../../chat21-core/utils/constants'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { URL_SOUND_LIST_CONVERSATION } from './../../../chat21-core/utils/constants'
|
|
2
|
+
import {
|
|
3
|
+
Component,
|
|
4
|
+
OnInit,
|
|
5
|
+
OnDestroy,
|
|
6
|
+
AfterViewInit,
|
|
7
|
+
ViewChild,
|
|
8
|
+
ElementRef,
|
|
9
|
+
Directive,
|
|
10
|
+
HostListener,
|
|
11
|
+
ChangeDetectorRef,
|
|
12
|
+
Renderer2,
|
|
13
|
+
} from '@angular/core'
|
|
14
|
+
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'
|
|
15
|
+
import {
|
|
16
|
+
ModalController,
|
|
17
|
+
ToastController,
|
|
18
|
+
PopoverController,
|
|
19
|
+
Platform,
|
|
20
|
+
ActionSheetController,
|
|
21
|
+
NavController,
|
|
22
|
+
IonContent,
|
|
23
|
+
IonTextarea,
|
|
24
|
+
IonButton,
|
|
25
|
+
} from '@ionic/angular'
|
|
5
26
|
|
|
6
27
|
// models
|
|
7
|
-
import { UserModel } from 'src/chat21-core/models/user'
|
|
8
|
-
import { MessageModel } from 'src/chat21-core/models/message'
|
|
9
|
-
import { ConversationModel } from 'src/chat21-core/models/conversation'
|
|
10
|
-
import { GroupModel } from 'src/chat21-core/models/group'
|
|
28
|
+
import { UserModel } from 'src/chat21-core/models/user'
|
|
29
|
+
import { MessageModel } from 'src/chat21-core/models/message'
|
|
30
|
+
import { ConversationModel } from 'src/chat21-core/models/conversation'
|
|
31
|
+
import { GroupModel } from 'src/chat21-core/models/group'
|
|
11
32
|
|
|
12
33
|
// services
|
|
13
|
-
import { ChatManager } from 'src/chat21-core/providers/chat-manager'
|
|
14
|
-
import { AppConfigProvider } from '../../services/app-config'
|
|
15
|
-
|
|
16
|
-
import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service'
|
|
17
|
-
import { TypingService } from 'src/chat21-core/providers/abstract/typing.service'
|
|
18
|
-
import { ConversationHandlerBuilderService } from 'src/chat21-core/providers/abstract/conversation-handler-builder.service'
|
|
19
|
-
import { GroupsHandlerService } from 'src/chat21-core/providers/abstract/groups-handler.service'
|
|
20
|
-
import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service'
|
|
21
|
-
import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service'
|
|
22
|
-
import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service'
|
|
23
|
-
import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service'
|
|
24
|
-
import { ContactsService } from 'src/app/services/contacts/contacts.service'
|
|
25
|
-
import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service'
|
|
26
|
-
import { compareValues } from '../../../chat21-core/utils/utils'
|
|
27
|
-
import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
|
|
28
|
-
import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service'
|
|
29
|
-
|
|
34
|
+
import { ChatManager } from 'src/chat21-core/providers/chat-manager'
|
|
35
|
+
import { AppConfigProvider } from '../../services/app-config'
|
|
36
|
+
|
|
37
|
+
import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service'
|
|
38
|
+
import { TypingService } from 'src/chat21-core/providers/abstract/typing.service'
|
|
39
|
+
import { ConversationHandlerBuilderService } from 'src/chat21-core/providers/abstract/conversation-handler-builder.service'
|
|
40
|
+
import { GroupsHandlerService } from 'src/chat21-core/providers/abstract/groups-handler.service'
|
|
41
|
+
import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service'
|
|
42
|
+
import { ConversationsHandlerService } from 'src/chat21-core/providers/abstract/conversations-handler.service'
|
|
43
|
+
import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service'
|
|
44
|
+
import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service'
|
|
45
|
+
import { ContactsService } from 'src/app/services/contacts/contacts.service'
|
|
46
|
+
import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service'
|
|
47
|
+
import { compareValues, htmlEntities } from '../../../chat21-core/utils/utils'
|
|
48
|
+
import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
|
|
49
|
+
import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service'
|
|
50
|
+
import { CreateCannedResponsePage } from 'src/app/pages/create-canned-response/create-canned-response.page'
|
|
30
51
|
// utils
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
import {
|
|
53
|
+
TYPE_MSG_TEXT,
|
|
54
|
+
MESSAGE_TYPE_INFO,
|
|
55
|
+
MESSAGE_TYPE_MINE,
|
|
56
|
+
MESSAGE_TYPE_OTHERS,
|
|
57
|
+
} from '../../../chat21-core/utils/constants'
|
|
58
|
+
import {
|
|
59
|
+
checkPlatformIsMobile,
|
|
60
|
+
checkWindowWidthIsLessThan991px,
|
|
61
|
+
setConversationAvatar,
|
|
62
|
+
setChannelType,
|
|
63
|
+
} from '../../../chat21-core/utils/utils'
|
|
64
|
+
import {
|
|
65
|
+
isFirstMessage,
|
|
66
|
+
isInfo,
|
|
67
|
+
isMine,
|
|
68
|
+
messageType,
|
|
69
|
+
} from 'src/chat21-core/utils/utils-message'
|
|
34
70
|
|
|
35
71
|
// Logger
|
|
36
|
-
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'
|
|
37
|
-
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
|
|
72
|
+
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service'
|
|
73
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
|
|
38
74
|
|
|
39
|
-
import { Subject } from 'rxjs'
|
|
40
|
-
import { takeUntil } from 'rxjs/operators'
|
|
41
|
-
import { TiledeskService } from '../../services/tiledesk/tiledesk.service'
|
|
42
|
-
import { NetworkService } from '../../services/network-service/network.service'
|
|
43
|
-
import { EventsService } from '../../services/events-service'
|
|
75
|
+
import { Subject } from 'rxjs'
|
|
76
|
+
import { takeUntil } from 'rxjs/operators'
|
|
77
|
+
import { TiledeskService } from '../../services/tiledesk/tiledesk.service'
|
|
78
|
+
import { NetworkService } from '../../services/network-service/network.service'
|
|
79
|
+
import { EventsService } from '../../services/events-service'
|
|
80
|
+
import { ScrollbarThemeDirective } from 'src/app/utils/scrollbar-theme.directive'
|
|
44
81
|
|
|
45
82
|
@Component({
|
|
46
83
|
selector: 'app-conversation-detail',
|
|
47
84
|
templateUrl: './conversation-detail.page.html',
|
|
48
85
|
styleUrls: ['./conversation-detail.page.scss'],
|
|
49
86
|
})
|
|
50
|
-
|
|
51
87
|
export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit {
|
|
52
|
-
@ViewChild('ionContentChatArea', { static: false })
|
|
53
|
-
|
|
54
|
-
|
|
88
|
+
@ViewChild('ionContentChatArea', { static: false })
|
|
89
|
+
ionContentChatArea: IonContent
|
|
90
|
+
@ViewChild('rowMessageTextArea', { static: false }) rowTextArea: ElementRef
|
|
91
|
+
@ViewChild('noCannedTitle', { static: false }) noCannedTitle: ElementRef
|
|
55
92
|
|
|
56
93
|
|
|
57
94
|
// @ViewChild('info_content', { static: false }) info_content_child : InfoContentComponent;
|
|
58
95
|
|
|
59
|
-
showButtonToBottom = false
|
|
60
|
-
NUM_BADGES = 0
|
|
61
|
-
COLOR_GREEN = '#24d066'
|
|
62
|
-
COLOR_RED = '#db4437'
|
|
63
|
-
|
|
64
|
-
private unsubscribe$: Subject<any> = new Subject<any>()
|
|
65
|
-
private subscriptions: Array<any
|
|
66
|
-
public tenant: string
|
|
67
|
-
public loggedUser: UserModel
|
|
68
|
-
public conversationWith: string
|
|
69
|
-
public conversationWithFullname: string
|
|
70
|
-
public messages: Array<MessageModel> = []
|
|
71
|
-
public groupDetail: GroupModel
|
|
72
|
-
public messageSelected: any
|
|
73
|
-
public channelType: string
|
|
74
|
-
public online: boolean
|
|
75
|
-
public lastConnectionDate: string
|
|
76
|
-
public showMessageWelcome: boolean
|
|
77
|
-
public openInfoConversation = false
|
|
78
|
-
public openInfoMessage: boolean
|
|
79
|
-
public isMobile = false
|
|
80
|
-
public isLessThan991px = false
|
|
81
|
-
public isTyping = false
|
|
82
|
-
public nameUserTypingNow: string
|
|
83
|
-
|
|
84
|
-
public heightMessageTextArea = ''
|
|
85
|
-
public translationMap: Map<string, string
|
|
86
|
-
public conversationAvatar: any
|
|
87
|
-
public membersConversation: any
|
|
88
|
-
public member: UserModel
|
|
89
|
-
public urlConversationSupportGroup: any
|
|
90
|
-
public isFileSelected: boolean
|
|
91
|
-
public showIonContent = false
|
|
92
|
-
public conv_type: string
|
|
93
|
-
|
|
94
|
-
public tagsCanned: any = []
|
|
96
|
+
showButtonToBottom = false // indica lo stato del pulsante per scrollare la chat (showed/hidden)
|
|
97
|
+
NUM_BADGES = 0 // numero di messaggi non letti
|
|
98
|
+
COLOR_GREEN = '#24d066' // colore presence active da spostare nelle costanti
|
|
99
|
+
COLOR_RED = '#db4437' // colore presence none da spostare nelle costanti
|
|
100
|
+
|
|
101
|
+
private unsubscribe$: Subject<any> = new Subject<any>()
|
|
102
|
+
private subscriptions: Array<any>
|
|
103
|
+
public tenant: string
|
|
104
|
+
public loggedUser: UserModel
|
|
105
|
+
public conversationWith: string
|
|
106
|
+
public conversationWithFullname: string
|
|
107
|
+
public messages: Array<MessageModel> = []
|
|
108
|
+
public groupDetail: GroupModel
|
|
109
|
+
public messageSelected: any
|
|
110
|
+
public channelType: string
|
|
111
|
+
public online: boolean
|
|
112
|
+
public lastConnectionDate: string
|
|
113
|
+
public showMessageWelcome: boolean
|
|
114
|
+
public openInfoConversation = false
|
|
115
|
+
public openInfoMessage: boolean // check is open info message
|
|
116
|
+
public isMobile = false
|
|
117
|
+
public isLessThan991px = false // nk added
|
|
118
|
+
public isTyping = false
|
|
119
|
+
public nameUserTypingNow: string
|
|
120
|
+
|
|
121
|
+
public heightMessageTextArea = ''
|
|
122
|
+
public translationMap: Map<string, string>
|
|
123
|
+
public conversationAvatar: any
|
|
124
|
+
public membersConversation: any
|
|
125
|
+
public member: UserModel
|
|
126
|
+
public urlConversationSupportGroup: any
|
|
127
|
+
public isFileSelected: boolean
|
|
128
|
+
public showIonContent = false
|
|
129
|
+
public conv_type: string
|
|
130
|
+
|
|
131
|
+
public tagsCanned: any = []
|
|
95
132
|
public tagsCannedCount: number
|
|
96
|
-
public tagsCannedFilter: any = []
|
|
97
|
-
public HIDE_CANNED_RESPONSES: boolean = false
|
|
133
|
+
public tagsCannedFilter: any = []
|
|
134
|
+
public HIDE_CANNED_RESPONSES: boolean = false
|
|
98
135
|
|
|
136
|
+
public window: any = window
|
|
137
|
+
public styleMap: Map<string, string> = new Map()
|
|
99
138
|
|
|
100
|
-
|
|
101
|
-
|
|
139
|
+
MESSAGE_TYPE_INFO = MESSAGE_TYPE_INFO
|
|
140
|
+
MESSAGE_TYPE_MINE = MESSAGE_TYPE_MINE
|
|
141
|
+
MESSAGE_TYPE_OTHERS = MESSAGE_TYPE_OTHERS
|
|
102
142
|
|
|
103
|
-
|
|
104
|
-
MESSAGE_TYPE_MINE = MESSAGE_TYPE_MINE;
|
|
105
|
-
MESSAGE_TYPE_OTHERS = MESSAGE_TYPE_OTHERS;
|
|
106
|
-
|
|
107
|
-
arrowkeyLocation = -1;
|
|
143
|
+
arrowkeyLocation = -1
|
|
108
144
|
public_Key: any;
|
|
109
|
-
areVisibleCAR: boolean
|
|
145
|
+
areVisibleCAR: boolean;
|
|
146
|
+
support_mode: boolean;
|
|
110
147
|
//SOUND
|
|
111
148
|
setTimeoutSound: any;
|
|
112
|
-
audio: any
|
|
149
|
+
audio: any;
|
|
113
150
|
isOpenInfoConversation: boolean;
|
|
114
|
-
USER_HAS_OPENED_CLOSE_INFO_CONV: boolean = false
|
|
151
|
+
USER_HAS_OPENED_CLOSE_INFO_CONV: boolean = false;
|
|
115
152
|
isHovering: boolean = false;
|
|
116
153
|
conversation_count: number;
|
|
117
|
-
showSpinner: boolean = true
|
|
118
|
-
dropEvent: any
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
154
|
+
showSpinner: boolean = true;
|
|
155
|
+
dropEvent: any;
|
|
156
|
+
conversation: any;
|
|
157
|
+
USER_ROLE: string;
|
|
158
|
+
isMine = isMine
|
|
159
|
+
isInfo = isInfo
|
|
160
|
+
isFirstMessage = isFirstMessage
|
|
161
|
+
messageType = messageType
|
|
123
162
|
// info_content_child_enabled: boolean = false
|
|
124
163
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
125
164
|
|
|
126
|
-
|
|
127
165
|
public isOnline: boolean = true;
|
|
128
166
|
public checkInternet: boolean;
|
|
129
|
-
public msgCount: number
|
|
167
|
+
public msgCount: number;
|
|
168
|
+
public disableTextarea: boolean;
|
|
169
|
+
|
|
130
170
|
/**
|
|
131
171
|
* Constructor
|
|
132
|
-
* @param route
|
|
133
|
-
* @param chatManager
|
|
134
|
-
* @param actionSheetCtrl
|
|
135
|
-
* @param platform
|
|
136
|
-
* @param customTranslateService
|
|
137
|
-
* @param appConfigProvider
|
|
138
|
-
* @param modalController
|
|
139
|
-
* @param typingService
|
|
140
|
-
* @param tiledeskAuthService
|
|
141
|
-
* @param conversationsHandlerService
|
|
142
|
-
* @param archivedConversationsHandlerService
|
|
143
|
-
* @param conversationHandlerService
|
|
144
|
-
* @param groupService
|
|
145
|
-
* @param contactsService
|
|
146
|
-
* @param conversationHandlerBuilderService
|
|
147
|
-
* @param linkifyService
|
|
148
|
-
* @param logger
|
|
149
|
-
* @param cannedResponsesService
|
|
150
|
-
* @param imageRepoService
|
|
151
|
-
* @param presenceService
|
|
152
|
-
* @param toastController
|
|
172
|
+
* @param route
|
|
173
|
+
* @param chatManager
|
|
174
|
+
* @param actionSheetCtrl
|
|
175
|
+
* @param platform
|
|
176
|
+
* @param customTranslateService
|
|
177
|
+
* @param appConfigProvider
|
|
178
|
+
* @param modalController
|
|
179
|
+
* @param typingService
|
|
180
|
+
* @param tiledeskAuthService
|
|
181
|
+
* @param conversationsHandlerService
|
|
182
|
+
* @param archivedConversationsHandlerService
|
|
183
|
+
* @param conversationHandlerService
|
|
184
|
+
* @param groupService
|
|
185
|
+
* @param contactsService
|
|
186
|
+
* @param conversationHandlerBuilderService
|
|
187
|
+
* @param linkifyService
|
|
188
|
+
* @param logger
|
|
189
|
+
* @param cannedResponsesService
|
|
190
|
+
* @param imageRepoService
|
|
191
|
+
* @param presenceService
|
|
192
|
+
* @param toastController
|
|
153
193
|
*/
|
|
154
194
|
constructor(
|
|
155
195
|
private route: ActivatedRoute,
|
|
@@ -173,19 +213,19 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
173
213
|
public toastController: ToastController,
|
|
174
214
|
public tiledeskService: TiledeskService,
|
|
175
215
|
private networkService: NetworkService,
|
|
176
|
-
private events: EventsService
|
|
216
|
+
private events: EventsService,
|
|
217
|
+
private renderer: Renderer2,
|
|
218
|
+
private el: ElementRef
|
|
177
219
|
) {
|
|
178
|
-
|
|
179
220
|
// Change list on date change
|
|
180
|
-
this.route.paramMap.subscribe(params => {
|
|
181
|
-
this.logger.log('[CONVS-DETAIL] - constructor -> params: ', params)
|
|
182
|
-
this.conversationWith = params.get('IDConv')
|
|
183
|
-
this.conversationWithFullname = params.get('FullNameConv')
|
|
184
|
-
this.conv_type = params.get('Convtype')
|
|
185
|
-
|
|
186
|
-
this.events.publish('supportconvid:haschanged', this.conversationWith);
|
|
187
|
-
});
|
|
221
|
+
this.route.paramMap.subscribe((params) => {
|
|
222
|
+
this.logger.log('[CONVS-DETAIL] - constructor -> params: ', params)
|
|
223
|
+
this.conversationWith = params.get('IDConv')
|
|
224
|
+
this.conversationWithFullname = params.get('FullNameConv')
|
|
225
|
+
this.conv_type = params.get('Convtype')
|
|
188
226
|
|
|
227
|
+
this.events.publish('supportconvid:haschanged', this.conversationWith)
|
|
228
|
+
})
|
|
189
229
|
}
|
|
190
230
|
|
|
191
231
|
// -----------------------------------------------------------
|
|
@@ -210,85 +250,122 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
210
250
|
// });
|
|
211
251
|
this.getConversations();
|
|
212
252
|
this.watchToConnectionStatus();
|
|
213
|
-
this.getOSCODE()
|
|
253
|
+
this.getOSCODE();
|
|
254
|
+
this.getStoredProjectAndUserRole();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
getStoredProjectAndUserRole() {
|
|
258
|
+
const stored_project = localStorage.getItem('last_project')
|
|
259
|
+
// console.log('[SIDEBAR] stored_project ', stored_project)
|
|
260
|
+
if (stored_project) {
|
|
261
|
+
const project = JSON.parse(stored_project)
|
|
262
|
+
// this.logger.log('[CONVS-DETAIL] project ', project)
|
|
263
|
+
|
|
264
|
+
// this.project_id = project.id_project.id
|
|
265
|
+
// this.logger.log('[CONVS-DETAIL] project_id ', this.project_id)
|
|
266
|
+
|
|
267
|
+
this.USER_ROLE = project.role;
|
|
268
|
+
// this.USER_ROLE = 'agent';
|
|
269
|
+
this.logger.log('[CONVS-DETAIL] USER_ROLE ', this.USER_ROLE)
|
|
270
|
+
}
|
|
214
271
|
}
|
|
215
272
|
|
|
216
273
|
getConversations() {
|
|
217
274
|
this.conversationsHandlerService.conversationAdded.subscribe((conv) => {
|
|
218
275
|
// console.log('[CONVS-DETAIL] - conv ', conv)
|
|
219
|
-
const conversations = this.conversationsHandlerService.conversations
|
|
276
|
+
const conversations = this.conversationsHandlerService.conversations
|
|
220
277
|
// console.log('[CONVS-DETAIL] conversations', conversations);
|
|
221
|
-
this.conversation_count = conversations.length
|
|
222
|
-
this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count)
|
|
223
|
-
})
|
|
278
|
+
this.conversation_count = conversations.length
|
|
279
|
+
this.logger.log('[CONVS-DETAIL] conversation_count', this.conversation_count)
|
|
280
|
+
})
|
|
224
281
|
|
|
225
282
|
this.conversationsHandlerService.conversationChanged.subscribe((conv) => {
|
|
226
283
|
// console.log('[CONVS-DETAIL] - conv ', conv)
|
|
227
|
-
const conversations = this.conversationsHandlerService.conversations
|
|
284
|
+
const conversations = this.conversationsHandlerService.conversations
|
|
228
285
|
// console.log('[CONVS-DETAIL] conversations', conversations);
|
|
229
|
-
this.conversation_count = conversations.length
|
|
230
|
-
this.logger.log(
|
|
231
|
-
|
|
286
|
+
this.conversation_count = conversations.length
|
|
287
|
+
this.logger.log(
|
|
288
|
+
'[CONVS-DETAIL] conversation_count',
|
|
289
|
+
this.conversation_count,
|
|
290
|
+
)
|
|
291
|
+
})
|
|
232
292
|
|
|
233
293
|
this.conversationsHandlerService.conversationRemoved.subscribe((conv) => {
|
|
234
294
|
// console.log('[CONVS-DETAIL] - conv ', conv)
|
|
235
|
-
const conversations = this.conversationsHandlerService.conversations
|
|
295
|
+
const conversations = this.conversationsHandlerService.conversations
|
|
236
296
|
// console.log('[CONVS-DETAIL] conversations', conversations);
|
|
237
|
-
this.conversation_count = conversations.length
|
|
238
|
-
this.logger.log(
|
|
239
|
-
|
|
297
|
+
this.conversation_count = conversations.length
|
|
298
|
+
this.logger.log(
|
|
299
|
+
'[CONVS-DETAIL] conversation_count',
|
|
300
|
+
this.conversation_count,
|
|
301
|
+
)
|
|
302
|
+
})
|
|
240
303
|
|
|
241
304
|
setTimeout(() => {
|
|
242
305
|
this.showSpinner = false
|
|
243
|
-
}, 3000)
|
|
244
|
-
|
|
306
|
+
}, 3000)
|
|
245
307
|
}
|
|
246
308
|
|
|
247
|
-
|
|
248
309
|
getOSCODE() {
|
|
249
|
-
this.
|
|
250
|
-
this.
|
|
310
|
+
this.support_mode = null
|
|
311
|
+
if( this.appConfigProvider.getConfig().supportMode === true || this.appConfigProvider.getConfig().supportMode === 'true') {
|
|
312
|
+
this.support_mode = true
|
|
313
|
+
} else if ( this.appConfigProvider.getConfig().supportMode === false || this.appConfigProvider.getConfig().supportMode === 'false') {
|
|
314
|
+
this.support_mode = false
|
|
315
|
+
} else if ( !this.appConfigProvider.getConfig().supportMode ) {
|
|
316
|
+
this.support_mode = false
|
|
317
|
+
}
|
|
318
|
+
this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig support_mode', this.support_mode)
|
|
319
|
+
this.public_Key = this.appConfigProvider.getConfig().t2y12PruGU9wUtEGzBJfolMIgK
|
|
320
|
+
this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig public_Key', this.public_Key)
|
|
251
321
|
|
|
252
322
|
if (this.public_Key) {
|
|
253
|
-
let keys = this.public_Key.split(
|
|
323
|
+
let keys = this.public_Key.split('-')
|
|
254
324
|
this.logger.log('[CONVS-DETAIL] PUBLIC-KEY - public_Key keys', keys)
|
|
255
325
|
|
|
256
|
-
keys.forEach(key => {
|
|
257
|
-
if (key.includes(
|
|
258
|
-
let car = key.split(
|
|
259
|
-
if (car[1] ===
|
|
260
|
-
this.areVisibleCAR = false
|
|
261
|
-
this.logger.log(
|
|
326
|
+
keys.forEach((key) => {
|
|
327
|
+
if (key.includes('CAR')) {
|
|
328
|
+
let car = key.split(':')
|
|
329
|
+
if (car[1] === 'F') {
|
|
330
|
+
this.areVisibleCAR = false
|
|
331
|
+
this.logger.log(
|
|
332
|
+
'[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
|
|
333
|
+
this.areVisibleCAR,
|
|
334
|
+
)
|
|
262
335
|
} else {
|
|
263
|
-
this.areVisibleCAR = true
|
|
264
|
-
this.logger.log(
|
|
336
|
+
this.areVisibleCAR = true
|
|
337
|
+
this.logger.log(
|
|
338
|
+
'[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
|
|
339
|
+
this.areVisibleCAR,
|
|
340
|
+
)
|
|
265
341
|
}
|
|
266
342
|
}
|
|
343
|
+
})
|
|
267
344
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
345
|
+
if (!this.public_Key.includes('CAR')) {
|
|
346
|
+
this.areVisibleCAR = false
|
|
347
|
+
this.logger.log(
|
|
348
|
+
'[CONVS-DETAIL] PUBLIC-KEY - areVisibleCAR',
|
|
349
|
+
this.areVisibleCAR,
|
|
350
|
+
)
|
|
273
351
|
}
|
|
274
352
|
} else {
|
|
275
|
-
this.areVisibleCAR = false
|
|
353
|
+
this.areVisibleCAR = false
|
|
276
354
|
}
|
|
277
355
|
}
|
|
278
356
|
|
|
279
357
|
watchToConnectionStatus() {
|
|
280
|
-
this.networkService.checkInternetFunc().subscribe(isOnline => {
|
|
358
|
+
this.networkService.checkInternetFunc().subscribe((isOnline) => {
|
|
281
359
|
this.checkInternet = isOnline
|
|
282
360
|
// console.log('[CONVS-LIST-PAGE] - watchToConnectionStatus - isOnline', this.checkInternet)
|
|
283
361
|
|
|
284
362
|
// checking internet connection
|
|
285
363
|
if (this.checkInternet == true) {
|
|
286
|
-
|
|
287
|
-
this.isOnline = true;
|
|
364
|
+
this.isOnline = true
|
|
288
365
|
} else {
|
|
289
|
-
this.isOnline = false
|
|
366
|
+
this.isOnline = false
|
|
290
367
|
}
|
|
291
|
-
})
|
|
368
|
+
})
|
|
292
369
|
}
|
|
293
370
|
|
|
294
371
|
ngAfterViewInit() {
|
|
@@ -303,13 +380,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
303
380
|
this.logger.log('[CONVS-DETAIL] > ngOnChanges')
|
|
304
381
|
}
|
|
305
382
|
|
|
306
|
-
|
|
307
383
|
ionViewWillEnter() {
|
|
308
384
|
// this.info_content_child_enabled = true;
|
|
309
385
|
this.logger.log('[CONVS-DETAIL] TEST > ionViewWillEnter - convId ', this.conversationWith)
|
|
310
|
-
this.loggedUser = this.tiledeskAuthService.getCurrentUser()
|
|
311
|
-
this.logger.log('[CONVS-DETAIL] ionViewWillEnter loggedUser: ', this.loggedUser)
|
|
312
|
-
this.listnerStart()
|
|
386
|
+
this.loggedUser = this.tiledeskAuthService.getCurrentUser()
|
|
387
|
+
this.logger.log('[CONVS-DETAIL] ionViewWillEnter loggedUser: ', this.loggedUser)
|
|
388
|
+
this.listnerStart()
|
|
313
389
|
}
|
|
314
390
|
|
|
315
391
|
ionViewDidEnter() {
|
|
@@ -321,14 +397,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
321
397
|
ionViewWillLeave() {
|
|
322
398
|
this.logger.log('[CONVS-DETAIL] > ionViewWillLeave')
|
|
323
399
|
|
|
324
|
-
// this.logger.log('[CONVS-DETAIL] > ionViewWillLeave info_content_child ', this.info_content_child)
|
|
400
|
+
// this.logger.log('[CONVS-DETAIL] > ionViewWillLeave info_content_child ', this.info_content_child)
|
|
325
401
|
// if (this.info_content_child) {
|
|
326
|
-
// this.logger.log('[CONVS-DETAIL] > HERE YES')
|
|
402
|
+
// this.logger.log('[CONVS-DETAIL] > HERE YES')
|
|
327
403
|
// this.info_content_child.destroy();
|
|
328
|
-
// }
|
|
404
|
+
// }
|
|
329
405
|
|
|
330
406
|
// this.logger.log('[CONVS-DETAIL] TEST > ionViewWillLeave info_content_child_enabled ', this.info_content_child_enabled , 'convId ', this.conversationWith)
|
|
331
|
-
this.unsubescribeAll()
|
|
407
|
+
this.unsubescribeAll()
|
|
332
408
|
}
|
|
333
409
|
|
|
334
410
|
// reloadTree() {
|
|
@@ -340,23 +416,20 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
340
416
|
// this.info_content_child_enabled = true;
|
|
341
417
|
// }
|
|
342
418
|
|
|
343
|
-
|
|
344
|
-
|
|
345
419
|
private listnerStart() {
|
|
346
|
-
const that = this
|
|
420
|
+
const that = this
|
|
347
421
|
this.chatManager.BSStart.subscribe((data: any) => {
|
|
348
|
-
this.logger.log('[CONVS-DETAIL] - BSStart data:', data)
|
|
422
|
+
this.logger.log('[CONVS-DETAIL] - BSStart data:', data)
|
|
349
423
|
if (data) {
|
|
350
|
-
that.initialize()
|
|
424
|
+
that.initialize()
|
|
351
425
|
}
|
|
352
|
-
})
|
|
426
|
+
})
|
|
353
427
|
}
|
|
354
428
|
|
|
355
|
-
// --------------------------------------------------
|
|
429
|
+
// --------------------------------------------------
|
|
356
430
|
// @ Inizialize
|
|
357
|
-
// --------------------------------------------------
|
|
431
|
+
// --------------------------------------------------
|
|
358
432
|
initialize() {
|
|
359
|
-
|
|
360
433
|
// this.logger.log('[CONVS-DETAIL] x conversationWith getConversationDetail', this.conversationWith)
|
|
361
434
|
// this.logger.log('[CONVS-DETAIL] x conversationsHandlerService getConversationDetail', this.conversationsHandlerService)
|
|
362
435
|
// this.logger.log('[CONVS-DETAIL] x this.conv_type getConversationDetail', this.conv_type)
|
|
@@ -373,87 +446,160 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
373
446
|
// })
|
|
374
447
|
// }
|
|
375
448
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
this.
|
|
379
|
-
this.logger.log('[CONVS-DETAIL] - initialize -> loggedUser: ', this.loggedUser);
|
|
380
|
-
this.translations();
|
|
449
|
+
this.loggedUser = this.tiledeskAuthService.getCurrentUser()
|
|
450
|
+
this.logger.log('[CONVS-DETAIL] - initialize -> loggedUser: ', this.loggedUser)
|
|
451
|
+
this.translations()
|
|
381
452
|
// this.conversationSelected = localStorage.getItem('conversationSelected');
|
|
382
|
-
this.showButtonToBottom = false
|
|
383
|
-
this.showMessageWelcome = false
|
|
453
|
+
this.showButtonToBottom = false
|
|
454
|
+
this.showMessageWelcome = false
|
|
384
455
|
|
|
385
456
|
const appconfig = this.appConfigProvider.getConfig()
|
|
386
457
|
// this.tenant = appconfig.tenant;
|
|
387
|
-
this.tenant = appconfig.firebaseConfig.tenant
|
|
388
|
-
this.logger.log('[CONVS-DETAIL] - initialize -> firebaseConfig tenant ', this.tenant)
|
|
389
|
-
|
|
390
|
-
|
|
458
|
+
this.tenant = appconfig.firebaseConfig.tenant
|
|
459
|
+
this.logger.log('[CONVS-DETAIL] - initialize -> firebaseConfig tenant ', this.tenant)
|
|
391
460
|
|
|
461
|
+
this.logger.log('[CONVS-DETAIL] - initialize -> conversationWith: ', this.conversationWith, ' -> conversationWithFullname: ', this.conversationWithFullname)
|
|
462
|
+
this.subscriptions = []
|
|
463
|
+
this.setHeightTextArea()
|
|
464
|
+
this.tagsCanned = [] // list of canned
|
|
392
465
|
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
395
|
-
this.
|
|
396
|
-
this.tagsCanned = []; // list of canned
|
|
397
|
-
|
|
398
|
-
this.messages = []; // list messages of conversation
|
|
399
|
-
this.isFileSelected = false; // indicates if a file has been selected (image to upload)
|
|
400
|
-
this.openInfoMessage = false; // indicates whether the info message panel is open
|
|
466
|
+
this.messages = [] // list messages of conversation
|
|
467
|
+
this.isFileSelected = false // indicates if a file has been selected (image to upload)
|
|
468
|
+
this.openInfoMessage = false // indicates whether the info message panel is open
|
|
401
469
|
|
|
402
470
|
if (checkPlatformIsMobile()) {
|
|
403
|
-
this.isMobile = true
|
|
471
|
+
this.isMobile = true
|
|
404
472
|
// this.openInfoConversation = false; // indica se è aperto il box info conversazione
|
|
405
473
|
this.logger.log('[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ', this.isMobile)
|
|
406
474
|
} else {
|
|
407
|
-
this.isMobile = false
|
|
408
|
-
this.logger.log(
|
|
475
|
+
this.isMobile = false
|
|
476
|
+
this.logger.log(
|
|
477
|
+
'[CONVS-DETAIL] - initialize -> checkPlatformIsMobile isMobile? ',
|
|
478
|
+
this.isMobile,
|
|
479
|
+
)
|
|
409
480
|
// this.openInfoConversation = true;
|
|
410
481
|
}
|
|
411
482
|
|
|
412
483
|
if (this.isMobile === false) {
|
|
413
484
|
if (checkWindowWidthIsLessThan991px()) {
|
|
414
|
-
this.logger.log(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
485
|
+
this.logger.log(
|
|
486
|
+
'[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ',
|
|
487
|
+
checkWindowWidthIsLessThan991px(),
|
|
488
|
+
)
|
|
489
|
+
this.openInfoConversation = false // indica se è aperto il box info conversazione
|
|
490
|
+
this.isOpenInfoConversation = false
|
|
491
|
+
this.logger.log(
|
|
492
|
+
'[CONVS-DETAIL] - initialize -> openInfoConversation ',
|
|
493
|
+
this.openInfoConversation,
|
|
494
|
+
' -> isOpenInfoConversation ',
|
|
495
|
+
this.isOpenInfoConversation,
|
|
496
|
+
)
|
|
418
497
|
} else {
|
|
419
|
-
this.logger.log(
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
498
|
+
this.logger.log(
|
|
499
|
+
'[CONVS-DETAIL] - initialize -> checkWindowWidthIsLessThan991px ',
|
|
500
|
+
checkWindowWidthIsLessThan991px(),
|
|
501
|
+
)
|
|
502
|
+
this.openInfoConversation = true
|
|
503
|
+
this.isOpenInfoConversation = true
|
|
504
|
+
this.logger.log(
|
|
505
|
+
'[CONVS-DETAIL] - initialize -> openInfoConversation ',
|
|
506
|
+
this.openInfoConversation,
|
|
507
|
+
' -> isOpenInfoConversation ',
|
|
508
|
+
this.isOpenInfoConversation,
|
|
509
|
+
)
|
|
423
510
|
}
|
|
424
511
|
}
|
|
425
512
|
|
|
426
|
-
this.online = false
|
|
427
|
-
this.lastConnectionDate = ''
|
|
513
|
+
this.online = false
|
|
514
|
+
this.lastConnectionDate = ''
|
|
428
515
|
|
|
429
516
|
// init handler vengono prima delle sottoscrizioni!
|
|
430
517
|
// this.initConversationsHandler(); // nk
|
|
431
518
|
if (this.conversationWith) {
|
|
432
|
-
this.
|
|
433
|
-
this.
|
|
434
|
-
this.
|
|
519
|
+
this.disableTextarea = false
|
|
520
|
+
this._getProjectIdByConversationWith(this.conversationWith)
|
|
521
|
+
this.initConversationHandler()
|
|
522
|
+
this.initGroupsHandler()
|
|
523
|
+
this.initSubscriptions()
|
|
435
524
|
}
|
|
436
|
-
this.addEventsKeyboard()
|
|
437
|
-
this.startConversation()
|
|
438
|
-
this.updateConversationBadge()
|
|
525
|
+
this.addEventsKeyboard()
|
|
526
|
+
this.startConversation()
|
|
527
|
+
this.updateConversationBadge() // AGGIORNO STATO DELLA CONVERSAZIONE A 'LETTA' (is_new = false)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
_getProjectIdByConversationWith(conversationWith: string) {
|
|
531
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
532
|
+
|
|
533
|
+
this.tiledeskService
|
|
534
|
+
.getProjectIdByConvRecipient(tiledeskToken, conversationWith)
|
|
535
|
+
.subscribe(
|
|
536
|
+
(res) => {
|
|
537
|
+
this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', res)
|
|
538
|
+
if (res) {
|
|
539
|
+
const projectId = res.id_project
|
|
540
|
+
this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
|
|
541
|
+
this.getProjectById(tiledeskToken, projectId)
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
(error) => {
|
|
545
|
+
this.logger.error('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
|
|
546
|
+
},
|
|
547
|
+
() => {
|
|
548
|
+
this.logger.log(
|
|
549
|
+
'[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
|
|
550
|
+
)
|
|
551
|
+
},
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
getProjectById(tiledeskToken, projectId) {
|
|
556
|
+
this.tiledeskService.getProjectById(tiledeskToken, projectId).subscribe(
|
|
557
|
+
(res) => {
|
|
558
|
+
this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES', res)
|
|
559
|
+
if (res) {
|
|
560
|
+
const projectId = res.id_project
|
|
561
|
+
this.logger.log(
|
|
562
|
+
'[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT projectId ',
|
|
563
|
+
projectId,
|
|
564
|
+
)
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
(error) => {
|
|
568
|
+
this.logger.error(
|
|
569
|
+
'[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT - ERROR ',
|
|
570
|
+
error,
|
|
571
|
+
)
|
|
572
|
+
if ((error.error.msg = 'you dont belong to the project.')) {
|
|
573
|
+
this.disableTextarea = true
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
() => {
|
|
577
|
+
this.logger.log(
|
|
578
|
+
'[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT * COMPLETE *',
|
|
579
|
+
)
|
|
580
|
+
},
|
|
581
|
+
)
|
|
439
582
|
}
|
|
440
583
|
|
|
441
584
|
returnOpenCloseInfoConversation(openInfoConversation: boolean) {
|
|
442
|
-
this.logger.log(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
585
|
+
this.logger.log(
|
|
586
|
+
'[CONVS-DETAIL] returnOpenCloseInfoConversation - openInfoConversation ',
|
|
587
|
+
openInfoConversation,
|
|
588
|
+
)
|
|
589
|
+
this.resizeTextArea()
|
|
590
|
+
this.openInfoMessage = false
|
|
591
|
+
this.openInfoConversation = openInfoConversation
|
|
446
592
|
this.isOpenInfoConversation = openInfoConversation
|
|
447
|
-
this.USER_HAS_OPENED_CLOSE_INFO_CONV = true
|
|
593
|
+
this.USER_HAS_OPENED_CLOSE_INFO_CONV = true
|
|
448
594
|
}
|
|
449
595
|
|
|
450
596
|
@HostListener('window:resize', ['$event'])
|
|
451
597
|
onResize(event: any) {
|
|
452
|
-
const newInnerWidth = event.target.innerWidth
|
|
598
|
+
const newInnerWidth = event.target.innerWidth
|
|
453
599
|
if (newInnerWidth < 991) {
|
|
454
600
|
if (this.USER_HAS_OPENED_CLOSE_INFO_CONV === false) {
|
|
455
|
-
this.openInfoConversation = false
|
|
456
|
-
this.isOpenInfoConversation = false
|
|
601
|
+
this.openInfoConversation = false
|
|
602
|
+
this.isOpenInfoConversation = false
|
|
457
603
|
}
|
|
458
604
|
}
|
|
459
605
|
}
|
|
@@ -484,16 +630,20 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
484
630
|
'NO_INFORMATION_AVAILABLE',
|
|
485
631
|
'CONTACT_ID',
|
|
486
632
|
'USER_ID',
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
this.
|
|
633
|
+
'UPLOAD',
|
|
634
|
+
'CANNED_RESPONSES',
|
|
635
|
+
'NO_CANNED_RESPONSES',
|
|
636
|
+
'YES_CANNED_RESPONSES',
|
|
637
|
+
'THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE',
|
|
638
|
+
'TO_CREATE_THEM_GO_TO_THE_PROJECT',
|
|
639
|
+
"AddNewCannedResponse"
|
|
640
|
+
]
|
|
641
|
+
|
|
642
|
+
this.translationMap = this.customTranslateService.translateLanguage(keys)
|
|
643
|
+
this.logger.log(
|
|
644
|
+
'[CONVS-DETAIL] x this.translationMap ',
|
|
645
|
+
this.translationMap,
|
|
646
|
+
)
|
|
497
647
|
}
|
|
498
648
|
|
|
499
649
|
// --------------------------------------------------------
|
|
@@ -512,9 +662,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
512
662
|
'LABEL_TOMORROW',
|
|
513
663
|
'LABEL_LAST_ACCESS',
|
|
514
664
|
'LABEL_TO',
|
|
515
|
-
'ARRAY_DAYS'
|
|
516
|
-
]
|
|
517
|
-
return this.customTranslateService.translateLanguage(keys)
|
|
665
|
+
'ARRAY_DAYS',
|
|
666
|
+
]
|
|
667
|
+
return this.customTranslateService.translateLanguage(keys)
|
|
518
668
|
}
|
|
519
669
|
|
|
520
670
|
// -------------------------------------------------------------------------------------
|
|
@@ -525,63 +675,75 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
525
675
|
// * I wait x sec if no messages arrive I display msg wellcome
|
|
526
676
|
// -------------------------------------------------------------------------------------
|
|
527
677
|
initConversationHandler() {
|
|
528
|
-
const translationMap = this.setTranslationMapForConversationHandler()
|
|
529
|
-
this.showMessageWelcome = false
|
|
530
|
-
const handler: ConversationHandlerService = this.chatManager.getConversationHandlerByConversationId(
|
|
531
|
-
|
|
678
|
+
const translationMap = this.setTranslationMapForConversationHandler()
|
|
679
|
+
this.showMessageWelcome = false
|
|
680
|
+
const handler: ConversationHandlerService = this.chatManager.getConversationHandlerByConversationId(
|
|
681
|
+
this.conversationWith,
|
|
682
|
+
)
|
|
683
|
+
this.logger.log(
|
|
684
|
+
'[CONVS-DETAIL] - initConversationHandler - handler ',
|
|
685
|
+
handler,
|
|
686
|
+
' conversationWith ',
|
|
687
|
+
this.conversationWith,
|
|
688
|
+
)
|
|
532
689
|
if (!handler) {
|
|
533
|
-
this.conversationHandlerService = this.conversationHandlerBuilderService.build()
|
|
690
|
+
this.conversationHandlerService = this.conversationHandlerBuilderService.build()
|
|
534
691
|
this.conversationHandlerService.initialize(
|
|
535
692
|
this.conversationWith,
|
|
536
693
|
this.conversationWithFullname,
|
|
537
694
|
this.loggedUser,
|
|
538
695
|
this.tenant,
|
|
539
|
-
translationMap
|
|
540
|
-
)
|
|
541
|
-
this.conversationHandlerService.connect()
|
|
542
|
-
this.logger.log(
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
696
|
+
translationMap,
|
|
697
|
+
)
|
|
698
|
+
this.conversationHandlerService.connect()
|
|
699
|
+
this.logger.log(
|
|
700
|
+
'[CONVS-DETAIL] - initConversationHandler - NEW handler - conversationHandlerService',
|
|
701
|
+
this.conversationHandlerService,
|
|
702
|
+
)
|
|
703
|
+
this.messages = this.conversationHandlerService.messages
|
|
704
|
+
this.logger.log(
|
|
705
|
+
'[CONVS-DETAIL] - initConversationHandler - messages: ',
|
|
706
|
+
this.messages,
|
|
707
|
+
)
|
|
708
|
+
this.chatManager.addConversationHandler(this.conversationHandlerService)
|
|
546
709
|
|
|
547
710
|
// // wait 8 second and then display the message if there are no messages
|
|
548
|
-
const that = this
|
|
549
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler that.messages ', that.messages)
|
|
550
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler that.messages.length ', that.messages.length)
|
|
711
|
+
const that = this
|
|
712
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler that.messages ', that.messages)
|
|
713
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler that.messages.length ', that.messages.length)
|
|
551
714
|
this.msgCount = that.messages.length
|
|
552
715
|
setTimeout(() => {
|
|
553
716
|
if (!that.messages || that.messages.length === 0) {
|
|
554
|
-
this.showIonContent = true
|
|
555
|
-
that.showMessageWelcome = true
|
|
556
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler - showMessageWelcome: ', that.showMessageWelcome)
|
|
717
|
+
this.showIonContent = true
|
|
718
|
+
that.showMessageWelcome = true
|
|
719
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler - showMessageWelcome: ', that.showMessageWelcome)
|
|
557
720
|
}
|
|
558
|
-
}, 8000)
|
|
559
|
-
|
|
721
|
+
}, 8000)
|
|
560
722
|
} else {
|
|
561
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - conversationHandlerService ', this.conversationHandlerService, ' handler', handler)
|
|
562
|
-
this.conversationHandlerService = handler
|
|
563
|
-
this.messages = this.conversationHandlerService.messages
|
|
564
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - this.messages: ', this.messages)
|
|
565
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - this.showMessageWelcome: ', this.showMessageWelcome)
|
|
723
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - conversationHandlerService ', this.conversationHandlerService, ' handler', handler)
|
|
724
|
+
this.conversationHandlerService = handler
|
|
725
|
+
this.messages = this.conversationHandlerService.messages
|
|
726
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - this.messages: ', this.messages)
|
|
727
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - this.showMessageWelcome: ', this.showMessageWelcome)
|
|
566
728
|
}
|
|
567
|
-
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - message ', this.messages, ' showIonContent', this.showIonContent)
|
|
729
|
+
this.logger.log('[CONVS-DETAIL] - initConversationHandler (else) - message ', this.messages, ' showIonContent', this.showIonContent)
|
|
568
730
|
}
|
|
569
731
|
|
|
570
|
-
|
|
571
732
|
initGroupsHandler() {
|
|
572
|
-
if (
|
|
733
|
+
if (
|
|
734
|
+
this.conversationWith.startsWith('support-group') ||
|
|
735
|
+
this.conversationWith.startsWith('group-')
|
|
736
|
+
) {
|
|
573
737
|
this.groupService.initialize(this.tenant, this.loggedUser.uid)
|
|
574
|
-
this.logger.log('[CONVS-DETAIL] - initGroupsHandler - tenant', this.tenant, ' loggedUser UID', this.loggedUser.uid)
|
|
738
|
+
this.logger.log('[CONVS-DETAIL] - initGroupsHandler - tenant', this.tenant, ' loggedUser UID', this.loggedUser.uid)
|
|
575
739
|
}
|
|
576
740
|
}
|
|
577
741
|
|
|
578
|
-
|
|
579
742
|
private setAttributes(): any {
|
|
580
743
|
const attributes: any = {
|
|
581
744
|
client: navigator.userAgent,
|
|
582
745
|
sourcePage: location.href,
|
|
583
|
-
|
|
584
|
-
};
|
|
746
|
+
}
|
|
585
747
|
|
|
586
748
|
//TODO: servono ???
|
|
587
749
|
if (this.loggedUser && this.loggedUser.email) {
|
|
@@ -591,21 +753,19 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
591
753
|
attributes.userFullname = this.loggedUser.fullname
|
|
592
754
|
}
|
|
593
755
|
|
|
594
|
-
return attributes
|
|
756
|
+
return attributes
|
|
595
757
|
}
|
|
596
758
|
|
|
597
|
-
|
|
598
|
-
|
|
599
759
|
// ---------------------------------
|
|
600
760
|
// startConversation
|
|
601
761
|
// ---------------------------------
|
|
602
762
|
startConversation() {
|
|
603
|
-
|
|
763
|
+
// console.log( '[CONVS-DETAIL] - startConversation conversationWith: ', this.conversationWith )
|
|
604
764
|
if (this.conversationWith) {
|
|
605
|
-
this.channelType = setChannelType(this.conversationWith)
|
|
606
|
-
this.logger.log('[CONVS-DETAIL] - startConversation channelType : ', this.channelType)
|
|
765
|
+
this.channelType = setChannelType(this.conversationWith)
|
|
766
|
+
this.logger.log('[CONVS-DETAIL] - startConversation channelType : ', this.channelType)
|
|
607
767
|
// this.selectInfoContentTypeComponent();
|
|
608
|
-
this.setHeaderContent()
|
|
768
|
+
this.setHeaderContent()
|
|
609
769
|
}
|
|
610
770
|
}
|
|
611
771
|
|
|
@@ -613,31 +773,39 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
613
773
|
// this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationWith', this.conversationWith)
|
|
614
774
|
// this.logger.log('[CONVS-DETAIL] - setHeaderContent conversationsHandlerService', this.conversationsHandlerService)
|
|
615
775
|
// this.logger.log('[CONVS-DETAIL] - setHeaderContent conv_type', this.conv_type)
|
|
616
|
-
if (
|
|
776
|
+
if (
|
|
777
|
+
this.conversationWith &&
|
|
778
|
+
this.conversationsHandlerService &&
|
|
779
|
+
this.conv_type === 'active'
|
|
780
|
+
) {
|
|
617
781
|
this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail CALLING')
|
|
618
782
|
this.conversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
|
|
619
783
|
if (conv) {
|
|
620
|
-
|
|
784
|
+
// console.log( '[CONVS-DETAIL] - setHeaderContent getConversationDetail (active)', this.conversationWith, conv )
|
|
621
785
|
this.conversationAvatar = setConversationAvatar(
|
|
622
786
|
conv.conversation_with,
|
|
623
787
|
conv.conversation_with_fullname,
|
|
624
|
-
conv.channel_type
|
|
625
|
-
)
|
|
788
|
+
conv.channel_type,
|
|
789
|
+
)
|
|
626
790
|
}
|
|
627
|
-
this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar)
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
else {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
791
|
+
this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar)
|
|
792
|
+
},
|
|
793
|
+
)
|
|
794
|
+
} else {
|
|
795
|
+
//get conversation from 'conversations' firebase node
|
|
796
|
+
this.archivedConversationsHandlerService.getConversationDetail(
|
|
797
|
+
this.conversationWith,
|
|
798
|
+
(conv) => {
|
|
799
|
+
if (conv) {
|
|
800
|
+
// console.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)', this.conversationWith, 'CONVS', conv)
|
|
801
|
+
this.conversationAvatar = setConversationAvatar(
|
|
802
|
+
conv.conversation_with,
|
|
803
|
+
conv.conversation_with_fullname,
|
|
804
|
+
conv.channel_type,
|
|
805
|
+
)
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
)
|
|
641
809
|
}
|
|
642
810
|
|
|
643
811
|
// this.conversationAvatar = setConversationAvatar(
|
|
@@ -649,62 +817,63 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
649
817
|
}
|
|
650
818
|
|
|
651
819
|
returnSendMessage(e: any) {
|
|
652
|
-
this.logger.log('[CONVS-DETAIL] - returnSendMessage event', e, ' - conversationWith', this.conversationWith)
|
|
820
|
+
this.logger.log('[CONVS-DETAIL] - returnSendMessage event', e, ' - conversationWith', this.conversationWith)
|
|
653
821
|
|
|
654
|
-
this.logger.log('[CONVS-DETAIL] - returnSendMessage event message', e.message)
|
|
822
|
+
this.logger.log('[CONVS-DETAIL] - returnSendMessage event message', e.message)
|
|
655
823
|
try {
|
|
656
|
-
let message = ''
|
|
824
|
+
let message = ''
|
|
657
825
|
if (e.message) {
|
|
658
|
-
message = e.message
|
|
826
|
+
message = e.message
|
|
659
827
|
}
|
|
660
|
-
const type = e.type
|
|
661
|
-
const metadata = e.metadata
|
|
662
|
-
|
|
663
|
-
this.sendMessage(message, type, metadata);
|
|
828
|
+
const type = e.type
|
|
829
|
+
const metadata = e.metadata
|
|
664
830
|
|
|
831
|
+
this.sendMessage(message, type, metadata)
|
|
665
832
|
} catch (err) {
|
|
666
|
-
this.logger.error('[CONVS-DETAIL] - returnSendMessage error: ', err)
|
|
833
|
+
this.logger.error('[CONVS-DETAIL] - returnSendMessage error: ', err)
|
|
667
834
|
}
|
|
668
835
|
}
|
|
669
836
|
|
|
670
|
-
|
|
671
837
|
/**
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
sendMessage(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
838
|
+
* SendMessage
|
|
839
|
+
* @param msg
|
|
840
|
+
* @param type
|
|
841
|
+
* @param metadata
|
|
842
|
+
* @param additional_attributes
|
|
843
|
+
*/
|
|
844
|
+
sendMessage(
|
|
845
|
+
msg: string,
|
|
846
|
+
type: string,
|
|
847
|
+
metadata?: any,
|
|
848
|
+
additional_attributes?: any,
|
|
849
|
+
) {
|
|
850
|
+
this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - MSG: ', msg)
|
|
851
|
+
this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - type: ', type)
|
|
852
|
+
this.logger.log('[CONVS-DETAIL] - SEND MESSAGE - metadata: ', metadata)
|
|
853
|
+
let fullname = this.loggedUser.uid
|
|
683
854
|
if (this.loggedUser.fullname) {
|
|
684
|
-
fullname = this.loggedUser.fullname
|
|
855
|
+
fullname = this.loggedUser.fullname
|
|
685
856
|
}
|
|
686
857
|
|
|
687
|
-
const g_attributes = this.setAttributes()
|
|
858
|
+
const g_attributes = this.setAttributes()
|
|
688
859
|
// added <any> to resolve the Error occurred during the npm installation: Property 'userFullname' does not exist on type '{}'
|
|
689
|
-
const attributes = <any>{}
|
|
860
|
+
const attributes = <any>{}
|
|
690
861
|
if (g_attributes) {
|
|
691
862
|
for (const [key, value] of Object.entries(g_attributes)) {
|
|
692
|
-
attributes[key] = value
|
|
863
|
+
attributes[key] = value
|
|
693
864
|
}
|
|
694
865
|
}
|
|
695
866
|
if (additional_attributes) {
|
|
696
867
|
for (const [key, value] of Object.entries(additional_attributes)) {
|
|
697
|
-
attributes[key] = value
|
|
868
|
+
attributes[key] = value
|
|
698
869
|
}
|
|
699
870
|
}
|
|
700
871
|
|
|
701
872
|
// || type === 'image'
|
|
702
873
|
if (type === 'file') {
|
|
703
|
-
|
|
704
874
|
if (msg) {
|
|
705
875
|
// msg = msg + '<br>' + 'File: ' + metadata.src;
|
|
706
876
|
msg = `[${metadata.name}](${metadata.src})` + '\n' + msg
|
|
707
|
-
|
|
708
877
|
} else {
|
|
709
878
|
// msg = 'File: ' + metadata.src;
|
|
710
879
|
// msg = `<a href=${metadata.src} download>
|
|
@@ -728,11 +897,10 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
728
897
|
|
|
729
898
|
// }
|
|
730
899
|
|
|
900
|
+
metadata ? (metadata = metadata) : (metadata = '')
|
|
901
|
+
this.logger.log('[CONVS-DETAIL] - SEND MESSAGE msg: ', msg, ' - messages: ', this.messages, ' - loggedUser: ', this.loggedUser)
|
|
731
902
|
|
|
732
|
-
(
|
|
733
|
-
this.logger.log('[CONVS-DETAIL] - SEND MESSAGE msg: ', msg, ' - messages: ', this.messages, ' - loggedUser: ', this.loggedUser);
|
|
734
|
-
|
|
735
|
-
if (msg && msg.trim() !== '' || type !== TYPE_MSG_TEXT) {
|
|
903
|
+
if ((msg && msg.trim() !== '') || type !== TYPE_MSG_TEXT) {
|
|
736
904
|
this.conversationHandlerService.sendMessage(
|
|
737
905
|
msg,
|
|
738
906
|
type,
|
|
@@ -742,186 +910,219 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
742
910
|
this.loggedUser.uid,
|
|
743
911
|
fullname,
|
|
744
912
|
this.channelType,
|
|
745
|
-
attributes
|
|
746
|
-
)
|
|
747
|
-
|
|
913
|
+
attributes,
|
|
914
|
+
)
|
|
748
915
|
}
|
|
749
916
|
}
|
|
750
917
|
// ----------------------------------------------------------
|
|
751
|
-
// InitSubscriptions BS subscriptions
|
|
918
|
+
// InitSubscriptions BS subscriptions
|
|
752
919
|
// ----------------------------------------------------------
|
|
753
920
|
initSubscriptions() {
|
|
754
|
-
this.logger.log('[CONVS-DETAIL] - initSubscriptions: ', this.subscriptions)
|
|
921
|
+
this.logger.log('[CONVS-DETAIL] - initSubscriptions: ', this.subscriptions)
|
|
755
922
|
|
|
756
|
-
const that = this
|
|
757
|
-
let subscription: any
|
|
758
|
-
let subscriptionKey: string
|
|
923
|
+
const that = this
|
|
924
|
+
let subscription: any
|
|
925
|
+
let subscriptionKey: string
|
|
759
926
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
927
|
+
subscriptionKey = 'BSConversationsChanged'
|
|
928
|
+
subscription = this.subscriptions.find(
|
|
929
|
+
(item) => item.key === subscriptionKey,
|
|
930
|
+
)
|
|
763
931
|
if (!subscription) {
|
|
764
|
-
subscription = this.conversationsHandlerService.conversationChanged.subscribe(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
this.
|
|
932
|
+
subscription = this.conversationsHandlerService.conversationChanged.subscribe(
|
|
933
|
+
(data: ConversationModel) => {
|
|
934
|
+
this.logger.log('[CONVS-DETAIL] subscribe BSConversationsChanged data ', data, ' this.loggedUser.uid:', this.loggedUser.uid)
|
|
935
|
+
|
|
936
|
+
if (data && data.sender !== this.loggedUser.uid) {
|
|
937
|
+
this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange data sender ', data.sender)
|
|
938
|
+
this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange this.loggedUser.uid ', this.loggedUser.uid)
|
|
939
|
+
this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange is_new ', data.is_new)
|
|
940
|
+
this.logger.log('[CONVS-DETAIL] subscribe to BSConversationsChange showButtonToBottom ', this.showButtonToBottom)
|
|
941
|
+
// UPDATE THE CONVERSATION TO 'READ' IF IT IS ME WHO WRITES THE LAST MESSAGE OF THE CONVERSATION
|
|
942
|
+
// AND IF THE POSITION OF THE SCROLL IS AT THE END
|
|
943
|
+
if (!this.showButtonToBottom && data.is_new) {
|
|
944
|
+
// ARE AT THE END
|
|
945
|
+
this.updateConversationBadge()
|
|
946
|
+
}
|
|
776
947
|
}
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
const subscribe = { key: subscriptionKey, value: subscription }
|
|
780
|
-
this.subscriptions.push(subscribe)
|
|
948
|
+
},
|
|
949
|
+
)
|
|
950
|
+
const subscribe = { key: subscriptionKey, value: subscription }
|
|
951
|
+
this.subscriptions.push(subscribe)
|
|
781
952
|
}
|
|
782
953
|
|
|
783
|
-
subscriptionKey = 'messageAdded'
|
|
784
|
-
subscription = this.subscriptions.find(
|
|
954
|
+
subscriptionKey = 'messageAdded'
|
|
955
|
+
subscription = this.subscriptions.find(
|
|
956
|
+
(item) => item.key === subscriptionKey,
|
|
957
|
+
)
|
|
785
958
|
if (!subscription) {
|
|
786
|
-
this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - conversationHandlerService', this.conversationHandlerService)
|
|
787
|
-
subscription = this.conversationHandlerService.messageAdded.subscribe(
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
959
|
+
this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - conversationHandlerService', this.conversationHandlerService)
|
|
960
|
+
subscription = this.conversationHandlerService.messageAdded.subscribe(
|
|
961
|
+
(msg: any) => {
|
|
962
|
+
this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - msg ', msg)
|
|
963
|
+
if (msg) {
|
|
964
|
+
that.newMessageAdded(msg)
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
)
|
|
968
|
+
const subscribe = { key: subscriptionKey, value: subscription }
|
|
969
|
+
this.subscriptions.push(subscribe)
|
|
795
970
|
}
|
|
796
971
|
|
|
797
972
|
// IS USED ?
|
|
798
|
-
subscriptionKey = 'messageChanged'
|
|
799
|
-
subscription = this.subscriptions.find(
|
|
973
|
+
subscriptionKey = 'messageChanged'
|
|
974
|
+
subscription = this.subscriptions.find(
|
|
975
|
+
(item) => item.key === subscriptionKey,
|
|
976
|
+
)
|
|
800
977
|
if (!subscription) {
|
|
801
|
-
this.logger.log('[CONVS-DETAIL] subscribe to messageChanged')
|
|
802
|
-
subscription = this.conversationHandlerService.messageChanged.subscribe(
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
978
|
+
this.logger.log('[CONVS-DETAIL] subscribe to messageChanged')
|
|
979
|
+
subscription = this.conversationHandlerService.messageChanged.subscribe(
|
|
980
|
+
(msg: any) => {
|
|
981
|
+
this.logger.log(
|
|
982
|
+
'[CONVS-DETAIL] subscribe to messageChanged - msg ',
|
|
983
|
+
msg,
|
|
984
|
+
)
|
|
985
|
+
},
|
|
986
|
+
)
|
|
987
|
+
const subscribe = { key: subscriptionKey, value: subscription }
|
|
988
|
+
this.subscriptions.push(subscribe)
|
|
807
989
|
}
|
|
808
990
|
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
991
|
+
subscriptionKey = 'messageRemoved'
|
|
992
|
+
subscription = this.subscriptions.find(
|
|
993
|
+
(item) => item.key === subscriptionKey,
|
|
994
|
+
)
|
|
812
995
|
if (!subscription) {
|
|
813
|
-
this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved')
|
|
814
|
-
subscription = this.conversationHandlerService.messageRemoved.subscribe(
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
996
|
+
this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved')
|
|
997
|
+
subscription = this.conversationHandlerService.messageRemoved.subscribe(
|
|
998
|
+
(messageId: any) => {
|
|
999
|
+
this.logger.log('[CONVS-DETAIL] subscribe to messageRemoved - messageId ', messageId)
|
|
1000
|
+
},
|
|
1001
|
+
)
|
|
1002
|
+
const subscribe = { key: subscriptionKey, value: subscription }
|
|
1003
|
+
this.subscriptions.push(subscribe)
|
|
819
1004
|
}
|
|
820
1005
|
|
|
821
1006
|
// subscriptionKey = 'onGroupChange';
|
|
822
1007
|
// subscription = this.subscriptions.find(item => item.key === subscriptionKey);
|
|
823
1008
|
// if (!subscription) {
|
|
824
|
-
// subscription =
|
|
825
|
-
if (this.conversationWith.startsWith(
|
|
826
|
-
this.groupService
|
|
1009
|
+
// subscription =
|
|
1010
|
+
if (this.conversationWith.startsWith('group-')) {
|
|
1011
|
+
this.groupService
|
|
1012
|
+
.onGroupChange(this.conversationWith)
|
|
827
1013
|
.pipe(takeUntil(this.unsubscribe$))
|
|
828
|
-
.subscribe(
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
1014
|
+
.subscribe(
|
|
1015
|
+
(groupDetail: any) => {
|
|
1016
|
+
this.groupDetail = groupDetail
|
|
1017
|
+
this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange - groupDetail ', this.groupDetail)
|
|
1018
|
+
},
|
|
1019
|
+
(error) => {
|
|
1020
|
+
this.logger.error('[CONVS-DETAIL] subscribe to onGroupChange - ERROR ', error)
|
|
1021
|
+
},
|
|
1022
|
+
() => {
|
|
1023
|
+
this.logger.log('[CONVS-DETAIL] subscribe to onGroupChange /* COMPLETE */')
|
|
1024
|
+
this.groupDetail = null
|
|
1025
|
+
},
|
|
1026
|
+
)
|
|
837
1027
|
}
|
|
838
1028
|
// const subscribe = { key: subscriptionKey, value: subscription };
|
|
839
1029
|
// this.subscriptions.push(subscribe);
|
|
840
1030
|
// }
|
|
841
1031
|
}
|
|
842
1032
|
|
|
843
|
-
|
|
844
1033
|
// -------------------------------------------------
|
|
845
1034
|
// addEventsKeyboard
|
|
846
1035
|
// -------------------------------------------------
|
|
847
1036
|
addEventsKeyboard() {
|
|
848
1037
|
window.addEventListener('keyboardWillShow', () => {
|
|
849
|
-
this.logger.log('[CONVS-DETAIL] - Keyboard will Show')
|
|
850
|
-
})
|
|
1038
|
+
this.logger.log('[CONVS-DETAIL] - Keyboard will Show')
|
|
1039
|
+
})
|
|
851
1040
|
window.addEventListener('keyboardDidShow', () => {
|
|
852
|
-
this.logger.log('[CONVS-DETAIL] - Keyboard is Shown')
|
|
853
|
-
})
|
|
1041
|
+
this.logger.log('[CONVS-DETAIL] - Keyboard is Shown')
|
|
1042
|
+
})
|
|
854
1043
|
window.addEventListener('keyboardWillHide', () => {
|
|
855
|
-
this.logger.log('[CONVS-DETAIL] - Keyboard will Hide')
|
|
856
|
-
})
|
|
1044
|
+
this.logger.log('[CONVS-DETAIL] - Keyboard will Hide')
|
|
1045
|
+
})
|
|
857
1046
|
window.addEventListener('keyboardDidHide', () => {
|
|
858
|
-
this.logger.log('[CONVS-DETAIL] - Keyboard is Hidden')
|
|
859
|
-
})
|
|
1047
|
+
this.logger.log('[CONVS-DETAIL] - Keyboard is Hidden')
|
|
1048
|
+
})
|
|
860
1049
|
}
|
|
861
1050
|
|
|
862
1051
|
// ----------------------------------------------------------------
|
|
863
1052
|
// @ Unsubscribe all subscribed events (called in ionViewWillLeave)
|
|
864
1053
|
// ----------------------------------------------------------------
|
|
865
1054
|
unsubescribeAll() {
|
|
866
|
-
this.logger.log('[CONVS-DETAIL] unsubescribeAll 1: ', this.subscriptions)
|
|
1055
|
+
this.logger.log('[CONVS-DETAIL] unsubescribeAll 1: ', this.subscriptions)
|
|
867
1056
|
if (this.subscriptions) {
|
|
868
|
-
this.logger.log('[CONVS-DETAIL] unsubescribeAll 2: ', this.subscriptions)
|
|
869
|
-
this.subscriptions.forEach(subscription => {
|
|
870
|
-
subscription.value.unsubscribe()
|
|
871
|
-
})
|
|
872
|
-
this.subscriptions = []
|
|
1057
|
+
this.logger.log('[CONVS-DETAIL] unsubescribeAll 2: ', this.subscriptions)
|
|
1058
|
+
this.subscriptions.forEach((subscription) => {
|
|
1059
|
+
subscription.value.unsubscribe() // vedere come fare l'unsubscribe!!!!
|
|
1060
|
+
})
|
|
1061
|
+
this.subscriptions = []
|
|
873
1062
|
|
|
874
1063
|
// https://www.w3schools.com/jsref/met_element_removeeventlistener.asp
|
|
875
|
-
window.removeEventListener('keyboardWillShow', null)
|
|
876
|
-
window.removeEventListener('keyboardDidShow', null)
|
|
877
|
-
window.removeEventListener('keyboardWillHide', null)
|
|
878
|
-
window.removeEventListener('keyboardDidHide', null)
|
|
1064
|
+
window.removeEventListener('keyboardWillShow', null)
|
|
1065
|
+
window.removeEventListener('keyboardDidShow', null)
|
|
1066
|
+
window.removeEventListener('keyboardWillHide', null)
|
|
1067
|
+
window.removeEventListener('keyboardDidHide', null)
|
|
879
1068
|
}
|
|
880
1069
|
|
|
881
|
-
this.unsubscribe$.next()
|
|
882
|
-
this.unsubscribe$.complete()
|
|
1070
|
+
this.unsubscribe$.next()
|
|
1071
|
+
this.unsubscribe$.complete()
|
|
883
1072
|
// this.conversationHandlerService.dispose();
|
|
884
1073
|
}
|
|
885
1074
|
|
|
886
|
-
|
|
887
1075
|
/**
|
|
888
|
-
* newMessageAdded
|
|
1076
|
+
* newMessageAdded
|
|
889
1077
|
* @param message
|
|
890
1078
|
*/
|
|
891
1079
|
newMessageAdded(message: MessageModel) {
|
|
892
1080
|
if (message) {
|
|
893
|
-
this.logger.log('[CONVS-DETAIL] - newMessageAdded message ', message)
|
|
1081
|
+
this.logger.log('[CONVS-DETAIL] - newMessageAdded message ', message)
|
|
894
1082
|
|
|
895
1083
|
if (message.isSender) {
|
|
896
|
-
this.scrollBottom(0)
|
|
897
|
-
|
|
1084
|
+
this.scrollBottom(0)
|
|
898
1085
|
} else if (!message.isSender) {
|
|
899
|
-
if (this.showButtonToBottom) {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1086
|
+
if (this.showButtonToBottom) {
|
|
1087
|
+
// NON SONO ALLA FINE
|
|
1088
|
+
this.NUM_BADGES++
|
|
1089
|
+
} else {
|
|
1090
|
+
//SONO ALLA FINE
|
|
1091
|
+
this.scrollBottom(0)
|
|
903
1092
|
}
|
|
904
1093
|
}
|
|
905
1094
|
}
|
|
906
1095
|
}
|
|
907
1096
|
|
|
908
1097
|
updateConversationBadge() {
|
|
909
|
-
if (
|
|
910
|
-
this.
|
|
911
|
-
|
|
912
|
-
this.
|
|
1098
|
+
if (
|
|
1099
|
+
this.conversationWith &&
|
|
1100
|
+
this.conversationsHandlerService &&
|
|
1101
|
+
this.conv_type === 'active'
|
|
1102
|
+
) {
|
|
1103
|
+
this.conversationsHandlerService.setConversationRead(
|
|
1104
|
+
this.conversationWith,
|
|
1105
|
+
)
|
|
1106
|
+
} else if (
|
|
1107
|
+
this.conversationWith &&
|
|
1108
|
+
this.archivedConversationsHandlerService &&
|
|
1109
|
+
this.conv_type === 'archived'
|
|
1110
|
+
) {
|
|
1111
|
+
this.archivedConversationsHandlerService.setConversationRead(
|
|
1112
|
+
this.conversationWith,
|
|
1113
|
+
)
|
|
913
1114
|
}
|
|
914
1115
|
}
|
|
915
1116
|
|
|
916
1117
|
// -----------------------------------------------------------
|
|
917
|
-
// OUTPUT-EVENT handler
|
|
1118
|
+
// OUTPUT-EVENT handler
|
|
918
1119
|
// -----------------------------------------------------------
|
|
919
1120
|
logScrollStart(event: any) {
|
|
920
|
-
this.logger.log('[CONVS-DETAIL] logScrollStart: ', event)
|
|
1121
|
+
this.logger.log('[CONVS-DETAIL] logScrollStart: ', event)
|
|
921
1122
|
}
|
|
922
1123
|
|
|
923
1124
|
logScrolling(event: any) {
|
|
924
|
-
// EVENTO IONIC-NATIVE: SCATTA SEMPRE, QUINDI DECIDO SE MOSTRARE O MENO IL BADGE
|
|
1125
|
+
// EVENTO IONIC-NATIVE: SCATTA SEMPRE, QUINDI DECIDO SE MOSTRARE O MENO IL BADGE
|
|
925
1126
|
// this.logger.log('[CONVS-DETAIL] logScrolling: ', event);
|
|
926
1127
|
this.detectBottom()
|
|
927
1128
|
}
|
|
@@ -930,50 +1131,58 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
930
1131
|
// this.logger.log('[CONVS-DETAIL] logScrollEnd: ', event);
|
|
931
1132
|
}
|
|
932
1133
|
|
|
933
|
-
|
|
934
1134
|
returnChangeTextArea(e: any) {
|
|
935
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea event', e)
|
|
1135
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea event', e)
|
|
936
1136
|
try {
|
|
937
|
-
let height: number = e.offsetHeight
|
|
1137
|
+
let height: number = e.offsetHeight
|
|
938
1138
|
if (height < 50) {
|
|
939
|
-
height = 50
|
|
1139
|
+
height = 50
|
|
940
1140
|
}
|
|
941
1141
|
|
|
942
|
-
this.heightMessageTextArea = height.toString()
|
|
943
|
-
const message = e.msg
|
|
944
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea heightMessageTextArea ', this.heightMessageTextArea)
|
|
1142
|
+
this.heightMessageTextArea = height.toString() //e.target.scrollHeight + 20;
|
|
1143
|
+
const message = e.msg
|
|
1144
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea heightMessageTextArea ', this.heightMessageTextArea)
|
|
945
1145
|
|
|
946
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea e.detail.value', e.msg)
|
|
947
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea loggedUser uid:', this.loggedUser.uid)
|
|
948
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea loggedUser firstname:', this.loggedUser.firstname)
|
|
949
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea conversationSelected uid:', this.conversationWith)
|
|
950
|
-
this.logger.log('[CONVS-DETAIL] returnChangeTextArea channelType:', this.channelType)
|
|
951
|
-
let idCurrentUser = ''
|
|
952
|
-
let userFullname = ''
|
|
1146
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea e.detail.value', e.msg)
|
|
1147
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea loggedUser uid:', this.loggedUser.uid)
|
|
1148
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea loggedUser firstname:', this.loggedUser.firstname)
|
|
1149
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea conversationSelected uid:', this.conversationWith)
|
|
1150
|
+
this.logger.log('[CONVS-DETAIL] returnChangeTextArea channelType:', this.channelType)
|
|
1151
|
+
let idCurrentUser = ''
|
|
1152
|
+
let userFullname = ''
|
|
953
1153
|
|
|
954
1154
|
// serve x mantenere la compatibilità con le vecchie chat
|
|
955
1155
|
// if (this.channelType === TYPE_DIRECT) {
|
|
956
1156
|
// userId = this.loggedUser.uid;
|
|
957
1157
|
// }
|
|
958
|
-
idCurrentUser = this.loggedUser.uid
|
|
1158
|
+
idCurrentUser = this.loggedUser.uid
|
|
959
1159
|
|
|
960
|
-
if (
|
|
961
|
-
|
|
1160
|
+
if (
|
|
1161
|
+
this.loggedUser.firstname &&
|
|
1162
|
+
this.loggedUser.firstname !== undefined
|
|
1163
|
+
) {
|
|
1164
|
+
userFullname = this.loggedUser.firstname
|
|
962
1165
|
}
|
|
963
|
-
this.typingService.setTyping(
|
|
964
|
-
|
|
965
|
-
|
|
1166
|
+
this.typingService.setTyping(
|
|
1167
|
+
this.conversationWith,
|
|
1168
|
+
message,
|
|
1169
|
+
idCurrentUser,
|
|
1170
|
+
userFullname,
|
|
1171
|
+
)
|
|
966
1172
|
|
|
967
1173
|
// ----------------------------------------------------------
|
|
968
1174
|
// DISPLAY CANNED RESPONSES if message.lastIndexOf("/")
|
|
969
1175
|
// ----------------------------------------------------------
|
|
970
|
-
if (this.areVisibleCAR) {
|
|
1176
|
+
if (this.areVisibleCAR && this.support_mode === true) {
|
|
971
1177
|
setTimeout(() => {
|
|
972
|
-
if (this.conversationWith.startsWith(
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
// console.log("[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ", pos);
|
|
1178
|
+
if (this.conversationWith.startsWith('support-group')) {
|
|
1179
|
+
const pos = message.lastIndexOf('/')
|
|
1180
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ', pos)
|
|
976
1181
|
|
|
1182
|
+
if (pos === -1) {
|
|
1183
|
+
this.tagsCannedFilter = []
|
|
1184
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1185
|
+
}
|
|
977
1186
|
// test
|
|
978
1187
|
// var rest = message.substring(0, message.lastIndexOf("/") + 1);
|
|
979
1188
|
// var last = message.substring(message.lastIndexOf("/") + 1, message.length);
|
|
@@ -986,33 +1195,37 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
986
1195
|
// console.log('[CONVS-DETAIL] - returnChangeTextArea last is NOT space ');
|
|
987
1196
|
// }
|
|
988
1197
|
|
|
989
|
-
|
|
990
1198
|
if (pos >= 0) {
|
|
991
|
-
var strSearch = message.substr(pos + 1)
|
|
992
|
-
this.logger.log(
|
|
1199
|
+
var strSearch = message.substr(pos + 1)
|
|
1200
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea - canned responses strSearch ', strSearch)
|
|
993
1201
|
|
|
994
1202
|
// --------------------------------------------
|
|
995
1203
|
// Load canned responses
|
|
996
1204
|
// --------------------------------------------
|
|
997
|
-
this.loadTagsCanned(strSearch, this.conversationWith)
|
|
1205
|
+
this.loadTagsCanned(strSearch, this.conversationWith)
|
|
998
1206
|
|
|
999
1207
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1000
1208
|
// Hide / display Canned when the SLASH has POSITION POS 0 and checking if there is a space after the SLASH (in this case it will be hidden)
|
|
1001
1209
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1002
1210
|
|
|
1003
|
-
var after_slash = message.substring(
|
|
1004
|
-
|
|
1005
|
-
|
|
1211
|
+
var after_slash = message.substring(
|
|
1212
|
+
message.lastIndexOf('/') + 1,
|
|
1213
|
+
message.length,
|
|
1214
|
+
)
|
|
1215
|
+
if (
|
|
1216
|
+
pos === 0 &&
|
|
1217
|
+
after_slash.length === 1 &&
|
|
1218
|
+
after_slash.trim() === ''
|
|
1219
|
+
) {
|
|
1220
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is a white space after ')
|
|
1006
1221
|
this.HIDE_CANNED_RESPONSES = true
|
|
1007
1222
|
this.tagsCannedFilter = []
|
|
1008
1223
|
} else if (pos === 0 && after_slash.length === 0) {
|
|
1009
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is NOT a white space after')
|
|
1224
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is NOT a white space after')
|
|
1010
1225
|
this.HIDE_CANNED_RESPONSES = false
|
|
1011
1226
|
}
|
|
1012
1227
|
|
|
1013
|
-
|
|
1014
1228
|
if (pos > 0) {
|
|
1015
|
-
|
|
1016
1229
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1017
1230
|
// Hide / display Canned when the SLASH has POSITION POS > and checking if there is a space after the SLASH (in this case they it be hidden)
|
|
1018
1231
|
// and if there is not a space before the SLASH (in this it will be hidden)
|
|
@@ -1020,225 +1233,304 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1020
1233
|
|
|
1021
1234
|
let beforeSlash = message.substr(pos - 1)
|
|
1022
1235
|
let afterSlash = message.substr(pos + 1)
|
|
1023
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
|
|
1236
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
|
|
1024
1237
|
|
|
1025
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash)
|
|
1026
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash)
|
|
1027
|
-
var afterSlashParts = afterSlash.split(
|
|
1028
|
-
var beforeSlashParts = beforeSlash.split(
|
|
1029
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts)
|
|
1030
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash parts', beforeSlashParts)
|
|
1238
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash)
|
|
1239
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash)
|
|
1240
|
+
var afterSlashParts = afterSlash.split('/')
|
|
1241
|
+
var beforeSlashParts = beforeSlash.split('/')
|
|
1242
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts)
|
|
1243
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash parts', beforeSlashParts)
|
|
1031
1244
|
|
|
1032
1245
|
if (beforeSlashParts.length === 2) {
|
|
1033
|
-
if (
|
|
1246
|
+
if (
|
|
1247
|
+
beforeSlashParts[0].indexOf(' ') >= 0 &&
|
|
1248
|
+
afterSlashParts[0] === ''
|
|
1249
|
+
) {
|
|
1034
1250
|
this.HIDE_CANNED_RESPONSES = false
|
|
1035
|
-
this.logger.log(
|
|
1251
|
+
this.logger.log(
|
|
1252
|
+
'[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash there is a white space After Not',
|
|
1253
|
+
)
|
|
1036
1254
|
// if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0].indexOf(' ') >= 0)
|
|
1037
|
-
} else if (
|
|
1038
|
-
|
|
1255
|
+
} else if (
|
|
1256
|
+
beforeSlashParts[0].indexOf(' ') < 0 &&
|
|
1257
|
+
afterSlashParts[0] === ''
|
|
1258
|
+
) {
|
|
1259
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1039
1260
|
this.tagsCannedFilter = []
|
|
1040
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not')
|
|
1041
|
-
} else if (
|
|
1042
|
-
|
|
1043
|
-
|
|
1261
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not')
|
|
1262
|
+
} else if (
|
|
1263
|
+
beforeSlashParts[0].indexOf(' ') >= 0 &&
|
|
1264
|
+
afterSlashParts[0] === ' '
|
|
1265
|
+
) {
|
|
1266
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After YES')
|
|
1267
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1044
1268
|
this.tagsCannedFilter = []
|
|
1045
1269
|
}
|
|
1046
1270
|
}
|
|
1047
1271
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
1272
|
} else {
|
|
1051
|
-
this.tagsCannedFilter = []
|
|
1273
|
+
this.tagsCannedFilter = []
|
|
1052
1274
|
}
|
|
1053
1275
|
}
|
|
1054
|
-
}, 300)
|
|
1055
|
-
|
|
1276
|
+
}, 300)
|
|
1056
1277
|
}
|
|
1057
1278
|
// ./ CANNED RESPONSES //
|
|
1058
|
-
|
|
1059
1279
|
} catch (err) {
|
|
1060
|
-
this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
|
|
1280
|
+
this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
|
|
1061
1281
|
}
|
|
1062
1282
|
}
|
|
1063
1283
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
1284
|
// ----------------------------------------------------------
|
|
1067
1285
|
// @ CANNED RESPONSES methods
|
|
1068
1286
|
// ----------------------------------------------------------
|
|
1069
1287
|
loadTagsCanned(strSearch, conversationWith) {
|
|
1070
|
-
this.logger.log(
|
|
1071
|
-
this.logger.log(
|
|
1072
|
-
this.logger.log(
|
|
1073
|
-
|
|
1074
|
-
const conversationWith_segments = conversationWith.split('-')
|
|
1075
|
-
// Removes the last element of the array if is = to the separator
|
|
1076
|
-
if (
|
|
1077
|
-
conversationWith_segments.
|
|
1288
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned strSearch ', strSearch)
|
|
1289
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned groupDetail ', this.groupDetail)
|
|
1290
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith ', conversationWith)
|
|
1291
|
+
|
|
1292
|
+
const conversationWith_segments = conversationWith.split('-')
|
|
1293
|
+
// Removes the last element of the array if is = to the separator
|
|
1294
|
+
if (
|
|
1295
|
+
conversationWith_segments[conversationWith_segments.length - 1] === ''
|
|
1296
|
+
) {
|
|
1297
|
+
conversationWith_segments.pop()
|
|
1078
1298
|
}
|
|
1079
1299
|
|
|
1080
1300
|
if (conversationWith_segments.length === 4) {
|
|
1081
|
-
const lastArrayElement =
|
|
1082
|
-
|
|
1083
|
-
this.logger.log('[CONVS-DETAIL] - lastArrayElement
|
|
1301
|
+
const lastArrayElement =
|
|
1302
|
+
conversationWith_segments[conversationWith_segments.length - 1]
|
|
1303
|
+
this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement)
|
|
1304
|
+
this.logger.log('[CONVS-DETAIL] - lastArrayElement length', lastArrayElement.length)
|
|
1084
1305
|
if (lastArrayElement.length !== 32) {
|
|
1085
|
-
conversationWith_segments.pop()
|
|
1306
|
+
conversationWith_segments.pop()
|
|
1086
1307
|
}
|
|
1087
1308
|
}
|
|
1088
1309
|
|
|
1089
|
-
this.logger.log(
|
|
1090
|
-
let projectId =
|
|
1310
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ', conversationWith_segments)
|
|
1311
|
+
let projectId = ''
|
|
1091
1312
|
|
|
1092
1313
|
if (conversationWith_segments.length === 4) {
|
|
1093
|
-
projectId = conversationWith_segments[2]
|
|
1094
|
-
this.logger.log(
|
|
1314
|
+
projectId = conversationWith_segments[2]
|
|
1315
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
|
|
1095
1316
|
|
|
1096
1317
|
this.getAndShowCannedResponses(strSearch, projectId)
|
|
1097
|
-
|
|
1098
1318
|
} else {
|
|
1099
1319
|
this.getProjectIdByConversationWith(strSearch, this.conversationWith)
|
|
1100
1320
|
}
|
|
1101
1321
|
}
|
|
1102
1322
|
|
|
1103
1323
|
getProjectIdByConversationWith(strSearch, conversationWith: string) {
|
|
1104
|
-
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1105
|
-
|
|
1106
|
-
this.tiledeskService
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1324
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1325
|
+
|
|
1326
|
+
this.tiledeskService
|
|
1327
|
+
.getProjectIdByConvRecipient(tiledeskToken, conversationWith)
|
|
1328
|
+
.subscribe(
|
|
1329
|
+
(res) => {
|
|
1330
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
|
|
1331
|
+
if (res) {
|
|
1332
|
+
const projectId = res.id_project
|
|
1333
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
|
|
1334
|
+
if (projectId) {
|
|
1335
|
+
this.getAndShowCannedResponses(strSearch, projectId)
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
},
|
|
1339
|
+
(error) => {
|
|
1340
|
+
this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
|
|
1341
|
+
},
|
|
1342
|
+
() => {
|
|
1343
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
|
|
1344
|
+
},
|
|
1345
|
+
)
|
|
1123
1346
|
}
|
|
1124
1347
|
|
|
1125
1348
|
getAndShowCannedResponses(strSearch, projectId) {
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1349
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1350
|
+
this.logger.log(
|
|
1351
|
+
'[CONVS-DETAIL] - loadTagsCanned tagsCanned.length',
|
|
1352
|
+
this.tagsCanned.length,
|
|
1353
|
+
)
|
|
1129
1354
|
//if(this.tagsCanned.length <= 0 ){
|
|
1130
|
-
this.tagsCanned = []
|
|
1131
|
-
this.cannedResponsesService
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1355
|
+
this.tagsCanned = []
|
|
1356
|
+
this.cannedResponsesService
|
|
1357
|
+
.getCannedResponses(tiledeskToken, projectId)
|
|
1358
|
+
.subscribe(
|
|
1359
|
+
(res) => {
|
|
1360
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res)
|
|
1361
|
+
|
|
1362
|
+
this.tagsCanned = res
|
|
1363
|
+
this.tagsCannedCount = res.length
|
|
1364
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount)
|
|
1365
|
+
if (this.HIDE_CANNED_RESPONSES === false) {
|
|
1366
|
+
this.showTagsCanned(strSearch)
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
(error) => {
|
|
1370
|
+
this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error)
|
|
1371
|
+
},
|
|
1372
|
+
() => {
|
|
1373
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *')
|
|
1374
|
+
},
|
|
1375
|
+
)
|
|
1148
1376
|
}
|
|
1149
1377
|
|
|
1150
|
-
|
|
1151
1378
|
showTagsCanned(strSearch) {
|
|
1152
|
-
this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch)
|
|
1153
|
-
this.tagsCannedFilter = []
|
|
1154
|
-
var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned))
|
|
1155
|
-
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedClone ', tagsCannedClone)
|
|
1379
|
+
this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch)
|
|
1380
|
+
this.tagsCannedFilter = []
|
|
1381
|
+
var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned))
|
|
1382
|
+
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedClone ', tagsCannedClone)
|
|
1156
1383
|
//this.logger.log("that.contacts lenght:: ", strSearch);
|
|
1157
|
-
this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
|
|
1158
|
-
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter)
|
|
1384
|
+
this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
|
|
1385
|
+
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter)
|
|
1159
1386
|
|
|
1160
|
-
this.tagsCannedFilter.sort(compareValues('title', 'asc'))
|
|
1161
|
-
var strReplace = strSearch
|
|
1387
|
+
this.tagsCannedFilter.sort(compareValues('title', 'asc'))
|
|
1388
|
+
var strReplace = strSearch
|
|
1162
1389
|
if (strSearch.length > 0) {
|
|
1163
|
-
strReplace = "<b class='highlight-search-string'>" + strSearch +
|
|
1390
|
+
strReplace = "<b class='highlight-search-string'>" + strSearch + '</b>'
|
|
1164
1391
|
}
|
|
1165
1392
|
for (var i = 0; i < this.tagsCannedFilter.length; i++) {
|
|
1166
|
-
|
|
1167
|
-
|
|
1393
|
+
let text = htmlEntities(this.tagsCannedFilter[i].text);
|
|
1394
|
+
// const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) + '</div>'
|
|
1395
|
+
const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(text) + '</div>'
|
|
1396
|
+
let title = htmlEntities(this.tagsCannedFilter[i].title)
|
|
1397
|
+
// this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + this.tagsCannedFilter[i].title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
|
|
1398
|
+
this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
|
|
1399
|
+
|
|
1168
1400
|
}
|
|
1169
1401
|
if (this.tagsCannedCount === 0) {
|
|
1170
|
-
const
|
|
1402
|
+
// const button = this.renderer.createElement('button');
|
|
1403
|
+
// const buttonText = this.renderer.createText('Click me');
|
|
1404
|
+
// this.renderer.appendChild(button, buttonText);
|
|
1405
|
+
// console.log('[CONVS-DETAIL] - this.el.nativeElement ', this.el.nativeElement)
|
|
1406
|
+
// this.renderer.listen(button, 'click', () => { alert('hi'); });
|
|
1407
|
+
// let nocanned = {}
|
|
1408
|
+
// if (this.USER_ROLE !== 'agent') {
|
|
1409
|
+
const nocanned = {
|
|
1410
|
+
// "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div><div class='cannedText'>" + this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') + '</div></div>'
|
|
1411
|
+
// <div class='cannedText no-canned-available-text'>" + this.translationMap.get('AddNewCannedResponse') + '</div>
|
|
1412
|
+
title:
|
|
1413
|
+
"<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div></div>",
|
|
1414
|
+
text: 'There are no canned responses available',
|
|
1415
|
+
}
|
|
1416
|
+
// } else if (this.USER_ROLE === 'agent') {
|
|
1417
|
+
// nocanned = {
|
|
1418
|
+
// // "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div><div class='cannedText'>" + this.translationMap.get('TO_CREATE_THEM_GO_TO_THE_PROJECT') + '</div></div>'
|
|
1419
|
+
// title:
|
|
1420
|
+
// "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div></div>",
|
|
1421
|
+
// text: 'There are no canned responses available',
|
|
1422
|
+
// }
|
|
1423
|
+
// }
|
|
1171
1424
|
this.tagsCannedFilter.push(nocanned)
|
|
1172
1425
|
}
|
|
1173
1426
|
}
|
|
1174
1427
|
|
|
1428
|
+
toggleSidebar() {
|
|
1429
|
+
// console.log('[CONVS-DETAIL] has clicked test')
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1175
1432
|
filterItems(items, searchTerm) {
|
|
1176
|
-
this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
|
|
1433
|
+
this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
|
|
1177
1434
|
//this.logger.log("filterItems::: ",searchTerm);
|
|
1178
1435
|
return items.filter((item) => {
|
|
1179
1436
|
//this.logger.log("filterItems::: ", item.title.toString().toLowerCase());
|
|
1180
|
-
this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
|
|
1181
|
-
return
|
|
1182
|
-
|
|
1437
|
+
this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
|
|
1438
|
+
return (
|
|
1439
|
+
item.title
|
|
1440
|
+
.toString()
|
|
1441
|
+
.toLowerCase()
|
|
1442
|
+
.indexOf(searchTerm.toString().toLowerCase()) > -1
|
|
1443
|
+
)
|
|
1444
|
+
})
|
|
1183
1445
|
}
|
|
1184
1446
|
|
|
1185
1447
|
replacePlaceholderInCanned(str) {
|
|
1186
|
-
this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
|
|
1187
|
-
str = str.replace('$recipient_name', this.conversationWithFullname)
|
|
1448
|
+
this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
|
|
1449
|
+
str = str.replace('$recipient_name', this.conversationWithFullname)
|
|
1188
1450
|
if (this.loggedUser && this.loggedUser.fullname) {
|
|
1189
|
-
str = str.replace('$agent_name', this.loggedUser.fullname)
|
|
1451
|
+
str = str.replace('$agent_name', this.loggedUser.fullname)
|
|
1190
1452
|
}
|
|
1191
|
-
return str
|
|
1453
|
+
return str
|
|
1192
1454
|
}
|
|
1193
1455
|
|
|
1194
1456
|
replaceTagInMessage(canned, event) {
|
|
1195
|
-
this.
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1457
|
+
if (this.tagsCannedCount > 0) {
|
|
1458
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage event ', event)
|
|
1459
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage canned ', canned)
|
|
1460
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage canned title', canned.title)
|
|
1461
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage canned contains nocannedTitle', canned.title.includes('nocannedTitle'))
|
|
1462
|
+
|
|
1463
|
+
const elTextArea = this.rowTextArea['el']
|
|
1464
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1465
|
+
|
|
1466
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage textArea ', textArea)
|
|
1467
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage textArea value', textArea.value,)
|
|
1468
|
+
|
|
1469
|
+
// var lastChar = textArea.value.substr(-1); // Selects the last character
|
|
1470
|
+
// if (lastChar === '/') {
|
|
1471
|
+
// textArea.value = textArea.value.substring(0, textArea.value.length() - 1);
|
|
1472
|
+
// }
|
|
1473
|
+
// this.insertAtCursor(this.textArea, textArea.value)
|
|
1474
|
+
|
|
1475
|
+
this.arrowkeyLocation = -1
|
|
1476
|
+
this.tagsCannedFilter = []
|
|
1477
|
+
this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned text ', canned.text)
|
|
1478
|
+
|
|
1479
|
+
// replace text
|
|
1480
|
+
var pos = textArea.value.lastIndexOf('/')
|
|
1481
|
+
var strSearch = textArea.value.substr(pos)
|
|
1482
|
+
this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strSearch)
|
|
1483
|
+
|
|
1484
|
+
var strTEMP = textArea.value.replace(strSearch, canned.text)
|
|
1485
|
+
strTEMP = this.replacePlaceholderInCanned(strTEMP)
|
|
1486
|
+
this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strTEMP)
|
|
1487
|
+
// strTEMP = this.replacePlaceholderInCanned(strTEMP);
|
|
1488
|
+
// textArea.value = '';
|
|
1489
|
+
// that.messageString = strTEMP;
|
|
1490
|
+
textArea.value = strTEMP
|
|
1491
|
+
setTimeout(() => {
|
|
1492
|
+
// textArea.focus();
|
|
1493
|
+
textArea.setFocus()
|
|
1494
|
+
this.resizeTextArea()
|
|
1495
|
+
}, 200)
|
|
1496
|
+
}
|
|
1497
|
+
else {
|
|
1498
|
+
this.logger.log('[CONVS-DETAIL] THERE IS NOT CANNED ', canned.text)
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1212
1501
|
|
|
1502
|
+
async presentCreateCannedResponseModal(): Promise<any> {
|
|
1503
|
+
const elTextArea = this.rowTextArea['el']
|
|
1504
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1505
|
+
textArea.value = ''
|
|
1213
1506
|
|
|
1214
|
-
//
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1507
|
+
// console.log('[CONVS-DETAIL] PRESENT CREATE CANNED RESPONSE MODAL ')
|
|
1508
|
+
const attributes = { conversationWith: this.conversationWith }
|
|
1509
|
+
const modal: HTMLIonModalElement = await this.modalController.create({
|
|
1510
|
+
component: CreateCannedResponsePage,
|
|
1511
|
+
componentProps: attributes,
|
|
1512
|
+
swipeToClose: false,
|
|
1513
|
+
backdropDismiss: false,
|
|
1514
|
+
})
|
|
1515
|
+
modal.onDidDismiss().then((dataReturned: any) => {
|
|
1516
|
+
this.logger.log('[CONVS-DETAIL] ', dataReturned.data)
|
|
1517
|
+
})
|
|
1218
1518
|
|
|
1219
|
-
|
|
1220
|
-
strTEMP = this.replacePlaceholderInCanned(strTEMP);
|
|
1221
|
-
this.logger.log("[CONVS-DETAIL] replaceTagInMessage strSearch ", strTEMP);
|
|
1222
|
-
// strTEMP = this.replacePlaceholderInCanned(strTEMP);
|
|
1223
|
-
// textArea.value = '';
|
|
1224
|
-
// that.messageString = strTEMP;
|
|
1225
|
-
textArea.value = strTEMP;
|
|
1226
|
-
setTimeout(() => {
|
|
1227
|
-
// textArea.focus();
|
|
1228
|
-
textArea.setFocus();
|
|
1229
|
-
this.resizeTextArea();
|
|
1230
|
-
}, 200);
|
|
1519
|
+
return await modal.present()
|
|
1231
1520
|
}
|
|
1232
1521
|
|
|
1233
|
-
|
|
1234
1522
|
hasClickedOpenCannedResponses($event) {
|
|
1235
1523
|
this.logger.log('[CONVS-DETAIL] - hasClickedOpenCannedResponses ', $event)
|
|
1236
|
-
const elTextArea = this.rowTextArea['el']
|
|
1237
|
-
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1238
|
-
|
|
1239
|
-
this.logger.log(
|
|
1240
|
-
|
|
1241
|
-
|
|
1524
|
+
const elTextArea = this.rowTextArea['el']
|
|
1525
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1526
|
+
|
|
1527
|
+
this.logger.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ', textArea)
|
|
1528
|
+
// console.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
|
|
1529
|
+
var lastChar = textArea.value[textArea.value.length - 1]
|
|
1530
|
+
// console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses lastChar', lastChar)
|
|
1531
|
+
if (lastChar !== '/') {
|
|
1532
|
+
this.insertAtCursor(textArea, '/')
|
|
1533
|
+
}
|
|
1242
1534
|
// console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea.value', textArea.value)
|
|
1243
1535
|
// setTimeout(() => {
|
|
1244
1536
|
// // if (textArea.value === '/') {
|
|
@@ -1252,13 +1544,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1252
1544
|
|
|
1253
1545
|
setCaretPosition(ctrl) {
|
|
1254
1546
|
ctrl.value.trim()
|
|
1255
|
-
ctrl.setFocus()
|
|
1547
|
+
ctrl.setFocus()
|
|
1256
1548
|
}
|
|
1257
1549
|
|
|
1258
1550
|
insertAtCursor(myField, myValue) {
|
|
1259
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
|
|
1260
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
|
|
1261
|
-
|
|
1551
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
|
|
1552
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
|
|
1262
1553
|
|
|
1263
1554
|
// myValue = ' ' + myValue;
|
|
1264
1555
|
|
|
@@ -1266,38 +1557,41 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1266
1557
|
// console.log('[CONVS-DETAIL] - GET TEXT AREA - Here yes textArea value length', myField.value.length);
|
|
1267
1558
|
|
|
1268
1559
|
if (myField.value.length > 0) {
|
|
1269
|
-
myValue = ' ' + myValue
|
|
1560
|
+
myValue = ' ' + myValue
|
|
1270
1561
|
}
|
|
1271
1562
|
|
|
1272
1563
|
//IE support
|
|
1273
1564
|
if (myField.selection) {
|
|
1274
|
-
myField.focus()
|
|
1275
|
-
let sel = myField.selection.createRange()
|
|
1276
|
-
sel.text = myValue
|
|
1565
|
+
myField.focus()
|
|
1566
|
+
let sel = myField.selection.createRange()
|
|
1567
|
+
sel.text = myValue
|
|
1277
1568
|
// this.cannedResponseMessage = sel.text;
|
|
1278
1569
|
}
|
|
1279
1570
|
//MOZILLA and others
|
|
1280
1571
|
else if (myField.selectionStart || myField.selectionStart == '0') {
|
|
1281
|
-
var startPos = myField.selectionStart
|
|
1282
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
|
|
1572
|
+
var startPos = myField.selectionStart
|
|
1573
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
|
|
1283
1574
|
|
|
1284
|
-
var endPos = myField.selectionEnd
|
|
1285
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
|
|
1575
|
+
var endPos = myField.selectionEnd
|
|
1576
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
|
|
1286
1577
|
|
|
1287
|
-
myField.value =
|
|
1578
|
+
myField.value =
|
|
1579
|
+
myField.value.substring(0, startPos) +
|
|
1580
|
+
myValue +
|
|
1581
|
+
myField.value.substring(endPos, myField.value.length)
|
|
1288
1582
|
|
|
1289
1583
|
// place cursor at end of text in text input element
|
|
1290
|
-
myField.focus()
|
|
1291
|
-
var val = myField.value
|
|
1292
|
-
myField.value = ''
|
|
1293
|
-
myField.value = val + ' '
|
|
1584
|
+
myField.focus()
|
|
1585
|
+
var val = myField.value //store the value of the element
|
|
1586
|
+
myField.value = '' //clear the value of the element
|
|
1587
|
+
myField.value = val + ' ' //set that value back.
|
|
1294
1588
|
|
|
1295
1589
|
// this.cannedResponseMessage = myField.value;
|
|
1296
1590
|
|
|
1297
1591
|
// this.texareaIsEmpty = false;
|
|
1298
1592
|
// myField.select();
|
|
1299
1593
|
} else {
|
|
1300
|
-
myField.value += myValue
|
|
1594
|
+
myField.value += myValue
|
|
1301
1595
|
// this.cannedResponseMessage = myField.value;
|
|
1302
1596
|
}
|
|
1303
1597
|
}
|
|
@@ -1307,30 +1601,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1307
1601
|
// this.logger.log("CONVERSATION-DETAIL handleKeyboardEvent event.key ", event.key);
|
|
1308
1602
|
|
|
1309
1603
|
if (this.tagsCannedFilter.length > 0) {
|
|
1310
|
-
|
|
1311
1604
|
if (event.key === 'ArrowDown') {
|
|
1312
|
-
|
|
1313
|
-
this.arrowkeyLocation++;
|
|
1605
|
+
this.arrowkeyLocation++
|
|
1314
1606
|
if (this.arrowkeyLocation === this.tagsCannedFilter.length) {
|
|
1315
1607
|
this.arrowkeyLocation--
|
|
1316
1608
|
}
|
|
1317
1609
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
1318
|
-
}
|
|
1319
|
-
else if (event.key === 'ArrowUp') {
|
|
1320
|
-
|
|
1610
|
+
} else if (event.key === 'ArrowUp') {
|
|
1321
1611
|
if (this.arrowkeyLocation > 0) {
|
|
1322
|
-
this.arrowkeyLocation
|
|
1612
|
+
this.arrowkeyLocation--
|
|
1323
1613
|
} else if (this.arrowkeyLocation < 0) {
|
|
1324
|
-
this.arrowkeyLocation
|
|
1614
|
+
this.arrowkeyLocation++
|
|
1325
1615
|
}
|
|
1326
1616
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
1327
1617
|
}
|
|
1328
1618
|
|
|
1329
1619
|
if (event.key === 'Enter') {
|
|
1330
1620
|
const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
|
|
1331
|
-
this.logger.log(
|
|
1621
|
+
this.logger.log(
|
|
1622
|
+
'[CONVS-DETAIL] replaceTagInMessage canned_selected ',
|
|
1623
|
+
canned_selected,
|
|
1624
|
+
)
|
|
1332
1625
|
if (canned_selected) {
|
|
1333
|
-
|
|
1334
1626
|
this.replaceTagInMessage(canned_selected, 'enter')
|
|
1335
1627
|
// event.preventDefault();
|
|
1336
1628
|
// return false;
|
|
@@ -1342,35 +1634,40 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1342
1634
|
// ./end CANNED RESPONSES methods
|
|
1343
1635
|
// ----------------------------------------------------------
|
|
1344
1636
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
1637
|
// ----------------------------------------------------------
|
|
1348
|
-
// @ Rule of sound message
|
|
1638
|
+
// @ Rule of sound message
|
|
1349
1639
|
// * if I send it -> NO SOUND
|
|
1350
1640
|
// * if I'm not in the conversation -> SOUND
|
|
1351
1641
|
// * if I'm in the conversation at the bottom of the page -> NO SOUND
|
|
1352
1642
|
// * otherwise -> SOUND
|
|
1353
1643
|
// ----------------------------------------------------------
|
|
1354
1644
|
soundMessage() {
|
|
1355
|
-
const that = this
|
|
1356
|
-
this.audio = new Audio()
|
|
1645
|
+
const that = this
|
|
1646
|
+
this.audio = new Audio()
|
|
1357
1647
|
// this.audio.src = '/assets/sounds/pling.mp3';
|
|
1358
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION
|
|
1359
|
-
this.audio.load()
|
|
1360
|
-
this.logger.log(
|
|
1361
|
-
|
|
1648
|
+
this.audio.src = URL_SOUND_LIST_CONVERSATION
|
|
1649
|
+
this.audio.load()
|
|
1650
|
+
this.logger.log(
|
|
1651
|
+
'[CONVS-DETAIL] soundMessage conversation this.audio',
|
|
1652
|
+
this.audio,
|
|
1653
|
+
)
|
|
1654
|
+
clearTimeout(this.setTimeoutSound)
|
|
1362
1655
|
this.setTimeoutSound = setTimeout(function () {
|
|
1363
|
-
that.audio
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1656
|
+
that.audio
|
|
1657
|
+
.play()
|
|
1658
|
+
.then(() => {
|
|
1659
|
+
// Audio is playing.
|
|
1660
|
+
this.logger.log(
|
|
1661
|
+
'[CONVS-DETAIL] soundMessag that.audio.src ',
|
|
1662
|
+
that.audio.src,
|
|
1663
|
+
)
|
|
1664
|
+
})
|
|
1665
|
+
.catch((error) => {
|
|
1666
|
+
that.logger.error(error)
|
|
1667
|
+
})
|
|
1668
|
+
}, 1000)
|
|
1370
1669
|
}
|
|
1371
1670
|
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
1671
|
returnOnBeforeMessageRender(event) {
|
|
1375
1672
|
//this.onBeforeMessageRender.emit(event)
|
|
1376
1673
|
}
|
|
@@ -1383,86 +1680,83 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1383
1680
|
// this.isMenuShow = event;
|
|
1384
1681
|
}
|
|
1385
1682
|
|
|
1386
|
-
returnOnScrollContent(event: boolean) {
|
|
1387
|
-
|
|
1388
|
-
}
|
|
1683
|
+
returnOnScrollContent(event: boolean) { }
|
|
1389
1684
|
|
|
1390
1685
|
returnOnAttachmentButtonClicked(event: any) {
|
|
1391
1686
|
this.logger.debug('[CONV-COMP] eventbutton', event)
|
|
1392
1687
|
if (!event || !event.target.type) {
|
|
1393
|
-
return
|
|
1688
|
+
return
|
|
1394
1689
|
}
|
|
1395
1690
|
switch (event.target.type) {
|
|
1396
1691
|
case 'url':
|
|
1397
1692
|
try {
|
|
1398
|
-
this.openLink(event.target.button)
|
|
1693
|
+
this.openLink(event.target.button)
|
|
1399
1694
|
} catch (err) {
|
|
1400
|
-
this.logger.error('[CONV-COMP] url > Error :' + err)
|
|
1695
|
+
this.logger.error('[CONV-COMP] url > Error :' + err)
|
|
1401
1696
|
}
|
|
1402
|
-
return
|
|
1697
|
+
return
|
|
1403
1698
|
case 'action':
|
|
1404
1699
|
try {
|
|
1405
|
-
this.actionButton(event.target.button)
|
|
1700
|
+
this.actionButton(event.target.button)
|
|
1406
1701
|
} catch (err) {
|
|
1407
|
-
this.logger.error('[CONV-COMP] action > Error :' + err)
|
|
1702
|
+
this.logger.error('[CONV-COMP] action > Error :' + err)
|
|
1408
1703
|
}
|
|
1409
|
-
return false
|
|
1704
|
+
return false
|
|
1410
1705
|
case 'text':
|
|
1411
1706
|
try {
|
|
1412
1707
|
const text = event.target.button.value
|
|
1413
|
-
const metadata = {
|
|
1414
|
-
this.sendMessage(text, TYPE_MSG_TEXT, metadata)
|
|
1708
|
+
const metadata = { button: true }
|
|
1709
|
+
this.sendMessage(text, TYPE_MSG_TEXT, metadata)
|
|
1415
1710
|
} catch (err) {
|
|
1416
|
-
this.logger.error('[CONV-COMP] text > Error :' + err)
|
|
1711
|
+
this.logger.error('[CONV-COMP] text > Error :' + err)
|
|
1417
1712
|
}
|
|
1418
|
-
default:
|
|
1713
|
+
default:
|
|
1714
|
+
return
|
|
1419
1715
|
}
|
|
1420
1716
|
}
|
|
1421
1717
|
|
|
1422
1718
|
onImageRenderedFN(event) {
|
|
1423
|
-
const imageRendered = event
|
|
1719
|
+
const imageRendered = event
|
|
1424
1720
|
if (this.showButtonToBottom) {
|
|
1425
1721
|
this.scrollBottom(0)
|
|
1426
1722
|
}
|
|
1427
1723
|
}
|
|
1428
1724
|
|
|
1429
|
-
|
|
1430
1725
|
private openLink(event: any) {
|
|
1431
|
-
const link = event.link ? event.link : ''
|
|
1432
|
-
const target = event.target ? event.target : ''
|
|
1726
|
+
const link = event.link ? event.link : ''
|
|
1727
|
+
const target = event.target ? event.target : ''
|
|
1433
1728
|
if (target === 'self' || target === 'parent') {
|
|
1434
|
-
window.open(link, '_parent')
|
|
1729
|
+
window.open(link, '_parent')
|
|
1435
1730
|
} else {
|
|
1436
|
-
window.open(link, '_blank')
|
|
1731
|
+
window.open(link, '_blank')
|
|
1437
1732
|
}
|
|
1438
1733
|
}
|
|
1439
1734
|
|
|
1440
|
-
|
|
1441
1735
|
private actionButton(event: any) {
|
|
1442
1736
|
// console.log(event);
|
|
1443
|
-
const action = event.action ? event.action : ''
|
|
1444
|
-
const message = event.value ? event.value : ''
|
|
1445
|
-
const subtype = event.show_reply ? '' : 'info'
|
|
1737
|
+
const action = event.action ? event.action : ''
|
|
1738
|
+
const message = event.value ? event.value : ''
|
|
1739
|
+
const subtype = event.show_reply ? '' : 'info'
|
|
1446
1740
|
|
|
1447
1741
|
const attributes = {
|
|
1448
1742
|
action: action,
|
|
1449
|
-
subtype: subtype
|
|
1450
|
-
}
|
|
1451
|
-
this.sendMessage(message, TYPE_MSG_TEXT, null, attributes)
|
|
1452
|
-
this.logger.debug('[CONV-COMP] > action :')
|
|
1743
|
+
subtype: subtype,
|
|
1744
|
+
}
|
|
1745
|
+
this.sendMessage(message, TYPE_MSG_TEXT, null, attributes)
|
|
1746
|
+
this.logger.debug('[CONV-COMP] > action :')
|
|
1453
1747
|
}
|
|
1454
1748
|
|
|
1455
1749
|
addUploadingBubbleEvent(event: boolean) {
|
|
1456
|
-
this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
|
|
1750
|
+
this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
|
|
1457
1751
|
if (event === true) {
|
|
1458
|
-
this.scrollBottom(0)
|
|
1752
|
+
this.scrollBottom(0)
|
|
1459
1753
|
}
|
|
1460
1754
|
}
|
|
1461
1755
|
|
|
1462
1756
|
onPresentModalScrollToBottom(event: boolean) {
|
|
1463
|
-
this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
|
|
1757
|
+
this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
|
|
1464
1758
|
if (event === true) {
|
|
1465
|
-
this.scrollBottom(0)
|
|
1759
|
+
this.scrollBottom(0)
|
|
1466
1760
|
}
|
|
1467
1761
|
}
|
|
1468
1762
|
|
|
@@ -1470,25 +1764,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1470
1764
|
/** */
|
|
1471
1765
|
resizeTextArea() {
|
|
1472
1766
|
try {
|
|
1473
|
-
const elTextArea = this.rowTextArea['el']
|
|
1474
|
-
const that = this
|
|
1767
|
+
const elTextArea = this.rowTextArea['el']
|
|
1768
|
+
const that = this
|
|
1475
1769
|
setTimeout(() => {
|
|
1476
|
-
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1770
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1477
1771
|
if (textArea) {
|
|
1478
|
-
this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
|
|
1479
|
-
const txtValue = textArea.value
|
|
1480
|
-
textArea.value = ' '
|
|
1481
|
-
textArea.value = txtValue
|
|
1772
|
+
this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
|
|
1773
|
+
const txtValue = textArea.value
|
|
1774
|
+
textArea.value = ' '
|
|
1775
|
+
textArea.value = txtValue
|
|
1482
1776
|
}
|
|
1483
|
-
}, 0)
|
|
1777
|
+
}, 0)
|
|
1484
1778
|
setTimeout(() => {
|
|
1485
1779
|
if (elTextArea) {
|
|
1486
|
-
this.logger.log(
|
|
1487
|
-
|
|
1780
|
+
this.logger.log(
|
|
1781
|
+
'[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ',
|
|
1782
|
+
elTextArea.offsetHeight,
|
|
1783
|
+
)
|
|
1784
|
+
that.heightMessageTextArea = elTextArea.offsetHeight
|
|
1488
1785
|
}
|
|
1489
|
-
}, 100)
|
|
1786
|
+
}, 100)
|
|
1490
1787
|
} catch (err) {
|
|
1491
|
-
this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
|
|
1788
|
+
this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
|
|
1492
1789
|
}
|
|
1493
1790
|
}
|
|
1494
1791
|
|
|
@@ -1497,11 +1794,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1497
1794
|
* @param time
|
|
1498
1795
|
*/
|
|
1499
1796
|
private scrollBottom(time: number) {
|
|
1500
|
-
this.showIonContent = true
|
|
1797
|
+
this.showIonContent = true
|
|
1501
1798
|
if (this.ionContentChatArea) {
|
|
1502
1799
|
setTimeout(() => {
|
|
1503
|
-
this.ionContentChatArea.scrollToBottom(time)
|
|
1504
|
-
}, 0)
|
|
1800
|
+
this.ionContentChatArea.scrollToBottom(time)
|
|
1801
|
+
}, 0)
|
|
1505
1802
|
// nota: se elimino il settimeout lo scrollToBottom non viene richiamato!!!!!
|
|
1506
1803
|
}
|
|
1507
1804
|
}
|
|
@@ -1510,14 +1807,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1510
1807
|
* detectBottom
|
|
1511
1808
|
*/
|
|
1512
1809
|
async detectBottom() {
|
|
1513
|
-
const scrollElement = await this.ionContentChatArea.getScrollElement()
|
|
1810
|
+
const scrollElement = await this.ionContentChatArea.getScrollElement()
|
|
1514
1811
|
|
|
1515
|
-
if (
|
|
1812
|
+
if (
|
|
1813
|
+
scrollElement.scrollTop <
|
|
1814
|
+
scrollElement.scrollHeight - scrollElement.clientHeight
|
|
1815
|
+
) {
|
|
1516
1816
|
//NON SONO ALLA FINE --> mostra badge
|
|
1517
|
-
this.showButtonToBottom = true
|
|
1817
|
+
this.showButtonToBottom = true
|
|
1518
1818
|
} else {
|
|
1519
1819
|
// SONO ALLA FINE --> non mostrare badge,
|
|
1520
|
-
this.showButtonToBottom = false
|
|
1820
|
+
this.showButtonToBottom = false
|
|
1521
1821
|
}
|
|
1522
1822
|
}
|
|
1523
1823
|
|
|
@@ -1526,149 +1826,203 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1526
1826
|
* FIREBY BY: click event ScrollToBottom bottom-right icon button
|
|
1527
1827
|
*/
|
|
1528
1828
|
public actionScrollBottom() {
|
|
1529
|
-
this.logger.log(
|
|
1829
|
+
this.logger.log(
|
|
1830
|
+
'[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ',
|
|
1831
|
+
this.ionContentChatArea,
|
|
1832
|
+
)
|
|
1530
1833
|
// const that = this;
|
|
1531
|
-
this.showButtonToBottom = false
|
|
1834
|
+
this.showButtonToBottom = false
|
|
1532
1835
|
this.updateConversationBadge()
|
|
1533
|
-
this.NUM_BADGES = 0
|
|
1836
|
+
this.NUM_BADGES = 0
|
|
1534
1837
|
setTimeout(() => {
|
|
1535
|
-
this.ionContentChatArea.scrollToBottom(0)
|
|
1838
|
+
this.ionContentChatArea.scrollToBottom(0)
|
|
1536
1839
|
// this.conversationsHandlerService.readAllMessages.next(this.conversationWith);
|
|
1537
|
-
}, 0)
|
|
1840
|
+
}, 0)
|
|
1538
1841
|
}
|
|
1539
1842
|
|
|
1540
1843
|
/**
|
|
1541
1844
|
* Scroll to top of the page after a short delay.
|
|
1542
1845
|
*/
|
|
1543
1846
|
scrollTop() {
|
|
1544
|
-
this.logger.log('[CONVS-DETAIL] scrollTop')
|
|
1545
|
-
this.ionContentChatArea.scrollToTop(100)
|
|
1847
|
+
this.logger.log('[CONVS-DETAIL] scrollTop')
|
|
1848
|
+
this.ionContentChatArea.scrollToTop(100)
|
|
1546
1849
|
}
|
|
1547
1850
|
|
|
1548
1851
|
/** */
|
|
1549
1852
|
setHeightTextArea() {
|
|
1550
1853
|
try {
|
|
1551
1854
|
if (this.rowTextArea) {
|
|
1552
|
-
this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
|
|
1553
|
-
this.logger.log(
|
|
1855
|
+
this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
|
|
1856
|
+
this.logger.log(
|
|
1857
|
+
'[CONVS-DETAIL] setHeightTextArea - heightMessageTextArea: ',
|
|
1858
|
+
this.heightMessageTextArea,
|
|
1859
|
+
)
|
|
1554
1860
|
}
|
|
1555
1861
|
} catch (e) {
|
|
1556
1862
|
this.logger.error('[CONVS-DETAIL] setHeightTextArea - ERROR ', e)
|
|
1557
1863
|
// this.heightMessageTextArea = '50';
|
|
1558
|
-
this.heightMessageTextArea = '57'
|
|
1864
|
+
this.heightMessageTextArea = '57' // NK edited
|
|
1559
1865
|
}
|
|
1560
1866
|
}
|
|
1561
1867
|
checkAcceptedFile(draggedFileMimeType) {
|
|
1562
|
-
let isAcceptFile = false
|
|
1563
|
-
this.logger.log(
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1868
|
+
let isAcceptFile = false
|
|
1869
|
+
this.logger.log(
|
|
1870
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept: ',
|
|
1871
|
+
this.appConfigProvider.getConfig().fileUploadAccept,
|
|
1872
|
+
)
|
|
1873
|
+
const accept_files = this.appConfigProvider.getConfig().fileUploadAccept
|
|
1874
|
+
this.logger.log(
|
|
1875
|
+
'[CONVS-DETAIL] > checkAcceptedFile - mimeType: ',
|
|
1876
|
+
draggedFileMimeType,
|
|
1877
|
+
)
|
|
1878
|
+
if (accept_files === '*/*') {
|
|
1879
|
+
isAcceptFile = true
|
|
1568
1880
|
return isAcceptFile
|
|
1569
|
-
} else if (accept_files !==
|
|
1570
|
-
this.logger.log(
|
|
1881
|
+
} else if (accept_files !== '*/*') {
|
|
1882
|
+
this.logger.log(
|
|
1883
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept typeof accept_files ',
|
|
1884
|
+
typeof accept_files,
|
|
1885
|
+
)
|
|
1571
1886
|
const accept_files_array = accept_files.split(',')
|
|
1572
|
-
this.logger.log(
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1887
|
+
this.logger.log(
|
|
1888
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array ',
|
|
1889
|
+
accept_files_array,
|
|
1890
|
+
)
|
|
1891
|
+
this.logger.log(
|
|
1892
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array typeof: ',
|
|
1893
|
+
typeof accept_files_array,
|
|
1894
|
+
)
|
|
1895
|
+
|
|
1896
|
+
accept_files_array.forEach((accept_file) => {
|
|
1897
|
+
this.logger.log(
|
|
1898
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file ',
|
|
1899
|
+
accept_file,
|
|
1900
|
+
)
|
|
1578
1901
|
const accept_file_segment = accept_file.split('/')
|
|
1579
|
-
this.logger.log(
|
|
1902
|
+
this.logger.log(
|
|
1903
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file_segment ',
|
|
1904
|
+
accept_file_segment,
|
|
1905
|
+
)
|
|
1580
1906
|
if (accept_file_segment[1] === '*') {
|
|
1581
1907
|
if (draggedFileMimeType.startsWith(accept_file_segment[0])) {
|
|
1582
|
-
isAcceptFile = true
|
|
1583
|
-
this.logger.log(
|
|
1908
|
+
isAcceptFile = true
|
|
1909
|
+
this.logger.log(
|
|
1910
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1911
|
+
isAcceptFile,
|
|
1912
|
+
)
|
|
1584
1913
|
return isAcceptFile
|
|
1585
|
-
|
|
1586
1914
|
} else {
|
|
1587
|
-
isAcceptFile = false
|
|
1588
|
-
this.logger.log(
|
|
1915
|
+
isAcceptFile = false
|
|
1916
|
+
this.logger.log(
|
|
1917
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1918
|
+
isAcceptFile,
|
|
1919
|
+
)
|
|
1589
1920
|
return isAcceptFile
|
|
1590
|
-
|
|
1591
1921
|
}
|
|
1592
1922
|
} else if (accept_file_segment[1] !== '*') {
|
|
1593
1923
|
if (draggedFileMimeType === accept_file) {
|
|
1594
|
-
isAcceptFile = true
|
|
1595
|
-
this.logger.log(
|
|
1924
|
+
isAcceptFile = true
|
|
1925
|
+
this.logger.log(
|
|
1926
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1927
|
+
isAcceptFile,
|
|
1928
|
+
)
|
|
1596
1929
|
return isAcceptFile
|
|
1597
1930
|
}
|
|
1598
1931
|
}
|
|
1599
1932
|
return isAcceptFile
|
|
1600
|
-
})
|
|
1933
|
+
})
|
|
1601
1934
|
return isAcceptFile
|
|
1602
1935
|
}
|
|
1603
1936
|
}
|
|
1604
1937
|
// -------------------------------------------------------------
|
|
1605
|
-
// DRAG FILE
|
|
1938
|
+
// DRAG FILE
|
|
1606
1939
|
// -------------------------------------------------------------
|
|
1607
1940
|
// DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
|
|
1608
1941
|
drop(ev: any) {
|
|
1609
|
-
ev.preventDefault()
|
|
1610
|
-
ev.stopPropagation()
|
|
1611
|
-
|
|
1612
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev)
|
|
1613
|
-
const fileList = ev.dataTransfer.files
|
|
1614
|
-
this.logger.log(
|
|
1615
|
-
|
|
1616
|
-
|
|
1942
|
+
ev.preventDefault()
|
|
1943
|
+
ev.stopPropagation()
|
|
1944
|
+
|
|
1945
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev)
|
|
1946
|
+
const fileList = ev.dataTransfer.files
|
|
1947
|
+
this.logger.log(
|
|
1948
|
+
'[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ',
|
|
1949
|
+
fileList,
|
|
1950
|
+
)
|
|
1951
|
+
this.isHovering = false
|
|
1952
|
+
this.logger.log(
|
|
1953
|
+
'[CONVS-DETAIL] ----> FILE - DROP isHovering ',
|
|
1954
|
+
this.isHovering,
|
|
1955
|
+
)
|
|
1617
1956
|
if (fileList.length > 0) {
|
|
1618
|
-
const file: File = fileList[0]
|
|
1619
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file)
|
|
1957
|
+
const file: File = fileList[0]
|
|
1958
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file)
|
|
1620
1959
|
|
|
1621
|
-
var mimeType = fileList[0].type
|
|
1622
|
-
this.logger.log(
|
|
1960
|
+
var mimeType = fileList[0].type
|
|
1961
|
+
this.logger.log(
|
|
1962
|
+
'[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
|
|
1963
|
+
mimeType,
|
|
1964
|
+
)
|
|
1623
1965
|
|
|
1624
1966
|
// if (mimeType.startsWith("image") || mimeType.startsWith("application")) {
|
|
1625
1967
|
// this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files: ', this.appConfigProvider.getConfig().fileUploadAccept);
|
|
1626
1968
|
// this.checkAcceptedFile(mimeType);
|
|
1627
|
-
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
1628
|
-
this.logger.log(
|
|
1969
|
+
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
1970
|
+
this.logger.log(
|
|
1971
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP',
|
|
1972
|
+
isAccepted,
|
|
1973
|
+
)
|
|
1629
1974
|
if (isAccepted === true) {
|
|
1630
|
-
this.handleDropEvent(ev)
|
|
1631
|
-
|
|
1975
|
+
this.handleDropEvent(ev)
|
|
1632
1976
|
} else {
|
|
1633
|
-
this.logger.log(
|
|
1977
|
+
this.logger.log(
|
|
1978
|
+
'[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
|
|
1979
|
+
mimeType,
|
|
1980
|
+
'NOT SUPPORTED FILE TYPE',
|
|
1981
|
+
)
|
|
1634
1982
|
this.presentToastOnlyImageFilesAreAllowedToDrag()
|
|
1635
1983
|
}
|
|
1636
1984
|
}
|
|
1637
1985
|
}
|
|
1638
1986
|
|
|
1639
1987
|
handleDropEvent(ev) {
|
|
1640
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
|
|
1988
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
|
|
1641
1989
|
this.dropEvent = ev
|
|
1642
1990
|
}
|
|
1643
1991
|
|
|
1644
1992
|
// DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
|
|
1645
1993
|
allowDrop(ev: any) {
|
|
1646
|
-
ev.preventDefault()
|
|
1647
|
-
ev.stopPropagation()
|
|
1648
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev)
|
|
1649
|
-
this.isHovering = true
|
|
1650
|
-
this.logger.log(
|
|
1994
|
+
ev.preventDefault()
|
|
1995
|
+
ev.stopPropagation()
|
|
1996
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev)
|
|
1997
|
+
this.isHovering = true
|
|
1998
|
+
this.logger.log(
|
|
1999
|
+
'[CONVS-DETAIL] ----> FILE - (dragover) allowDrop isHovering ',
|
|
2000
|
+
this.isHovering,
|
|
2001
|
+
)
|
|
1651
2002
|
}
|
|
1652
2003
|
|
|
1653
2004
|
// DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
|
|
1654
2005
|
drag(ev: any) {
|
|
1655
|
-
ev.preventDefault()
|
|
1656
|
-
ev.stopPropagation()
|
|
1657
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev)
|
|
1658
|
-
this.isHovering = false
|
|
1659
|
-
this.logger.log(
|
|
2006
|
+
ev.preventDefault()
|
|
2007
|
+
ev.stopPropagation()
|
|
2008
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev)
|
|
2009
|
+
this.isHovering = false
|
|
2010
|
+
this.logger.log(
|
|
2011
|
+
'[CONVS-DETAIL] ----> FILE - FILE - (dragleave) drag his.isHovering ',
|
|
2012
|
+
this.isHovering,
|
|
2013
|
+
)
|
|
1660
2014
|
}
|
|
1661
2015
|
|
|
1662
2016
|
async presentToastOnlyImageFilesAreAllowedToDrag() {
|
|
1663
2017
|
const toast = await this.toastController.create({
|
|
1664
|
-
message: this.translationMap.get(
|
|
2018
|
+
message: this.translationMap.get(
|
|
2019
|
+
'FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED',
|
|
2020
|
+
),
|
|
1665
2021
|
duration: 5000,
|
|
1666
|
-
color:
|
|
2022
|
+
color: 'danger',
|
|
1667
2023
|
cssClass: 'toast-custom-class',
|
|
1668
|
-
})
|
|
1669
|
-
toast.present()
|
|
2024
|
+
})
|
|
2025
|
+
toast.present()
|
|
1670
2026
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
2027
|
}
|
|
1674
|
-
// END ALL //
|
|
2028
|
+
// END ALL //
|