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