@chat21/chat21-ionic 3.0.61-rc5 → 3.0.61
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 +90 -0
- package/README.md +6 -0
- package/angular.json +2 -0
- package/config.xml +4 -5
- package/deploy_pre.sh +10 -10
- package/deploy_prod.sh +4 -0
- package/env.sample +1 -1
- 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 +2 -2
- package/src/app/app.component.scss +2 -1
- package/src/app/app.component.ts +34 -20
- 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.ts +78 -15
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.ts +13 -10
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +11 -4
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +3 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +142 -71
- 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/ddp-header/ddp-header.component.html +9 -2
- package/src/app/components/ddp-header/ddp-header.component.ts +93 -18
- package/src/app/components/project-item/project-item.component.html +1 -1
- package/src/app/components/project-item/project-item.component.scss +1 -1
- package/src/app/components/project-item/project-item.component.ts +3 -3
- package/src/app/components/sidebar/sidebar.component.html +151 -86
- package/src/app/components/sidebar/sidebar.component.scss +60 -3
- package/src/app/components/sidebar/sidebar.component.ts +173 -47
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +26 -7
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.scss +44 -19
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +109 -35
- package/src/app/pages/conversation-detail/conversation-detail.module.ts +5 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +19 -9
- package/src/app/pages/conversation-detail/conversation-detail.page.scss +28 -0
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +1124 -778
- package/src/app/pages/conversations-list/conversations-list.page.html +3 -1
- package/src/app/pages/conversations-list/conversations-list.page.ts +647 -445
- 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/assets/i18n/de.json +45 -7
- package/src/assets/i18n/en.json +41 -3
- package/src/assets/i18n/es.json +41 -3
- package/src/assets/i18n/fr.json +44 -6
- package/src/assets/i18n/it.json +41 -3
- package/src/assets/i18n/pt.json +41 -3
- package/src/assets/i18n/ru.json +42 -4
- package/src/assets/i18n/sr.json +265 -0
- package/src/assets/i18n/tr.json +41 -4
- package/src/assets/images/default-avatar-x-select.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-mqtt.json +25 -16
- package/src/chat-config-template.json +5 -4
- package/src/chat-config.json +1 -0
- 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 -76
- 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 && stored_project !== undefined) {
|
|
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
|
-
|
|
458
|
+
this.tenant = appconfig.firebaseConfig.tenant
|
|
459
|
+
this.logger.log('[CONVS-DETAIL] - initialize -> firebaseConfig tenant ', this.tenant)
|
|
390
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
|
|
391
465
|
|
|
392
|
-
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
395
|
-
this.setHeightTextArea();
|
|
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
|
-
|
|
621
|
-
this.conversationAvatar = setConversationAvatar(
|
|
622
|
-
conv.conversation_with,
|
|
623
|
-
conv.conversation_with_fullname,
|
|
624
|
-
conv.channel_type
|
|
625
|
-
);
|
|
626
|
-
}
|
|
627
|
-
this.logger.log('[CONVS-DETAIL] - setHeaderContent > conversationAvatar: ', this.conversationAvatar);
|
|
628
|
-
})
|
|
629
|
-
}
|
|
630
|
-
else { //get conversation from 'conversations' firebase node
|
|
631
|
-
this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, (conv) => {
|
|
632
|
-
if (conv) {
|
|
633
|
-
this.logger.log('[CONVS-DETAIL] - setHeaderContent getConversationDetail (archived)', this.conversationWith, conv)
|
|
784
|
+
// console.log( '[CONVS-DETAIL] - setHeaderContent getConversationDetail (active)', this.conversationWith, conv )
|
|
634
785
|
this.conversationAvatar = setConversationAvatar(
|
|
635
786
|
conv.conversation_with,
|
|
636
787
|
conv.conversation_with_fullname,
|
|
637
|
-
conv.channel_type
|
|
638
|
-
)
|
|
788
|
+
conv.channel_type,
|
|
789
|
+
)
|
|
639
790
|
}
|
|
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,53 +1131,57 @@ 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
|
-
this.logger.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
|
|
|
977
1182
|
if (pos === -1) {
|
|
978
|
-
this.tagsCannedFilter = []
|
|
979
|
-
this.HIDE_CANNED_RESPONSES = true
|
|
1183
|
+
this.tagsCannedFilter = []
|
|
1184
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
980
1185
|
}
|
|
981
1186
|
// test
|
|
982
1187
|
// var rest = message.substring(0, message.lastIndexOf("/") + 1);
|
|
@@ -990,33 +1195,37 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
990
1195
|
// console.log('[CONVS-DETAIL] - returnChangeTextArea last is NOT space ');
|
|
991
1196
|
// }
|
|
992
1197
|
|
|
993
|
-
|
|
994
1198
|
if (pos >= 0) {
|
|
995
|
-
var strSearch = message.substr(pos + 1)
|
|
996
|
-
this.logger.log(
|
|
1199
|
+
var strSearch = message.substr(pos + 1)
|
|
1200
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea - canned responses strSearch ', strSearch)
|
|
997
1201
|
|
|
998
1202
|
// --------------------------------------------
|
|
999
1203
|
// Load canned responses
|
|
1000
1204
|
// --------------------------------------------
|
|
1001
|
-
this.loadTagsCanned(strSearch, this.conversationWith)
|
|
1205
|
+
this.loadTagsCanned(strSearch, this.conversationWith)
|
|
1002
1206
|
|
|
1003
1207
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1004
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)
|
|
1005
1209
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1006
1210
|
|
|
1007
|
-
var after_slash = message.substring(
|
|
1008
|
-
|
|
1009
|
-
|
|
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 ')
|
|
1010
1221
|
this.HIDE_CANNED_RESPONSES = true
|
|
1011
1222
|
this.tagsCannedFilter = []
|
|
1012
1223
|
} else if (pos === 0 && after_slash.length === 0) {
|
|
1013
|
-
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')
|
|
1014
1225
|
this.HIDE_CANNED_RESPONSES = false
|
|
1015
1226
|
}
|
|
1016
1227
|
|
|
1017
|
-
|
|
1018
1228
|
if (pos > 0) {
|
|
1019
|
-
|
|
1020
1229
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1021
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)
|
|
1022
1231
|
// and if there is not a space before the SLASH (in this it will be hidden)
|
|
@@ -1024,228 +1233,303 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1024
1233
|
|
|
1025
1234
|
let beforeSlash = message.substr(pos - 1)
|
|
1026
1235
|
let afterSlash = message.substr(pos + 1)
|
|
1027
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
|
|
1236
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
|
|
1028
1237
|
|
|
1029
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash)
|
|
1030
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash)
|
|
1031
|
-
var afterSlashParts = afterSlash.split(
|
|
1032
|
-
var beforeSlashParts = beforeSlash.split(
|
|
1033
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts)
|
|
1034
|
-
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)
|
|
1035
1244
|
|
|
1036
1245
|
if (beforeSlashParts.length === 2) {
|
|
1037
|
-
if (
|
|
1246
|
+
if (
|
|
1247
|
+
beforeSlashParts[0].indexOf(' ') >= 0 &&
|
|
1248
|
+
afterSlashParts[0] === ''
|
|
1249
|
+
) {
|
|
1038
1250
|
this.HIDE_CANNED_RESPONSES = false
|
|
1039
|
-
this.logger.log(
|
|
1251
|
+
this.logger.log(
|
|
1252
|
+
'[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash there is a white space After Not',
|
|
1253
|
+
)
|
|
1040
1254
|
// if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0].indexOf(' ') >= 0)
|
|
1041
|
-
} else if (
|
|
1042
|
-
|
|
1255
|
+
} else if (
|
|
1256
|
+
beforeSlashParts[0].indexOf(' ') < 0 &&
|
|
1257
|
+
afterSlashParts[0] === ''
|
|
1258
|
+
) {
|
|
1259
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1043
1260
|
this.tagsCannedFilter = []
|
|
1044
|
-
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not')
|
|
1045
|
-
} else if (
|
|
1046
|
-
|
|
1047
|
-
|
|
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
|
|
1048
1268
|
this.tagsCannedFilter = []
|
|
1049
1269
|
}
|
|
1050
1270
|
}
|
|
1051
1271
|
}
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
1272
|
} else {
|
|
1055
|
-
this.tagsCannedFilter = []
|
|
1273
|
+
this.tagsCannedFilter = []
|
|
1056
1274
|
}
|
|
1057
1275
|
}
|
|
1058
|
-
}, 300)
|
|
1059
|
-
|
|
1276
|
+
}, 300)
|
|
1060
1277
|
}
|
|
1061
1278
|
// ./ CANNED RESPONSES //
|
|
1062
|
-
|
|
1063
1279
|
} catch (err) {
|
|
1064
|
-
this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
|
|
1280
|
+
this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
|
|
1065
1281
|
}
|
|
1066
1282
|
}
|
|
1067
1283
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
1284
|
// ----------------------------------------------------------
|
|
1071
1285
|
// @ CANNED RESPONSES methods
|
|
1072
1286
|
// ----------------------------------------------------------
|
|
1073
1287
|
loadTagsCanned(strSearch, conversationWith) {
|
|
1074
|
-
this.logger.log(
|
|
1075
|
-
this.logger.log(
|
|
1076
|
-
this.logger.log(
|
|
1077
|
-
|
|
1078
|
-
const conversationWith_segments = conversationWith.split('-')
|
|
1079
|
-
// Removes the last element of the array if is = to the separator
|
|
1080
|
-
if (
|
|
1081
|
-
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()
|
|
1082
1298
|
}
|
|
1083
1299
|
|
|
1084
1300
|
if (conversationWith_segments.length === 4) {
|
|
1085
|
-
const lastArrayElement =
|
|
1086
|
-
|
|
1087
|
-
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)
|
|
1088
1305
|
if (lastArrayElement.length !== 32) {
|
|
1089
|
-
conversationWith_segments.pop()
|
|
1306
|
+
conversationWith_segments.pop()
|
|
1090
1307
|
}
|
|
1091
1308
|
}
|
|
1092
1309
|
|
|
1093
|
-
this.logger.log(
|
|
1094
|
-
let projectId =
|
|
1310
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ', conversationWith_segments)
|
|
1311
|
+
let projectId = ''
|
|
1095
1312
|
|
|
1096
1313
|
if (conversationWith_segments.length === 4) {
|
|
1097
|
-
projectId = conversationWith_segments[2]
|
|
1098
|
-
this.logger.log(
|
|
1314
|
+
projectId = conversationWith_segments[2]
|
|
1315
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
|
|
1099
1316
|
|
|
1100
1317
|
this.getAndShowCannedResponses(strSearch, projectId)
|
|
1101
|
-
|
|
1102
1318
|
} else {
|
|
1103
1319
|
this.getProjectIdByConversationWith(strSearch, this.conversationWith)
|
|
1104
1320
|
}
|
|
1105
1321
|
}
|
|
1106
1322
|
|
|
1107
1323
|
getProjectIdByConversationWith(strSearch, conversationWith: string) {
|
|
1108
|
-
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1109
|
-
|
|
1110
|
-
this.tiledeskService
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
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
|
+
)
|
|
1127
1346
|
}
|
|
1128
1347
|
|
|
1129
1348
|
getAndShowCannedResponses(strSearch, projectId) {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1349
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1350
|
+
this.logger.log(
|
|
1351
|
+
'[CONVS-DETAIL] - loadTagsCanned tagsCanned.length',
|
|
1352
|
+
this.tagsCanned.length,
|
|
1353
|
+
)
|
|
1133
1354
|
//if(this.tagsCanned.length <= 0 ){
|
|
1134
|
-
this.tagsCanned = []
|
|
1135
|
-
this.cannedResponsesService
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
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
|
+
)
|
|
1152
1376
|
}
|
|
1153
1377
|
|
|
1154
|
-
|
|
1155
1378
|
showTagsCanned(strSearch) {
|
|
1156
|
-
this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch)
|
|
1157
|
-
this.tagsCannedFilter = []
|
|
1158
|
-
var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned))
|
|
1159
|
-
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)
|
|
1160
1383
|
//this.logger.log("that.contacts lenght:: ", strSearch);
|
|
1161
|
-
this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
|
|
1162
|
-
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)
|
|
1163
1386
|
|
|
1164
|
-
this.tagsCannedFilter.sort(compareValues('title', 'asc'))
|
|
1165
|
-
var strReplace = strSearch
|
|
1387
|
+
this.tagsCannedFilter.sort(compareValues('title', 'asc'))
|
|
1388
|
+
var strReplace = strSearch
|
|
1166
1389
|
if (strSearch.length > 0) {
|
|
1167
|
-
strReplace = "<b class='highlight-search-string'>" + strSearch +
|
|
1390
|
+
strReplace = "<b class='highlight-search-string'>" + strSearch + '</b>'
|
|
1168
1391
|
}
|
|
1169
1392
|
for (var i = 0; i < this.tagsCannedFilter.length; i++) {
|
|
1170
|
-
|
|
1171
|
-
|
|
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
|
+
|
|
1172
1400
|
}
|
|
1173
1401
|
if (this.tagsCannedCount === 0) {
|
|
1174
|
-
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
|
+
// }
|
|
1175
1424
|
this.tagsCannedFilter.push(nocanned)
|
|
1176
1425
|
}
|
|
1177
1426
|
}
|
|
1178
1427
|
|
|
1428
|
+
toggleSidebar() {
|
|
1429
|
+
// console.log('[CONVS-DETAIL] has clicked test')
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1179
1432
|
filterItems(items, searchTerm) {
|
|
1180
|
-
this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
|
|
1433
|
+
this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
|
|
1181
1434
|
//this.logger.log("filterItems::: ",searchTerm);
|
|
1182
1435
|
return items.filter((item) => {
|
|
1183
1436
|
//this.logger.log("filterItems::: ", item.title.toString().toLowerCase());
|
|
1184
|
-
this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
|
|
1185
|
-
return
|
|
1186
|
-
|
|
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
|
+
})
|
|
1187
1445
|
}
|
|
1188
1446
|
|
|
1189
1447
|
replacePlaceholderInCanned(str) {
|
|
1190
|
-
this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
|
|
1191
|
-
str = str.replace('$recipient_name', this.conversationWithFullname)
|
|
1448
|
+
this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
|
|
1449
|
+
str = str.replace('$recipient_name', this.conversationWithFullname)
|
|
1192
1450
|
if (this.loggedUser && this.loggedUser.fullname) {
|
|
1193
|
-
str = str.replace('$agent_name', this.loggedUser.fullname)
|
|
1451
|
+
str = str.replace('$agent_name', this.loggedUser.fullname)
|
|
1194
1452
|
}
|
|
1195
|
-
return str
|
|
1453
|
+
return str
|
|
1196
1454
|
}
|
|
1197
1455
|
|
|
1198
1456
|
replaceTagInMessage(canned, event) {
|
|
1199
|
-
this.
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
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
|
+
}
|
|
1216
1501
|
|
|
1502
|
+
async presentCreateCannedResponseModal(): Promise<any> {
|
|
1503
|
+
const elTextArea = this.rowTextArea['el']
|
|
1504
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1505
|
+
textArea.value = ''
|
|
1217
1506
|
|
|
1218
|
-
//
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
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
|
+
})
|
|
1222
1518
|
|
|
1223
|
-
|
|
1224
|
-
strTEMP = this.replacePlaceholderInCanned(strTEMP);
|
|
1225
|
-
this.logger.log("[CONVS-DETAIL] replaceTagInMessage strSearch ", strTEMP);
|
|
1226
|
-
// strTEMP = this.replacePlaceholderInCanned(strTEMP);
|
|
1227
|
-
// textArea.value = '';
|
|
1228
|
-
// that.messageString = strTEMP;
|
|
1229
|
-
textArea.value = strTEMP;
|
|
1230
|
-
setTimeout(() => {
|
|
1231
|
-
// textArea.focus();
|
|
1232
|
-
textArea.setFocus();
|
|
1233
|
-
this.resizeTextArea();
|
|
1234
|
-
}, 200);
|
|
1519
|
+
return await modal.present()
|
|
1235
1520
|
}
|
|
1236
1521
|
|
|
1237
|
-
|
|
1238
1522
|
hasClickedOpenCannedResponses($event) {
|
|
1239
1523
|
this.logger.log('[CONVS-DETAIL] - hasClickedOpenCannedResponses ', $event)
|
|
1240
|
-
const elTextArea = this.rowTextArea['el']
|
|
1241
|
-
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1524
|
+
const elTextArea = this.rowTextArea['el']
|
|
1525
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1242
1526
|
|
|
1243
|
-
this.logger.log(
|
|
1527
|
+
this.logger.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ', textArea)
|
|
1244
1528
|
// console.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
|
|
1245
1529
|
var lastChar = textArea.value[textArea.value.length - 1]
|
|
1246
1530
|
// console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses lastChar', lastChar)
|
|
1247
|
-
if (lastChar !== '/'
|
|
1248
|
-
this.insertAtCursor(textArea, '/')
|
|
1531
|
+
if (lastChar !== '/') {
|
|
1532
|
+
this.insertAtCursor(textArea, '/')
|
|
1249
1533
|
}
|
|
1250
1534
|
// console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea.value', textArea.value)
|
|
1251
1535
|
// setTimeout(() => {
|
|
@@ -1260,13 +1544,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1260
1544
|
|
|
1261
1545
|
setCaretPosition(ctrl) {
|
|
1262
1546
|
ctrl.value.trim()
|
|
1263
|
-
ctrl.setFocus()
|
|
1547
|
+
ctrl.setFocus()
|
|
1264
1548
|
}
|
|
1265
1549
|
|
|
1266
1550
|
insertAtCursor(myField, myValue) {
|
|
1267
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
|
|
1268
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
|
|
1269
|
-
|
|
1551
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
|
|
1552
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
|
|
1270
1553
|
|
|
1271
1554
|
// myValue = ' ' + myValue;
|
|
1272
1555
|
|
|
@@ -1274,38 +1557,41 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1274
1557
|
// console.log('[CONVS-DETAIL] - GET TEXT AREA - Here yes textArea value length', myField.value.length);
|
|
1275
1558
|
|
|
1276
1559
|
if (myField.value.length > 0) {
|
|
1277
|
-
myValue = ' ' + myValue
|
|
1560
|
+
myValue = ' ' + myValue
|
|
1278
1561
|
}
|
|
1279
1562
|
|
|
1280
1563
|
//IE support
|
|
1281
1564
|
if (myField.selection) {
|
|
1282
|
-
myField.focus()
|
|
1283
|
-
let sel = myField.selection.createRange()
|
|
1284
|
-
sel.text = myValue
|
|
1565
|
+
myField.focus()
|
|
1566
|
+
let sel = myField.selection.createRange()
|
|
1567
|
+
sel.text = myValue
|
|
1285
1568
|
// this.cannedResponseMessage = sel.text;
|
|
1286
1569
|
}
|
|
1287
1570
|
//MOZILLA and others
|
|
1288
1571
|
else if (myField.selectionStart || myField.selectionStart == '0') {
|
|
1289
|
-
var startPos = myField.selectionStart
|
|
1290
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
|
|
1572
|
+
var startPos = myField.selectionStart
|
|
1573
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
|
|
1291
1574
|
|
|
1292
|
-
var endPos = myField.selectionEnd
|
|
1293
|
-
this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
|
|
1575
|
+
var endPos = myField.selectionEnd
|
|
1576
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
|
|
1294
1577
|
|
|
1295
|
-
myField.value =
|
|
1578
|
+
myField.value =
|
|
1579
|
+
myField.value.substring(0, startPos) +
|
|
1580
|
+
myValue +
|
|
1581
|
+
myField.value.substring(endPos, myField.value.length)
|
|
1296
1582
|
|
|
1297
1583
|
// place cursor at end of text in text input element
|
|
1298
|
-
myField.focus()
|
|
1299
|
-
var val = myField.value
|
|
1300
|
-
myField.value = ''
|
|
1301
|
-
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.
|
|
1302
1588
|
|
|
1303
1589
|
// this.cannedResponseMessage = myField.value;
|
|
1304
1590
|
|
|
1305
1591
|
// this.texareaIsEmpty = false;
|
|
1306
1592
|
// myField.select();
|
|
1307
1593
|
} else {
|
|
1308
|
-
myField.value += myValue
|
|
1594
|
+
myField.value += myValue
|
|
1309
1595
|
// this.cannedResponseMessage = myField.value;
|
|
1310
1596
|
}
|
|
1311
1597
|
}
|
|
@@ -1315,30 +1601,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1315
1601
|
// this.logger.log("CONVERSATION-DETAIL handleKeyboardEvent event.key ", event.key);
|
|
1316
1602
|
|
|
1317
1603
|
if (this.tagsCannedFilter.length > 0) {
|
|
1318
|
-
|
|
1319
1604
|
if (event.key === 'ArrowDown') {
|
|
1320
|
-
|
|
1321
|
-
this.arrowkeyLocation++;
|
|
1605
|
+
this.arrowkeyLocation++
|
|
1322
1606
|
if (this.arrowkeyLocation === this.tagsCannedFilter.length) {
|
|
1323
1607
|
this.arrowkeyLocation--
|
|
1324
1608
|
}
|
|
1325
1609
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
1326
|
-
}
|
|
1327
|
-
else if (event.key === 'ArrowUp') {
|
|
1328
|
-
|
|
1610
|
+
} else if (event.key === 'ArrowUp') {
|
|
1329
1611
|
if (this.arrowkeyLocation > 0) {
|
|
1330
|
-
this.arrowkeyLocation
|
|
1612
|
+
this.arrowkeyLocation--
|
|
1331
1613
|
} else if (this.arrowkeyLocation < 0) {
|
|
1332
|
-
this.arrowkeyLocation
|
|
1614
|
+
this.arrowkeyLocation++
|
|
1333
1615
|
}
|
|
1334
1616
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
1335
1617
|
}
|
|
1336
1618
|
|
|
1337
1619
|
if (event.key === 'Enter') {
|
|
1338
1620
|
const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
|
|
1339
|
-
this.logger.log(
|
|
1621
|
+
this.logger.log(
|
|
1622
|
+
'[CONVS-DETAIL] replaceTagInMessage canned_selected ',
|
|
1623
|
+
canned_selected,
|
|
1624
|
+
)
|
|
1340
1625
|
if (canned_selected) {
|
|
1341
|
-
|
|
1342
1626
|
this.replaceTagInMessage(canned_selected, 'enter')
|
|
1343
1627
|
// event.preventDefault();
|
|
1344
1628
|
// return false;
|
|
@@ -1350,35 +1634,40 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1350
1634
|
// ./end CANNED RESPONSES methods
|
|
1351
1635
|
// ----------------------------------------------------------
|
|
1352
1636
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
1637
|
// ----------------------------------------------------------
|
|
1356
|
-
// @ Rule of sound message
|
|
1638
|
+
// @ Rule of sound message
|
|
1357
1639
|
// * if I send it -> NO SOUND
|
|
1358
1640
|
// * if I'm not in the conversation -> SOUND
|
|
1359
1641
|
// * if I'm in the conversation at the bottom of the page -> NO SOUND
|
|
1360
1642
|
// * otherwise -> SOUND
|
|
1361
1643
|
// ----------------------------------------------------------
|
|
1362
1644
|
soundMessage() {
|
|
1363
|
-
const that = this
|
|
1364
|
-
this.audio = new Audio()
|
|
1645
|
+
const that = this
|
|
1646
|
+
this.audio = new Audio()
|
|
1365
1647
|
// this.audio.src = '/assets/sounds/pling.mp3';
|
|
1366
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION
|
|
1367
|
-
this.audio.load()
|
|
1368
|
-
this.logger.log(
|
|
1369
|
-
|
|
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)
|
|
1370
1655
|
this.setTimeoutSound = setTimeout(function () {
|
|
1371
|
-
that.audio
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
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)
|
|
1378
1669
|
}
|
|
1379
1670
|
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
1671
|
returnOnBeforeMessageRender(event) {
|
|
1383
1672
|
//this.onBeforeMessageRender.emit(event)
|
|
1384
1673
|
}
|
|
@@ -1391,86 +1680,83 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1391
1680
|
// this.isMenuShow = event;
|
|
1392
1681
|
}
|
|
1393
1682
|
|
|
1394
|
-
returnOnScrollContent(event: boolean) {
|
|
1395
|
-
|
|
1396
|
-
}
|
|
1683
|
+
returnOnScrollContent(event: boolean) { }
|
|
1397
1684
|
|
|
1398
1685
|
returnOnAttachmentButtonClicked(event: any) {
|
|
1399
1686
|
this.logger.debug('[CONV-COMP] eventbutton', event)
|
|
1400
1687
|
if (!event || !event.target.type) {
|
|
1401
|
-
return
|
|
1688
|
+
return
|
|
1402
1689
|
}
|
|
1403
1690
|
switch (event.target.type) {
|
|
1404
1691
|
case 'url':
|
|
1405
1692
|
try {
|
|
1406
|
-
this.openLink(event.target.button)
|
|
1693
|
+
this.openLink(event.target.button)
|
|
1407
1694
|
} catch (err) {
|
|
1408
|
-
this.logger.error('[CONV-COMP] url > Error :' + err)
|
|
1695
|
+
this.logger.error('[CONV-COMP] url > Error :' + err)
|
|
1409
1696
|
}
|
|
1410
|
-
return
|
|
1697
|
+
return
|
|
1411
1698
|
case 'action':
|
|
1412
1699
|
try {
|
|
1413
|
-
this.actionButton(event.target.button)
|
|
1700
|
+
this.actionButton(event.target.button)
|
|
1414
1701
|
} catch (err) {
|
|
1415
|
-
this.logger.error('[CONV-COMP] action > Error :' + err)
|
|
1702
|
+
this.logger.error('[CONV-COMP] action > Error :' + err)
|
|
1416
1703
|
}
|
|
1417
|
-
return false
|
|
1704
|
+
return false
|
|
1418
1705
|
case 'text':
|
|
1419
1706
|
try {
|
|
1420
1707
|
const text = event.target.button.value
|
|
1421
|
-
const metadata = {
|
|
1422
|
-
this.sendMessage(text, TYPE_MSG_TEXT, metadata)
|
|
1708
|
+
const metadata = { button: true }
|
|
1709
|
+
this.sendMessage(text, TYPE_MSG_TEXT, metadata)
|
|
1423
1710
|
} catch (err) {
|
|
1424
|
-
this.logger.error('[CONV-COMP] text > Error :' + err)
|
|
1711
|
+
this.logger.error('[CONV-COMP] text > Error :' + err)
|
|
1425
1712
|
}
|
|
1426
|
-
default:
|
|
1713
|
+
default:
|
|
1714
|
+
return
|
|
1427
1715
|
}
|
|
1428
1716
|
}
|
|
1429
1717
|
|
|
1430
1718
|
onImageRenderedFN(event) {
|
|
1431
|
-
const imageRendered = event
|
|
1719
|
+
const imageRendered = event
|
|
1432
1720
|
if (this.showButtonToBottom) {
|
|
1433
1721
|
this.scrollBottom(0)
|
|
1434
1722
|
}
|
|
1435
1723
|
}
|
|
1436
1724
|
|
|
1437
|
-
|
|
1438
1725
|
private openLink(event: any) {
|
|
1439
|
-
const link = event.link ? event.link : ''
|
|
1440
|
-
const target = event.target ? event.target : ''
|
|
1726
|
+
const link = event.link ? event.link : ''
|
|
1727
|
+
const target = event.target ? event.target : ''
|
|
1441
1728
|
if (target === 'self' || target === 'parent') {
|
|
1442
|
-
window.open(link, '_parent')
|
|
1729
|
+
window.open(link, '_parent')
|
|
1443
1730
|
} else {
|
|
1444
|
-
window.open(link, '_blank')
|
|
1731
|
+
window.open(link, '_blank')
|
|
1445
1732
|
}
|
|
1446
1733
|
}
|
|
1447
1734
|
|
|
1448
|
-
|
|
1449
1735
|
private actionButton(event: any) {
|
|
1450
1736
|
// console.log(event);
|
|
1451
|
-
const action = event.action ? event.action : ''
|
|
1452
|
-
const message = event.value ? event.value : ''
|
|
1453
|
-
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'
|
|
1454
1740
|
|
|
1455
1741
|
const attributes = {
|
|
1456
1742
|
action: action,
|
|
1457
|
-
subtype: subtype
|
|
1458
|
-
}
|
|
1459
|
-
this.sendMessage(message, TYPE_MSG_TEXT, null, attributes)
|
|
1460
|
-
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 :')
|
|
1461
1747
|
}
|
|
1462
1748
|
|
|
1463
1749
|
addUploadingBubbleEvent(event: boolean) {
|
|
1464
|
-
this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
|
|
1750
|
+
this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
|
|
1465
1751
|
if (event === true) {
|
|
1466
|
-
this.scrollBottom(0)
|
|
1752
|
+
this.scrollBottom(0)
|
|
1467
1753
|
}
|
|
1468
1754
|
}
|
|
1469
1755
|
|
|
1470
1756
|
onPresentModalScrollToBottom(event: boolean) {
|
|
1471
|
-
this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
|
|
1757
|
+
this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
|
|
1472
1758
|
if (event === true) {
|
|
1473
|
-
this.scrollBottom(0)
|
|
1759
|
+
this.scrollBottom(0)
|
|
1474
1760
|
}
|
|
1475
1761
|
}
|
|
1476
1762
|
|
|
@@ -1478,25 +1764,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1478
1764
|
/** */
|
|
1479
1765
|
resizeTextArea() {
|
|
1480
1766
|
try {
|
|
1481
|
-
const elTextArea = this.rowTextArea['el']
|
|
1482
|
-
const that = this
|
|
1767
|
+
const elTextArea = this.rowTextArea['el']
|
|
1768
|
+
const that = this
|
|
1483
1769
|
setTimeout(() => {
|
|
1484
|
-
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1770
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1485
1771
|
if (textArea) {
|
|
1486
|
-
this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
|
|
1487
|
-
const txtValue = textArea.value
|
|
1488
|
-
textArea.value = ' '
|
|
1489
|
-
textArea.value = txtValue
|
|
1772
|
+
this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
|
|
1773
|
+
const txtValue = textArea.value
|
|
1774
|
+
textArea.value = ' '
|
|
1775
|
+
textArea.value = txtValue
|
|
1490
1776
|
}
|
|
1491
|
-
}, 0)
|
|
1777
|
+
}, 0)
|
|
1492
1778
|
setTimeout(() => {
|
|
1493
1779
|
if (elTextArea) {
|
|
1494
|
-
this.logger.log(
|
|
1495
|
-
|
|
1780
|
+
this.logger.log(
|
|
1781
|
+
'[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ',
|
|
1782
|
+
elTextArea.offsetHeight,
|
|
1783
|
+
)
|
|
1784
|
+
that.heightMessageTextArea = elTextArea.offsetHeight
|
|
1496
1785
|
}
|
|
1497
|
-
}, 100)
|
|
1786
|
+
}, 100)
|
|
1498
1787
|
} catch (err) {
|
|
1499
|
-
this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
|
|
1788
|
+
this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
|
|
1500
1789
|
}
|
|
1501
1790
|
}
|
|
1502
1791
|
|
|
@@ -1505,11 +1794,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1505
1794
|
* @param time
|
|
1506
1795
|
*/
|
|
1507
1796
|
private scrollBottom(time: number) {
|
|
1508
|
-
this.showIonContent = true
|
|
1797
|
+
this.showIonContent = true
|
|
1509
1798
|
if (this.ionContentChatArea) {
|
|
1510
1799
|
setTimeout(() => {
|
|
1511
|
-
this.ionContentChatArea.scrollToBottom(time)
|
|
1512
|
-
}, 0)
|
|
1800
|
+
this.ionContentChatArea.scrollToBottom(time)
|
|
1801
|
+
}, 0)
|
|
1513
1802
|
// nota: se elimino il settimeout lo scrollToBottom non viene richiamato!!!!!
|
|
1514
1803
|
}
|
|
1515
1804
|
}
|
|
@@ -1518,14 +1807,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1518
1807
|
* detectBottom
|
|
1519
1808
|
*/
|
|
1520
1809
|
async detectBottom() {
|
|
1521
|
-
const scrollElement = await this.ionContentChatArea.getScrollElement()
|
|
1810
|
+
const scrollElement = await this.ionContentChatArea.getScrollElement()
|
|
1522
1811
|
|
|
1523
|
-
if (
|
|
1812
|
+
if (
|
|
1813
|
+
scrollElement.scrollTop <
|
|
1814
|
+
scrollElement.scrollHeight - scrollElement.clientHeight
|
|
1815
|
+
) {
|
|
1524
1816
|
//NON SONO ALLA FINE --> mostra badge
|
|
1525
|
-
this.showButtonToBottom = true
|
|
1817
|
+
this.showButtonToBottom = true
|
|
1526
1818
|
} else {
|
|
1527
1819
|
// SONO ALLA FINE --> non mostrare badge,
|
|
1528
|
-
this.showButtonToBottom = false
|
|
1820
|
+
this.showButtonToBottom = false
|
|
1529
1821
|
}
|
|
1530
1822
|
}
|
|
1531
1823
|
|
|
@@ -1534,149 +1826,203 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1534
1826
|
* FIREBY BY: click event ScrollToBottom bottom-right icon button
|
|
1535
1827
|
*/
|
|
1536
1828
|
public actionScrollBottom() {
|
|
1537
|
-
this.logger.log(
|
|
1829
|
+
this.logger.log(
|
|
1830
|
+
'[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ',
|
|
1831
|
+
this.ionContentChatArea,
|
|
1832
|
+
)
|
|
1538
1833
|
// const that = this;
|
|
1539
|
-
this.showButtonToBottom = false
|
|
1834
|
+
this.showButtonToBottom = false
|
|
1540
1835
|
this.updateConversationBadge()
|
|
1541
|
-
this.NUM_BADGES = 0
|
|
1836
|
+
this.NUM_BADGES = 0
|
|
1542
1837
|
setTimeout(() => {
|
|
1543
|
-
this.ionContentChatArea.scrollToBottom(0)
|
|
1838
|
+
this.ionContentChatArea.scrollToBottom(0)
|
|
1544
1839
|
// this.conversationsHandlerService.readAllMessages.next(this.conversationWith);
|
|
1545
|
-
}, 0)
|
|
1840
|
+
}, 0)
|
|
1546
1841
|
}
|
|
1547
1842
|
|
|
1548
1843
|
/**
|
|
1549
1844
|
* Scroll to top of the page after a short delay.
|
|
1550
1845
|
*/
|
|
1551
1846
|
scrollTop() {
|
|
1552
|
-
this.logger.log('[CONVS-DETAIL] scrollTop')
|
|
1553
|
-
this.ionContentChatArea.scrollToTop(100)
|
|
1847
|
+
this.logger.log('[CONVS-DETAIL] scrollTop')
|
|
1848
|
+
this.ionContentChatArea.scrollToTop(100)
|
|
1554
1849
|
}
|
|
1555
1850
|
|
|
1556
1851
|
/** */
|
|
1557
1852
|
setHeightTextArea() {
|
|
1558
1853
|
try {
|
|
1559
1854
|
if (this.rowTextArea) {
|
|
1560
|
-
this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
|
|
1561
|
-
this.logger.log(
|
|
1855
|
+
this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
|
|
1856
|
+
this.logger.log(
|
|
1857
|
+
'[CONVS-DETAIL] setHeightTextArea - heightMessageTextArea: ',
|
|
1858
|
+
this.heightMessageTextArea,
|
|
1859
|
+
)
|
|
1562
1860
|
}
|
|
1563
1861
|
} catch (e) {
|
|
1564
1862
|
this.logger.error('[CONVS-DETAIL] setHeightTextArea - ERROR ', e)
|
|
1565
1863
|
// this.heightMessageTextArea = '50';
|
|
1566
|
-
this.heightMessageTextArea = '57'
|
|
1864
|
+
this.heightMessageTextArea = '57' // NK edited
|
|
1567
1865
|
}
|
|
1568
1866
|
}
|
|
1569
1867
|
checkAcceptedFile(draggedFileMimeType) {
|
|
1570
|
-
let isAcceptFile = false
|
|
1571
|
-
this.logger.log(
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
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
|
|
1576
1880
|
return isAcceptFile
|
|
1577
|
-
} else if (accept_files !==
|
|
1578
|
-
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
|
+
)
|
|
1579
1886
|
const accept_files_array = accept_files.split(',')
|
|
1580
|
-
this.logger.log(
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
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
|
+
)
|
|
1586
1901
|
const accept_file_segment = accept_file.split('/')
|
|
1587
|
-
this.logger.log(
|
|
1902
|
+
this.logger.log(
|
|
1903
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file_segment ',
|
|
1904
|
+
accept_file_segment,
|
|
1905
|
+
)
|
|
1588
1906
|
if (accept_file_segment[1] === '*') {
|
|
1589
1907
|
if (draggedFileMimeType.startsWith(accept_file_segment[0])) {
|
|
1590
|
-
isAcceptFile = true
|
|
1591
|
-
this.logger.log(
|
|
1908
|
+
isAcceptFile = true
|
|
1909
|
+
this.logger.log(
|
|
1910
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1911
|
+
isAcceptFile,
|
|
1912
|
+
)
|
|
1592
1913
|
return isAcceptFile
|
|
1593
|
-
|
|
1594
1914
|
} else {
|
|
1595
|
-
isAcceptFile = false
|
|
1596
|
-
this.logger.log(
|
|
1915
|
+
isAcceptFile = false
|
|
1916
|
+
this.logger.log(
|
|
1917
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1918
|
+
isAcceptFile,
|
|
1919
|
+
)
|
|
1597
1920
|
return isAcceptFile
|
|
1598
|
-
|
|
1599
1921
|
}
|
|
1600
1922
|
} else if (accept_file_segment[1] !== '*') {
|
|
1601
1923
|
if (draggedFileMimeType === accept_file) {
|
|
1602
|
-
isAcceptFile = true
|
|
1603
|
-
this.logger.log(
|
|
1924
|
+
isAcceptFile = true
|
|
1925
|
+
this.logger.log(
|
|
1926
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1927
|
+
isAcceptFile,
|
|
1928
|
+
)
|
|
1604
1929
|
return isAcceptFile
|
|
1605
1930
|
}
|
|
1606
1931
|
}
|
|
1607
1932
|
return isAcceptFile
|
|
1608
|
-
})
|
|
1933
|
+
})
|
|
1609
1934
|
return isAcceptFile
|
|
1610
1935
|
}
|
|
1611
1936
|
}
|
|
1612
1937
|
// -------------------------------------------------------------
|
|
1613
|
-
// DRAG FILE
|
|
1938
|
+
// DRAG FILE
|
|
1614
1939
|
// -------------------------------------------------------------
|
|
1615
1940
|
// DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
|
|
1616
1941
|
drop(ev: any) {
|
|
1617
|
-
ev.preventDefault()
|
|
1618
|
-
ev.stopPropagation()
|
|
1619
|
-
|
|
1620
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev)
|
|
1621
|
-
const fileList = ev.dataTransfer.files
|
|
1622
|
-
this.logger.log(
|
|
1623
|
-
|
|
1624
|
-
|
|
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
|
+
)
|
|
1625
1956
|
if (fileList.length > 0) {
|
|
1626
|
-
const file: File = fileList[0]
|
|
1627
|
-
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)
|
|
1628
1959
|
|
|
1629
|
-
var mimeType = fileList[0].type
|
|
1630
|
-
this.logger.log(
|
|
1960
|
+
var mimeType = fileList[0].type
|
|
1961
|
+
this.logger.log(
|
|
1962
|
+
'[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
|
|
1963
|
+
mimeType,
|
|
1964
|
+
)
|
|
1631
1965
|
|
|
1632
1966
|
// if (mimeType.startsWith("image") || mimeType.startsWith("application")) {
|
|
1633
1967
|
// this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files: ', this.appConfigProvider.getConfig().fileUploadAccept);
|
|
1634
1968
|
// this.checkAcceptedFile(mimeType);
|
|
1635
|
-
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
1636
|
-
this.logger.log(
|
|
1969
|
+
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
1970
|
+
this.logger.log(
|
|
1971
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP',
|
|
1972
|
+
isAccepted,
|
|
1973
|
+
)
|
|
1637
1974
|
if (isAccepted === true) {
|
|
1638
|
-
this.handleDropEvent(ev)
|
|
1639
|
-
|
|
1975
|
+
this.handleDropEvent(ev)
|
|
1640
1976
|
} else {
|
|
1641
|
-
this.logger.log(
|
|
1977
|
+
this.logger.log(
|
|
1978
|
+
'[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
|
|
1979
|
+
mimeType,
|
|
1980
|
+
'NOT SUPPORTED FILE TYPE',
|
|
1981
|
+
)
|
|
1642
1982
|
this.presentToastOnlyImageFilesAreAllowedToDrag()
|
|
1643
1983
|
}
|
|
1644
1984
|
}
|
|
1645
1985
|
}
|
|
1646
1986
|
|
|
1647
1987
|
handleDropEvent(ev) {
|
|
1648
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
|
|
1988
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
|
|
1649
1989
|
this.dropEvent = ev
|
|
1650
1990
|
}
|
|
1651
1991
|
|
|
1652
1992
|
// DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
|
|
1653
1993
|
allowDrop(ev: any) {
|
|
1654
|
-
ev.preventDefault()
|
|
1655
|
-
ev.stopPropagation()
|
|
1656
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev)
|
|
1657
|
-
this.isHovering = true
|
|
1658
|
-
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
|
+
)
|
|
1659
2002
|
}
|
|
1660
2003
|
|
|
1661
2004
|
// DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
|
|
1662
2005
|
drag(ev: any) {
|
|
1663
|
-
ev.preventDefault()
|
|
1664
|
-
ev.stopPropagation()
|
|
1665
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev)
|
|
1666
|
-
this.isHovering = false
|
|
1667
|
-
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
|
+
)
|
|
1668
2014
|
}
|
|
1669
2015
|
|
|
1670
2016
|
async presentToastOnlyImageFilesAreAllowedToDrag() {
|
|
1671
2017
|
const toast = await this.toastController.create({
|
|
1672
|
-
message: this.translationMap.get(
|
|
2018
|
+
message: this.translationMap.get(
|
|
2019
|
+
'FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED',
|
|
2020
|
+
),
|
|
1673
2021
|
duration: 5000,
|
|
1674
|
-
color:
|
|
2022
|
+
color: 'danger',
|
|
1675
2023
|
cssClass: 'toast-custom-class',
|
|
1676
|
-
})
|
|
1677
|
-
toast.present()
|
|
2024
|
+
})
|
|
2025
|
+
toast.present()
|
|
1678
2026
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
2027
|
}
|
|
1682
|
-
// END ALL //
|
|
2028
|
+
// END ALL //
|