@chat21/chat21-web-widget 5.0.60 → 5.0.61-rc.1
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
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# chat21-web-widget ver 5.0
|
|
2
2
|
|
|
3
|
+
### 5.0.61-rc.1
|
|
4
|
+
- added: 'flags' emojii category in conversatio-footer component
|
|
5
|
+
- added: 'share prototype' button inside 'chatbot-panel.html' page to copy link to clipboard
|
|
6
|
+
- added: forceDisconnet var to disconnet messaging client if no interaction is handled within 60s
|
|
7
|
+
|
|
3
8
|
### 5.0.60 in PROD
|
|
4
9
|
|
|
5
10
|
### 5.0.60-rc.2
|
package/package.json
CHANGED
package/src/app/app.component.ts
CHANGED
|
@@ -103,6 +103,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
103
103
|
styleMapConversation: Map<string, string> = new Map();
|
|
104
104
|
marginBottom: number;
|
|
105
105
|
|
|
106
|
+
forceDisconnect: boolean = false;
|
|
106
107
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
107
108
|
constructor(
|
|
108
109
|
private el: ElementRef,
|
|
@@ -407,8 +408,12 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
407
408
|
rules.initRules(that.g.windowContext, that.g.tiledeskToken, user, that.generateNewUidConversation(), that.g.botsRules)
|
|
408
409
|
}
|
|
409
410
|
|
|
411
|
+
//if widget is closed subscribe to 'click' event and set a 60sec timer to disconnect if handler isn't fired
|
|
412
|
+
if(!this.g.isOpen){
|
|
413
|
+
that.listenToWidgetClick()
|
|
414
|
+
}
|
|
410
415
|
|
|
411
|
-
} else if (state && state === AUTH_STATE_OFFLINE) {
|
|
416
|
+
} else if (state && state === AUTH_STATE_OFFLINE && !this.forceDisconnect) {
|
|
412
417
|
/** non sono loggato */
|
|
413
418
|
that.logger.info('[APP-COMP] OFFLINE - NO CURRENT USER AUTENTICATE: ');
|
|
414
419
|
that.g.setParameter('isLogged', false);
|
|
@@ -427,7 +432,8 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
427
432
|
|
|
428
433
|
const subUserLogOut = this.messagingAuthService.BSSignOut.subscribe((state) => {
|
|
429
434
|
// that.ngZone.run(() => {
|
|
430
|
-
|
|
435
|
+
console.log('[FORCE] messagingAuthService BSSignOut', state, this.forceDisconnect)
|
|
436
|
+
if (state === true && !this.forceDisconnect) { //state = true -> user has logged out
|
|
431
437
|
/** ho effettuato il logout: nascondo il widget */
|
|
432
438
|
that.logger.debug('[APP-COMP] sono nel caso logout -1');
|
|
433
439
|
// that.g.wdLog(['obsLoggedUser', obsLoggedUser);
|
|
@@ -1580,6 +1586,12 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
1580
1586
|
this.g.setParameter('recipientId', recipientId);
|
|
1581
1587
|
this.logger.debug('[APP-COMP] openCloseWidget', recipientId, this.g.isOpen, this.g.startFromHome);
|
|
1582
1588
|
if (this.g.isOpen === false) {
|
|
1589
|
+
if(this.forceDisconnect){
|
|
1590
|
+
console.log('[FORCE] onOpenCloseWidget --> reconnect', this.forceDisconnect)
|
|
1591
|
+
this.messagingAuthService.createCustomToken(this.g.tiledeskToken)
|
|
1592
|
+
this.forceDisconnect = false;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1583
1595
|
if (!recipientId) {
|
|
1584
1596
|
if(this.g.singleConversation){
|
|
1585
1597
|
this.isOpenHome = false;
|
|
@@ -2075,6 +2087,20 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
|
|
2075
2087
|
}
|
|
2076
2088
|
}
|
|
2077
2089
|
|
|
2090
|
+
|
|
2091
|
+
private listenToWidgetClick(){
|
|
2092
|
+
let clickTimeout = setTimeout(() => {
|
|
2093
|
+
console.log('[FORCE] --> NO INTERACTION: disconnection... <--- ')
|
|
2094
|
+
//disconnect
|
|
2095
|
+
this.forceDisconnect = true
|
|
2096
|
+
this.messagingAuthService.logout()
|
|
2097
|
+
}, 10*1000);
|
|
2098
|
+
window.addEventListener("click", function(){
|
|
2099
|
+
console.log('[FORCE] <<INTERACTION>> within 1 minute')
|
|
2100
|
+
clearTimeout(clickTimeout)
|
|
2101
|
+
})
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2078
2104
|
// ========= begin:: DESTROY ALL SUBSCRIPTIONS ============//
|
|
2079
2105
|
/** elimino tutte le sottoscrizioni */
|
|
2080
2106
|
ngOnDestroy() {
|
package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts
CHANGED
|
@@ -68,7 +68,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
|
|
|
68
68
|
showPreview: false,
|
|
69
69
|
darkMode: false,
|
|
70
70
|
enableSearch: false,
|
|
71
|
-
include: [ 'recent', 'people', 'nature', 'activity']
|
|
71
|
+
include: [ 'recent', 'people', 'nature', 'activity', 'flags']
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
convertColorToRGBA = convertColorToRGBA;
|
|
@@ -992,7 +992,6 @@ class Chat21Client {
|
|
|
992
992
|
}
|
|
993
993
|
if (this.log) {console.log("starting mqtt connection with LWT on:", this.presence_topic, this.endpoint)}
|
|
994
994
|
// client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
|
|
995
|
-
console.log("starting mqtt connection with LWT on:", this.presence_topic, this.endpoint)
|
|
996
995
|
this.client = mqtt.connect(this.endpoint,options)
|
|
997
996
|
|
|
998
997
|
this.client.on('connect', // TODO if token is wrong it must reply with an error!
|
|
@@ -158,6 +158,31 @@
|
|
|
158
158
|
text-align: center;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
header#header{
|
|
162
|
+
z-index: 2;
|
|
163
|
+
position: absolute;
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.share-btn{
|
|
168
|
+
transition: color 0.15s ease 0s, opacity 0.15s ease 0s, box-shadow 0.15s ease 0s, background-color 0.15s ease 0s;
|
|
169
|
+
height: 41px;
|
|
170
|
+
box-sizing: border-box;
|
|
171
|
+
color: rgb(19, 33, 68);
|
|
172
|
+
font-weight: 600;
|
|
173
|
+
line-height: 22px;
|
|
174
|
+
background-size: 1px 41px;
|
|
175
|
+
padding: 10px 19px;
|
|
176
|
+
border-radius: 10px;
|
|
177
|
+
border: 1px solid rgb(255, 255, 255);
|
|
178
|
+
background-color: rgb(231, 240, 242);
|
|
179
|
+
box-shadow: rgb(204, 211, 228) 0px 0px 0px 1px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.share-btn:hover{
|
|
183
|
+
opacity: 0.8;
|
|
184
|
+
}
|
|
185
|
+
|
|
161
186
|
footer#footer {
|
|
162
187
|
background-color: white;
|
|
163
188
|
text-align: center;
|
|
@@ -190,7 +215,53 @@
|
|
|
190
215
|
height: 24px;
|
|
191
216
|
/* margin-left: 20px; */
|
|
192
217
|
}
|
|
193
|
-
|
|
218
|
+
|
|
219
|
+
/* The snackbar - position it at the bottom and in the middle of the screen */
|
|
220
|
+
#snackbar {
|
|
221
|
+
visibility: hidden; /* Hidden by default. Visible on click */
|
|
222
|
+
min-width: 250px; /* Set a default minimum width */
|
|
223
|
+
margin-left: -125px; /* Divide value of min-width by 2 */
|
|
224
|
+
background-color: #504a4a; /* Black background color */
|
|
225
|
+
color: #fff; /* White text color */
|
|
226
|
+
text-align: center; /* Centered text */
|
|
227
|
+
border-radius: 10px; /* Rounded borders */
|
|
228
|
+
padding: 16px; /* Padding */
|
|
229
|
+
position: fixed; /* Sit on top of the screen */
|
|
230
|
+
z-index: 1; /* Add a z-index if needed */
|
|
231
|
+
left: 50%; /* Center the snackbar */
|
|
232
|
+
bottom: 30px; /* 30px from the bottom */
|
|
233
|
+
font-size: medium;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/* Show the snackbar when clicking on a button (class added with JavaScript) */
|
|
237
|
+
#snackbar.show {
|
|
238
|
+
visibility: visible; /* Show the snackbar */
|
|
239
|
+
/* Add animation: Take 0.5 seconds to fade in and out the snackbar.
|
|
240
|
+
However, delay the fade out process for 2.5 seconds */
|
|
241
|
+
-webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
|
242
|
+
animation: fadein 0.5s, fadeout 0.5s 2.5s;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* Animations to fade the snackbar in and out */
|
|
246
|
+
@-webkit-keyframes fadein {
|
|
247
|
+
from {bottom: 0; opacity: 0;}
|
|
248
|
+
to {bottom: 30px; opacity: 1;}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@keyframes fadein {
|
|
252
|
+
from {bottom: 0; opacity: 0;}
|
|
253
|
+
to {bottom: 30px; opacity: 1;}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@-webkit-keyframes fadeout {
|
|
257
|
+
from {bottom: 30px; opacity: 1;}
|
|
258
|
+
to {bottom: 0; opacity: 0;}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@keyframes fadeout {
|
|
262
|
+
from {bottom: 30px; opacity: 1;}
|
|
263
|
+
to {bottom: 0; opacity: 0;}
|
|
264
|
+
}
|
|
194
265
|
|
|
195
266
|
</style>
|
|
196
267
|
|
|
@@ -367,15 +438,28 @@
|
|
|
367
438
|
}
|
|
368
439
|
return(false);
|
|
369
440
|
}
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
370
444
|
</script>
|
|
371
445
|
|
|
372
446
|
</head>
|
|
373
447
|
|
|
374
448
|
<body class="website white" >
|
|
449
|
+
|
|
450
|
+
|
|
375
451
|
<div id="preloader">
|
|
376
452
|
<div class="logo"></div>
|
|
377
453
|
</div>
|
|
378
454
|
|
|
455
|
+
<header id="header">
|
|
456
|
+
<ul class="nav navbar-nav navbar-left">
|
|
457
|
+
<li class="sign-up"><button class="share-btn" onclick="copyLink()">SHARE THIS PROTOTYPE</button></li>
|
|
458
|
+
</ul>
|
|
459
|
+
</header>
|
|
460
|
+
<!-- The actual snackbar -->
|
|
461
|
+
<div id="snackbar">Copied to clipboard...</div>
|
|
462
|
+
|
|
379
463
|
<div id="wrapper" class="mockup">
|
|
380
464
|
</div>
|
|
381
465
|
|
|
@@ -389,24 +473,38 @@
|
|
|
389
473
|
</footer>
|
|
390
474
|
|
|
391
475
|
|
|
392
|
-
|
|
476
|
+
<script>
|
|
393
477
|
// non-blocking CSS delivery
|
|
394
|
-
var loadDeferredStyles = function() {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
};
|
|
402
|
-
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
|
403
|
-
|
|
404
|
-
if (raf) {
|
|
405
|
-
|
|
406
|
-
} else {
|
|
407
|
-
|
|
478
|
+
// var loadDeferredStyles = function() {
|
|
479
|
+
// var addStylesNode = document.getElementById("deferred-styles");
|
|
480
|
+
// console.log('addStylesNode ', addStylesNode)
|
|
481
|
+
// var replacement = document.createElement("div");
|
|
482
|
+
// replacement.innerHTML = addStylesNode.textContent;
|
|
483
|
+
// document.body.appendChild(replacement);
|
|
484
|
+
// addStylesNode.parentElement.removeChild(addStylesNode);
|
|
485
|
+
// };
|
|
486
|
+
// var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
|
|
487
|
+
// window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
|
|
488
|
+
// if (raf) {
|
|
489
|
+
// raf(function() { window.setTimeout(loadDeferredStyles, 0); });
|
|
490
|
+
// } else {
|
|
491
|
+
// window.addEventListener('load', loadDeferredStyles);
|
|
492
|
+
// }
|
|
493
|
+
function copyLink(){
|
|
494
|
+
let url = window.location.href
|
|
495
|
+
navigator.clipboard.writeText(url)
|
|
496
|
+
|
|
497
|
+
// Get the snackbar DIV
|
|
498
|
+
var toast = document.getElementById("snackbar");
|
|
499
|
+
|
|
500
|
+
// Add the "show" class to DIV
|
|
501
|
+
toast.className = "show";
|
|
502
|
+
|
|
503
|
+
// After 3 seconds, remove the show class from DIV
|
|
504
|
+
setTimeout(function(){ toast.className = toast.className.replace("show", ""); }, 3000);
|
|
505
|
+
|
|
408
506
|
}
|
|
409
|
-
</script>
|
|
507
|
+
</script>
|
|
410
508
|
|
|
411
509
|
<!-- Google Analytics -->
|
|
412
510
|
|