@chat21/chat21-web-widget 5.0.56-rc.2 → 5.0.56-rc.4
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 +10 -0
- package/package.json +1 -1
- package/src/app/app.component.html +1 -1
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +2 -2
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +17 -13
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +1 -1
- package/src/app/component/last-message/last-message.component.html +64 -88
- package/src/app/component/last-message/last-message.component.scss +49 -93
- package/src/app/component/last-message/last-message.component.ts +64 -6
- package/src/app/component/message/text/text.component.scss +8 -2
- package/src/app/utils/globals.ts +10 -0
- package/src/assets/twp/chatbot-panel.html +4 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +1 -1
- package/src/chat21-core/utils/utils-message.ts +57 -21
- package/src/iframe-style.css +2 -2
- package/src/launch.js +14 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# chat21-web-widget ver 5.0
|
|
2
2
|
|
|
3
|
+
### 5.0.56-rc.4
|
|
4
|
+
- added: function to manage messagePreview height programatically
|
|
5
|
+
- added: implementation of commands messages inside callout component
|
|
6
|
+
- added: isFirstMessage, isSameSender, isLastMessage, isFirstMessage function to utils-message
|
|
7
|
+
- removed: margin-block of inner p html tag in chat-text base message component
|
|
8
|
+
- bug-fixed: cannot read trim() of undefined with image text message
|
|
9
|
+
|
|
10
|
+
### 5.0.56-rc.3
|
|
11
|
+
- added: widget loading in chatbot-panel.html page
|
|
12
|
+
|
|
3
13
|
### 5.0.56-rc.2
|
|
4
14
|
- added: firebase laxy loading
|
|
5
15
|
- added: dynamic base herf to load chunk files
|
package/package.json
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
******* EYE-CATCHER (aka CALLOUT) *********
|
|
105
105
|
*******************************************
|
|
106
106
|
tabindex -> 20 -->
|
|
107
|
-
<chat-eyeeye-catcher-card *ngIf="g.senderId"
|
|
107
|
+
<chat-eyeeye-catcher-card *ngIf="g.senderId && !g.isOpenNewMessage"
|
|
108
108
|
(onOpenChat)="onOpenCloseWidget($event)"
|
|
109
109
|
(onCloseEyeCatcherCard)="onCloseEyeCatcherCard($event)">
|
|
110
110
|
</chat-eyeeye-catcher-card>
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<!--backgroundColor non viene ancora usato -->
|
|
29
29
|
<!-- class="messages msg_sent slide-in-right" -->
|
|
30
30
|
<chat-bubble-message class="messages msg_sent"
|
|
31
|
-
[class.no-background]="(isImage(message) || isFrame(message)) && message?.text && message?.
|
|
31
|
+
[class.no-background]="(isImage(message) || isFrame(message)) && message?.text && message?.text.trim() === '' "
|
|
32
32
|
[class.emoticon]="isEmojii(message?.text)"
|
|
33
33
|
[ngStyle]="{'background': stylesMap.get('bubbleSentBackground'), 'color': stylesMap.get('bubbleSentTextColor')}"
|
|
34
34
|
[ngClass]="{'button-in-msg' : message?.metadata && message?.metadata?.button}"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
<!-- [ngClass]="{'slide-in-left': !isFirstMessage(message?.sender, i)}" -->
|
|
64
64
|
<chat-bubble-message class="messages msg_receive"
|
|
65
65
|
[ngClass]="{'slide-in-left': false}"
|
|
66
|
-
[class.no-background]="(isImage(message) || isFrame(message)) && message?.text && message?.text.trim() === '' "
|
|
66
|
+
[class.no-background]="(isImage(message) || isFrame(message)) && message?.text && message?.text && message?.text.trim() === '' "
|
|
67
67
|
[class.emoticon]="isEmojii(message?.text)"
|
|
68
68
|
[style.margin-left]="isSameSender(message?.sender, i)? '50px': null"
|
|
69
69
|
[ngStyle]="{'background': stylesMap.get('bubbleReceivedBackground'), 'color': stylesMap.get('bubbleReceivedTextColor')}"
|
package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { UploadService } from 'src/chat21-core/providers/abstract/upload.service
|
|
|
6
6
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
7
7
|
import { MESSAGE_TYPE_INFO, MESSAGE_TYPE_MINE, MESSAGE_TYPE_OTHERS } from 'src/chat21-core/utils/constants';
|
|
8
8
|
import { isPopupUrl, popupUrl } from 'src/chat21-core/utils/utils';
|
|
9
|
-
import { isEmojii, isFrame, isImage, isInfo, isMine, messageType } from 'src/chat21-core/utils/utils-message';
|
|
9
|
+
import { isEmojii, isFirstMessage, isFrame, isImage, isInfo, isLastMessage, isMine, isSameSender, messageType } from 'src/chat21-core/utils/utils-message';
|
|
10
10
|
|
|
11
11
|
@Component({
|
|
12
12
|
selector: 'chat-conversation-content',
|
|
@@ -198,27 +198,31 @@ export class ConversationContentComponent implements OnInit {
|
|
|
198
198
|
|
|
199
199
|
// ========= END:: functions scroll position ======= //
|
|
200
200
|
isLastMessage(idMessage: string):boolean {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
return isLastMessage(this.messages, idMessage)
|
|
202
|
+
// if (idMessage === this.messages[this.messages.length - 1].uid) {
|
|
203
|
+
// return true;
|
|
204
|
+
// }
|
|
205
|
+
// return false;
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
isSameSender(senderId, index):boolean{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
return isSameSender(this.messages, senderId, index)
|
|
210
|
+
// if(senderId && this.messages[index - 1] && (senderId === this.messages[index - 1].sender)){
|
|
211
|
+
// return true;
|
|
212
|
+
// }
|
|
213
|
+
// return false;
|
|
212
214
|
}
|
|
213
215
|
|
|
214
216
|
|
|
215
217
|
isFirstMessage(senderId, index):boolean{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
return isFirstMessage(this.messages, senderId, index)
|
|
219
|
+
// if(senderId && index == 0 && this.messages[index] && (this.messages[index] !== senderId)){
|
|
220
|
+
// return true;
|
|
221
|
+
// }
|
|
222
|
+
// return false;
|
|
220
223
|
}
|
|
221
224
|
|
|
225
|
+
|
|
222
226
|
hideOutsideElements(){
|
|
223
227
|
this.onMenuOptionShow.emit(false)
|
|
224
228
|
this.onEmojiiPickerShow.emit(false)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
<!-- ******* EYE-CATCHER CARD - DISPLAYED ONLY IS-MOBILE IS FALSE ******** -->
|
|
3
|
-
<div
|
|
3
|
+
<div class="eye-catcher-card scale-in-center"
|
|
4
4
|
[class.mobile]="g.isMobile"
|
|
5
5
|
[ngClass]="{'c21-align-left' : g.align === 'left', 'c21-align-right' : g.align !== 'left'}"
|
|
6
6
|
[ngStyle]="{ 'display':g.displayEyeCatcherCard, 'bottom': g.marginY+'px', 'left':(g.align==='left')?g.marginX+'px':'', 'right':(g.align==='right')?g.marginX+'px':'' }">
|
|
@@ -1,94 +1,70 @@
|
|
|
1
|
-
<div *ngIf="
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<
|
|
1
|
+
<div id="messagePreview" *ngIf="g.isOpenNewMessage">
|
|
2
|
+
<div *ngFor="let message of messages; let i = index; first as isFirst; let last=last" class="message-wrp" #message_wrp>
|
|
3
|
+
<!-- message recipient:: -->
|
|
4
|
+
|
|
5
|
+
<div class="headerPreviewMessage" *ngIf="isFirst">
|
|
6
|
+
|
|
7
|
+
<div class="boxButtons">
|
|
8
|
+
|
|
9
|
+
<!-- <div role="button" tabindex="0" class="buttonMore" (click)="openConversationByID(conversation)">
|
|
10
|
+
<span>View more</span>
|
|
11
|
+
</div> -->
|
|
12
|
+
|
|
13
|
+
<div aria-label="Dismiss" role="button" tabindex="0" class="buttonClose" (click)="closeMessagePreview()">
|
|
14
|
+
<span>
|
|
15
|
+
<svg aria-labelledby="altIconTitle" height="20px" role="img" viewBox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg" style="fill: rgb(255, 255, 255);">
|
|
16
|
+
<path d="M0 0h24v24H0V0z" fill="none"></path>
|
|
17
|
+
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path>
|
|
18
|
+
</svg>
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
10
22
|
</div>
|
|
11
|
-
|
|
12
|
-
<div aria-label="Dismiss" role="button" tabindex="0" class="buttonClose" (click)="closeMessagePreview()">
|
|
13
|
-
<span>
|
|
14
|
-
<svg aria-labelledby="altIconTitle" height="20px" role="img" viewBox="0 0 24 24" width="20px" xmlns="http://www.w3.org/2000/svg" style="fill: rgb(255, 255, 255);">
|
|
15
|
-
<path d="M0 0h24v24H0V0z" fill="none"></path>
|
|
16
|
-
<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path>
|
|
17
|
-
</svg>
|
|
18
|
-
</span>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
23
|
+
|
|
21
24
|
</div>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<div
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<div class="container">
|
|
28
|
+
|
|
29
|
+
<div class="previewNewMessagge" (click)="openConversationByID(conversation)"
|
|
30
|
+
[class.left-indicator]="isFirst && (!isImage(message) || isFrame(message))"
|
|
31
|
+
[class.no-background]="(isImage(message) || isFrame(message)) && message?.text?.trim() === ''">
|
|
32
|
+
|
|
33
|
+
<chat-bubble-message class="messages no-background"
|
|
34
|
+
[class.emoticon]="isEmojii(message?.text)"
|
|
35
|
+
[ngClass]="{'button-in-msg' : message?.metadata && message?.metadata?.button}"
|
|
36
|
+
[message]="message"
|
|
37
|
+
[isSameSender]="isSameSender(message?.sender, i)"
|
|
38
|
+
[fontColor]="stylesMap.get('bubbleReceivedTextColor')"
|
|
39
|
+
[fontSize]="stylesMap.get('fontSize')"
|
|
40
|
+
[fontFamily]="stylesMap.get('fontFamily')"
|
|
41
|
+
[stylesMap]="stylesMap">
|
|
42
|
+
</chat-bubble-message>
|
|
43
|
+
|
|
44
|
+
<div class="c21-icon-avatar" *ngIf="isFirst">
|
|
45
|
+
<div class="c21-avatar-image profile_image">
|
|
46
|
+
<chat-avatar-image class="slide-in-left"
|
|
47
|
+
[senderID]="message?.sender"
|
|
48
|
+
[senderFullname]="message?.sender_fullname"
|
|
49
|
+
[baseLocation]="baseLocation">
|
|
50
|
+
</chat-avatar-image>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
41
54
|
</div>
|
|
42
|
-
|
|
43
|
-
<div *ngIf="
|
|
44
|
-
<chat-
|
|
45
|
-
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
[class.emoticon]="isEmojii(message?.text)"
|
|
53
|
-
[ngClass]="{'button-in-msg' : message?.metadata && message?.metadata?.button}"
|
|
54
|
-
[message]="message"
|
|
55
|
-
[fontColor]="stylesMap.get('bubbleReceivedTextColor')"
|
|
56
|
-
[fontSize]="stylesMap.get('fontSize')"
|
|
57
|
-
[fontFamily]="stylesMap.get('fontFamily')"
|
|
58
|
-
[stylesMap]="stylesMap">
|
|
59
|
-
</chat-bubble-message>
|
|
60
|
-
|
|
61
|
-
<div class="c21-icon-avatar">
|
|
62
|
-
<div class="c21-avatar-image profile_image">
|
|
63
|
-
<chat-avatar-image class="slide-in-left"
|
|
64
|
-
[senderID]="message?.sender"
|
|
65
|
-
[senderFullname]="message?.sender_fullname"
|
|
66
|
-
[baseLocation]="baseLocation">
|
|
67
|
-
</chat-avatar-image>
|
|
68
|
-
</div>
|
|
55
|
+
|
|
56
|
+
<div *ngIf="message?.attributes && message?.attributes?.attachment && last" class="conversations-buttons">
|
|
57
|
+
<chat-message-attachment
|
|
58
|
+
style="height: 100%; display: block;"
|
|
59
|
+
[message]="message"
|
|
60
|
+
[isLastMessage] = "true"
|
|
61
|
+
[limit]="3"
|
|
62
|
+
[stylesMap]="stylesMap"
|
|
63
|
+
(onAttachmentButtonClicked)="onAttachmentButtonClicked($event)">
|
|
64
|
+
</chat-message-attachment>
|
|
69
65
|
</div>
|
|
70
|
-
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<div *ngIf="message.attributes && message.attributes.attachment " class="conversations-buttons">
|
|
74
|
-
<chat-message-attachment
|
|
75
|
-
style="height: 100%; display: block;"
|
|
76
|
-
[message]="message"
|
|
77
|
-
[isLastMessage] = "true"
|
|
78
|
-
[limit]="3"
|
|
79
|
-
[stylesMap]="stylesMap"
|
|
80
|
-
(onAttachmentButtonClicked)="onAttachmentButtonClicked($event)">
|
|
81
|
-
</chat-message-attachment>
|
|
66
|
+
|
|
82
67
|
</div>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<!-- <div class="c21-time c21-text">
|
|
88
|
-
<time *ngIf="conversation.timestamp !== '{.sv: timestamp}'" >{{conversation.timestamp | amTimeAgo}} </time>
|
|
89
|
-
</div> -->
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
</div>
|
|
93
|
-
|
|
68
|
+
|
|
69
|
+
</div>
|
|
94
70
|
</div>
|
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
min-height: 32px;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
:host .previewNewMessagge ::ng-deep > chat-bubble-message > #bubble-message > div > div > chat-text {
|
|
13
|
+
p {
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
text-overflow: ellipsis;
|
|
16
|
+
display: -webkit-box;
|
|
17
|
+
-webkit-line-clamp: 4;
|
|
18
|
+
-webkit-box-orient: vertical;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
12
21
|
|
|
13
22
|
:host .slide-in-left ::ng-deep > chat-message-attachment > #buttons-in-message > span > chat-text-button-attachment{
|
|
14
23
|
|
|
@@ -19,36 +28,15 @@
|
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
#messagePreview {
|
|
22
|
-
// position: relative;
|
|
23
|
-
// width: 320px;
|
|
24
|
-
// /* bottom: 90; */
|
|
25
|
-
// max-height: 200px;
|
|
26
|
-
// height: 200px; //100%;
|
|
27
|
-
// padding: 0px 10px 10px;
|
|
28
|
-
// background-color: transparent;
|
|
29
|
-
|
|
30
|
-
// font-family: "Helvetica Neue", "Apple Color Emoji", Helvetica, Arial, sans-serif;
|
|
31
|
-
// font-size: 100%;
|
|
32
|
-
// font-style: normal;
|
|
33
|
-
// letter-spacing: normal;
|
|
34
|
-
// font-stretch: normal;
|
|
35
|
-
// font-weight: normal;
|
|
36
|
-
// text-align: left;
|
|
37
|
-
// text-align-last: initial;
|
|
38
|
-
// text-indent: 0px;
|
|
39
|
-
// text-shadow: none;
|
|
40
|
-
// text-transform: none;
|
|
41
|
-
// box-sizing: content-box;
|
|
42
|
-
// -webkit-font-smoothing: antialiased;
|
|
43
|
-
// line-height: 1;
|
|
44
|
-
// font-variant: normal;
|
|
45
|
-
|
|
46
31
|
position: fixed;
|
|
47
32
|
// right: 5px;
|
|
48
33
|
bottom: 90px;
|
|
49
34
|
// max-height: calc(100% - 75px);
|
|
50
35
|
width: 375px;
|
|
51
36
|
max-width: 100%;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: 5px;
|
|
52
40
|
}
|
|
53
41
|
|
|
54
42
|
#messagePreview:hover {
|
|
@@ -59,13 +47,20 @@
|
|
|
59
47
|
}
|
|
60
48
|
}
|
|
61
49
|
|
|
50
|
+
.message-wrp{
|
|
51
|
+
animation: fade-in-dw-up 0.3s ease-in 0.0s;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.container{
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
}
|
|
62
58
|
|
|
63
59
|
.messages {
|
|
64
|
-
border-radius: var(--border-radius-bubble-message);
|
|
65
60
|
padding: 0;
|
|
66
61
|
word-wrap: break-word;
|
|
67
62
|
|
|
68
|
-
max-height: 160px;
|
|
63
|
+
// max-height: 160px;
|
|
69
64
|
display: flex;
|
|
70
65
|
overflow-y: auto;
|
|
71
66
|
// padding: 14px;
|
|
@@ -109,70 +104,37 @@
|
|
|
109
104
|
position: relative;
|
|
110
105
|
box-sizing: border-box;
|
|
111
106
|
background-color: rgb(255, 255, 255);
|
|
112
|
-
box-shadow: rgba(
|
|
107
|
+
box-shadow: rgba(35, 47, 53, 0.09) 0px 2px 8px 0px;
|
|
113
108
|
clear: both;
|
|
114
109
|
margin-left: 45px;
|
|
115
110
|
margin-right: 16px;
|
|
116
|
-
|
|
117
|
-
border-radius: 12px 12px 12px 0px;
|
|
111
|
+
border-radius: 12px 12px 12px 12px;
|
|
118
112
|
padding: 5px;
|
|
119
113
|
}
|
|
120
114
|
|
|
121
|
-
.previewNewMessagge
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
bottom: 0px;
|
|
125
|
-
left: -5px;
|
|
126
|
-
width: 0px;
|
|
127
|
-
height: 0px;
|
|
128
|
-
border-style: solid;
|
|
129
|
-
border-width: 0px 0px 13px 5px;
|
|
130
|
-
border-color: transparent transparent white;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.c21-text.message_sender_fullname {
|
|
134
|
-
font-size: 13px;
|
|
135
|
-
padding: 0px 10px;
|
|
136
|
-
margin: 4px 0px;
|
|
137
|
-
clear: both;
|
|
138
|
-
color: rgb(104, 104, 104);
|
|
115
|
+
.previewNewMessagge.no-background{
|
|
116
|
+
background-color: transparent;
|
|
117
|
+
box-shadow: unset;
|
|
139
118
|
}
|
|
140
119
|
|
|
141
|
-
.
|
|
142
|
-
max-height: 110px;
|
|
143
|
-
height: 100%;
|
|
144
|
-
width: 100%;
|
|
145
|
-
overflow-y: auto;
|
|
146
|
-
overflow-x: hidden;
|
|
147
|
-
border-radius: 12px 12px 12px 0px;
|
|
148
|
-
|
|
149
|
-
&::-webkit-scrollbar {
|
|
150
|
-
width: 6px;
|
|
151
|
-
background-color: #00000000!important;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
}
|
|
120
|
+
.left-indicator{
|
|
155
121
|
|
|
156
|
-
|
|
157
|
-
&::-webkit-scrollbar-track {
|
|
158
|
-
background-color: #f9f9f9 !important;
|
|
159
|
-
}
|
|
122
|
+
border-radius: 12px 12px 12px 0px;
|
|
160
123
|
|
|
161
|
-
|
|
162
|
-
|
|
124
|
+
&::after {
|
|
125
|
+
content: "";
|
|
126
|
+
position: absolute;
|
|
127
|
+
bottom: 0px;
|
|
128
|
+
left: -5px;
|
|
129
|
+
width: 0px;
|
|
130
|
+
height: 0px;
|
|
131
|
+
border-style: solid;
|
|
132
|
+
border-width: 0px 0px 13px 5px;
|
|
133
|
+
border-color: transparent transparent white;
|
|
134
|
+
|
|
163
135
|
}
|
|
164
136
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.c21-text {
|
|
168
|
-
font-size: 14px;
|
|
169
|
-
color: black;
|
|
170
|
-
padding: 0px 10px;
|
|
171
|
-
margin: 0px 0px;// margin: 4 0;
|
|
172
|
-
line-height: 1.4;
|
|
173
|
-
word-break: break-word;
|
|
174
|
-
}
|
|
175
|
-
|
|
137
|
+
|
|
176
138
|
.overflow4Lines {
|
|
177
139
|
overflow: hidden;
|
|
178
140
|
text-overflow: ellipsis;
|
|
@@ -181,19 +143,6 @@
|
|
|
181
143
|
-webkit-box-orient: vertical;
|
|
182
144
|
}
|
|
183
145
|
|
|
184
|
-
.c21-img{
|
|
185
|
-
margin-left: 5px;
|
|
186
|
-
width: 120px;
|
|
187
|
-
// height: 100px;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.c21-text.c21-time {
|
|
191
|
-
font-size: 13px;
|
|
192
|
-
padding: 0px 10px;
|
|
193
|
-
clear: both;
|
|
194
|
-
color: rgb(115, 115, 118);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
146
|
.c21-link {
|
|
198
147
|
text-decoration: underline;
|
|
199
148
|
padding: 8px;
|
|
@@ -224,11 +173,17 @@
|
|
|
224
173
|
height: 100%;
|
|
225
174
|
}
|
|
226
175
|
|
|
176
|
+
|
|
177
|
+
//__________START: HEADER ____________
|
|
227
178
|
.headerPreviewMessage {
|
|
228
179
|
margin-right: 16px;
|
|
229
180
|
position: relative;
|
|
230
|
-
height: 40;// height: 50;
|
|
231
|
-
margin: 10px 0px 0px 50px;
|
|
181
|
+
// height: 40;// height: 50;
|
|
182
|
+
// margin: 10px 0px 0px 50px;
|
|
183
|
+
bottom: -20px;
|
|
184
|
+
right: -15px;
|
|
185
|
+
top: -15px;
|
|
186
|
+
z-index: 1;
|
|
232
187
|
}
|
|
233
188
|
|
|
234
189
|
.boxButtons {
|
|
@@ -275,6 +230,7 @@
|
|
|
275
230
|
.buttonClose span svg {
|
|
276
231
|
padding: 6px;
|
|
277
232
|
}
|
|
233
|
+
//__________END: HEADER ____________
|
|
278
234
|
|
|
279
235
|
#new_message {
|
|
280
236
|
position: absolute;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { style } from '@angular/animations';
|
|
2
|
+
import { AfterViewInit, Component, EventEmitter, Input, OnDestroy, OnInit, Output, SimpleChanges, ElementRef, QueryList, ViewChildren } from '@angular/core';
|
|
2
3
|
import { Subscription } from 'rxjs';
|
|
3
4
|
import { MessageModel } from './../../../chat21-core/models/message';
|
|
4
5
|
import { EventsService } from './../../providers/events.service';
|
|
@@ -11,7 +12,7 @@ import { MIN_WIDTH_IMAGES } from 'src/app/utils/constants';
|
|
|
11
12
|
import { ConversationModel } from 'src/chat21-core/models/conversation';
|
|
12
13
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
13
14
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
14
|
-
import { conversationToMessage, isEmojii } from 'src/chat21-core/utils/utils-message';
|
|
15
|
+
import { commandToMessage, conversationToMessage, isEmojii, isFrame, isImage, isSameSender } from 'src/chat21-core/utils/utils-message';
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
@Component({
|
|
@@ -21,6 +22,8 @@ import { conversationToMessage, isEmojii } from 'src/chat21-core/utils/utils-mes
|
|
|
21
22
|
})
|
|
22
23
|
export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
23
24
|
|
|
25
|
+
@ViewChildren("message_wrp") messageListWRP: QueryList<ElementRef>;
|
|
26
|
+
|
|
24
27
|
@Input() conversation: ConversationModel
|
|
25
28
|
@Input() baseLocation: string;
|
|
26
29
|
@Input() stylesMap: Map<string, string>;
|
|
@@ -31,14 +34,17 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
31
34
|
// ========= end:: sottoscrizioni ======= //
|
|
32
35
|
|
|
33
36
|
isEmojii = isEmojii;
|
|
34
|
-
|
|
37
|
+
isImage = isImage;
|
|
38
|
+
isFrame = isFrame;
|
|
39
|
+
|
|
35
40
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
36
41
|
public fileSelected: any;
|
|
37
|
-
public
|
|
42
|
+
public messages: MessageModel[] = [];
|
|
38
43
|
|
|
39
44
|
constructor(
|
|
40
45
|
private events: EventsService,
|
|
41
46
|
public g: Globals,
|
|
47
|
+
private el: ElementRef
|
|
42
48
|
// public conversationsService: ConversationsService
|
|
43
49
|
) { }
|
|
44
50
|
|
|
@@ -53,8 +59,14 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
53
59
|
ngOnChanges(changes: SimpleChanges) {
|
|
54
60
|
this.logger.debug('[LASTMESSAGE] onChanges', changes)
|
|
55
61
|
if(this.conversation){
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
|
|
63
|
+
if(this.conversation.attributes && this.conversation.attributes.commands){
|
|
64
|
+
this.addCommandMessage(this.conversation)
|
|
65
|
+
}else{
|
|
66
|
+
this.messages.push(conversationToMessage(this.conversation, this.g.senderId))
|
|
67
|
+
this.manageIframeHeight();
|
|
68
|
+
}
|
|
69
|
+
console.log('messsageeeeeeeee', this.messages)
|
|
58
70
|
// if(isImage(this.conversation)){
|
|
59
71
|
// this.fileSelected = Object.assign({}, this.conversation.metadata)
|
|
60
72
|
// this.fileSelected = Object.assign(this.fileSelected, this.getMetadataSize(this.fileSelected))
|
|
@@ -103,6 +115,51 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
103
115
|
}
|
|
104
116
|
|
|
105
117
|
|
|
118
|
+
addCommandMessage(conversation: ConversationModel){
|
|
119
|
+
const that = this;
|
|
120
|
+
const commands = conversation.attributes.commands;
|
|
121
|
+
let i=0;
|
|
122
|
+
function execute(command){
|
|
123
|
+
if(command.type === "message"){
|
|
124
|
+
that.messages.push(commandToMessage(command.message,that.conversation, that.g.senderId))
|
|
125
|
+
that.manageIframeHeight()
|
|
126
|
+
i += 1
|
|
127
|
+
if (i < commands.length) {
|
|
128
|
+
execute(commands[i])
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (wait), exit')
|
|
132
|
+
}
|
|
133
|
+
}else if(command.type === "wait"){
|
|
134
|
+
setTimeout(function() {
|
|
135
|
+
i += 1
|
|
136
|
+
if (i < commands.length) {
|
|
137
|
+
execute(commands[i])
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> last command executed (send message), exit')
|
|
141
|
+
}
|
|
142
|
+
},command.time)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
execute(commands[0])
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private manageIframeHeight(){
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
if(this.messageListWRP.get(this.messages.length-1)){
|
|
152
|
+
let height = getComputedStyle(this.messageListWRP.get(this.messages.length-1).nativeElement).height
|
|
153
|
+
this.g.setWidgetPreviewContainerSize(0, +height.substring(0, height.length-2))
|
|
154
|
+
}
|
|
155
|
+
}, 50);
|
|
156
|
+
}
|
|
157
|
+
isSameSender(senderId: string, index: number){
|
|
158
|
+
return isSameSender(this.messages, senderId, index)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
106
163
|
|
|
107
164
|
// ========= begin:: event emitter function ============//
|
|
108
165
|
|
|
@@ -136,6 +193,7 @@ export class LastMessageComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
136
193
|
ngOnDestroy() {
|
|
137
194
|
this.conversation = null;
|
|
138
195
|
this.g.isOpenNewMessage = false;
|
|
196
|
+
this.messages = []
|
|
139
197
|
// this.logger.debug('4 isOpenNewMessage: ' + this.g.isOpenNewMessage);
|
|
140
198
|
//this.unsubscribe();
|
|
141
199
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// padding: 0px 14px;
|
|
6
6
|
&.marked{
|
|
7
7
|
padding:8px;
|
|
8
|
-
margin-block-start:
|
|
9
|
-
margin-block-end:
|
|
8
|
+
margin-block-start: 0em!important;
|
|
9
|
+
margin-block-end: 0em!important;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.text-message {
|
|
@@ -25,8 +25,14 @@ p {
|
|
|
25
25
|
font-variant: normal;
|
|
26
26
|
font-weight: 300;
|
|
27
27
|
overflow: hidden;
|
|
28
|
+
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
p ::ng-deep a {
|
|
31
32
|
word-break: break-word;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
p ::ng-deep p{
|
|
36
|
+
margin-block-end: 0em;
|
|
37
|
+
margin-block-start: 0em
|
|
32
38
|
}
|
package/src/app/utils/globals.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { style } from '@angular/animations';
|
|
1
2
|
import { Injectable } from '@angular/core';
|
|
2
3
|
import { BehaviorSubject } from 'rxjs';
|
|
3
4
|
import { environment } from '../../environments/environment';
|
|
@@ -586,6 +587,15 @@ export class Globals {
|
|
|
586
587
|
}
|
|
587
588
|
}
|
|
588
589
|
|
|
590
|
+
setWidgetPreviewContainerSize(width: number, height: number){
|
|
591
|
+
const divTiledeskWidget = this.windowContext.document.querySelector('.messagePreview');
|
|
592
|
+
|
|
593
|
+
let headerPadding = 10
|
|
594
|
+
let style = getComputedStyle(divTiledeskWidget)
|
|
595
|
+
let currentHeight = +style.height.substring(0, style.height.length -2)
|
|
596
|
+
divTiledeskWidget.style.height = currentHeight + height + headerPadding + 'px'
|
|
597
|
+
}
|
|
598
|
+
|
|
589
599
|
|
|
590
600
|
/**
|
|
591
601
|
*
|
|
@@ -285,6 +285,10 @@
|
|
|
285
285
|
fjs.parentNode.insertBefore(js, fjs);
|
|
286
286
|
}(document, 'script', 'tiledesk-jssdk'));
|
|
287
287
|
|
|
288
|
+
window.addEventListener('load', (event)=> {
|
|
289
|
+
document.dispatchEvent(new Event('mousemove'))
|
|
290
|
+
})
|
|
291
|
+
|
|
288
292
|
window.Tiledesk('onLoadParams', function(event_data) {
|
|
289
293
|
console.log("onLoadParams Tiledesk FN", event_data);
|
|
290
294
|
// window.Tiledesk('signInWithCustomToken', 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MDliOGVmYTg3MzJlYjAwMTQxNzYzZDlfNWU0ZWNiOThiNzhlZTQwMDE3NDA2MTEwIiwiZmlyc3RuYW1lIjoiS2VsbHkiLCJsYXN0bmFtZSI6IkdyYWNlIiwiZW1haWwiOiJncmFjZUBlbWFpbG5hLmNvIiwic3ViIjoidXNlcmV4dGVybmFsIiwiYXVkIjoiaHR0cHM6Ly90aWxlZGVzay5jb20vcHJvamVjdHMvNjA5YjhlZmE4NzMyZWIwMDE0MTc2M2Q5IiwiaWF0IjoxNjQxODAzODk0fQ.p0reTwd25p93CsDTyQa8tkihgFxThAI4DXloNc6vbXw')
|
|
@@ -299,7 +299,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
299
299
|
private messageGenerate(childSnapshot: any) {
|
|
300
300
|
const msg: MessageModel = childSnapshot.val();
|
|
301
301
|
msg.uid = childSnapshot.key;
|
|
302
|
-
msg.text = msg.text.trim() //remove black msg with only spaces
|
|
302
|
+
if(msg.text) msg.text = msg.text.trim(); //remove black msg with only spaces
|
|
303
303
|
// controllo fatto per i gruppi da rifattorizzare
|
|
304
304
|
if (!msg.sender_fullname || msg.sender_fullname === 'undefined') {
|
|
305
305
|
msg.sender_fullname = msg.sender;
|
|
@@ -297,7 +297,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
297
297
|
this.logger.log("[MQTTConversationHandlerSERVICE] childSnapshot >" + JSON.stringify(childSnapshot));
|
|
298
298
|
const msg = childSnapshot;
|
|
299
299
|
// msg.uid = childSnapshot.key;
|
|
300
|
-
msg.text = msg.text.trim() //remove black msg with only spaces
|
|
300
|
+
if(msg.text) msg.text = msg.text.trim(); //remove black msg with only spaces
|
|
301
301
|
// controllo fatto per i gruppi da rifattorizzare
|
|
302
302
|
if (!msg.sender_fullname || msg.sender_fullname === 'undefined') {
|
|
303
303
|
msg.sender_fullname = msg.sender;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { convertMessage } from 'src/app/utils/utils';
|
|
2
1
|
import { MessageModel } from './../models/message';
|
|
3
2
|
import { ConversationModel } from './../models/conversation';
|
|
4
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -11,28 +10,12 @@ import {
|
|
|
11
10
|
TYPE_SUPPORT_GROUP
|
|
12
11
|
} from '../../chat21-core/utils/constants';
|
|
13
12
|
|
|
14
|
-
/** */
|
|
15
|
-
export function isFirstMessage(i: number) {
|
|
16
|
-
if ( i > 0 ) {
|
|
17
|
-
try {
|
|
18
|
-
const message = this.messages[i];
|
|
19
|
-
const prevMessage = this.messages[ i - 1 ];
|
|
20
|
-
if (prevMessage.sender !== message.sender || message.headerDate || (prevMessage && this.isInfo(prevMessage))) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
} catch (err) {
|
|
25
|
-
console.log('error: ', err);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
13
|
/** */
|
|
31
14
|
export function isImage(message: any) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
15
|
+
if (message && message.type && message.metadata && message.metadata.src && message.type === 'image') {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
36
19
|
}
|
|
37
20
|
|
|
38
21
|
export function isFrame(message: any) {
|
|
@@ -85,6 +68,28 @@ export function isSender(sender: string, currentUserId: string) {
|
|
|
85
68
|
}
|
|
86
69
|
}
|
|
87
70
|
|
|
71
|
+
export function isSameSender(messages, senderId, index):boolean{
|
|
72
|
+
if(senderId && messages[index - 1] && (senderId === messages[index - 1].sender)){
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function isLastMessage(messages, idMessage):boolean {
|
|
79
|
+
if (idMessage === messages[messages.length - 1].uid) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function isFirstMessage(messages, senderId, index):boolean{
|
|
86
|
+
if(senderId && index == 0 && messages[index] && (messages[index] !== senderId)){
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
88
93
|
/** */
|
|
89
94
|
export function messageType(msgType: string, message: any) {
|
|
90
95
|
|
|
@@ -194,6 +199,18 @@ export function hideInfoMessage(msg, infoMessageKeyEnabled): boolean{
|
|
|
194
199
|
return true
|
|
195
200
|
}
|
|
196
201
|
|
|
202
|
+
export function getProjectIdSelectedConversation(conversationWith: string): string{
|
|
203
|
+
const conversationWith_segments = conversationWith.split('-')
|
|
204
|
+
// Removes the last element of the array if is = to the separator
|
|
205
|
+
if (conversationWith_segments[conversationWith_segments.length - 1] === '') {
|
|
206
|
+
conversationWith_segments.pop()
|
|
207
|
+
}
|
|
208
|
+
let projectId = ''
|
|
209
|
+
if (conversationWith_segments.length >= 4) {
|
|
210
|
+
projectId = conversationWith_segments[2]
|
|
211
|
+
}
|
|
212
|
+
return projectId
|
|
213
|
+
}
|
|
197
214
|
|
|
198
215
|
export function conversationToMessage(conversation: ConversationModel, currentUserId: string): MessageModel{
|
|
199
216
|
let message: any = {}
|
|
@@ -213,3 +230,22 @@ export function conversationToMessage(conversation: ConversationModel, currentUs
|
|
|
213
230
|
|
|
214
231
|
return message as MessageModel
|
|
215
232
|
}
|
|
233
|
+
|
|
234
|
+
export function commandToMessage(msg: MessageModel, conversation: ConversationModel, currentUserId: string): MessageModel{
|
|
235
|
+
let message: any = {}
|
|
236
|
+
message.uid = conversation['message_id']? conversation['message_id'] : uuidv4()
|
|
237
|
+
message.text = msg.text? msg.text.trim(): '';
|
|
238
|
+
message.sender = conversation.sender
|
|
239
|
+
message.sender_fullname = conversation.sender_fullname
|
|
240
|
+
message.recipient = conversation.recipient
|
|
241
|
+
message.recipient_fullname = conversation.recipient_fullname
|
|
242
|
+
message.status = +conversation.status
|
|
243
|
+
message.timestamp = conversation.timestamp
|
|
244
|
+
message.metadata = msg['metadata']
|
|
245
|
+
message.channel_type = conversation.channel_type
|
|
246
|
+
message.type = msg.type
|
|
247
|
+
message.isSender = isSender(message.sender, currentUserId)
|
|
248
|
+
message.attributes = { ...conversation.attributes, ...msg.attributes}
|
|
249
|
+
|
|
250
|
+
return message as MessageModel
|
|
251
|
+
}
|
package/src/iframe-style.css
CHANGED
package/src/launch.js
CHANGED
|
@@ -66,7 +66,7 @@ function loadIframe(tiledeskScriptBaseLocation) {
|
|
|
66
66
|
srcTileDesk += '<meta charset="utf-8">';
|
|
67
67
|
srcTileDesk += '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />';
|
|
68
68
|
srcTileDesk += '<title>Tilechat Widget</title>';
|
|
69
|
-
srcTileDesk += '<base href="'+tiledeskScriptBaseLocation+ '">';
|
|
69
|
+
srcTileDesk += '<base href="'+tiledeskScriptBaseLocation+ '/">';
|
|
70
70
|
srcTileDesk += '<link rel="icon" type="image/x-icon" href="favicon.ico">';
|
|
71
71
|
srcTileDesk += '<link rel="stylesheet" type="text/css" href="' + tiledeskScriptBaseLocation +'/assets/styles/tiledesk_v1.scss" media="all">';
|
|
72
72
|
srcTileDesk += '</head>';
|
|
@@ -152,7 +152,19 @@ function loadIframe(tiledeskScriptBaseLocation) {
|
|
|
152
152
|
var httpRequest = createCORSRequest('POST', event_data.detail.appConfigs.apiUrl+event_data.detail.default_settings.projectid+'/events',true); //set async to false because loadParams must return when the get is complete
|
|
153
153
|
httpRequest.setRequestHeader('Content-type', 'application/json');
|
|
154
154
|
httpRequest.setRequestHeader('Authorization',tiledeskToken);
|
|
155
|
-
httpRequest.send(JSON.stringify({"name":"new_conversation",
|
|
155
|
+
httpRequest.send(JSON.stringify({ "name":"new_conversation",
|
|
156
|
+
"attributes": {
|
|
157
|
+
"request_id":event_data.detail.newConvId,
|
|
158
|
+
"department": event_data.detail.global.departmentSelected.id,
|
|
159
|
+
"participants": event_data.detail.global.participants,
|
|
160
|
+
"language": event_data.detail.global.lang,
|
|
161
|
+
"subtype":"info",
|
|
162
|
+
"fullname":event_data.detail.global.attributes.userFullname,
|
|
163
|
+
"email":event_data.detail.global.attributes.userEmail,
|
|
164
|
+
"attributes":event_data.detail.global.attributes
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
));
|
|
156
168
|
}
|
|
157
169
|
});
|
|
158
170
|
|