@chat21/chat21-web-widget 5.0.73 → 5.0.74-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 CHANGED
@@ -1,4 +1,21 @@
1
- # chat21-web-widget ver 5.0
1
+ # **CHAT21-WEB-WIDGET - Changelog** ver 5.0
2
+
3
+ ### **Authors**:
4
+ *Gabriele Panico*
5
+ *Dario De Pascalis*
6
+ ### **Copyrigth**: *Tiledesk SRL*
7
+
8
+ ### 5.0.74-rc.4
9
+ - added: clearStorage method to index-dev.html file
10
+
11
+ ### 5.0.74-rc.3
12
+ - added: brand-service and BrandResources class to manage resources
13
+
14
+ ### 5.0.74-rc.2
15
+ - added: clearStorage public method from external iframe
16
+
17
+ ### 5.0.74-rc.1
18
+ - minor improvement
2
19
 
3
20
  ### 5.0.73 in PROD
4
21
 
package/angular.json CHANGED
@@ -27,6 +27,7 @@
27
27
  "src/assets",
28
28
  "src/test.html",
29
29
  "src/test-new.html",
30
+ "src/test-custom-authentication.html",
30
31
  "src/test-custom-auth.html",
31
32
  "src/tiledesk.js",
32
33
  "src/launch.js",
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.0.73",
4
+ "version": "5.0.74-rc.4",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -944,7 +944,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
944
944
  * 2 - remove user in firebase
945
945
  */
946
946
  signOut(): Promise<boolean> {
947
- this.logger.debug('[APP-COMP] SIGNOUT');
947
+ this.logger.debug('[APP-COMP] SIGNOUT', this.g.isLogged);
948
948
  if (this.g.isLogged === true) {
949
949
  this.logger.debug('[APP-COMP] prima ero loggato allora mi sloggo!');
950
950
  this.g.setIsOpen(false);
@@ -960,6 +960,11 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
960
960
  }
961
961
  }
962
962
 
963
+ clearStorage(){
964
+ this.logger.debug('[APP-COMP] clearStorage');
965
+ this.appStorageService.clear();
966
+ }
967
+
963
968
  /** show widget */
964
969
  private showWidget() {
965
970
  this.logger.debug('[APP-COMP] show widget--> autoStart:', this.g.autoStart, 'startHidden', this.g.startHidden, 'isShown', this.g.isShown)
@@ -1411,6 +1416,13 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
1411
1416
  });
1412
1417
  };
1413
1418
 
1419
+ /** set logout */
1420
+ windowContext['tiledesk'].clearStorage = function (): Promise<boolean> {
1421
+ return ngZone.run(() => {
1422
+ return windowContext['tiledesk']['angularcomponent'].component.clearStorage();
1423
+ });
1424
+ };
1425
+
1414
1426
  /** show callout */
1415
1427
  windowContext['tiledesk'].showCallout = function () {
1416
1428
  ngZone.run(() => {
@@ -132,16 +132,18 @@ import { LikeUnlikeComponent } from './component/message/like-unlike/like-unlike
132
132
  import { Rules } from './utils/rules';
133
133
  import { ScriptService } from 'src/chat21-core/providers/scripts/script.service';
134
134
  import { CarouselComponent } from './component/message/carousel/carousel.component';
135
+ import { BrandService } from './providers/brand.service';
135
136
 
136
137
 
137
138
 
138
- const appInitializerFn = (appConfig: AppConfigService, logger: NGXLogger) => {
139
- return () => {
139
+ const appInitializerFn = (appConfig: AppConfigService, brandService: BrandService, logger: NGXLogger) => {
140
+ return async() => {
140
141
  let customLogger = new CustomLogger(logger)
141
142
  LoggerInstance.setInstance(customLogger)
142
143
  if (environment.remoteConfig) {
143
- return appConfig.loadAppConfig();
144
+ await appConfig.loadAppConfig();
144
145
  }
146
+ await brandService.loadBrand();
145
147
  };
146
148
  };
147
149
 
@@ -331,7 +333,7 @@ export function uploadFactory(http: HttpClient, appConfig: AppConfigService, app
331
333
  provide: APP_INITIALIZER,
332
334
  useFactory: appInitializerFn,
333
335
  multi: true,
334
- deps: [AppConfigService, NGXLogger]
336
+ deps: [AppConfigService, BrandService, NGXLogger]
335
337
  },
336
338
  {
337
339
  provide: AppStorageService,
@@ -388,7 +390,8 @@ export function uploadFactory(http: HttpClient, appConfig: AppConfigService, app
388
390
  CustomTranslateService,
389
391
  Triggerhandler,
390
392
  WaitingService,
391
- ScriptService
393
+ ScriptService,
394
+ BrandService
392
395
  ],
393
396
  bootstrap: [AppComponent]
394
397
  })
@@ -27,8 +27,8 @@
27
27
  <div class="c21-content" #scrollMePreview id="scroll-me-preview">
28
28
  <chat-image *ngIf="fileSelected"
29
29
  [metadata]="fileSelected"
30
- [width]="fileSelected?.width"
31
- [height]="fileSelected?.height"
30
+ [width]="sizeImage?.width"
31
+ [height]="sizeImage?.height"
32
32
  (onImageRendered)="onImageRenderedFN($event)">
33
33
  </chat-image>
34
34
  <div id="img-preview-file-extension">{{ file_extension }} </div>
@@ -40,6 +40,7 @@ export class ConversationPreviewComponent implements OnInit {
40
40
  firstScroll = true;
41
41
  // ========= end:: gestione scroll view messaggi ======= //
42
42
 
43
+ sizeImage : { width: number, height: number}
43
44
 
44
45
  public logger: LoggerService = LoggerInstance.getInstance()
45
46
  constructor(private sanitizer: DomSanitizer) { }
@@ -64,6 +65,7 @@ export class ConversationPreviewComponent implements OnInit {
64
65
  getMetadataSize(metadata): {width, height} {
65
66
  const MAX_WIDTH_IMAGES_PREVIEW = 230
66
67
  const MAX_HEIGHT_IMAGES_PREIEW = 150
68
+ console.log('PREVIEW - getMetadataSize metadata', metadata)
67
69
  if(metadata.width === undefined){
68
70
  metadata.width= MAX_WIDTH_IMAGES_PREVIEW
69
71
  }
@@ -94,6 +96,7 @@ export class ConversationPreviewComponent implements OnInit {
94
96
  sizeImage.width = MAX_HEIGHT_IMAGES_PREIEW / ratio;
95
97
  sizeImage.height = MAX_HEIGHT_IMAGES_PREIEW ;
96
98
  }
99
+ console.log('PREVIEW - getMetadataSize return sizeimage', sizeImage)
97
100
  return sizeImage; // h.toString();
98
101
  }
99
102
 
@@ -108,7 +111,8 @@ export class ConversationPreviewComponent implements OnInit {
108
111
  this.logger.log('[LOADER-PREVIEW-PAGE] - readAsDataURL - USE CASE IMAGE - IMAGE ', attachment);
109
112
  if(!this.fileSelected){
110
113
  this.fileSelected = Object.assign({}, this.attachments[0].metadata)
111
- this.fileSelected = Object.assign(this.fileSelected, this.getMetadataSize(this.fileSelected))
114
+ // this.fileSelected = Object.assign(this.fileSelected, this.getMetadataSize(this.fileSelected))
115
+ this.sizeImage = this.getMetadataSize(this.fileSelected)
112
116
 
113
117
  }
114
118
  } else if ((attachment.file.type.startsWith("image")) && (attachment.file.type.includes("svg"))){
@@ -119,7 +123,8 @@ export class ConversationPreviewComponent implements OnInit {
119
123
  attachment.metadata.src = this.sanitizer.bypassSecurityTrustUrl(attachment.metadata.src)
120
124
  if(!this.fileSelected){
121
125
  this.fileSelected = Object.assign({}, this.attachments[0].metadata)
122
- this.fileSelected = Object.assign(this.fileSelected, this.getMetadataSize(this.fileSelected))
126
+ // this.fileSelected = Object.assign(this.fileSelected, this.getMetadataSize(this.fileSelected))
127
+ this.sizeImage = this.getMetadataSize(this.fileSelected)
123
128
  }
124
129
  }else if(!attachment.file.type.startsWith("image")){
125
130
  // ---------------------------------------------------------------------
@@ -158,7 +163,8 @@ export class ConversationPreviewComponent implements OnInit {
158
163
  that.arrayFiles.push({metadata});
159
164
  if (!that.fileSelected) {
160
165
  that.fileSelected = Object.assign({}, metadata)
161
- that.fileSelected = Object.assign(that.fileSelected, that.getMetadataSize(that.fileSelected))
166
+ // that.fileSelected = Object.assign(that.fileSelected, that.getMetadataSize(that.fileSelected))
167
+ that.sizeImage = that.getMetadataSize(that.fileSelected)
162
168
  }
163
169
  };
164
170
  }
@@ -0,0 +1,12 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { BrandService } from './brand.service';
4
+
5
+ describe('BrandService', () => {
6
+ beforeEach(() => TestBed.configureTestingModule({}));
7
+
8
+ it('should be created', () => {
9
+ const service: BrandService = TestBed.get(BrandService);
10
+ expect(service).toBeTruthy();
11
+ });
12
+ });
@@ -0,0 +1,232 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { environment } from '../../environments/environment';
4
+
5
+ // import brand from "../../assets/brand/brand.json";
6
+ // import * as brand from 'assets/brand/brand.json';
7
+ import { TranslateService } from '@ngx-translate/core';
8
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
9
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
10
+ import { AppConfigService } from './app-config.service';
11
+ import { BrandResources } from '../utils/BrandResources';
12
+
13
+ // const swal = require('sweetalert');
14
+
15
+ @Injectable()
16
+ export class BrandService {
17
+
18
+ // "brandSrc":"https://tiledeskbrand.nicolan74.repl.co/mybrand",
19
+
20
+ public brand: any;
21
+
22
+ _brand = {
23
+ DASHBOARD: {
24
+ META_TITLE: "Tiledesk Support Dashboard",
25
+ FAVICON_URL: "https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v13-300x300.png",
26
+ "company_name": "Tiledesk",
27
+ "company_site_name": "tiledesk.com",
28
+ "company_site_url": "https://www.tiledesk.com",
29
+ "company_logo_white__url": "assets/img/logos/tiledesk-logo_white_orange.svg",
30
+ "company_logo_black__url": "assets/img/logos/tiledesk_3.0_logo_black_v2_no_version.svg",
31
+ "company_logo_allwhite__url": "assets/img/logos/tiledesk_3.0_logo_all_white_v2_no_version.svg",
32
+ "company_logo_no_text__url": "assets/img/logos/tiledesk-solo-logo.png",
33
+ "privacy_policy_link_text": "Privacy Policy",
34
+ "privacy_policy_url": "https://www.tiledesk.com/privacy.html",
35
+ "display_terms_and_conditions_link": true,
36
+ "terms_and_conditions_url": "https://www.tiledesk.com/termsofservice.html",
37
+ "contact_us_email": "support@tiledesk.com",
38
+ "footer": {
39
+ "display_terms_and_conditions_link": true,
40
+ "display_contact_us_email": true
41
+ },
42
+ "recent_project_page": {
43
+ "company_logo_black__width": "130px"
44
+ },
45
+ "signup_page": {
46
+ "display_terms_and_conditions_link": true
47
+ },
48
+ "handle_invitation_page": {
49
+ "company_logo_45x45": "assets/img/logos/tiledesk-solo-logo.png"
50
+ },
51
+ "wizard_create_project_page": {
52
+ "logo_x_rocket": "assets/img/logos/logo_x_rocket4x4.svg"
53
+ },
54
+ "wizard_install_widget_page": {
55
+ "logo_on_rocket": "assets/img/logos/tiledesk-solo-logo.png"
56
+ },
57
+ },
58
+ CHAT: {
59
+
60
+ },
61
+ WIDGET: {
62
+ LOGO_CHAT: "https://smartflows-eu-public.s3.eu-central-1.amazonaws.com/imagicle-resources/SmartflowsLogo-NoText.svg",
63
+ POWERED_BY: "<a tabindex='-1' target='_blank href='https://www.imagicle.com/en/products/conversational-ai/'><img src='https://smartflows-eu-public.s3.eu-central-1.amazonaws.com/imagicle-resources/SmartflowsLogo-NoText.svg'/><span> Powered by Conversational AI</span></a>",
64
+ },
65
+ CDS: {
66
+ META_TITLE:"Design Studio",
67
+ FAVICON_URL: "https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v13-300x300.png",
68
+ INFO_MENU_ITEMS: [
69
+ { key: 'HELP_CENTER', icon: "", src:"", status: "inactive"},
70
+ { key: 'ROAD_MAP', icon: "", src:"", status: "inactive"},
71
+ { key: 'FEEDBACK', icon: "", src:"", status: "inactive"},
72
+ { key: 'SUPPORT', icon: "", src:"", status: "inactive"},
73
+ { key: 'CHANGELOG', icon: "", src:"", status: "inactive"},
74
+ { key: 'GITHUB', icon: "", src:"", status: "inactive"},
75
+ ]
76
+ },
77
+ COMMON: {
78
+ COMPANY_LOGO:"assets/logos/tiledesk_logo.svg",
79
+ COMPANY_LOGO_NO_TEXT:"assets/logos/tiledesk_logo.svg",
80
+ BASE_LOGO: "assets/logos/tiledesk_logo.svg",
81
+ BASE_LOGO_NO_TEXT: "assets/logos/tiledesk_logo.svg",
82
+ BASE_LOGO_WHITE: "assets/logos/tiledesk-logo_new_white.svg",
83
+ BASE_LOGO_WHITE_NO_TEXT:"",
84
+ COMPANY_NAME: "Tiledesk",
85
+ BRAND_NAME: "Tiledesk",
86
+ COMPANY_SITE_NAME:"tiledesk.com",
87
+ COMANY_SITE_URL:"https://www.tiledesk.com",
88
+ CONTACT_US_EMAIL: "support@tiledesk.com",
89
+ COMPANY_PRIMARY_COLOR:"",
90
+ DOCS: true
91
+ }
92
+ }
93
+
94
+ public assetBrand: any;
95
+ // public brand = brand
96
+ // local_url = '/assets/brand/brand.json';
97
+ warning: string;
98
+ loadBrandError: string;
99
+
100
+ private logger: LoggerService = LoggerInstance.getInstance();
101
+
102
+ constructor(
103
+ private httpClient: HttpClient,
104
+ private translate: TranslateService,
105
+ private appConfig: AppConfigService
106
+ ) {
107
+ this.getTranslations()
108
+ this.brand = this._brand
109
+ }
110
+
111
+ getTranslations() {
112
+ this.translate.get('Warning')
113
+ .subscribe((text: string) => {
114
+ this.warning = text;
115
+ });
116
+
117
+ this.translate.get('RelatedKnowledgeBase')
118
+ .subscribe((text: string) => {
119
+ this.loadBrandError = text;
120
+ });
121
+ }
122
+
123
+ isEmpty(url: string) {
124
+ return (url === undefined || url == null || url.length <= 0) ? true : false;
125
+ }
126
+
127
+ // getData() {
128
+ // return this.httpClient.get('/assets/brand/brand.json');
129
+ // }
130
+
131
+
132
+
133
+ async loadBrand() {
134
+ // this.getData()
135
+ // .subscribe(data => {
136
+ // this.assetBrand = data
137
+ // console.log('[BRAND-SERV] BRAND RETIEVED FROM ASSET assetBrand ', this.assetBrand);
138
+ // });
139
+
140
+ // let url = ''
141
+ // if (environment.remoteConfig === false) {
142
+
143
+ // if (environment.hasOwnProperty("brandSrc")) {
144
+
145
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env has Property brandSrc');
146
+ // const remoteBrandUrl = this.isEmpty(environment['brandSrc']);
147
+
148
+ // if (!remoteBrandUrl) {
149
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env brandSrc is empty ? ', remoteBrandUrl);
150
+ // url = environment['brandSrc']
151
+ // } else {
152
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env brandSrc is empty ? ', remoteBrandUrl, ' -> load from assets')
153
+ // this.brand = this._brand;
154
+ // }
155
+ // } else {
156
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is false - env NOT has Property brandSrc -> load from assets');
157
+ // this.brand = this._brand;
158
+ // }
159
+ // } else {
160
+ // const res = await this.httpClient.get(environment['remoteConfigUrl']).toPromise();
161
+ // this.logger.log('[BRAND-SERV] loadBrand - remoteConfig -> true get remoteConfig response ', res);
162
+
163
+ // // const remoteConfigData = JSON.parse(res['_body'])
164
+ // const remoteConfigData = res
165
+ // // this.logger.log('BrandService loadBrand - remoteConfig is true - get remoteConfigData res ', remoteConfigData);
166
+
167
+ // if (remoteConfigData.hasOwnProperty("brandSrc")) {
168
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData has Property brandSrc');
169
+
170
+ // const remoteBrandUrl = this.isEmpty(remoteConfigData['brandSrc']);
171
+ // if (!remoteBrandUrl) {
172
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData brandSrc is empty ?', remoteBrandUrl);
173
+
174
+ // url = remoteConfigData['brandSrc']
175
+
176
+
177
+ // } else {
178
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData brandSrc is empty ?', remoteBrandUrl, ' -> load from assets');
179
+
180
+ // this.brand = this._brand;
181
+ // }
182
+
183
+ // } else {
184
+ // this.logger.log('[BRAND-SERV] loadBrand remoteConfig is true - remoteConfigData NOT has Property brandSrc -> load from assets');
185
+ // // this.setBrand(this.local_url)
186
+ // // url = this.local_url
187
+ // this.brand = this._brand;
188
+ // }
189
+ // }
190
+ const that = this
191
+ try {
192
+ let url = this.appConfig.getConfig().brandSrc
193
+ if (url && url !== 'CHANGEIT') {
194
+ console.log('[BRAND-SERV] **** GET BRAND FROM URL ****', url);
195
+ const data = await this.httpClient.get(url).toPromise();
196
+
197
+
198
+ this.brand =data
199
+
200
+ console.log('[BRAND-SERV] loadBrand - brand: ', this.brand);
201
+
202
+ const resources = new BrandResources(this);
203
+ resources.loadResources()
204
+ }
205
+ } catch (err) {
206
+ console.error('[BRAND-SERV] loadBrand error : ', err);
207
+
208
+ this.brand = this._brand;
209
+ // this.notify.showNotificationChangeProject('ops', 2, 'done');
210
+ // this.displaySwalAlert(err)
211
+ }
212
+
213
+
214
+ }
215
+
216
+ // displaySwalAlert(err) {
217
+ // swal({
218
+ // title: this.warning,
219
+ // text: 'An error occurred while uploading your brand. Error code: ' + err.status,
220
+ // icon: "warning",
221
+ // button: true,
222
+ // dangerMode: false,
223
+ // })
224
+ // }
225
+
226
+ getBrand() {
227
+ //this.logger.log('BrandService getBrand has been called - brand: ', this.brand);
228
+ return { ...this.brand['WIDGET'], ...this.brand['COMMON'] }
229
+ }
230
+
231
+
232
+ }
@@ -0,0 +1,38 @@
1
+ import { Injectable } from "@angular/core";
2
+ import { BrandService } from "../providers/brand.service";
3
+ import { BRAND_BASE_INFO, LOGOS_ITEMS } from "./utils-resources";
4
+
5
+ @Injectable({
6
+ providedIn: 'root'
7
+ })
8
+ export class BrandResources {
9
+
10
+ brand: {}
11
+
12
+ constructor(
13
+ brandService: BrandService
14
+ ) {
15
+ this.brand = brandService.getBrand()
16
+ }
17
+
18
+ loadResources(){
19
+ if(!this.brand){
20
+ return;
21
+ }
22
+
23
+ /** META TITLE and FAVICON */
24
+ document.title = this.brand['BRAND_NAME'] + ' ' + this.brand['META_TITLE']
25
+ // var icon = document.querySelector("link[rel~='icon']") as HTMLElement;
26
+ // icon.setAttribute('href', this.brand['FAVICON_URL'])
27
+
28
+ /** CSS */
29
+ document.documentElement.style.setProperty('--base-brand-color', this.brand['BRAND_PRIMARY_COLOR']);
30
+
31
+ /** BRAND_BASE_INFO */
32
+ Object.keys(BRAND_BASE_INFO).forEach(key => BRAND_BASE_INFO[key] = this.brand[key])
33
+
34
+ /** LOGOS_ITEMS */
35
+ Object.keys(LOGOS_ITEMS).forEach(key => { LOGOS_ITEMS[key].icon = this.brand[key] })
36
+
37
+ }
38
+ }
@@ -16,16 +16,13 @@ import { avatarPlaceholder, detectIfIsMobile, getParameterByName, setColorFromSt
16
16
  import { ConversationModel } from 'src/chat21-core/models/conversation';
17
17
  import { convertColorToRGBA } from 'src/chat21-core/utils/utils';
18
18
  import { Rule } from 'src/models/rule';
19
+ import { BRAND_BASE_INFO } from './utils-resources';
19
20
 
20
21
  @Injectable({
21
22
  providedIn: 'root'
22
23
  })
23
24
  export class Globals {
24
25
 
25
- BASE_LOCATION = 'https://widget.tiledesk.com/v2';
26
- POWERED_BY ='<a tabindex="-1" target="_blank" href="https://www.tiledesk.com/?utm_source=widget"><img src="https://support-pre.tiledesk.com/dashboard/assets/img/logos/tiledesk-solo_logo_new_gray.svg"/><span>Powered by Tiledesk</span></a>'
27
- DEFAULT_LOGO_CHAT = '/assets/images/tiledesk_logo_white_small.svg';
28
-
29
26
  // ============ BEGIN: SET FUNCTION BY UTILS ==============//
30
27
  // getParameterByName = getParameterByName;
31
28
  // convertColorToRGBA = convertColorToRGBA;
@@ -226,7 +223,6 @@ export class Globals {
226
223
  * 1: initParameters
227
224
  */
228
225
  initDefafultParameters() {
229
-
230
226
  let wContext: any = window;
231
227
  if (window.frameElement && window.frameElement.getAttribute('tiledesk_context') === 'parent') {
232
228
  wContext = window.parent;
@@ -239,7 +235,7 @@ export class Globals {
239
235
  this.windowContext = wContext;
240
236
 
241
237
  // ============ BEGIN: SET EXTERNAL PARAMETERS ==============//
242
- this.baseLocation = this.BASE_LOCATION;
238
+ this.baseLocation = 'https://widget.tiledesk.com/v2';
243
239
  this.autoStart = true;
244
240
  this.startHidden = false;
245
241
  /** start Authentication and startUI */
@@ -309,9 +305,9 @@ export class Globals {
309
305
  /** allows the user to download the chat transcript. The download button appears
310
306
  when the chat is closed by the operator. Permitter values: true, false.
311
307
  Default value: false */
312
- this.poweredBy = this.POWERED_BY;
308
+ this.poweredBy = BRAND_BASE_INFO.POWERED_BY;
313
309
  /** link nel footer widget */
314
- this.logoChat = this.BASE_LOCATION + this.DEFAULT_LOGO_CHAT;
310
+ this.logoChat = BRAND_BASE_INFO.LOGO_CHAT;
315
311
  /** url img logo */
316
312
  this.marginX = '20px';
317
313
  /** set margin left or rigth widget */
@@ -0,0 +1,21 @@
1
+ export const BRAND_BASE_INFO: { [key: string] : string} ={
2
+ COMPANY_NAME: "Tiledesk",
3
+ BRAND_NAME: "Tiledesk",
4
+ COMPANY_SITE_NAME:"tiledesk.com",
5
+ COMPANY_SITE_URL:"https://www.tiledesk.com",
6
+ CONTACT_US_EMAIL: "support@tiledesk.com",
7
+ FAVICON: "https://tiledesk.com/wp-content/uploads/2022/07/tiledesk_v13-300x300.png",
8
+ META_TITLE:"Design Studio",
9
+ LOGO_CHAT:"https://widget.tiledesk.com/v2/assets/images/tiledesk_logo_white_small.svg",
10
+ POWERED_BY:"<a tabindex='-1' target='_blank' ref='https://www.tiledesk.com/?utm_source=widget'><img src='https://support-pre.tiledesk.com/dashboard/assets/img/logos/tiledesk-solo_logo_new_gray.svg'/><span>Powered by Tiledesk</span></a>",
11
+ }
12
+
13
+ export const LOGOS_ITEMS: { [key: string] : { label: string, icon: string }} ={
14
+ COMPANY_LOGO: {label: BRAND_BASE_INFO.COMPANY_NAME, icon: 'assets/logos/tiledesk_logo.svg'},
15
+ COMPANY_LOGO_NO_TEXT: {label: BRAND_BASE_INFO.COMPANY_NAME, icon: 'assets/logos/tiledesk_logo_no_text.svg'},
16
+ BASE_LOGO: {label: BRAND_BASE_INFO.BRAND_NAME, icon: 'assets/logos/tiledesk_logo.svg'},
17
+ BASE_LOGO_NO_TEXT: {label: BRAND_BASE_INFO.BRAND_NAME, icon: 'assets/logos/tiledesk_logo_no_text.svg'},
18
+ BASE_LOGO_WHITE: { label: BRAND_BASE_INFO.BRAND_NAME, icon: '"assets/logos/tiledesk-logo_new_white.svg'},
19
+ BASE_LOGO_WHITE_NO_TEXT: { label: BRAND_BASE_INFO.BRAND_NAME, icon: '"assets/logos/tiledesk-logo_new_white.svg'},
20
+ BASE_LOGO_GRAY: { label: BRAND_BASE_INFO.BRAND_NAME, icon: 'https://support-pre.tiledesk.com/dashboard/assets/img/logos/tiledesk-logo_new_gray.svg'}
21
+ }
@@ -1710,13 +1710,14 @@
1710
1710
  <div class="row method_container">
1711
1711
  <button class="btn btn-light" onclick="onClickTestButton('open')">Open <em class="fa-arrow-up fa"></em></button>
1712
1712
  <button class="btn btn-light" onclick="onClickTestButton('close')">Close <em class="fa fa-arrow-down"></em></button>
1713
- <button class="btn btn-light" onclick="onClickTestButton('hide')">Hide</button>
1714
- <button class="btn btn-light" onclick="onClickTestButton('show')">Show</button>
1715
- <button class="btn btn-light" onclick="onClickTestButton('startConversation')">Start Conversation</button>
1713
+ <button class="btn btn-light" onclick="onClickTestButton('hide')">Hide <em class="fa fa-eye-slash"></em></button>
1714
+ <button class="btn btn-light" onclick="onClickTestButton('show')">Show <em class="fa fa-eye"></em></button>
1715
+ <button class="btn btn-light" onclick="onClickTestButton('startConversation')">Start Conversation <em class="fa fa-play"></em></button>
1716
+ <button class="btn btn-light" onclick="onClickTestButton('clearStorage')">Clear data <em class="fa fa-trash"></em></button>
1716
1717
  <button class="btn btn-light" onclick="onClickTestButton('dispose')">Dispose</button>
1717
1718
  <button class="btn btn-light" onclick="onClickTestButton('showCallout')">Show callout</button>
1718
- <button class="btn btn-light" onclick="onClickTestButton('reInit')">ReInit</button>
1719
- <button class="btn btn-light" onclick="onClickTestButton('restart')">ReStart</button>
1719
+ <button class="btn btn-light" onclick="onClickTestButton('reInit')">ReInit <em class="fa fa-rotate-right"></em></button>
1720
+ <button class="btn btn-light" onclick="onClickTestButton('restart')">ReStart <em class="fa fa-rotate-right"></em></button>
1720
1721
  <button class="btn btn-light" onclick="onClickTestButton('logout')">LogOut</button>
1721
1722
  </div>
1722
1723
  <div class="row section">
@@ -131,6 +131,7 @@ export class TiledeskAuthService {
131
131
  this.appStorage.removeItem('tiledeskToken');
132
132
  this.appStorage.removeItem('currentUser');
133
133
  this.setCurrentUser(null);
134
+ this.setTiledeskToken(null);
134
135
  }
135
136
 
136
137
 
@@ -191,4 +192,8 @@ export class TiledeskAuthService {
191
192
  return this.tiledeskToken;
192
193
  }
193
194
 
195
+ setTiledeskToken(token: string) {
196
+ this.tiledeskToken = token
197
+ }
198
+
194
199
  }
@@ -0,0 +1,143 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <base href="./">
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Widget Test Page</title>
8
+ <script type="application/javascript" async>
9
+ // Handler for .ready() called.
10
+ window.tiledeskSettings =
11
+ {
12
+ // PRE:
13
+ // projectid: "6066e60cc3dade4e7389d182", //mqtt
14
+ projectid:"615577276b34e900353c1a63", //"62445574a0353b0035a05f27", //"6013ec749b32000045be650e", // firebase
15
+ // projectid: "609b8efa8732eb00141763d9", //mqtt-docker
16
+ // projectid: "61ae2f221c081a001a045961",//" 61b7840c7b4c750013b69025", //native-mqtt
17
+ // preChatForm: true,
18
+ align:'left',
19
+ calloutTimer: 5,
20
+ // calloutTitle: 'TITOLO CALLOUT',
21
+ // calloutMsg: 'messaggio callout widget',
22
+ // welcomeTitle: 'CIAO CLIENT',
23
+ // welcomeMsg: 'Messaggio benvenuto widget',
24
+ widgetTitle: "widget Title Test",
25
+ //startFromHome: false,
26
+ // logoChat: 'https://miro.medium.com/proxy/1*8mpWApzQD5gZZlnYYUkbcA.png',
27
+ // lang: 'fr',
28
+ // hideHeaderCloseButton: true,1626341000398
29
+ // isOpen: true,
30
+ // fullscreenMode: true,
31
+ // themeColor: '#ffcb05',
32
+ // themeForegroundColor: '#000000',
33
+ // departmentID : "615579216b34e900353c1da0",
34
+ // isShown: true,
35
+ allowTranscriptDownload: true,
36
+ marginX: "100px",
37
+ // marginY: "200px",
38
+ // startHidden: true,
39
+ // persistence: 'session',
40
+ // showWaitTime: false,
41
+ autoStart: false,
42
+ showAvailableAgents: true,
43
+ // showLogoutOption: false,
44
+ isLogEnabled: true,
45
+ // logLevel: "DEBUG"
46
+ // userFullname: " ",
47
+ // userEmail: "",
48
+ // autoStart: false,
49
+ // persistence: 'session'
50
+ // tenant: "tenant test",
51
+ // showAttachmentButton: false,
52
+ // privacyField: 'Accetto i termini della privacy <a style="text-transform: none" target="_blank" href="http://www.tiledesk.com/privacy.html">Privacy Policy</a>'
53
+ // customAttributes: {"nome": "Andrea", "nazione": "italia", "userFullname":"carlo"},
54
+ // bubbleSentBackground: "#828282",
55
+ // bubbleSentTextColor: "#b61416",
56
+ // bubbleReceivedBackground: "rgb(182, 20, 22)",
57
+ // bubbleReceivedTextColor: "rgb(247, 247, 247)",
58
+ // buttonBackgroundColor: "#828282",
59
+ // buttonTextColor: "#b61416",
60
+ // buttonHoverTextColor: "#828282",
61
+ // buttonHoverBackgroundColor: "#b61416",
62
+ // preChatFormJson: [{"name": "userFullname", "type":"text", "mandatory":true, "label":"LABEL_FIELD_NAME"}]
63
+ hideSettings: false
64
+ };
65
+
66
+ (function(d, s, id) {
67
+ var w = window; var d = document; var i = function () {i.c(arguments);};
68
+ i.q = []; i.c = function (args) {i.q.push(args);}; w.Tiledesk = i;
69
+ var js, fjs = d.getElementsByTagName(s)[0];
70
+ if (d.getElementById(id)) return;
71
+ js = d.createElement(s);
72
+ js.id = id; js.async = true; js.src = "./launch.js"; //
73
+ fjs.parentNode.insertBefore(js, fjs);
74
+
75
+ }(document, 'script', 'tiledesk-jssdk'));
76
+
77
+
78
+ window.Tiledesk('logout');
79
+
80
+ window.Tiledesk('onLoadParams', function(event_data) {
81
+ console.log("onLoadParams Tiledesk FN", event_data);
82
+ // let token = 'JWT eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI4ODgzNTQ4Ny05ZjllLTRiMGItOGRmNy0wMDA0NWUwYTY4NjYiLCJmaXJzdG5hbWUiOiJndWVzdCM4ODgzIiwiaWQiOiI4ODgzNTQ4Ny05ZjllLTRiMGItOGRmNy0wMDA0NWUwYTY4NjYiLCJmdWxsTmFtZSI6Imd1ZXN0Izg4ODMgIiwiaWF0IjoxNzEyNzQyNTA1LCJhdWQiOiJodHRwczovL3RpbGVkZXNrLmNvbSIsImlzcyI6Imh0dHBzOi8vdGlsZWRlc2suY29tIiwic3ViIjoiZ3Vlc3QiLCJqdGkiOiJkNDJhZmY5MS0xZTgxLTQyYjAtOGIyYS1mMjU3YzdmMzc4YWEifQ.UCKvk5VE4XMlXKB20hjOYZTuq3YE1XyfpcXQfJnwclgvFaoyZzIuX5_1mz1ZMauWMV69ZecwkkwKb1S6rPH4bf0VqWO0Ez9LJYA1ZI0FU4HZO4oAGivYh-tPArP41k7bxl369314QKesm4-a7_S81T_i4wrmB663u7th5WVKjkg'
83
+ // window.Tiledesk('signInWithCustomToken',token);
84
+ window.Tiledesk('signInAnonymous')
85
+
86
+ });
87
+
88
+ window.Tiledesk('onBeforeInit', function(event_data) {
89
+ console.log("onBeforeInit Tiledesk FN", event_data);
90
+
91
+ });
92
+
93
+ window.Tiledesk('onAuthStateChanged', function(event_data) {
94
+ console.log("onAuthStateChanged FN", event_data);
95
+ if (event_data.detail.isLogged) {
96
+ document.getElementById("status").innerHTML = "Signed in.";
97
+ window.Tiledesk('show')
98
+ }
99
+ });
100
+
101
+ window.Tiledesk('onLoggedOut', function(event_data) {
102
+ console.log("onLoggedOut FN", event_data);
103
+ });
104
+
105
+
106
+
107
+
108
+ function authenticate(email, password, callback) {
109
+ // Endpoint's backend source code: https://replit.com/@tiledesk/tiledesk-jwt-token-example#index.js
110
+ const options = {
111
+ url: `https://87d1bd2e-fa44-4b02-b8ab-e7797f7d92f7-00-eswv3xnlk9yn.kirk.replit.dev/authpre`, // https://tiledesk-jwt-token-example.tiledesk.repl.co/auth
112
+ method: 'POST'
113
+ };
114
+ let xmlhttp = new XMLHttpRequest();
115
+ xmlhttp.open(options.method, options.url, true);
116
+ xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
117
+ xmlhttp.onreadystatechange = function () {
118
+ if (callback && xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.responseText) {
119
+ try {
120
+ const json = JSON.parse(xmlhttp.responseText);
121
+ let token = json.token;
122
+ if (token && !token.startsWith("JWT ")) {
123
+ token = "JWT " + token;
124
+ }
125
+ callback(null, token);
126
+ }
127
+ catch (err) {
128
+ callback(err, null);
129
+ }
130
+ }
131
+ };
132
+ xmlhttp.send(JSON.stringify({
133
+ "email": email,
134
+ "password": password
135
+ }));
136
+ }
137
+ </script>
138
+ </head>
139
+ <body>
140
+ <h1>Tiledesk Custom JWT Authentication live App</h1>
141
+ <h2 id="status">Authenticating...</h2>
142
+ </body>
143
+ </html>