@chat21/chat21-web-widget 5.0.71-rc.1 → 5.0.71-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/app/app.component.ts +29 -54
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +2 -3
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +2 -1
- package/src/app/component/message/carousel/carousel.component.scss +1 -0
- package/src/app/component/message/carousel/carousel.component.ts +3 -3
- package/src/app/providers/global-settings.service.ts +5 -0
- package/src/app/utils/globals.ts +4 -0
- package/src/assets/js/chat21client.js +1 -1
- package/src/assets/twp/chatbot-panel.html +7 -0
- package/src/chat21-core/utils/utils-message.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# chat21-web-widget ver 5.0
|
|
2
2
|
|
|
3
|
+
### 5.0.71-rc.2
|
|
4
|
+
- added: hiddenMessage tiledesk property to start a conversation with an hidden info message
|
|
5
|
+
- added: ability to listen from parent message and start a new Conversation with an hidden intentName info message
|
|
6
|
+
- changed: minor UI fix carousel component
|
|
7
|
+
|
|
3
8
|
### 5.0.71-rc.1
|
|
4
9
|
- added: ability to start conversation from an intent hiddenMessage name
|
|
5
10
|
- added: postMessage to notice parent the current message
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -690,42 +690,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
690
690
|
}
|
|
691
691
|
// ========= end:: START UI ============//
|
|
692
692
|
|
|
693
|
-
// private openNewConversation() {
|
|
694
|
-
// this.logger.debug('[APP-COMP] openNewConversation in APP COMPONENT');
|
|
695
|
-
// this.g.newConversationStart = true;
|
|
696
|
-
// // controllo i dipartimenti se sono 1 o 2 seleziono dipartimento e nascondo modale dipartimento
|
|
697
|
-
// // altrimenti mostro modale dipartimenti
|
|
698
|
-
// const preChatForm = this.g.preChatForm;
|
|
699
|
-
// const attributes = this.g.attributes;
|
|
700
|
-
// const departments = this.g.departments;
|
|
701
|
-
// // that.g.wdLog(['departments: ', departments, departments.length);
|
|
702
|
-
// if (preChatForm && (!attributes || !attributes.userFullname || !attributes.userEmail)) {
|
|
703
|
-
// // if (preChatForm && (!attributes.userFullname || !attributes.userEmail)) {
|
|
704
|
-
// this.isOpenConversation = false;
|
|
705
|
-
// this.g.setParameter('isOpenPrechatForm', true);
|
|
706
|
-
// // this.settingsSaverService.setVariable('isOpenPrechatForm', true);
|
|
707
|
-
// this.isOpenSelectionDepartment = false;
|
|
708
|
-
// if (departments && departments.length > 1 && this.g.departmentID == null) {
|
|
709
|
-
// this.isOpenSelectionDepartment = true;
|
|
710
|
-
// }
|
|
711
|
-
// } else {
|
|
712
|
-
// // this.g.isOpenPrechatForm = false;
|
|
713
|
-
// this.g.setParameter('isOpenPrechatForm', false);
|
|
714
|
-
// // this.settingsSaverService.setVariable('isOpenPrechatForm', false);
|
|
715
|
-
// this.isOpenConversation = false;
|
|
716
|
-
// this.isOpenSelectionDepartment = false;
|
|
717
|
-
// if (departments && departments.length > 1 && this.g.departmentID == null) {
|
|
718
|
-
// this.isOpenSelectionDepartment = true;
|
|
719
|
-
// } else {
|
|
720
|
-
// this.isOpenConversation = true;
|
|
721
|
-
// }
|
|
722
|
-
// }
|
|
723
|
-
|
|
724
|
-
// this.logger.debug('[APP-COMP] isOpenPrechatForm', this.g.isOpenPrechatForm, ' isOpenSelectionDepartment:', this.isOpenSelectionDepartment);
|
|
725
|
-
// if (this.g.isOpenPrechatForm === false && this.isOpenSelectionDepartment === false) {
|
|
726
|
-
// this.startNewConversation();
|
|
727
|
-
// }
|
|
728
|
-
// }
|
|
729
693
|
|
|
730
694
|
/**
|
|
731
695
|
* genero un nuovo conversationWith
|
|
@@ -749,21 +713,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
749
713
|
this.logger.debug('[APP-COMP] recipientId: ', this.g.recipientId);
|
|
750
714
|
this.isConversationArchived = false;
|
|
751
715
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
this.logger.debug('[APP-COMP] startNewConversation ', window.location.search.substring(1).split('&').find((param => param.includes('tiledesk_hiddenMessage'))))
|
|
756
|
-
let message: any = {}
|
|
757
|
-
message.attributes = { subtype: 'info', ...this.g.attributes}
|
|
758
|
-
message.userAgent = this.g.attributes['client']
|
|
759
|
-
message.request_id = newConvId
|
|
760
|
-
message.sourcePage = this.g.attributes['sourcePage']
|
|
761
|
-
message.language = this.g.lang
|
|
762
|
-
message.text = '/'+ hiddenMessage
|
|
763
|
-
message.participants = [ participant ]
|
|
764
|
-
message.departmentid = this.g.attributes.departmentId
|
|
765
|
-
// this.sendMessage(message)
|
|
766
|
-
this.tiledeskRequestsService.sendMessageToRequest(newConvId, this.g.tiledeskToken, message)
|
|
716
|
+
/** allow to start conversation with an hidden message (without publishing 'new_conversation' event) */
|
|
717
|
+
if(this.g.hiddenMessage){
|
|
718
|
+
this.onNewConversationWithMessage(this.g.hiddenMessage)
|
|
767
719
|
return;
|
|
768
720
|
}
|
|
769
721
|
|
|
@@ -1431,9 +1383,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
1431
1383
|
};
|
|
1432
1384
|
|
|
1433
1385
|
/** set state reinit */
|
|
1434
|
-
windowContext['tiledesk'].startConversation = function () {
|
|
1386
|
+
windowContext['tiledesk'].startConversation = function (text: string) {
|
|
1435
1387
|
ngZone.run(() => {
|
|
1436
|
-
windowContext['tiledesk']['angularcomponent'].component.onNewConversation();
|
|
1388
|
+
windowContext['tiledesk']['angularcomponent'].component.onNewConversation(text);
|
|
1437
1389
|
});
|
|
1438
1390
|
};
|
|
1439
1391
|
|
|
@@ -1763,8 +1715,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
1763
1715
|
* carico conversazione - stack 1
|
|
1764
1716
|
* home - stack 0
|
|
1765
1717
|
*/
|
|
1766
|
-
onNewConversation() {
|
|
1718
|
+
onNewConversation(text?: string) {
|
|
1767
1719
|
this.logger.debug('[APP-COMP] returnNewConversation in APP COMPONENT');
|
|
1720
|
+
if(text) this.g.setParameter('hiddenMessage', text);
|
|
1768
1721
|
this.g.newConversationStart = true;
|
|
1769
1722
|
// controllo i dipartimenti se sono 1 o 2 seleziono dipartimento e nascondo modale dipartimento
|
|
1770
1723
|
// altrimenti mostro modale dipartimenti
|
|
@@ -1801,6 +1754,28 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
1801
1754
|
}
|
|
1802
1755
|
}
|
|
1803
1756
|
|
|
1757
|
+
|
|
1758
|
+
onNewConversationWithMessage(text: string, subType: string = 'info'){
|
|
1759
|
+
this.logger.log('[APP-COMP] onNewConversationWithMessage in APP COMPONENT', text);
|
|
1760
|
+
|
|
1761
|
+
const newConvId = this.generateNewUidConversation();
|
|
1762
|
+
this.g.setParameter('recipientId', newConvId);
|
|
1763
|
+
this.appStorageService.setItem('recipientId', newConvId)
|
|
1764
|
+
|
|
1765
|
+
let message: any = {}
|
|
1766
|
+
message.attributes = { subtype: subType, ...this.g.attributes}
|
|
1767
|
+
message.userAgent = this.g.attributes['client']
|
|
1768
|
+
message.request_id = newConvId
|
|
1769
|
+
message.sourcePage = this.g.attributes['sourcePage']
|
|
1770
|
+
message.language = this.g.lang
|
|
1771
|
+
message.text = '/'+ text
|
|
1772
|
+
message.participants = this.g.participants
|
|
1773
|
+
message.departmentid = this.g.attributes.departmentId
|
|
1774
|
+
// this.sendMessage(message)
|
|
1775
|
+
this.tiledeskRequestsService.sendMessageToRequest(newConvId, this.g.tiledeskToken, message)
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1804
1779
|
/**
|
|
1805
1780
|
* MODAL HOME:
|
|
1806
1781
|
* open all-conversation
|
|
@@ -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() === '') || !message?.text)"
|
|
66
|
+
[class.no-background]="(isImage(message) || isFrame(message) || isCarousel(message)) && ((message?.text && message?.text.trim() === '') || !message?.text)"
|
|
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')}"
|
|
@@ -109,8 +109,7 @@
|
|
|
109
109
|
</div>
|
|
110
110
|
|
|
111
111
|
<!-- carousel -->
|
|
112
|
-
<div *ngIf="message
|
|
113
|
-
&& message?.attributes?.attachment?.gallery" [ngClass]="{'slide-in-left': false}" class="carousel_container">
|
|
112
|
+
<div *ngIf="isCarousel(message)" [ngClass]="{'slide-in-left': false}" class="carousel_container">
|
|
114
113
|
<chat-carousel class="carousel_container"
|
|
115
114
|
[message]="message"
|
|
116
115
|
[isConversationArchived]="isConversationArchived"
|
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, isFirstMessage, isFrame, isImage, isInfo, isLastMessage, isMine, isSameSender, messageType } from 'src/chat21-core/utils/utils-message';
|
|
9
|
+
import { isCarousel, 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',
|
|
@@ -45,6 +45,7 @@ export class ConversationContentComponent implements OnInit {
|
|
|
45
45
|
// ========= begin:: dichiarazione funzioni ======= //
|
|
46
46
|
isPopupUrl = isPopupUrl;
|
|
47
47
|
popupUrl = popupUrl;
|
|
48
|
+
isCarousel = isCarousel;
|
|
48
49
|
// ========= end:: dichiarazione funzioni ======= //
|
|
49
50
|
|
|
50
51
|
// ========== begin:: set icon status message ======= //
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, SimpleChange, SimpleChanges, ViewChildren } from '@angular/core';
|
|
2
2
|
import { MessageModel } from 'src/chat21-core/models/message';
|
|
3
|
+
import { isCarousel } from 'src/chat21-core/utils/utils-message';
|
|
3
4
|
|
|
4
5
|
@Component({
|
|
5
6
|
selector: 'chat-carousel',
|
|
@@ -34,7 +35,7 @@ export class CarouselComponent implements OnInit{
|
|
|
34
35
|
constructor(private elementRef: ElementRef) { }
|
|
35
36
|
|
|
36
37
|
ngOnInit() {
|
|
37
|
-
console.log('[CAROUSEL-MESSAGE] hello', this.message)
|
|
38
|
+
console.log('[CAROUSEL-MESSAGE] hello', this.message, isCarousel(this.message))
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
this.wrapper = this.elementRef.nativeElement.querySelector('.wrapper')
|
|
@@ -95,7 +96,7 @@ export class CarouselComponent implements OnInit{
|
|
|
95
96
|
let gap = 17
|
|
96
97
|
let cardPerView = Math.round(this.carousel.offsetWidth / width);
|
|
97
98
|
|
|
98
|
-
console.log('go to -->', direction, width, this.firstCardWidth, cardPerView, this.carousel.offsetWidth)
|
|
99
|
+
// console.log('go to -->', direction, width, this.firstCardWidth, cardPerView, this.carousel.offsetWidth)
|
|
99
100
|
|
|
100
101
|
// this.carousel.scrollLeft += direction == "previous" ? -(width+gap) : width+gap;
|
|
101
102
|
this.carousel.scrollLeft += direction == "previous" ? -width : width;
|
|
@@ -110,7 +111,6 @@ export class CarouselComponent implements OnInit{
|
|
|
110
111
|
actionButtonClick(ev, button, index){
|
|
111
112
|
this.button = button
|
|
112
113
|
this.type = button.type
|
|
113
|
-
console.log('buttonnnnnnn', ev, button)
|
|
114
114
|
if ( button && ((button.action && button.action !== '') || (button.link && button.link !== '') || button.text !== '' )) {
|
|
115
115
|
|
|
116
116
|
//set clicked button as the active one
|
|
@@ -1774,6 +1774,11 @@ export class GlobalSettingsService {
|
|
|
1774
1774
|
if (TEMP) {
|
|
1775
1775
|
globals.disconnetTime = stringToNumber(TEMP);
|
|
1776
1776
|
}
|
|
1777
|
+
|
|
1778
|
+
TEMP = getParameterByName(windowContext, 'tiledesk_hiddenMessage');
|
|
1779
|
+
if (TEMP) {
|
|
1780
|
+
globals.hiddenMessage = TEMP;
|
|
1781
|
+
}
|
|
1777
1782
|
|
|
1778
1783
|
}
|
|
1779
1784
|
|
package/src/app/utils/globals.ts
CHANGED
|
@@ -218,6 +218,8 @@ export class Globals {
|
|
|
218
218
|
onPageChangeVisibilityDesktop: 'open' | 'close' | 'last'; // ******* new ********
|
|
219
219
|
displayOnMobile: boolean; // ******* new ********
|
|
220
220
|
displayOnDesktop: boolean; // ******* new ********
|
|
221
|
+
|
|
222
|
+
hiddenMessage: string; // ******* new ********
|
|
221
223
|
constructor(
|
|
222
224
|
) { }
|
|
223
225
|
|
|
@@ -414,6 +416,8 @@ export class Globals {
|
|
|
414
416
|
this.displayOnMobile = true
|
|
415
417
|
this.onPageChangeVisibilityMobile = 'close'
|
|
416
418
|
|
|
419
|
+
/**set an hidden message to show when conversation starts */
|
|
420
|
+
this.hiddenMessage = null
|
|
417
421
|
|
|
418
422
|
// ============ END: SET EXTERNAL PARAMETERS ==============//
|
|
419
423
|
|
|
@@ -546,7 +546,7 @@ class Chat21Client {
|
|
|
546
546
|
if (this.log) {
|
|
547
547
|
console.log("this.on_message_handler already subscribed. Reconnected num", this.reconnections)
|
|
548
548
|
}
|
|
549
|
-
|
|
549
|
+
subscribedCallback();
|
|
550
550
|
return
|
|
551
551
|
}
|
|
552
552
|
this.subscribeToMyConversations(() => {
|
|
@@ -415,6 +415,13 @@
|
|
|
415
415
|
// window.Tiledesk('show')
|
|
416
416
|
// }
|
|
417
417
|
});
|
|
418
|
+
|
|
419
|
+
window.addEventListener('message', (event_data)=> {
|
|
420
|
+
if(event_data && event_data.data && event_data.data.action === 'restart'){
|
|
421
|
+
window.Tiledesk('startConversation', event_data.data.intentName)
|
|
422
|
+
}
|
|
423
|
+
})
|
|
424
|
+
|
|
418
425
|
</script>
|
|
419
426
|
|
|
420
427
|
<script type="application/javascript">
|
|
@@ -10,6 +10,14 @@ import {
|
|
|
10
10
|
TYPE_SUPPORT_GROUP
|
|
11
11
|
} from './constants';
|
|
12
12
|
|
|
13
|
+
/** */
|
|
14
|
+
export function isCarousel(message: any) {
|
|
15
|
+
if (message && message.type && message.type === 'gallery' && message?.attributes && message?.attributes?.attachment && message?.attributes?.attachment?.gallery ) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
/** */
|
|
14
22
|
export function isImage(message: any) {
|
|
15
23
|
if (message && message.type && message.type === 'image' && message.metadata && message.metadata.src) {
|