@chat21/chat21-ionic 3.0.5-9.2 → 3.0.6-2.3
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 +202 -0
- 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 +98 -37
- 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 +59 -25
- 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 +389 -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 +1254 -753
- 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/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,151 @@ 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(this.conversationWith, message, idCurrentUser, userFullname);
|
|
889
|
-
|
|
890
1166
|
|
|
1167
|
+
if (message !== '') {
|
|
1168
|
+
this.typingService.setTyping(this.conversationWith, message, idCurrentUser, userFullname)
|
|
1169
|
+
}
|
|
891
1170
|
|
|
892
1171
|
// ----------------------------------------------------------
|
|
893
1172
|
// DISPLAY CANNED RESPONSES if message.lastIndexOf("/")
|
|
894
1173
|
// ----------------------------------------------------------
|
|
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
|
|
1174
|
+
if (this.areVisibleCAR && this.support_mode === true) {
|
|
1175
|
+
setTimeout(() => {
|
|
1176
|
+
if (this.conversationWith.startsWith('support-group')) {
|
|
1177
|
+
const pos = message.lastIndexOf('/')
|
|
1178
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea - canned responses pos of / (using lastIndexOf) ', pos)
|
|
1179
|
+
|
|
1180
|
+
if (pos === -1) {
|
|
931
1181
|
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
|
|
1182
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
935
1183
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
1184
|
+
// test
|
|
1185
|
+
// var rest = message.substring(0, message.lastIndexOf("/") + 1);
|
|
1186
|
+
// var last = message.substring(message.lastIndexOf("/") + 1, message.length);
|
|
1187
|
+
// console.log('[CONVS-DETAIL] - returnChangeTextArea rest', rest);
|
|
1188
|
+
// console.log('[CONVS-DETAIL] - returnChangeTextArea last', last);
|
|
1189
|
+
// console.log('[CONVS-DETAIL] - returnChangeTextArea last', last.length);
|
|
1190
|
+
// if (last.length === 1 && last.trim() === '') {
|
|
1191
|
+
// console.log('[CONVS-DETAIL] - returnChangeTextArea last is a white space ');
|
|
1192
|
+
// } else if (last.length === 1 && last.trim() !== '') {
|
|
1193
|
+
// console.log('[CONVS-DETAIL] - returnChangeTextArea last is NOT space ');
|
|
1194
|
+
// }
|
|
1195
|
+
|
|
1196
|
+
if (pos >= 0) {
|
|
1197
|
+
var strSearch = message.substr(pos + 1)
|
|
1198
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea - canned responses strSearch ', strSearch)
|
|
1199
|
+
|
|
1200
|
+
// --------------------------------------------
|
|
1201
|
+
// Load canned responses
|
|
1202
|
+
// --------------------------------------------
|
|
1203
|
+
this.loadTagsCanned(strSearch, this.conversationWith)
|
|
939
1204
|
|
|
940
1205
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
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)
|
|
1206
|
+
// 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
1207
|
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
944
1208
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1209
|
+
var after_slash = message.substring(
|
|
1210
|
+
message.lastIndexOf('/') + 1,
|
|
1211
|
+
message.length,
|
|
1212
|
+
)
|
|
1213
|
+
if (
|
|
1214
|
+
pos === 0 &&
|
|
1215
|
+
after_slash.length === 1 &&
|
|
1216
|
+
after_slash.trim() === ''
|
|
1217
|
+
) {
|
|
1218
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is a white space after ')
|
|
1219
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1220
|
+
this.tagsCannedFilter = []
|
|
1221
|
+
} else if (pos === 0 && after_slash.length === 0) {
|
|
1222
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea after_slash --> there is NOT a white space after')
|
|
1223
|
+
this.HIDE_CANNED_RESPONSES = false
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
if (pos > 0) {
|
|
1227
|
+
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1228
|
+
// 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)
|
|
1229
|
+
// and if there is not a space before the SLASH (in this it will be hidden)
|
|
1230
|
+
// ------------------------------------------------------------------------------------------------------------------------------------------
|
|
1231
|
+
|
|
1232
|
+
let beforeSlash = message.substr(pos - 1)
|
|
1233
|
+
let afterSlash = message.substr(pos + 1)
|
|
1234
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea * POS ', pos)
|
|
1235
|
+
|
|
1236
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash', beforeSlash)
|
|
1237
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash', afterSlash)
|
|
1238
|
+
var afterSlashParts = afterSlash.split('/')
|
|
1239
|
+
var beforeSlashParts = beforeSlash.split('/')
|
|
1240
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> afterSlash parts', afterSlashParts)
|
|
1241
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash parts', beforeSlashParts)
|
|
1242
|
+
|
|
1243
|
+
if (beforeSlashParts.length === 2) {
|
|
1244
|
+
if (
|
|
1245
|
+
beforeSlashParts[0].indexOf(' ') >= 0 &&
|
|
1246
|
+
afterSlashParts[0] === ''
|
|
1247
|
+
) {
|
|
1248
|
+
this.HIDE_CANNED_RESPONSES = false
|
|
1249
|
+
this.logger.log(
|
|
1250
|
+
'[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash there is a white space After Not',
|
|
1251
|
+
)
|
|
1252
|
+
// if (beforeSlashParts[0].indexOf(' ') >= 0 && afterSlashParts[0].indexOf(' ') >= 0)
|
|
1253
|
+
} else if (
|
|
1254
|
+
beforeSlashParts[0].indexOf(' ') < 0 &&
|
|
1255
|
+
afterSlashParts[0] === ''
|
|
1256
|
+
) {
|
|
1257
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1258
|
+
this.tagsCannedFilter = []
|
|
1259
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After Not')
|
|
1260
|
+
} else if (
|
|
1261
|
+
beforeSlashParts[0].indexOf(' ') >= 0 &&
|
|
1262
|
+
afterSlashParts[0] === ' '
|
|
1263
|
+
) {
|
|
1264
|
+
this.logger.log('[CONVS-DETAIL] - returnChangeTextArea --> beforeSlash not thete is a white space After YES')
|
|
1265
|
+
this.HIDE_CANNED_RESPONSES = true
|
|
1266
|
+
this.tagsCannedFilter = []
|
|
1267
|
+
}
|
|
969
1268
|
}
|
|
970
1269
|
}
|
|
1270
|
+
} else {
|
|
1271
|
+
this.tagsCannedFilter = []
|
|
971
1272
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
} else {
|
|
975
|
-
this.tagsCannedFilter = [];
|
|
976
1273
|
}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
1274
|
+
}, 300)
|
|
1275
|
+
}
|
|
979
1276
|
// ./ CANNED RESPONSES //
|
|
980
|
-
|
|
981
1277
|
} catch (err) {
|
|
982
|
-
this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
|
|
1278
|
+
this.logger.error('[CONVS-DETAIL] - returnChangeTextArea - error: ', err)
|
|
983
1279
|
}
|
|
984
1280
|
}
|
|
985
1281
|
|
|
@@ -987,201 +1283,344 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
987
1283
|
// @ CANNED RESPONSES methods
|
|
988
1284
|
// ----------------------------------------------------------
|
|
989
1285
|
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.
|
|
1286
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned strSearch ', strSearch)
|
|
1287
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned groupDetail ', this.groupDetail)
|
|
1288
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith ', conversationWith)
|
|
1289
|
+
|
|
1290
|
+
const conversationWith_segments = conversationWith.split('-')
|
|
1291
|
+
// Removes the last element of the array if is = to the separator
|
|
1292
|
+
if (
|
|
1293
|
+
conversationWith_segments[conversationWith_segments.length - 1] === ''
|
|
1294
|
+
) {
|
|
1295
|
+
conversationWith_segments.pop()
|
|
998
1296
|
}
|
|
999
1297
|
|
|
1000
1298
|
if (conversationWith_segments.length === 4) {
|
|
1001
|
-
const lastArrayElement =
|
|
1002
|
-
|
|
1003
|
-
this.logger.log('[CONVS-DETAIL] - lastArrayElement
|
|
1299
|
+
const lastArrayElement =
|
|
1300
|
+
conversationWith_segments[conversationWith_segments.length - 1]
|
|
1301
|
+
this.logger.log('[CONVS-DETAIL] - lastArrayElement ', lastArrayElement)
|
|
1302
|
+
this.logger.log('[CONVS-DETAIL] - lastArrayElement length', lastArrayElement.length)
|
|
1004
1303
|
if (lastArrayElement.length !== 32) {
|
|
1005
|
-
conversationWith_segments.pop()
|
|
1304
|
+
conversationWith_segments.pop()
|
|
1006
1305
|
}
|
|
1007
1306
|
}
|
|
1008
1307
|
|
|
1009
|
-
this.logger.log(
|
|
1010
|
-
let projectId =
|
|
1308
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned conversationWith_segments ', conversationWith_segments)
|
|
1309
|
+
let projectId = ''
|
|
1011
1310
|
|
|
1012
1311
|
if (conversationWith_segments.length === 4) {
|
|
1013
|
-
projectId = conversationWith_segments[2]
|
|
1014
|
-
this.logger.log(
|
|
1312
|
+
projectId = conversationWith_segments[2]
|
|
1313
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned projectId ', projectId)
|
|
1015
1314
|
|
|
1016
1315
|
this.getAndShowCannedResponses(strSearch, projectId)
|
|
1017
|
-
|
|
1018
1316
|
} else {
|
|
1019
1317
|
this.getProjectIdByConversationWith(strSearch, this.conversationWith)
|
|
1020
1318
|
}
|
|
1021
1319
|
}
|
|
1022
1320
|
|
|
1023
1321
|
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
|
-
|
|
1322
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1323
|
+
|
|
1324
|
+
this.tiledeskService
|
|
1325
|
+
.getProjectIdByConvRecipient(tiledeskToken, conversationWith)
|
|
1326
|
+
.subscribe(
|
|
1327
|
+
(res) => {
|
|
1328
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
|
|
1329
|
+
if (res) {
|
|
1330
|
+
const projectId = res.id_project
|
|
1331
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT projectId ', projectId)
|
|
1332
|
+
if (projectId) {
|
|
1333
|
+
this.getAndShowCannedResponses(strSearch, projectId)
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1337
|
+
(error) => {
|
|
1338
|
+
this.logger.error('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT - ERROR ', error)
|
|
1339
|
+
},
|
|
1340
|
+
() => {
|
|
1341
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT * COMPLETE *')
|
|
1342
|
+
},
|
|
1343
|
+
)
|
|
1043
1344
|
}
|
|
1044
1345
|
|
|
1045
1346
|
getAndShowCannedResponses(strSearch, projectId) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1347
|
+
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
|
|
1348
|
+
this.logger.log(
|
|
1349
|
+
'[CONVS-DETAIL] - loadTagsCanned tagsCanned.length',
|
|
1350
|
+
this.tagsCanned.length,
|
|
1351
|
+
)
|
|
1049
1352
|
//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
|
-
|
|
1353
|
+
this.tagsCanned = []
|
|
1354
|
+
this.cannedResponsesService
|
|
1355
|
+
.getCannedResponses(tiledeskToken, projectId)
|
|
1356
|
+
.subscribe(
|
|
1357
|
+
(res) => {
|
|
1358
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses RES', res)
|
|
1359
|
+
|
|
1360
|
+
this.tagsCanned = res
|
|
1361
|
+
this.tagsCannedCount = res.length
|
|
1362
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses tagsCannedCount', this.tagsCannedCount)
|
|
1363
|
+
if (this.HIDE_CANNED_RESPONSES === false) {
|
|
1364
|
+
this.showTagsCanned(strSearch)
|
|
1365
|
+
}
|
|
1366
|
+
},
|
|
1367
|
+
(error) => {
|
|
1368
|
+
this.logger.error('[CONVS-DETAIL] - loadTagsCanned getCannedResponses - ERROR ', error)
|
|
1369
|
+
},
|
|
1370
|
+
() => {
|
|
1371
|
+
this.logger.log('[CONVS-DETAIL] - loadTagsCanned getCannedResponses * COMPLETE *')
|
|
1372
|
+
},
|
|
1373
|
+
)
|
|
1067
1374
|
}
|
|
1068
1375
|
|
|
1069
|
-
|
|
1070
1376
|
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)
|
|
1377
|
+
this.logger.log('[CONVS-DETAIL] - showTagsCanned strSearch ', strSearch)
|
|
1378
|
+
this.tagsCannedFilter = []
|
|
1379
|
+
var tagsCannedClone = JSON.parse(JSON.stringify(this.tagsCanned))
|
|
1380
|
+
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedClone ', tagsCannedClone)
|
|
1075
1381
|
//this.logger.log("that.contacts lenght:: ", strSearch);
|
|
1076
|
-
this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
|
|
1077
|
-
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter)
|
|
1382
|
+
this.tagsCannedFilter = this.filterItems(tagsCannedClone, strSearch)
|
|
1383
|
+
this.logger.log('[CONVS-DETAIL] - showTagsCanned tagsCannedFilter ', this.tagsCannedFilter)
|
|
1078
1384
|
|
|
1079
|
-
this.tagsCannedFilter.sort(compareValues('title', 'asc'))
|
|
1080
|
-
var strReplace = strSearch
|
|
1385
|
+
this.tagsCannedFilter.sort(compareValues('title', 'asc'))
|
|
1386
|
+
var strReplace = strSearch
|
|
1081
1387
|
if (strSearch.length > 0) {
|
|
1082
|
-
strReplace = "<b class='highlight-search-string'>" + strSearch +
|
|
1388
|
+
strReplace = "<b class='highlight-search-string'>" + strSearch + '</b>'
|
|
1083
1389
|
}
|
|
1084
1390
|
for (var i = 0; i < this.tagsCannedFilter.length; i++) {
|
|
1391
|
+
let text = htmlEntities(this.tagsCannedFilter[i].text);
|
|
1392
|
+
// const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) + '</div>'
|
|
1393
|
+
const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(text) + '</div>'
|
|
1394
|
+
let title = htmlEntities(this.tagsCannedFilter[i].title)
|
|
1395
|
+
// this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + this.tagsCannedFilter[i].title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
|
|
1396
|
+
this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + title.toString().replace(strSearch, strReplace.trim()) + '</div>' + textCanned + '</div>'
|
|
1085
1397
|
|
|
1086
|
-
const textCanned = "<div class='cannedText'>" + this.replacePlaceholderInCanned(this.tagsCannedFilter[i].text) + "</div>";
|
|
1087
|
-
this.tagsCannedFilter[i].title = "<div class='cannedContent'><div class='cannedTitle'>" + this.tagsCannedFilter[i].title.toString().replace(strSearch, strReplace.trim()) + "</div>" + textCanned + '</div>';
|
|
1088
|
-
|
|
1089
1398
|
}
|
|
1399
|
+
if (this.tagsCannedCount === 0) {
|
|
1400
|
+
// const button = this.renderer.createElement('button');
|
|
1401
|
+
// const buttonText = this.renderer.createText('Click me');
|
|
1402
|
+
// this.renderer.appendChild(button, buttonText);
|
|
1403
|
+
// console.log('[CONVS-DETAIL] - this.el.nativeElement ', this.el.nativeElement)
|
|
1404
|
+
// this.renderer.listen(button, 'click', () => { alert('hi'); });
|
|
1405
|
+
// let nocanned = {}
|
|
1406
|
+
// if (this.USER_ROLE !== 'agent') {
|
|
1407
|
+
const nocanned = {
|
|
1408
|
+
// "<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>'
|
|
1409
|
+
// <div class='cannedText no-canned-available-text'>" + this.translationMap.get('AddNewCannedResponse') + '</div>
|
|
1410
|
+
title:
|
|
1411
|
+
"<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div></div>",
|
|
1412
|
+
text: 'There are no canned responses available',
|
|
1413
|
+
}
|
|
1414
|
+
// } else if (this.USER_ROLE === 'agent') {
|
|
1415
|
+
// nocanned = {
|
|
1416
|
+
// // "<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>'
|
|
1417
|
+
// title:
|
|
1418
|
+
// "<div class='cannedContent'><div class='cannedTitle nocannedTitle #noCannedTitle'>" + this.translationMap.get('THERE_ARE_NO_CANNED_RESPONSES_AVAILABLE') + ".</div></div>",
|
|
1419
|
+
// text: 'There are no canned responses available',
|
|
1420
|
+
// }
|
|
1421
|
+
// }
|
|
1422
|
+
this.tagsCannedFilter.push(nocanned)
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
toggleSidebar() {
|
|
1427
|
+
// console.log('[CONVS-DETAIL] has clicked test')
|
|
1090
1428
|
}
|
|
1091
1429
|
|
|
1092
1430
|
filterItems(items, searchTerm) {
|
|
1093
|
-
this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
|
|
1431
|
+
this.logger.log('[CONVS-DETAIL] filterItems tagsCannedClone ', items, ' searchTerm: ', searchTerm)
|
|
1094
1432
|
//this.logger.log("filterItems::: ",searchTerm);
|
|
1095
1433
|
return items.filter((item) => {
|
|
1096
1434
|
//this.logger.log("filterItems::: ", item.title.toString().toLowerCase());
|
|
1097
|
-
this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
|
|
1098
|
-
return
|
|
1099
|
-
|
|
1435
|
+
this.logger.log('[CONVS-DETAIL] filtered tagsCannedClone item ', item)
|
|
1436
|
+
return (
|
|
1437
|
+
item.title
|
|
1438
|
+
.toString()
|
|
1439
|
+
.toLowerCase()
|
|
1440
|
+
.indexOf(searchTerm.toString().toLowerCase()) > -1
|
|
1441
|
+
)
|
|
1442
|
+
})
|
|
1100
1443
|
}
|
|
1101
1444
|
|
|
1102
1445
|
replacePlaceholderInCanned(str) {
|
|
1103
|
-
this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
|
|
1446
|
+
this.logger.log('[CONVS-DETAIL] - replacePlaceholderInCanned str ', str)
|
|
1447
|
+
str = str.replace('$recipient_name', this.conversationWithFullname)
|
|
1448
|
+
if (this.loggedUser && this.loggedUser.fullname) {
|
|
1449
|
+
str = str.replace('$agent_name', this.loggedUser.fullname)
|
|
1450
|
+
}
|
|
1451
|
+
return str
|
|
1452
|
+
}
|
|
1104
1453
|
|
|
1454
|
+
replaceTagInMessage(canned, event) {
|
|
1455
|
+
if (this.tagsCannedCount > 0) {
|
|
1456
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage event ', event)
|
|
1457
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage canned ', canned)
|
|
1458
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage canned title', canned.title)
|
|
1459
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage canned contains nocannedTitle', canned.title.includes('nocannedTitle'))
|
|
1105
1460
|
|
|
1106
|
-
|
|
1461
|
+
const elTextArea = this.rowTextArea['el']
|
|
1462
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1107
1463
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1464
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage textArea ', textArea)
|
|
1465
|
+
// console.log('[CONVS-DETAIL] replaceTagInMessage textArea value', textArea.value,)
|
|
1466
|
+
|
|
1467
|
+
// var lastChar = textArea.value.substr(-1); // Selects the last character
|
|
1468
|
+
// if (lastChar === '/') {
|
|
1469
|
+
// textArea.value = textArea.value.substring(0, textArea.value.length() - 1);
|
|
1470
|
+
// }
|
|
1471
|
+
// this.insertAtCursor(this.textArea, textArea.value)
|
|
1472
|
+
|
|
1473
|
+
this.arrowkeyLocation = -1
|
|
1474
|
+
this.tagsCannedFilter = []
|
|
1475
|
+
this.logger.log('[CONVS-DETAIL] replaceTagInMessage canned text ', canned.text)
|
|
1476
|
+
|
|
1477
|
+
// replace text
|
|
1478
|
+
var pos = textArea.value.lastIndexOf('/')
|
|
1479
|
+
var strSearch = textArea.value.substr(pos)
|
|
1480
|
+
this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strSearch)
|
|
1481
|
+
|
|
1482
|
+
var strTEMP = textArea.value.replace(strSearch, canned.text)
|
|
1483
|
+
strTEMP = this.replacePlaceholderInCanned(strTEMP)
|
|
1484
|
+
this.logger.log('[CONVS-DETAIL] replaceTagInMessage strSearch ', strTEMP)
|
|
1485
|
+
// strTEMP = this.replacePlaceholderInCanned(strTEMP);
|
|
1486
|
+
// textArea.value = '';
|
|
1487
|
+
// that.messageString = strTEMP;
|
|
1488
|
+
textArea.value = strTEMP
|
|
1489
|
+
setTimeout(() => {
|
|
1490
|
+
// textArea.focus();
|
|
1491
|
+
textArea.setFocus()
|
|
1492
|
+
this.resizeTextArea()
|
|
1493
|
+
}, 200)
|
|
1494
|
+
}
|
|
1495
|
+
else {
|
|
1496
|
+
this.logger.log('[CONVS-DETAIL] THERE IS NOT CANNED ', canned.text)
|
|
1110
1497
|
}
|
|
1111
|
-
return str;
|
|
1112
1498
|
}
|
|
1113
1499
|
|
|
1114
|
-
|
|
1115
|
-
this.
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1500
|
+
async presentCreateCannedResponseModal(): Promise<any> {
|
|
1501
|
+
const elTextArea = this.rowTextArea['el']
|
|
1502
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1503
|
+
textArea.value = ''
|
|
1504
|
+
|
|
1505
|
+
// console.log('[CONVS-DETAIL] PRESENT CREATE CANNED RESPONSE MODAL ')
|
|
1506
|
+
const attributes = { conversationWith: this.conversationWith }
|
|
1507
|
+
const modal: HTMLIonModalElement = await this.modalController.create({
|
|
1508
|
+
component: CreateCannedResponsePage,
|
|
1509
|
+
componentProps: attributes,
|
|
1510
|
+
swipeToClose: false,
|
|
1511
|
+
backdropDismiss: false,
|
|
1512
|
+
})
|
|
1513
|
+
modal.onDidDismiss().then((dataReturned: any) => {
|
|
1514
|
+
this.logger.log('[CONVS-DETAIL] ', dataReturned.data)
|
|
1515
|
+
})
|
|
1516
|
+
|
|
1517
|
+
return await modal.present()
|
|
1518
|
+
}
|
|
1118
1519
|
|
|
1119
|
-
|
|
1120
|
-
this.logger.log(
|
|
1520
|
+
hasClickedOpenCannedResponses($event) {
|
|
1521
|
+
this.logger.log('[CONVS-DETAIL] - hasClickedOpenCannedResponses ', $event)
|
|
1522
|
+
const elTextArea = this.rowTextArea['el']
|
|
1523
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1524
|
+
|
|
1525
|
+
this.logger.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea ', textArea)
|
|
1526
|
+
// console.log("[CONVS-DETAIL] hasClickedOpenCannedResponses textArea value", textArea.value)
|
|
1527
|
+
var lastChar = textArea.value[textArea.value.length - 1]
|
|
1528
|
+
// console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses lastChar', lastChar)
|
|
1529
|
+
if (lastChar !== '/') {
|
|
1530
|
+
this.insertAtCursor(textArea, '/')
|
|
1531
|
+
}
|
|
1532
|
+
// console.log('[CONVS-DETAIL] hasClickedOpenCannedResponses textArea.value', textArea.value)
|
|
1533
|
+
// setTimeout(() => {
|
|
1534
|
+
// // if (textArea.value === '/') {
|
|
1535
|
+
// // textArea.focus();
|
|
1536
|
+
// textArea.setFocus();
|
|
1537
|
+
// // }
|
|
1538
|
+
// }, 1500);
|
|
1539
|
+
|
|
1540
|
+
this.setCaretPosition(textArea)
|
|
1541
|
+
}
|
|
1121
1542
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
// this.insertAtCursor(this.textArea, textArea.value)
|
|
1543
|
+
setCaretPosition(ctrl) {
|
|
1544
|
+
ctrl.value.trim()
|
|
1545
|
+
ctrl.setFocus()
|
|
1546
|
+
}
|
|
1127
1547
|
|
|
1548
|
+
insertAtCursor(myField, myValue) {
|
|
1549
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myValue ', myValue)
|
|
1550
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - myField ', myField)
|
|
1128
1551
|
|
|
1129
|
-
|
|
1130
|
-
this.tagsCannedFilter = [];
|
|
1131
|
-
this.logger.log("[CONVS-DETAIL] replaceTagInMessage canned text ", canned.text);
|
|
1132
|
-
// // prendo val input
|
|
1552
|
+
// myValue = ' ' + myValue;
|
|
1133
1553
|
|
|
1554
|
+
// console.log('[CONVS-DETAIL] - GET TEXT AREA - Here yes myValue ', myValue);
|
|
1555
|
+
// console.log('[CONVS-DETAIL] - GET TEXT AREA - Here yes textArea value length', myField.value.length);
|
|
1134
1556
|
|
|
1557
|
+
if (myField.value.length > 0) {
|
|
1558
|
+
myValue = ' ' + myValue
|
|
1559
|
+
}
|
|
1135
1560
|
|
|
1136
|
-
//
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1561
|
+
//IE support
|
|
1562
|
+
if (myField.selection) {
|
|
1563
|
+
myField.focus()
|
|
1564
|
+
let sel = myField.selection.createRange()
|
|
1565
|
+
sel.text = myValue
|
|
1566
|
+
// this.cannedResponseMessage = sel.text;
|
|
1567
|
+
}
|
|
1568
|
+
//MOZILLA and others
|
|
1569
|
+
else if (myField.selectionStart || myField.selectionStart == '0') {
|
|
1570
|
+
var startPos = myField.selectionStart
|
|
1571
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - startPos ', startPos)
|
|
1140
1572
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
setTimeout(() => {
|
|
1149
|
-
// textArea.focus();
|
|
1150
|
-
textArea.setFocus();
|
|
1151
|
-
this.resizeTextArea();
|
|
1152
|
-
}, 200);
|
|
1153
|
-
}
|
|
1573
|
+
var endPos = myField.selectionEnd
|
|
1574
|
+
this.logger.log('[CONVS-DETAIL] - insertAtCursor - endPos ', endPos)
|
|
1575
|
+
|
|
1576
|
+
myField.value =
|
|
1577
|
+
myField.value.substring(0, startPos) +
|
|
1578
|
+
myValue +
|
|
1579
|
+
myField.value.substring(endPos, myField.value.length)
|
|
1154
1580
|
|
|
1581
|
+
// place cursor at end of text in text input element
|
|
1582
|
+
myField.focus()
|
|
1583
|
+
var val = myField.value //store the value of the element
|
|
1584
|
+
myField.value = '' //clear the value of the element
|
|
1585
|
+
myField.value = val + ' ' //set that value back.
|
|
1586
|
+
|
|
1587
|
+
// this.cannedResponseMessage = myField.value;
|
|
1588
|
+
|
|
1589
|
+
// this.texareaIsEmpty = false;
|
|
1590
|
+
// myField.select();
|
|
1591
|
+
} else {
|
|
1592
|
+
myField.value += myValue
|
|
1593
|
+
// this.cannedResponseMessage = myField.value;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1155
1596
|
|
|
1156
1597
|
@HostListener('document:keydown', ['$event'])
|
|
1157
1598
|
handleKeyboardEvent(event: KeyboardEvent) {
|
|
1158
1599
|
// this.logger.log("CONVERSATION-DETAIL handleKeyboardEvent event.key ", event.key);
|
|
1159
1600
|
|
|
1160
1601
|
if (this.tagsCannedFilter.length > 0) {
|
|
1161
|
-
|
|
1162
1602
|
if (event.key === 'ArrowDown') {
|
|
1163
|
-
|
|
1164
|
-
this.arrowkeyLocation++;
|
|
1603
|
+
this.arrowkeyLocation++
|
|
1165
1604
|
if (this.arrowkeyLocation === this.tagsCannedFilter.length) {
|
|
1166
1605
|
this.arrowkeyLocation--
|
|
1167
1606
|
}
|
|
1168
1607
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
1169
|
-
}
|
|
1170
|
-
else if (event.key === 'ArrowUp') {
|
|
1171
|
-
|
|
1608
|
+
} else if (event.key === 'ArrowUp') {
|
|
1172
1609
|
if (this.arrowkeyLocation > 0) {
|
|
1173
|
-
this.arrowkeyLocation
|
|
1610
|
+
this.arrowkeyLocation--
|
|
1174
1611
|
} else if (this.arrowkeyLocation < 0) {
|
|
1175
|
-
this.arrowkeyLocation
|
|
1612
|
+
this.arrowkeyLocation++
|
|
1176
1613
|
}
|
|
1177
1614
|
// this.replaceTagInMessage(this.tagsCannedFilter[this.arrowkeyLocation])
|
|
1178
1615
|
}
|
|
1179
1616
|
|
|
1180
1617
|
if (event.key === 'Enter') {
|
|
1181
1618
|
const canned_selected = this.tagsCannedFilter[this.arrowkeyLocation]
|
|
1182
|
-
this.logger.log(
|
|
1619
|
+
this.logger.log(
|
|
1620
|
+
'[CONVS-DETAIL] replaceTagInMessage canned_selected ',
|
|
1621
|
+
canned_selected,
|
|
1622
|
+
)
|
|
1183
1623
|
if (canned_selected) {
|
|
1184
|
-
|
|
1185
1624
|
this.replaceTagInMessage(canned_selected, 'enter')
|
|
1186
1625
|
// event.preventDefault();
|
|
1187
1626
|
// return false;
|
|
@@ -1193,35 +1632,40 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1193
1632
|
// ./end CANNED RESPONSES methods
|
|
1194
1633
|
// ----------------------------------------------------------
|
|
1195
1634
|
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
1635
|
// ----------------------------------------------------------
|
|
1199
|
-
// @ Rule of sound message
|
|
1636
|
+
// @ Rule of sound message
|
|
1200
1637
|
// * if I send it -> NO SOUND
|
|
1201
1638
|
// * if I'm not in the conversation -> SOUND
|
|
1202
1639
|
// * if I'm in the conversation at the bottom of the page -> NO SOUND
|
|
1203
1640
|
// * otherwise -> SOUND
|
|
1204
1641
|
// ----------------------------------------------------------
|
|
1205
1642
|
soundMessage() {
|
|
1206
|
-
const that = this
|
|
1207
|
-
this.audio = new Audio()
|
|
1643
|
+
const that = this
|
|
1644
|
+
this.audio = new Audio()
|
|
1208
1645
|
// this.audio.src = '/assets/sounds/pling.mp3';
|
|
1209
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION
|
|
1210
|
-
this.audio.load()
|
|
1211
|
-
this.logger.log(
|
|
1212
|
-
|
|
1646
|
+
this.audio.src = URL_SOUND_LIST_CONVERSATION
|
|
1647
|
+
this.audio.load()
|
|
1648
|
+
this.logger.log(
|
|
1649
|
+
'[CONVS-DETAIL] soundMessage conversation this.audio',
|
|
1650
|
+
this.audio,
|
|
1651
|
+
)
|
|
1652
|
+
clearTimeout(this.setTimeoutSound)
|
|
1213
1653
|
this.setTimeoutSound = setTimeout(function () {
|
|
1214
|
-
that.audio
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1654
|
+
that.audio
|
|
1655
|
+
.play()
|
|
1656
|
+
.then(() => {
|
|
1657
|
+
// Audio is playing.
|
|
1658
|
+
this.logger.log(
|
|
1659
|
+
'[CONVS-DETAIL] soundMessag that.audio.src ',
|
|
1660
|
+
that.audio.src,
|
|
1661
|
+
)
|
|
1662
|
+
})
|
|
1663
|
+
.catch((error) => {
|
|
1664
|
+
that.logger.error(error)
|
|
1665
|
+
})
|
|
1666
|
+
}, 1000)
|
|
1221
1667
|
}
|
|
1222
1668
|
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
1669
|
returnOnBeforeMessageRender(event) {
|
|
1226
1670
|
//this.onBeforeMessageRender.emit(event)
|
|
1227
1671
|
}
|
|
@@ -1234,86 +1678,83 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1234
1678
|
// this.isMenuShow = event;
|
|
1235
1679
|
}
|
|
1236
1680
|
|
|
1237
|
-
returnOnScrollContent(event: boolean) {
|
|
1238
|
-
|
|
1239
|
-
}
|
|
1681
|
+
returnOnScrollContent(event: boolean) { }
|
|
1240
1682
|
|
|
1241
1683
|
returnOnAttachmentButtonClicked(event: any) {
|
|
1242
1684
|
this.logger.debug('[CONV-COMP] eventbutton', event)
|
|
1243
1685
|
if (!event || !event.target.type) {
|
|
1244
|
-
return
|
|
1686
|
+
return
|
|
1245
1687
|
}
|
|
1246
1688
|
switch (event.target.type) {
|
|
1247
1689
|
case 'url':
|
|
1248
1690
|
try {
|
|
1249
|
-
this.openLink(event.target.button)
|
|
1691
|
+
this.openLink(event.target.button)
|
|
1250
1692
|
} catch (err) {
|
|
1251
|
-
this.logger.error('[CONV-COMP] url > Error :' + err)
|
|
1693
|
+
this.logger.error('[CONV-COMP] url > Error :' + err)
|
|
1252
1694
|
}
|
|
1253
|
-
return
|
|
1695
|
+
return
|
|
1254
1696
|
case 'action':
|
|
1255
1697
|
try {
|
|
1256
|
-
this.actionButton(event.target.button)
|
|
1698
|
+
this.actionButton(event.target.button)
|
|
1257
1699
|
} catch (err) {
|
|
1258
|
-
this.logger.error('[CONV-COMP] action > Error :' + err)
|
|
1700
|
+
this.logger.error('[CONV-COMP] action > Error :' + err)
|
|
1259
1701
|
}
|
|
1260
|
-
return false
|
|
1702
|
+
return false
|
|
1261
1703
|
case 'text':
|
|
1262
1704
|
try {
|
|
1263
1705
|
const text = event.target.button.value
|
|
1264
|
-
const metadata = {
|
|
1265
|
-
this.sendMessage(text, TYPE_MSG_TEXT, metadata)
|
|
1706
|
+
const metadata = { button: true }
|
|
1707
|
+
this.sendMessage(text, TYPE_MSG_TEXT, metadata)
|
|
1266
1708
|
} catch (err) {
|
|
1267
|
-
this.logger.error('[CONV-COMP] text > Error :' + err)
|
|
1709
|
+
this.logger.error('[CONV-COMP] text > Error :' + err)
|
|
1268
1710
|
}
|
|
1269
|
-
default:
|
|
1711
|
+
default:
|
|
1712
|
+
return
|
|
1270
1713
|
}
|
|
1271
1714
|
}
|
|
1272
1715
|
|
|
1273
1716
|
onImageRenderedFN(event) {
|
|
1274
|
-
const imageRendered = event
|
|
1717
|
+
const imageRendered = event
|
|
1275
1718
|
if (this.showButtonToBottom) {
|
|
1276
1719
|
this.scrollBottom(0)
|
|
1277
1720
|
}
|
|
1278
1721
|
}
|
|
1279
1722
|
|
|
1280
|
-
|
|
1281
1723
|
private openLink(event: any) {
|
|
1282
|
-
const link = event.link ? event.link : ''
|
|
1283
|
-
const target = event.target ? event.target : ''
|
|
1724
|
+
const link = event.link ? event.link : ''
|
|
1725
|
+
const target = event.target ? event.target : ''
|
|
1284
1726
|
if (target === 'self' || target === 'parent') {
|
|
1285
|
-
window.open(link, '_parent')
|
|
1727
|
+
window.open(link, '_parent')
|
|
1286
1728
|
} else {
|
|
1287
|
-
window.open(link, '_blank')
|
|
1729
|
+
window.open(link, '_blank')
|
|
1288
1730
|
}
|
|
1289
1731
|
}
|
|
1290
1732
|
|
|
1291
|
-
|
|
1292
1733
|
private actionButton(event: any) {
|
|
1293
1734
|
// console.log(event);
|
|
1294
|
-
const action = event.action ? event.action : ''
|
|
1295
|
-
const message = event.value ? event.value : ''
|
|
1296
|
-
const subtype = event.show_reply ? '' : 'info'
|
|
1735
|
+
const action = event.action ? event.action : ''
|
|
1736
|
+
const message = event.value ? event.value : ''
|
|
1737
|
+
const subtype = event.show_reply ? '' : 'info'
|
|
1297
1738
|
|
|
1298
1739
|
const attributes = {
|
|
1299
1740
|
action: action,
|
|
1300
|
-
subtype: subtype
|
|
1301
|
-
}
|
|
1302
|
-
this.sendMessage(message, TYPE_MSG_TEXT, null, attributes)
|
|
1303
|
-
this.logger.debug('[CONV-COMP] > action :')
|
|
1741
|
+
subtype: subtype,
|
|
1742
|
+
}
|
|
1743
|
+
this.sendMessage(message, TYPE_MSG_TEXT, null, attributes)
|
|
1744
|
+
this.logger.debug('[CONV-COMP] > action :')
|
|
1304
1745
|
}
|
|
1305
1746
|
|
|
1306
1747
|
addUploadingBubbleEvent(event: boolean) {
|
|
1307
|
-
this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
|
|
1748
|
+
this.logger.log('[CONVS-DETAIL] addUploadingBubbleEvent event', event)
|
|
1308
1749
|
if (event === true) {
|
|
1309
|
-
this.scrollBottom(0)
|
|
1750
|
+
this.scrollBottom(0)
|
|
1310
1751
|
}
|
|
1311
1752
|
}
|
|
1312
1753
|
|
|
1313
1754
|
onPresentModalScrollToBottom(event: boolean) {
|
|
1314
|
-
this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
|
|
1755
|
+
this.logger.log('[CONVS-DETAIL] onPresentModalScrollToBottom event', event)
|
|
1315
1756
|
if (event === true) {
|
|
1316
|
-
this.scrollBottom(0)
|
|
1757
|
+
this.scrollBottom(0)
|
|
1317
1758
|
}
|
|
1318
1759
|
}
|
|
1319
1760
|
|
|
@@ -1321,25 +1762,28 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1321
1762
|
/** */
|
|
1322
1763
|
resizeTextArea() {
|
|
1323
1764
|
try {
|
|
1324
|
-
const elTextArea = this.rowTextArea['el']
|
|
1325
|
-
const that = this
|
|
1765
|
+
const elTextArea = this.rowTextArea['el']
|
|
1766
|
+
const that = this
|
|
1326
1767
|
setTimeout(() => {
|
|
1327
|
-
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1768
|
+
const textArea = elTextArea.getElementsByTagName('ion-textarea')[0]
|
|
1328
1769
|
if (textArea) {
|
|
1329
|
-
this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
|
|
1330
|
-
const txtValue = textArea.value
|
|
1331
|
-
textArea.value = ' '
|
|
1332
|
-
textArea.value = txtValue
|
|
1770
|
+
this.logger.log('[CONVS-DETAIL] resizeTextArea textArea ', textArea)
|
|
1771
|
+
const txtValue = textArea.value
|
|
1772
|
+
textArea.value = ' '
|
|
1773
|
+
textArea.value = txtValue
|
|
1333
1774
|
}
|
|
1334
|
-
}, 0)
|
|
1775
|
+
}, 0)
|
|
1335
1776
|
setTimeout(() => {
|
|
1336
1777
|
if (elTextArea) {
|
|
1337
|
-
this.logger.log(
|
|
1338
|
-
|
|
1778
|
+
this.logger.log(
|
|
1779
|
+
'[CONVS-DETAIL] resizeTextArea elTextArea.offsetHeight ',
|
|
1780
|
+
elTextArea.offsetHeight,
|
|
1781
|
+
)
|
|
1782
|
+
that.heightMessageTextArea = elTextArea.offsetHeight
|
|
1339
1783
|
}
|
|
1340
|
-
}, 100)
|
|
1784
|
+
}, 100)
|
|
1341
1785
|
} catch (err) {
|
|
1342
|
-
this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
|
|
1786
|
+
this.logger.error('[CONVS-DETAIL] resizeTextArea - error: ', err)
|
|
1343
1787
|
}
|
|
1344
1788
|
}
|
|
1345
1789
|
|
|
@@ -1348,11 +1792,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1348
1792
|
* @param time
|
|
1349
1793
|
*/
|
|
1350
1794
|
private scrollBottom(time: number) {
|
|
1351
|
-
this.showIonContent = true
|
|
1795
|
+
this.showIonContent = true
|
|
1352
1796
|
if (this.ionContentChatArea) {
|
|
1353
1797
|
setTimeout(() => {
|
|
1354
|
-
this.ionContentChatArea.scrollToBottom(time)
|
|
1355
|
-
}, 0)
|
|
1798
|
+
this.ionContentChatArea.scrollToBottom(time)
|
|
1799
|
+
}, 0)
|
|
1356
1800
|
// nota: se elimino il settimeout lo scrollToBottom non viene richiamato!!!!!
|
|
1357
1801
|
}
|
|
1358
1802
|
}
|
|
@@ -1361,14 +1805,17 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1361
1805
|
* detectBottom
|
|
1362
1806
|
*/
|
|
1363
1807
|
async detectBottom() {
|
|
1364
|
-
const scrollElement = await this.ionContentChatArea.getScrollElement()
|
|
1808
|
+
const scrollElement = await this.ionContentChatArea.getScrollElement()
|
|
1365
1809
|
|
|
1366
|
-
if (
|
|
1810
|
+
if (
|
|
1811
|
+
scrollElement.scrollTop <
|
|
1812
|
+
scrollElement.scrollHeight - scrollElement.clientHeight
|
|
1813
|
+
) {
|
|
1367
1814
|
//NON SONO ALLA FINE --> mostra badge
|
|
1368
|
-
this.showButtonToBottom = true
|
|
1815
|
+
this.showButtonToBottom = true
|
|
1369
1816
|
} else {
|
|
1370
1817
|
// SONO ALLA FINE --> non mostrare badge,
|
|
1371
|
-
this.showButtonToBottom = false
|
|
1818
|
+
this.showButtonToBottom = false
|
|
1372
1819
|
}
|
|
1373
1820
|
}
|
|
1374
1821
|
|
|
@@ -1377,149 +1824,203 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
|
|
|
1377
1824
|
* FIREBY BY: click event ScrollToBottom bottom-right icon button
|
|
1378
1825
|
*/
|
|
1379
1826
|
public actionScrollBottom() {
|
|
1380
|
-
this.logger.log(
|
|
1827
|
+
this.logger.log(
|
|
1828
|
+
'[CONVS-DETAIL] actionScrollBottom - ionContentChatArea: ',
|
|
1829
|
+
this.ionContentChatArea,
|
|
1830
|
+
)
|
|
1381
1831
|
// const that = this;
|
|
1382
|
-
this.showButtonToBottom = false
|
|
1832
|
+
this.showButtonToBottom = false
|
|
1383
1833
|
this.updateConversationBadge()
|
|
1384
|
-
this.NUM_BADGES = 0
|
|
1834
|
+
this.NUM_BADGES = 0
|
|
1385
1835
|
setTimeout(() => {
|
|
1386
|
-
this.ionContentChatArea.scrollToBottom(0)
|
|
1836
|
+
this.ionContentChatArea.scrollToBottom(0)
|
|
1387
1837
|
// this.conversationsHandlerService.readAllMessages.next(this.conversationWith);
|
|
1388
|
-
}, 0)
|
|
1838
|
+
}, 0)
|
|
1389
1839
|
}
|
|
1390
1840
|
|
|
1391
1841
|
/**
|
|
1392
1842
|
* Scroll to top of the page after a short delay.
|
|
1393
1843
|
*/
|
|
1394
1844
|
scrollTop() {
|
|
1395
|
-
this.logger.log('[CONVS-DETAIL] scrollTop')
|
|
1396
|
-
this.ionContentChatArea.scrollToTop(100)
|
|
1845
|
+
this.logger.log('[CONVS-DETAIL] scrollTop')
|
|
1846
|
+
this.ionContentChatArea.scrollToTop(100)
|
|
1397
1847
|
}
|
|
1398
1848
|
|
|
1399
1849
|
/** */
|
|
1400
1850
|
setHeightTextArea() {
|
|
1401
1851
|
try {
|
|
1402
1852
|
if (this.rowTextArea) {
|
|
1403
|
-
this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
|
|
1404
|
-
this.logger.log(
|
|
1853
|
+
this.heightMessageTextArea = this.rowTextArea['el'].offsetHeight
|
|
1854
|
+
this.logger.log(
|
|
1855
|
+
'[CONVS-DETAIL] setHeightTextArea - heightMessageTextArea: ',
|
|
1856
|
+
this.heightMessageTextArea,
|
|
1857
|
+
)
|
|
1405
1858
|
}
|
|
1406
1859
|
} catch (e) {
|
|
1407
1860
|
this.logger.error('[CONVS-DETAIL] setHeightTextArea - ERROR ', e)
|
|
1408
1861
|
// this.heightMessageTextArea = '50';
|
|
1409
|
-
this.heightMessageTextArea = '57'
|
|
1862
|
+
this.heightMessageTextArea = '57' // NK edited
|
|
1410
1863
|
}
|
|
1411
1864
|
}
|
|
1412
1865
|
checkAcceptedFile(draggedFileMimeType) {
|
|
1413
|
-
let isAcceptFile = false
|
|
1414
|
-
this.logger.log(
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1866
|
+
let isAcceptFile = false
|
|
1867
|
+
this.logger.log(
|
|
1868
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept: ',
|
|
1869
|
+
this.appConfigProvider.getConfig().fileUploadAccept,
|
|
1870
|
+
)
|
|
1871
|
+
const accept_files = this.appConfigProvider.getConfig().fileUploadAccept
|
|
1872
|
+
this.logger.log(
|
|
1873
|
+
'[CONVS-DETAIL] > checkAcceptedFile - mimeType: ',
|
|
1874
|
+
draggedFileMimeType,
|
|
1875
|
+
)
|
|
1876
|
+
if (accept_files === '*/*') {
|
|
1877
|
+
isAcceptFile = true
|
|
1419
1878
|
return isAcceptFile
|
|
1420
|
-
} else if (accept_files !==
|
|
1421
|
-
this.logger.log(
|
|
1879
|
+
} else if (accept_files !== '*/*') {
|
|
1880
|
+
this.logger.log(
|
|
1881
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept typeof accept_files ',
|
|
1882
|
+
typeof accept_files,
|
|
1883
|
+
)
|
|
1422
1884
|
const accept_files_array = accept_files.split(',')
|
|
1423
|
-
this.logger.log(
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1885
|
+
this.logger.log(
|
|
1886
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array ',
|
|
1887
|
+
accept_files_array,
|
|
1888
|
+
)
|
|
1889
|
+
this.logger.log(
|
|
1890
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_files_array typeof: ',
|
|
1891
|
+
typeof accept_files_array,
|
|
1892
|
+
)
|
|
1893
|
+
|
|
1894
|
+
accept_files_array.forEach((accept_file) => {
|
|
1895
|
+
this.logger.log(
|
|
1896
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file ',
|
|
1897
|
+
accept_file,
|
|
1898
|
+
)
|
|
1429
1899
|
const accept_file_segment = accept_file.split('/')
|
|
1430
|
-
this.logger.log(
|
|
1900
|
+
this.logger.log(
|
|
1901
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept accept_file_segment ',
|
|
1902
|
+
accept_file_segment,
|
|
1903
|
+
)
|
|
1431
1904
|
if (accept_file_segment[1] === '*') {
|
|
1432
1905
|
if (draggedFileMimeType.startsWith(accept_file_segment[0])) {
|
|
1433
|
-
isAcceptFile = true
|
|
1434
|
-
this.logger.log(
|
|
1906
|
+
isAcceptFile = true
|
|
1907
|
+
this.logger.log(
|
|
1908
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1909
|
+
isAcceptFile,
|
|
1910
|
+
)
|
|
1435
1911
|
return isAcceptFile
|
|
1436
|
-
|
|
1437
1912
|
} else {
|
|
1438
|
-
isAcceptFile = false
|
|
1439
|
-
this.logger.log(
|
|
1913
|
+
isAcceptFile = false
|
|
1914
|
+
this.logger.log(
|
|
1915
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1916
|
+
isAcceptFile,
|
|
1917
|
+
)
|
|
1440
1918
|
return isAcceptFile
|
|
1441
|
-
|
|
1442
1919
|
}
|
|
1443
1920
|
} else if (accept_file_segment[1] !== '*') {
|
|
1444
1921
|
if (draggedFileMimeType === accept_file) {
|
|
1445
|
-
isAcceptFile = true
|
|
1446
|
-
this.logger.log(
|
|
1922
|
+
isAcceptFile = true
|
|
1923
|
+
this.logger.log(
|
|
1924
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile',
|
|
1925
|
+
isAcceptFile,
|
|
1926
|
+
)
|
|
1447
1927
|
return isAcceptFile
|
|
1448
1928
|
}
|
|
1449
1929
|
}
|
|
1450
1930
|
return isAcceptFile
|
|
1451
|
-
})
|
|
1931
|
+
})
|
|
1452
1932
|
return isAcceptFile
|
|
1453
1933
|
}
|
|
1454
1934
|
}
|
|
1455
1935
|
// -------------------------------------------------------------
|
|
1456
|
-
// DRAG FILE
|
|
1936
|
+
// DRAG FILE
|
|
1457
1937
|
// -------------------------------------------------------------
|
|
1458
1938
|
// DROP (WHEN THE FILE IS RELEASED ON THE DROP ZONE)
|
|
1459
1939
|
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
|
-
|
|
1940
|
+
ev.preventDefault()
|
|
1941
|
+
ev.stopPropagation()
|
|
1942
|
+
|
|
1943
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP ev ', ev)
|
|
1944
|
+
const fileList = ev.dataTransfer.files
|
|
1945
|
+
this.logger.log(
|
|
1946
|
+
'[CONVS-DETAIL] ----> FILE - DROP ev.dataTransfer.files ',
|
|
1947
|
+
fileList,
|
|
1948
|
+
)
|
|
1949
|
+
this.isHovering = false
|
|
1950
|
+
this.logger.log(
|
|
1951
|
+
'[CONVS-DETAIL] ----> FILE - DROP isHovering ',
|
|
1952
|
+
this.isHovering,
|
|
1953
|
+
)
|
|
1468
1954
|
if (fileList.length > 0) {
|
|
1469
|
-
const file: File = fileList[0]
|
|
1470
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file)
|
|
1955
|
+
const file: File = fileList[0]
|
|
1956
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - DROP file ', file)
|
|
1471
1957
|
|
|
1472
|
-
var mimeType = fileList[0].type
|
|
1473
|
-
this.logger.log(
|
|
1958
|
+
var mimeType = fileList[0].type
|
|
1959
|
+
this.logger.log(
|
|
1960
|
+
'[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
|
|
1961
|
+
mimeType,
|
|
1962
|
+
)
|
|
1474
1963
|
|
|
1475
1964
|
// if (mimeType.startsWith("image") || mimeType.startsWith("application")) {
|
|
1476
1965
|
// this.logger.log('[CONVS-DETAIL] ----> FILE - DROP mimeType files: ', this.appConfigProvider.getConfig().fileUploadAccept);
|
|
1477
1966
|
// this.checkAcceptedFile(mimeType);
|
|
1478
|
-
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
1479
|
-
this.logger.log(
|
|
1967
|
+
const isAccepted = this.checkAcceptedFile(mimeType)
|
|
1968
|
+
this.logger.log(
|
|
1969
|
+
'[CONVS-DETAIL] > checkAcceptedFile - fileUploadAccept isAcceptFile FILE - DROP',
|
|
1970
|
+
isAccepted,
|
|
1971
|
+
)
|
|
1480
1972
|
if (isAccepted === true) {
|
|
1481
|
-
this.handleDropEvent(ev)
|
|
1482
|
-
|
|
1973
|
+
this.handleDropEvent(ev)
|
|
1483
1974
|
} else {
|
|
1484
|
-
this.logger.log(
|
|
1975
|
+
this.logger.log(
|
|
1976
|
+
'[CONVS-DETAIL] ----> FILE - DROP mimeType files ',
|
|
1977
|
+
mimeType,
|
|
1978
|
+
'NOT SUPPORTED FILE TYPE',
|
|
1979
|
+
)
|
|
1485
1980
|
this.presentToastOnlyImageFilesAreAllowedToDrag()
|
|
1486
1981
|
}
|
|
1487
1982
|
}
|
|
1488
1983
|
}
|
|
1489
1984
|
|
|
1490
1985
|
handleDropEvent(ev) {
|
|
1491
|
-
this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
|
|
1986
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - HANDLE DROP EVENT ', ev)
|
|
1492
1987
|
this.dropEvent = ev
|
|
1493
1988
|
}
|
|
1494
1989
|
|
|
1495
1990
|
// DRAG OVER (WHEN HOVER OVER ON THE "DROP ZONE")
|
|
1496
1991
|
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(
|
|
1992
|
+
ev.preventDefault()
|
|
1993
|
+
ev.stopPropagation()
|
|
1994
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragover) allowDrop ev ', ev)
|
|
1995
|
+
this.isHovering = true
|
|
1996
|
+
this.logger.log(
|
|
1997
|
+
'[CONVS-DETAIL] ----> FILE - (dragover) allowDrop isHovering ',
|
|
1998
|
+
this.isHovering,
|
|
1999
|
+
)
|
|
1502
2000
|
}
|
|
1503
2001
|
|
|
1504
2002
|
// DRAG LEAVE (WHEN LEAVE FROM THE DROP ZONE)
|
|
1505
2003
|
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(
|
|
2004
|
+
ev.preventDefault()
|
|
2005
|
+
ev.stopPropagation()
|
|
2006
|
+
this.logger.log('[CONVS-DETAIL] ----> FILE - (dragleave) drag ev ', ev)
|
|
2007
|
+
this.isHovering = false
|
|
2008
|
+
this.logger.log(
|
|
2009
|
+
'[CONVS-DETAIL] ----> FILE - FILE - (dragleave) drag his.isHovering ',
|
|
2010
|
+
this.isHovering,
|
|
2011
|
+
)
|
|
1511
2012
|
}
|
|
1512
2013
|
|
|
1513
2014
|
async presentToastOnlyImageFilesAreAllowedToDrag() {
|
|
1514
2015
|
const toast = await this.toastController.create({
|
|
1515
|
-
message: this.translationMap.get(
|
|
2016
|
+
message: this.translationMap.get(
|
|
2017
|
+
'FAILED_TO_UPLOAD_THE_FORMAT_IS_NOT_SUPPORTED',
|
|
2018
|
+
),
|
|
1516
2019
|
duration: 5000,
|
|
1517
|
-
color:
|
|
2020
|
+
color: 'danger',
|
|
1518
2021
|
cssClass: 'toast-custom-class',
|
|
1519
|
-
})
|
|
1520
|
-
toast.present()
|
|
2022
|
+
})
|
|
2023
|
+
toast.present()
|
|
1521
2024
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
2025
|
}
|
|
1525
|
-
// END ALL //
|
|
2026
|
+
// END ALL //
|