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