@chat21/chat21-ionic 3.0.59-rc15 → 3.0.59-rc16

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,11 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.59-rc16
4
+ - Changes in config.xml the value of the "SplashScreen"
5
+ - Improves the method to avoid page reloading when an agent clicks the "Open Chat" button of the dashboard on the realtime and non-real time conversation list page and on the conversation detail page
6
+ - Modifies the "app-config" service by adding the ability to pass relative URLs to the websocket
7
+ - Adds "wsUrlRel" property to env.sample, chat-config-template.json and chat-config.json
8
+
3
9
  ### 3.0.59-rc15
4
10
  - Implements a method in app.components that counts and stores the number of open Chat tabs
5
11
  - Implements a method on the conversation list page that prevents a new chat tab from opening when the agent clicks "Open Chat" from the dashboard
package/config.xml CHANGED
@@ -18,17 +18,8 @@
18
18
  <preference name="SplashMaintainAspectRatio" value="true" />
19
19
  <preference name="FadeSplashScreenDuration" value="300" />
20
20
  <preference name="SplashShowOnlyFirstTime" value="false" />
21
- <preference name="SplashScreen" value="assets/splash_white.jpg" />
21
+ <preference name="SplashScreen" value="assets/logo.png" />
22
22
  <preference name="SplashScreenDelay" value="3000" />
23
- <platform name="browser">
24
- <preference name="SplashScreen" value="assets/transparent.png" />
25
- <preference name="AutoHideSplashScreen" value="true" />
26
- <preference name="SplashScreenDelay" value="3000" />
27
- <preference name="SplashScreenBackgroundColor" value="white" />
28
- <preference name="ShowSplashScreen" value="false" />
29
- <preference name="SplashScreenWidth" value="600" />
30
- <preference name="SplashScreenHeight" value="300" />
31
- </platform>
32
23
  <platform name="android">
33
24
  <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
34
25
  <application android:networkSecurityConfig="@xml/network_security_config" />
package/env.sample CHANGED
@@ -1,7 +1,7 @@
1
1
  API_BASEIMAGE_URL=CHANGEIT
2
2
  DASHBOARD_URL=https://YOUR_DASHBOARD_URL
3
3
  WS_URL=wss://YOUR_TILEDESK_SERVER_URL?token=
4
-
4
+ WS_URL_RELATIVE=********
5
5
  SERVER_BASE_URL=http://localhost:3000/
6
6
 
7
7
  CHAT21_ENGINE=mqtt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
- "version": "3.0.59-rc15",
3
+ "version": "3.0.59-rc16",
4
4
  "author": "Tiledesk SRL",
5
5
  "homepage": "https://ionicframework.com/",
6
6
  "scripts": {
@@ -2,7 +2,7 @@ import { URL_SOUND_LIST_CONVERSATION } from './../chat21-core/utils/constants';
2
2
  import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
3
3
  import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
4
4
 
5
- import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, } from '@angular/core';
5
+ import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, AfterViewInit, } from '@angular/core';
6
6
  import { Config, Platform, IonRouterOutlet, IonSplitPane, NavController, MenuController, AlertController, IonNav, ToastController } from '@ionic/angular';
7
7
  import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
8
8
  import { Subscription, VirtualTimeScheduler } from 'rxjs';
@@ -57,7 +57,7 @@ import { NetworkService } from './services/network-service/network.service';
57
57
  import * as PACKAGE from 'package.json';
58
58
  import { filter } from 'rxjs/operators'
59
59
  import { WebSocketJs } from './services/websocket/websocket-js';
60
-
60
+ import { Location } from '@angular/common'
61
61
  // import { filter } from 'rxjs/operators';
62
62
 
63
63
  @Component({
@@ -108,7 +108,7 @@ export class AppComponent implements OnInit {
108
108
  private splashScreen: SplashScreen,
109
109
  private statusBar: StatusBar,
110
110
  private appConfigProvider: AppConfigProvider,
111
- private events: EventsService,
111
+ public events: EventsService,
112
112
  public config: Config,
113
113
  public chatManager: ChatManager,
114
114
  public translate: TranslateService,
@@ -139,14 +139,67 @@ export class AppComponent implements OnInit {
139
139
  // private tiledeskService: TiledeskService,
140
140
  private networkService: NetworkService,
141
141
  public webSocketJs: WebSocketJs,
142
+ public location: Location
142
143
  ) {
143
144
 
144
145
  this.saveInStorageNumberOfOpenedChatTab();
145
146
  this.getPageState();
147
+
148
+ // location.subscribe((val) => {
149
+
150
+ // console.log('location subscribe val', val)
151
+ // if (val.type == "hashchange") {
152
+ // const convId = getParameterByName('convId')
153
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
154
+ // const requesterFullaname = getParameterByName('requester_fullaname')
155
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', requesterFullaname);
156
+
157
+ // this.navigateToDetail(convId, requesterFullaname)
158
+
159
+ // this.events.publish('convid:haschanged', convId);
160
+ // }
161
+ // });
162
+
163
+ window.addEventListener('hashchange', function () {
164
+ console.log('location changed!');
165
+ const convId = getParameterByName('convId')
166
+ console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
167
+
168
+ if (convId) {
169
+ setTimeout(() => {
170
+ events.publish('convid:haschanged', convId);
171
+ }, 0);
172
+ }
173
+
174
+
175
+ // this.navigateToDetail(convId, requesterFullaname)
176
+
177
+
178
+
179
+ })
180
+
181
+
182
+ // router.events.subscribe((val) => {
183
+ // this.checkCurrentURL();
184
+ // });
146
185
  // FOR TEST
147
186
  // const last_project = { "user_available": true, "number_assigned_requests": 59, "last_login_at": "2021-08-09T17:30:55.234Z", "status": "active", "_id": "6112bc8f58c958003495a2cb", "id_project": { "status": 100, "_id": "60ffe291f725db00347661ef", "name": "27-LUGLIO-21-STRIPE-TEST", "activeOperatingHours": false, "createdBy": "608ad02d3a4dc000344ade17", "profile": { "name": "pro", "trialDays": 30, "agents": 5, "type": "payment", "subStart": "2021-11-18T10:42:41.000Z", "subEnd": "2021-11-19T10:42:41.000Z", "subscriptionId": "sub_Jvf4kABe9t8JvX", "last_stripe_event": "invoice.payment_succeeded" }, "versions": 20115, "channels": [{ "name": "chat21" }], "createdAt": "2021-07-27T10:40:17.752Z", "updatedAt": "2021-11-18T11:55:01.346Z", "__v": 0, "widget": { "preChatForm": true, "preChatFormJson": [{ "name": "userFullname", "type": "text", "mandatory": true, "label": { "en": "Your name", "it": "Il tuo nome" } }, { "name": "userEmail", "type": "text", "mandatory": true, "regex": "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/", "label": { "en": "Your email", "it": "La tua email" }, "errorLabel": { "en": "Invalid email address", "it": "Indirizzo email non valido" } }, { "name": "tel", "mandatory": true, "label": { "en": "Your phone number", "it": "Il tuo numero di telefono" } }], "preChatFormCustomFieldsEnabled": true }, "trialExpired": true, "trialDaysLeft": 84, "isActiveSubscription": true, "id": "60ffe291f725db00347661ef" }, "id_user": "60aa0fef1482fe00346854a7", "role": "admin", "createdBy": "608ad02d3a4dc000344ade17", "createdAt": "2021-08-10T17:51:11.318Z", "updatedAt": "2021-11-19T08:08:21.437Z", "__v": 0, "presence": { "status": "online", "changedAt": "2021-11-19T08:08:21.432Z" }, "isAuthenticated": true, "id": "6112bc8f58c958003495a2cb" }
148
187
  // localStorage.setItem('last_project', JSON.stringify(last_project))
149
188
  }
189
+ navigateToDetail(convId, requesterFullaname) {
190
+ console.log('[APP-COMP] navigateToDetail ');
191
+ let pageUrl = 'conversation-detail/' + convId + '/' + requesterFullaname + '/active';
192
+ this.router.navigateByUrl(pageUrl);
193
+ this.location.replaceState('conversation-detail/' + convId + '/' + requesterFullaname + '/active');
194
+ }
195
+
196
+
197
+ // private checkCurrentURL() {
198
+ // console.log("location : " + window.location.pathname)
199
+ // const convId = getParameterByName('convId')
200
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
201
+ // this.events.publish('convid:haschanged', convId);
202
+ // }
150
203
  saveInStorageNumberOfOpenedChatTab() {
151
204
  this.logger.log('Calling saveInStorageChatOpenedTab!');
152
205
 
@@ -165,6 +218,7 @@ export class AppComponent implements OnInit {
165
218
  }
166
219
 
167
220
  getPageState() {
221
+
168
222
  const getState = () => {
169
223
  localStorage.setItem('visibilityState', document.visibilityState)
170
224
  if (document.visibilityState === 'hidden') {
@@ -184,6 +238,7 @@ export class AppComponent implements OnInit {
184
238
  // }
185
239
 
186
240
  const logStateChange = (nextState) => {
241
+
187
242
  const prevState = state;
188
243
  if (nextState !== prevState) {
189
244
  console.log(`State change: ${prevState} >>> ${nextState}`);
@@ -243,7 +298,7 @@ export class AppComponent implements OnInit {
243
298
  if (token) {
244
299
  // this.isOnline = false;
245
300
  // this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with this.isOnline ', this.isOnline)
246
- this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName ', token)
301
+ console.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName ', token)
247
302
  // save token in local storage then
248
303
 
249
304
  const storedToken = this.appStorageService.getItem('tiledeskToken');
@@ -255,11 +310,21 @@ export class AppComponent implements OnInit {
255
310
  this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
256
311
  }
257
312
  }
258
- this.initializeApp('oninit');
259
313
 
314
+
315
+ this.initializeApp('oninit');
260
316
  this.listenToPostMsgs();
261
317
  }
262
318
 
319
+ // ngAfterViewInit() {
320
+ // console.log('[APP-COMP] ngAfterViewInit')
321
+ // }
322
+
323
+ // ngDoCheck(){
324
+ // console.log('[APP-COMP] ngDoCheck')
325
+ // }
326
+
327
+
263
328
 
264
329
 
265
330
  listenToPostMsgs() {
@@ -846,7 +911,7 @@ export class AppComponent implements OnInit {
846
911
 
847
912
  this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
848
913
 
849
- this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
914
+ console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
850
915
  const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
851
916
  this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
852
917
 
@@ -865,7 +930,7 @@ export class AppComponent implements OnInit {
865
930
  * apro dettaglio conversazione
866
931
  */
867
932
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
868
- this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
933
+ console.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
869
934
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
870
935
  this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
871
936
  }
@@ -106,6 +106,22 @@ export class ConversationListPage implements OnInit {
106
106
  this.listenGoOnline();
107
107
  this.listenGoOffline();
108
108
  this.listenToSwPostMessage();
109
+ this.listenConvIdHasChanged();
110
+
111
+ }
112
+
113
+ listenConvIdHasChanged() {
114
+ this.events.subscribe('convid:haschanged', (convId) => {
115
+ console.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', convId);
116
+ // this.events.unsubscribe('profileInfoButtonClick:logout')
117
+ // this.setUidConvSelected(uid , 'active')
118
+ // const conversation = {}
119
+ if (convId) {
120
+ const conversationSelected = this.conversations.find(item => item.uid === convId);
121
+ console.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - conversationSelected', conversationSelected);
122
+ this.onConversationSelected(conversationSelected)
123
+ }
124
+ });
109
125
 
110
126
  }
111
127
 
@@ -121,19 +137,19 @@ export class ConversationListPage implements OnInit {
121
137
  this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
122
138
  this.route.queryParams.subscribe(params => {
123
139
  this.logger.log('[CONVS-LIST-PAGE] ngOnInit params', params);
124
- if (params && params.convselected) {
125
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params convselected:', params.convselected);
126
-
127
- const conversationSelected = this.conversations.find(item => item.uid === params.convselected);
128
- if (conversationSelected) {
129
- this.conversationSelected = conversationSelected;
130
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params convselected - conversationSelected: ', this.conversationSelected);
131
- this.navigateByUrl('active', params.convselected)
132
- }
133
-
134
- } else {
135
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
136
- }
140
+ // if (params && params.convselected) {
141
+ // console.log('[CONVS-LIST-PAGE] ngOnInit params convselected:', params.convselected);
142
+
143
+ // const conversationSelected = this.conversations.find(item => item.uid === params.convselected);
144
+ // if (conversationSelected) {
145
+ // this.conversationSelected = conversationSelected;
146
+ // console.log('[CONVS-LIST-PAGE] ngOnInit params convselected - conversationSelected: ', this.conversationSelected);
147
+ // this.navigateByUrl('active', params.convselected)
148
+ // }
149
+
150
+ // } else {
151
+ // console.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
152
+ // }
137
153
  if (params && params.contact_id && params.contact_fullname) {
138
154
  this.logger.log('[CONVS-LIST-PAGE] ngOnInit params contact_id:', params.contact_id, 'contact_fullname ', params.contact_fullname);
139
155
  this.router.navigateByUrl('conversation-detail/' + params.contact_id + '/' + params.contact_fullname + '/new');
@@ -153,7 +169,7 @@ export class ConversationListPage implements OnInit {
153
169
  });
154
170
  }
155
171
 
156
-
172
+
157
173
 
158
174
  getSupportMode() {
159
175
  this.supportMode = this.appConfigProvider.getConfig().supportMode;
@@ -335,7 +351,6 @@ export class ConversationListPage implements OnInit {
335
351
  }
336
352
 
337
353
  listenGoOnline() {
338
-
339
354
  this.events.subscribe('go:online', (goonline) => {
340
355
  this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline', goonline);
341
356
  // this.events.unsubscribe('profileInfoButtonClick:logout')
@@ -471,8 +486,11 @@ export class ConversationListPage implements OnInit {
471
486
  * evento richiamato quando si seleziona un utente nell'elenco degli user
472
487
  * apro dettaglio conversazione
473
488
  */
489
+ // --------------------------------
490
+ // !!!!!! IS USED? ?????
491
+ // ------------------------------
474
492
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
475
- this.logger.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
493
+ console.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
476
494
  this.uidConvSelected = user.uid;
477
495
  this.logger.log('[CONVS-LIST-PAGE] ************** uidConvSelected ', this.uidConvSelected);
478
496
  // this.conversationsHandlerService.uidConvSelected = user.uid;
@@ -561,6 +579,7 @@ export class ConversationListPage implements OnInit {
561
579
  this.initConversationsHandler();
562
580
  this.initVariables();
563
581
  this.initSubscriptions();
582
+
564
583
  // this.initHandlerEventEmitter();
565
584
  }
566
585
 
@@ -586,7 +605,7 @@ export class ConversationListPage implements OnInit {
586
605
 
587
606
  if (this.route && this.route.snapshot && this.route.snapshot.firstChild) {
588
607
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
589
- this.logger.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv);
608
+ console.log('[CONVS-LIST-PAGE] conversationWith 2: ', IDConv);
590
609
  if (IDConv) {
591
610
  this.setUidConvSelected(IDConv);
592
611
  } else {
@@ -603,7 +622,7 @@ export class ConversationListPage implements OnInit {
603
622
  * ::: setUidConvSelected :::
604
623
  */
605
624
  setUidConvSelected(uidConvSelected: string, conversationType?: string,) {
606
- this.logger.log('[CONVS-LIST-PAGE] setuidCOnvSelected', uidConvSelected)
625
+ console.log('[CONVS-LIST-PAGE] setuidCOnvSelected', uidConvSelected)
607
626
  this.uidConvSelected = uidConvSelected;
608
627
  // this.conversationsHandlerService.uidConvSelected = uidConvSelected;
609
628
  if (uidConvSelected) {
@@ -615,7 +634,7 @@ export class ConversationListPage implements OnInit {
615
634
  }
616
635
  if (conversationSelected) {
617
636
  this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected);
618
- this.logger.log('[CONVS-LIST-PAGE] la conv ', this.conversationSelected, ' has already been loaded');
637
+ this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded');
619
638
  this.conversationSelected = conversationSelected;
620
639
  this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected);
621
640
  }
@@ -623,7 +642,7 @@ export class ConversationListPage implements OnInit {
623
642
  }
624
643
 
625
644
  onConversationSelected(conversation: ConversationModel) {
626
- //console.log('returnSelectedConversation::', conversation)
645
+ console.log('onConversationSelected conversation', conversation)
627
646
  if (conversation.archived) {
628
647
  this.navigateByUrl('archived', conversation.uid)
629
648
  this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid)
@@ -720,19 +739,22 @@ export class ConversationListPage implements OnInit {
720
739
 
721
740
 
722
741
  navigateByUrl(converationType: string, uidConvSelected: string) {
723
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
724
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected');
725
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected);
726
- this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected ', this.conversationSelected)
742
+ console.log('[CONVS-LIST-PAGE] calling navigateByUrl: ');
743
+ console.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
744
+ console.log('[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected');
745
+ console.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected);
746
+ console.log('[CONVS-LIST-PAGE] navigateByUrl this.conversationSelected ', this.conversationSelected)
727
747
 
728
748
  this.setUidConvSelected(uidConvSelected, converationType);
729
749
  if (checkPlatformIsMobile()) {
730
- this.logger.log('[CONVS-LIST-PAGE] PLATFORM_MOBILE 1', this.navService);
750
+ console.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
751
+ console.log('[CONVS-LIST-PAGE] DESKTOP (window >= 768)', this.navService);
731
752
  let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
732
753
  this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
733
754
  this.router.navigateByUrl(pageUrl);
734
755
  } else {
735
- this.logger.log('[CONVS-LIST-PAGE] PLATFORM_DESKTOP 2', this.navService);
756
+ console.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
757
+ this.logger.log('[CONVS-LIST-PAGE] MOBILE (window < 768) ', this.navService);
736
758
  let pageUrl = 'conversation-detail/' + this.uidConvSelected;
737
759
  if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
738
760
  pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
@@ -18,18 +18,88 @@ export class AppConfigProvider {
18
18
 
19
19
  /** */
20
20
  loadAppConfig() {
21
- const that = this;
22
- return this.http.get(this.appConfig.remoteConfigUrl).toPromise().then(data => {
23
- that.appConfig = data;
21
+ // const that = this;
22
+ // return this.http.get(this.appConfig.remoteConfigUrl).toPromise().then(data => {
23
+ // that.appConfig = data;
24
+ // }).catch(err => {
25
+ // console.log('error loadAppConfig' + err);
26
+ // });
27
+
28
+ // ---- new
29
+
30
+
31
+ return this.http.get(this.appConfig.remoteConfigUrl)
32
+ .toPromise().then((data: any ) => {
33
+ console.log('AppConfigService loadAppConfig data: ', data);
34
+
35
+ const allconfig = data
36
+ // console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig: ', allconfig);
37
+
38
+ if (allconfig.hasOwnProperty('wsUrlRel')) {
39
+
40
+ // console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig !!!! exist wsUrlRel ->: ', allconfig.wsUrlRel);
41
+ var wsUrlRelIsEmpty = this.isEmpty(allconfig.wsUrlRel)
42
+ // console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig !!!! exist wsUrlRel -> wsUrlRelIsEmpty ?', wsUrlRelIsEmpty);
43
+
44
+ if (wsUrlRelIsEmpty === false) {
45
+ // console.log('[APP-CONFIG-SERVICE]- loadAppConfig allconfig !!!! exist - SERVER_BASE_URL', data.apiUrl);
46
+
47
+ if (allconfig.apiUrl.indexOf("http://") !== -1) {
48
+
49
+ const ws_url = allconfig.apiUrl.replace("http://", "ws://").slice(0, -1) + allconfig.wsUrlRel;
50
+ // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL protocol is HTTP - wsUrl', ws_url);
51
+
52
+ allconfig.wsUrl = ws_url
53
+
54
+ } else if (allconfig.apiUrl.indexOf("https://") !== -1) {
55
+
56
+ const ws_url = allconfig.apiUrl.replace("https://", "wss://").slice(0, -1) + allconfig.wsUrlRel;
57
+
58
+ allconfig.wsUrl = ws_url
59
+
60
+ // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL protocol is HTTPS - wsUrl', ws_url);
61
+ } else {
62
+ console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL !!! IS RELATIVE - window.location ', window.location);
63
+
64
+ // console.log(window.location)
65
+
66
+ if (window.location.protocol === 'http:') {
67
+ allconfig.wsUrl = 'ws://' + window.location.hostname + '/ws/'
68
+
69
+ } else if (window.location.protocol === 'https:') {
70
+
71
+ allconfig.wsUrl = 'wss://' + window.location.hostname + '/ws/'
72
+ } else {
73
+
74
+ allconfig.wsUrl = 'ws://' + window.location.hostname + '/ws/'
75
+ }
76
+ }
77
+
78
+ } else {
79
+ console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! exist wsUrlRel but IS EMPTY');
80
+ }
81
+
82
+ } else {
83
+
84
+ console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! does not exist wsUrlRel');
85
+ }
86
+
87
+ this.appConfig = allconfig;
88
+
89
+
24
90
  }).catch(err => {
25
- // console.log('error loadAppConfig' + err);
91
+ console.error('error loadAppConfig' + err);
26
92
  });
27
93
  }
28
94
 
95
+ isEmpty(wsUrlRel: string) {
96
+ return (wsUrlRel === undefined || wsUrlRel == null || wsUrlRel.length <= 0) ? true : false;
97
+ }
98
+
29
99
  /** */
30
100
  getConfig() {
31
101
  return this.appConfig;
32
102
  }
33
-
103
+
34
104
 
35
105
  }
@@ -170,11 +170,11 @@ export class WebSocketJs {
170
170
  var str = JSON.stringify(message);
171
171
  this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE str " + str);
172
172
 
173
- if (this.ws.readyState == 1) {
173
+ if (this.ws && this.ws.readyState == 1) {
174
174
  this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TO TOPIC - STRING TO SEND " + str, " FOR UNSUBSCRIBE TO TOPIC: ", topic);
175
175
  this.send(str, `UNSUSCRIBE from ${topic}`);
176
176
 
177
- } else {
177
+ } else if (this.ws) {
178
178
  this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TRY 'SEND' BUT READY STASTE IS : ", this.ws.readyState);
179
179
  }
180
180
  }
@@ -194,7 +194,7 @@ export class WebSocketJs {
194
194
  // -----------------------------------------------------------------------------------------------------
195
195
  close() {
196
196
  this.topics = [];
197
- this.callbacks = [];
197
+ this.callbacks = [];
198
198
  this.logger.log("[WEBSOCKET-JS] - CALLED CLOSE - TOPICS ", this.topics, ' - CALLLBACKS ', this.callbacks);
199
199
 
200
200
  if (this.ws) {
@@ -275,13 +275,13 @@ export class WebSocketJs {
275
275
 
276
276
  // Qui viene inviato un battito cardiaco Dopo averlo ricevuto, viene restituito un messaggio di battito cardiaco.
277
277
  // onmessage Ottieni il battito cardiaco restituito per indicare che la connessione è normale
278
- if (this.ws.readyState == 1) {
278
+ if (this.ws && this.ws.readyState == 1) {
279
279
 
280
280
  // this.logger.log("[WEBSOCKET-JS] - HEART-START - SEND PING-MSG");
281
281
 
282
282
  this.send(JSON.stringify(this.pingMsg), 'HEART-START')
283
283
 
284
- } else {
284
+ } else if (this.ws) {
285
285
 
286
286
  this.logger.log("[WEBSOCKET-JS] - HEART-START - TRY TO SEND PING-MSG BUT READY STATE IS ", this.ws.readyState);
287
287
 
@@ -440,7 +440,7 @@ export class WebSocketJs {
440
440
  // @ send PONG
441
441
  // -------------------
442
442
  // that.logger.log('[WEBSOCKET-JS] - RECEIVED PING -> SEND PONG MSG');
443
-
443
+
444
444
  that.send(JSON.stringify(that.pongMsg), 'ON-MESSAGE')
445
445
 
446
446
  } else {
@@ -463,15 +463,15 @@ export class WebSocketJs {
463
463
  if (json && json.payload && json.payload.message && that.isArray(json.payload.message)) {
464
464
 
465
465
  json.payload.message.forEach(element => {
466
-
466
+
467
467
  //let insUp = that.insertOrUpdate(element);
468
468
  let insUp = json.payload.method;
469
-
469
+
470
470
  var object = { event: json.payload, data: element };
471
471
 
472
472
  var callbackObj = that.callbacks.get(object.event.topic);
473
473
 
474
-
474
+
475
475
  if (insUp == "CREATE") {
476
476
  if (that.onCreate) {
477
477
  that.onCreate(element, object);
@@ -497,10 +497,10 @@ export class WebSocketJs {
497
497
  } else {
498
498
  //let insUp = that.insertOrUpdate(json.payload.message);
499
499
  let insUp = json.payload.method;
500
-
500
+
501
501
  var object = { event: json.payload, data: json };
502
502
  var callbackObj = that.callbacks.get(object.event.topic);
503
-
503
+
504
504
 
505
505
  if (insUp == "CREATE") {
506
506
  if (that.onCreate) {
Binary file
@@ -25,5 +25,6 @@
25
25
  "baseImageUrl": "${API_BASEIMAGE_URL}",
26
26
  "dashboardUrl": "${DASHBOARD_URL}",
27
27
  "wsUrl": "${WS_URL}",
28
+ "wsUrlRel": "${WS_URL_RELATIVE}",
28
29
  "supportMode": "${SUPPORT_MODE}"
29
30
  }
@@ -25,5 +25,6 @@
25
25
  "baseImageUrl": "https://firebasestorage.googleapis.com/v0/b/",
26
26
  "dashboardUrl": "https://support-pre.tiledesk.com/dashboard/",
27
27
  "wsUrl": "ws://localhost:3000/",
28
+ "wsUrlRel": "${WS_URL_RELATIVE}",
28
29
  "supportMode": false
29
30
  }