@chat21/chat21-web-widget 5.1.0-rc12 → 5.1.0-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 CHANGED
@@ -6,6 +6,12 @@
6
6
  ### **Copyrigth**:
7
7
  *Tiledesk SRL*
8
8
 
9
+ # 5.1.0-rc14
10
+ - **added**: ability to hide widget on selected domains based on hideOnSpecificDomainList variable
11
+
12
+ # 5.1.0-rc13
13
+ - **added**: ability to manage embedded chatbot-panel.html page into an iframe and hide some elements
14
+
9
15
  # 5.1.0-rc12
10
16
  - **added**: ability to get all my request from Tiledesk API
11
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.1.0-rc12",
4
+ "version": "5.1.0-rc14",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -262,6 +262,14 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
262
262
  this.tabTitle = this.g.windowContext.window.document.title
263
263
  this.appStorageService.initialize(environment.storage_prefix, this.g.persistence, this.g.projectid)
264
264
 
265
+ //check if allowed to load
266
+ let canLoad = this.globalSettingsService.manageLoadingDomains();
267
+ if(!canLoad){
268
+ this.logger.error('[Check canLoad] Widget is not able to load on this domain!!!')
269
+ this.hideWidget()
270
+ this.disposeWidget();
271
+ }
272
+
265
273
  //set visibility
266
274
  if((this.g.isMobile && !this.g.displayOnMobile) || (!this.g.isMobile && !this.g.displayOnDesktop)){
267
275
  this.disposeWidget()
@@ -10,7 +10,7 @@ import { TemplateBindingParseResult } from '@angular/compiler';
10
10
  import { AppStorageService } from '../../chat21-core/providers/abstract/app-storage.service';
11
11
  import { LoggerService } from '../../chat21-core/providers/abstract/logger.service';
12
12
  import { LoggerInstance } from '../../chat21-core/providers/logger/loggerInstance';
13
- import { invertColor, isJsonArray } from '../../chat21-core/utils/utils';
13
+ import { invertColor, isAllowedUrlInText, isJsonArray } from '../../chat21-core/utils/utils';
14
14
  import { AppConfigService } from './app-config.service';
15
15
 
16
16
 
@@ -516,6 +516,9 @@ export class GlobalSettingsService {
516
516
  if (variables.hasOwnProperty('showAudioRecorderFooterButton')) {
517
517
  globals['showAudioRecorderFooterButton'] = variables['showAudioRecorderFooterButton'];
518
518
  }
519
+ if (variables.hasOwnProperty('hideOnSpecificDomainList')) {
520
+ globals['hideOnSpecificDomainList'] = variables['hideOnSpecificDomainList'];
521
+ }
519
522
 
520
523
  }
521
524
  }
@@ -1970,4 +1973,12 @@ export class GlobalSettingsService {
1970
1973
  }
1971
1974
  }
1972
1975
 
1976
+ manageLoadingDomains(): boolean {
1977
+ if(!this.globals.hideOnSpecificDomainList){
1978
+ return true
1979
+ }
1980
+ let isAllowedToLoad = !isAllowedUrlInText(this.globals.windowContext.location.origin, [])
1981
+ return isAllowedToLoad
1982
+ }
1983
+
1973
1984
  }
@@ -218,6 +218,8 @@ export class Globals {
218
218
  showEmojiFooterButton: boolean // ******* new ********
219
219
  showAttachmentFooterButton: boolean // ******* new ********
220
220
  showAudioRecorderFooterButton: boolean // ******* new ********
221
+
222
+ hideOnSpecificDomainList: Array<string> // ******* new ********
221
223
  constructor(
222
224
  ) { }
223
225
 
@@ -417,6 +419,8 @@ export class Globals {
417
419
  this.showAttachmentFooterButton = true;
418
420
  /** show/hide rec audio option in footer chat-detail page */
419
421
  this.showAudioRecorderFooterButton = true;
422
+ /** set a list of domain not able to load the widget */
423
+ this.hideOnSpecificDomainList = [];
420
424
 
421
425
  // ============ END: SET EXTERNAL PARAMETERS ==============//
422
426
 
@@ -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"){
@@ -619,7 +619,6 @@ function componentFromStr(numStr, percent) {
619
619
 
620
620
  export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
621
621
  const urlsInMessage = extractUrls(text);
622
- console.log('urlsInMessage ++++ :', urlsInMessage);
623
622
 
624
623
  const allowedPatterns = allowedUrls.map((url) => {
625
624
  try {
@@ -634,6 +633,9 @@ export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
634
633
 
635
634
  const matchesAllowed = (domain: string) => {
636
635
  return allowedPatterns.some((pattern) => {
636
+ if (pattern === '*') {
637
+ return true; //accept all
638
+ }
637
639
  if (pattern.startsWith('*.')) {
638
640
  const base = pattern.replace(/^\*\./, '');
639
641
  return domain === base || domain.endsWith('.' + base);