@chat21/chat21-web-widget 5.0.101 → 5.0.103
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 +7 -0
- package/package.json +1 -1
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +69 -40
- package/src/assets/twp/chatbot-panel.html +39 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -0
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +1 -0
- package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
### **Copyrigth**:
|
|
7
7
|
*Tiledesk SRL*
|
|
8
8
|
|
|
9
|
+
# 5.0.103
|
|
10
|
+
- **added**: new /me tiledesk api to get all my requests
|
|
11
|
+
- **changed**: removed header and footer for chatbot-panel.html page in case widget is embedded
|
|
12
|
+
|
|
13
|
+
# 5.0.102
|
|
14
|
+
- **bug-fixed**: cannot add message if array is empty
|
|
15
|
+
|
|
9
16
|
# 5.0.101
|
|
10
17
|
- **bug-fixed**: removed private note msgs
|
|
11
18
|
|
package/package.json
CHANGED
|
@@ -361,14 +361,21 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
|
|
|
361
361
|
// this.logger.debug('[CONV-COMP] ------ 5: updateConversationbage ------ ');
|
|
362
362
|
// this.updateConversationBadge();
|
|
363
363
|
|
|
364
|
-
|
|
365
|
-
this.getConversationDetail((isConversationArchived) => {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}) //check if conv is archived or not
|
|
364
|
+
|
|
365
|
+
// this.getConversationDetail((isConversationArchived) => {
|
|
366
|
+
// this.logger.debug('[CONV-COMP] ------ 6: updateConversationbage ------ ');
|
|
367
|
+
// this.updateConversationBadge();
|
|
368
|
+
// return;
|
|
369
|
+
// }) //check if conv is archived or not
|
|
370
370
|
// this.checkListMessages();
|
|
371
371
|
|
|
372
|
+
this.logger.debug('[CONV-COMP] ------ 5: getConversationDetail ------ ', this.conversationId);
|
|
373
|
+
await this.getConversationDetail();
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
this.logger.debug('[CONV-COMP] ------ 6: updateConversationBadge ------ ');
|
|
377
|
+
this.updateConversationBadge();
|
|
378
|
+
|
|
372
379
|
if(this.g.customAttributes){
|
|
373
380
|
this.updateUserInfo(this.g.customAttributes)
|
|
374
381
|
}
|
|
@@ -382,7 +389,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
|
|
|
382
389
|
* @param callback
|
|
383
390
|
* @returns isConversationArchived (status conversation archived: boolean)
|
|
384
391
|
*/
|
|
385
|
-
|
|
392
|
+
getConversationDetail_old(callback:(isConversationArchived: boolean)=>void){
|
|
386
393
|
// if(!this.isConversationArchived){
|
|
387
394
|
//get conversation from 'conversations' firebase node
|
|
388
395
|
this.logger.debug('[CONV-COMP] getConversationDetail: isConversationArchived???', this.isConversationArchived, this.conversationWith)
|
|
@@ -412,39 +419,60 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
|
|
|
412
419
|
})
|
|
413
420
|
}
|
|
414
421
|
});
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* @description get detail of conversation by uid and then return callback with conversation status
|
|
426
|
+
* @param callback
|
|
427
|
+
* @returns isConversationArchived (status conversation archived: boolean)
|
|
428
|
+
*/
|
|
429
|
+
async getConversationDetail(): Promise<boolean> {
|
|
430
|
+
this.logger.debug('[CONV-COMP] getConversationDetail: isConversationArchived???', this.isConversationArchived, this.conversationWith);
|
|
431
|
+
|
|
432
|
+
const conv = await new Promise<any>((resolve) => {
|
|
433
|
+
this.conversationsHandlerService.getConversationDetail(this.conversationWith, resolve);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
if (conv) {
|
|
437
|
+
this.logger.debug('[CONV-COMP] getConversationDetail: conversationsHandlerService ', this.conversationWith, conv, this.isConversationArchived);
|
|
438
|
+
this.conversation = conv;
|
|
439
|
+
this.isConversationArchived = false;
|
|
440
|
+
return this.isConversationArchived;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
this.logger.debug('[CONV-COMP] getConversationDetail: conv not exist --> search in archived list', this.isConversationArchived, this.conversationWith);
|
|
444
|
+
|
|
445
|
+
const archivedConv = await new Promise<any>((resolve) => {
|
|
446
|
+
this.archivedConversationsHandlerService.getConversationDetail(this.conversationWith, resolve);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
if (archivedConv) {
|
|
450
|
+
this.logger.debug('[CONV-COMP] getConversationDetail: archivedConversationsHandlerService', this.conversationWith, archivedConv, this.isConversationArchived);
|
|
451
|
+
this.conversation = archivedConv;
|
|
452
|
+
this.isConversationArchived = true;
|
|
453
|
+
return this.isConversationArchived;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
//FALLBACK TO TILEDESK
|
|
457
|
+
const requests_list = await this.tiledeskRequestService.getMyRequests().catch(err => {
|
|
458
|
+
this.logger.error('[CONV-COMP] getConversationDetail: error getting request from Tiledesk', err);
|
|
459
|
+
this.isConversationArchived=true
|
|
460
|
+
return { requests: [] }
|
|
461
|
+
});
|
|
462
|
+
if (requests_list && requests_list.requests.length > 0) {
|
|
463
|
+
this.logger.debug('[CONV-COMP] getConversationDetail: request exist on Tiledesk', requests_list);
|
|
464
|
+
let conversation = requests_list.requests.find((request)=> request.request_id === this.conversationId)
|
|
465
|
+
if(conversation){
|
|
466
|
+
this.isConversationArchived = false
|
|
467
|
+
return this.isConversationArchived
|
|
468
|
+
}
|
|
469
|
+
this.logger.debug('[CONV-COMP] getConversationDetail: request NOT EXIST on Tiledesk', requests_list);
|
|
470
|
+
this.isConversationArchived = true
|
|
471
|
+
return this.isConversationArchived
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
this.isConversationArchived = true;
|
|
475
|
+
return this.isConversationArchived;
|
|
448
476
|
}
|
|
449
477
|
|
|
450
478
|
/**
|
|
@@ -742,6 +770,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
|
|
|
742
770
|
subscribtion = this.conversationHandlerService.messageAdded.pipe(takeUntil(this.unsubscribe$)).subscribe((msg: MessageModel) => {
|
|
743
771
|
this.logger.debug('[CONV-COMP] ***** DETAIL messageAdded *****', msg);
|
|
744
772
|
if (msg) {
|
|
773
|
+
|
|
745
774
|
that.newMessageAdded(msg);
|
|
746
775
|
this.checkMessagesLegntForTranscriptDownloadMenuOption();
|
|
747
776
|
this.resetTimeout();
|
|
@@ -108,6 +108,27 @@
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
.loading-text {
|
|
112
|
+
position: absolute;
|
|
113
|
+
top: 60%;
|
|
114
|
+
left: 50%;
|
|
115
|
+
transform: translateX(-50%);
|
|
116
|
+
font-family: sans-serif;
|
|
117
|
+
font-size: 18px;
|
|
118
|
+
color: rgb(224, 106, 88);;
|
|
119
|
+
animation: blinkText 1.5s infinite ease-in-out;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* Animazione lampeggiante */
|
|
123
|
+
@keyframes blinkText {
|
|
124
|
+
0%, 100% {
|
|
125
|
+
opacity: 1;
|
|
126
|
+
}
|
|
127
|
+
50% {
|
|
128
|
+
opacity: 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
111
132
|
#deferred-styles {
|
|
112
133
|
display: none;
|
|
113
134
|
}
|
|
@@ -458,6 +479,23 @@
|
|
|
458
479
|
}(document, 'script', 'tiledesk-jssdk'));
|
|
459
480
|
|
|
460
481
|
</script> -->
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
<script type="application/javascript" id="check_embed">
|
|
485
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
486
|
+
const isEmbedded = window.self !== window.top;
|
|
487
|
+
|
|
488
|
+
if (isEmbedded) {
|
|
489
|
+
//HIDE header and footer elements
|
|
490
|
+
const header = document.querySelector('header');
|
|
491
|
+
const footer = document.querySelector('footer');
|
|
492
|
+
if (header) header.style.display = 'none';
|
|
493
|
+
if (footer) footer.style.display = 'none';
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
</script>
|
|
497
|
+
|
|
498
|
+
|
|
461
499
|
<script type="application/javascript">
|
|
462
500
|
window.tiledeskSettings = {
|
|
463
501
|
marginX: "100px",
|
|
@@ -654,6 +692,7 @@
|
|
|
654
692
|
|
|
655
693
|
<div id="preloader">
|
|
656
694
|
<div class="loader"></div>
|
|
695
|
+
<!-- <div class="loading-text">Loading . . .</div> -->
|
|
657
696
|
</div>
|
|
658
697
|
|
|
659
698
|
<header id="header">
|
|
@@ -470,6 +470,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
470
470
|
const that = this;
|
|
471
471
|
const commands = msg.attributes.commands;
|
|
472
472
|
let i=0;
|
|
473
|
+
if(commands.length === 0) return;
|
|
473
474
|
return new Promise((resolve, reject)=>{
|
|
474
475
|
function execute(command){
|
|
475
476
|
if(command.type === "message"){
|
|
@@ -465,6 +465,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
465
465
|
const that = this;
|
|
466
466
|
const commands = msg.attributes.commands;
|
|
467
467
|
let i=0;
|
|
468
|
+
if(commands.length === 0) return;
|
|
468
469
|
return new Promise((resolve, reject)=>{
|
|
469
470
|
function execute(command){
|
|
470
471
|
if(command.type === "message"){
|
|
@@ -68,4 +68,18 @@ export class TiledeskRequestsService {
|
|
|
68
68
|
return res
|
|
69
69
|
})
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
public getMyRequests(): Promise<{ requests: Array<any>}> {
|
|
73
|
+
this.tiledeskToken = this.appStorage.getItem('tiledeskToken')
|
|
74
|
+
const url = this.URL_TILEDESK_REQUEST + '/me?preflight=true'
|
|
75
|
+
this.logger.log('[TILEDESK-SERVICE] - GET REQUEST url ', url);
|
|
76
|
+
const httpOptions = {
|
|
77
|
+
headers: new HttpHeaders({
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
Authorization: this.tiledeskToken
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return this.http.get<{ requests: Array<any>}>(url, httpOptions).toPromise()
|
|
84
|
+
}
|
|
71
85
|
}
|