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

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,25 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.59-rc21
4
+ - chat21client.js -> v0.1.9
5
+
6
+ ### 3.0.59-rc20
7
+ - Improves the transition from "mobile" to "desktop" mode and vice versa by not reloading the app
8
+
9
+ ### 3.0.59-rc19
10
+ - Fixes the bug: when the chat is in "mobile" mode and from the dashboard the agent clicks on "Open chat" for a specific conversation the "back" button of the chat does not return to the list of conversations
11
+ - Fixes the bug: when the chat is in "mobile" mode and from the dashboard the agent clicks on "Open chat" for a specific conversation the chat does not display the details of the conversation
12
+
13
+ ### 3.0.59-rc18
14
+ - Improves the "app-config" service
15
+
16
+ ### 3.0.59-rc16
17
+ - Changes in config.xml the value of the "SplashScreen"
18
+ - 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
19
+ - Modifies the "app-config" service by adding the ability to pass relative URLs to the websocket
20
+ - Adds "wsUrlRel" property to env.sample, chat-config-template.json and chat-config.json
21
+ - Adds a check in the "websocket-js.ts" service on the existence of the "ws" property of the "WebSocketJs" class before accessing the property "readyState"
22
+
3
23
  ### 3.0.59-rc15
4
24
  - Implements a method in app.components that counts and stores the number of open Chat tabs
5
25
  - 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-rc21",
4
4
  "author": "Tiledesk SRL",
5
5
  "homepage": "https://ionicframework.com/",
6
6
  "scripts": {
@@ -1,6 +1,11 @@
1
- @media (min-width: 768px) {
2
- .split-pane-md.split-pane-visible > .split-pane-side {
3
- min-width: 312px;
4
- display: block; // Safari bug fix
5
- }
1
+ .split-pane-md.split-pane-visible > .split-pane-side {
2
+ min-width: 312px;
3
+ display: block; // Safari bug fix
6
4
  }
5
+
6
+ // @media (min-width: 768px) {
7
+ // .split-pane-md.split-pane-visible > .split-pane-side {
8
+ // min-width: 312px;
9
+ // display: block; // Safari bug fix
10
+ // }
11
+ // }
@@ -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,71 @@ 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
- this.getPageState();
146
- // FOR TEST
147
- // 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
- // localStorage.setItem('last_project', JSON.stringify(last_project))
146
+
147
+ this.listenToUrlChanges();
148
+ // this.getPageState();
149
+
150
+ // location.subscribe((val) => {
151
+
152
+ // console.log('location subscribe val', val)
153
+ // if (val.type == "hashchange") {
154
+ // const convId = getParameterByName('convId')
155
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
156
+ // const requesterFullaname = getParameterByName('requester_fullaname')
157
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', requesterFullaname);
158
+
159
+ // this.navigateToDetail(convId, requesterFullaname)
160
+
161
+ // this.events.publish('convid:haschanged', convId);
162
+ // }
163
+ // });
164
+
165
+
166
+
167
+
149
168
  }
169
+
170
+ listenToUrlChanges() {
171
+ const self = this;
172
+ window.addEventListener('hashchange', function () {
173
+ // console.log('location changed!');
174
+
175
+ const convId = getParameterByName('convId')
176
+ // console.log('[APP-COMP] getParameterByName convId ', convId)
177
+ if (convId) {
178
+ setTimeout(() => {
179
+ self.events.publish('supportconvid:haschanged', convId);
180
+ }, 0);
181
+ }
182
+
183
+ const contact_id = getParameterByName('contact_id')
184
+ // console.log('[APP-COMP] getParameterByName contact_id ', contact_id)
185
+ const contact_fullname = getParameterByName('contact_fullname')
186
+ // console.log('[APP-COMP] getParameterByName contact_fullname ', contact_fullname)
187
+ if (contact_id && contact_fullname) {
188
+ setTimeout(() => {
189
+ self.router.navigateByUrl('conversation-detail/' + contact_id + '/' + contact_fullname + '/new');
190
+ self.events.publish('directconvid:haschanged', contact_id);
191
+ }, 0);
192
+
193
+ } else {
194
+ // console.log('[APP-COMP] contact_id and contact_fullname are null')
195
+ }
196
+
197
+ const conversation_detail = getParameterByName('conversation_detail')
198
+ // console.log('[APP-COMP] getParameterByName conversation_detail ', conversation_detail)
199
+ if (conversation_detail) {
200
+ setTimeout(() => {
201
+ self.router.navigate(['conversation-detail/'])
202
+ }, 0);
203
+ }
204
+ });
205
+ }
206
+
150
207
  saveInStorageNumberOfOpenedChatTab() {
151
208
  this.logger.log('Calling saveInStorageChatOpenedTab!');
152
209
 
@@ -160,7 +217,9 @@ export class AppComponent implements OnInit {
160
217
  }
161
218
  const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
162
219
  window.addEventListener(terminationEvent, (event) => {
163
- localStorage.tabCount = +localStorage.tabCount - 1;
220
+ if (localStorage.tabCount > 0) {
221
+ localStorage.tabCount = +localStorage.tabCount - 1;
222
+ }
164
223
  }, { capture: true });
165
224
  }
166
225
 
@@ -184,6 +243,7 @@ export class AppComponent implements OnInit {
184
243
  // }
185
244
 
186
245
  const logStateChange = (nextState) => {
246
+
187
247
  const prevState = state;
188
248
  if (nextState !== prevState) {
189
249
  console.log(`State change: ${prevState} >>> ${nextState}`);
@@ -243,7 +303,7 @@ export class AppComponent implements OnInit {
243
303
  if (token) {
244
304
  // this.isOnline = false;
245
305
  // 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)
306
+ console.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName ', token)
247
307
  // save token in local storage then
248
308
 
249
309
  const storedToken = this.appStorageService.getItem('tiledeskToken');
@@ -255,13 +315,13 @@ export class AppComponent implements OnInit {
255
315
  this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
256
316
  }
257
317
  }
258
- this.initializeApp('oninit');
259
318
 
319
+
320
+ this.initializeApp('oninit');
260
321
  this.listenToPostMsgs();
261
322
  }
262
323
 
263
-
264
-
324
+
265
325
  listenToPostMsgs() {
266
326
  window.addEventListener("message", (event) => {
267
327
  // console.log("[APP-COMP] message event ", event);
@@ -616,7 +676,7 @@ export class AppComponent implements OnInit {
616
676
  } catch (err) {
617
677
  this.logger.error('[APP-COMP] -> error:', err);
618
678
  }
619
- this.chatManager.startApp();
679
+ // this.chatManager.startApp() // nk moved in chevk platform
620
680
  }
621
681
 
622
682
 
@@ -671,7 +731,7 @@ export class AppComponent implements OnInit {
671
731
  }
672
732
 
673
733
  checkPlatform() {
674
- this.logger.debug('[APP-COMP] checkPlatform');
734
+ // console.log('[APP-COMP] checkPlatform');
675
735
  // let pageUrl = '';
676
736
  // try {
677
737
  // const pathPage = this.route.snapshot.firstChild.routeConfig.path;
@@ -687,16 +747,23 @@ export class AppComponent implements OnInit {
687
747
  // }
688
748
 
689
749
  if (checkPlatformIsMobile()) {
750
+ this.chatManager.startApp()
751
+ console.log('[APP-COMP] checkPlatformIsMobile',checkPlatformIsMobile());
690
752
  this.platformIs = PLATFORM_MOBILE;
691
753
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
692
- this.logger.log('[APP-COMP] PLATFORM_MOBILE2 navigateByUrl', PLATFORM_MOBILE, this.route.snapshot);
754
+ // console.log('[APP-COMP] platformIs', this.platformIs);
755
+ // console.log('[APP-COMP] PLATFORM', PLATFORM_MOBILE, 'route.snapshot', this.route.snapshot);
693
756
  if (!IDConv) {
694
757
  this.router.navigateByUrl('conversations-list')
695
758
  }
696
759
  // this.router.navigateByUrl(pageUrl);
697
760
  // this.navService.setRoot(ConversationListPage, {});
698
761
  } else {
762
+ this.chatManager.startApp()
763
+ console.log('[APP-COMP] checkPlatformIsMobile',checkPlatformIsMobile());
699
764
  this.platformIs = PLATFORM_DESKTOP;
765
+ // console.log('[APP-COMP] platformIs', this.platformIs);
766
+ // console.log('[APP-COMP] PLATFORM', PLATFORM_DESKTOP, 'route.snapshot', this.route.snapshot);
700
767
  this.logger.log('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
701
768
 
702
769
  this.navService.setRoot(ConversationListPage, {});
@@ -846,7 +913,7 @@ export class AppComponent implements OnInit {
846
913
 
847
914
  this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
848
915
 
849
- this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
916
+ // console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
850
917
  const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
851
918
  this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
852
919
 
@@ -865,7 +932,7 @@ export class AppComponent implements OnInit {
865
932
  * apro dettaglio conversazione
866
933
  */
867
934
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
868
- this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
935
+ console.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
869
936
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
870
937
  this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
871
938
  }
@@ -1018,8 +1085,8 @@ export class AppComponent implements OnInit {
1018
1085
  onResize(event: any) {
1019
1086
  const that = this;
1020
1087
  // this.logger.debug('this.doitResize)', this.doitResize)
1021
- clearTimeout(this.doitResize);
1022
- this.doitResize = setTimeout(() => {
1088
+ // clearTimeout(this.doitResize);
1089
+ // this.doitResize = setTimeout(() => {
1023
1090
  let platformIsNow = PLATFORM_DESKTOP;
1024
1091
  if (checkPlatformIsMobile()) {
1025
1092
  platformIsNow = PLATFORM_MOBILE;
@@ -1029,11 +1096,14 @@ export class AppComponent implements OnInit {
1029
1096
  }
1030
1097
  this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
1031
1098
  this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
1032
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
1099
+ console.log('[APP-COMP] onResize width:::: this.platformIs', this.platformIs);
1100
+ console.log('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
1033
1101
  if (platformIsNow !== this.platformIs) {
1034
- window.location.reload();
1102
+ // window.location.reload();
1103
+ this.checkPlatform()
1035
1104
  }
1036
- }, 500);
1105
+
1106
+ // }, 0);
1037
1107
  }
1038
1108
  // END RESIZE FUNCTIONS //
1039
1109
 
@@ -3,10 +3,8 @@
3
3
  <ion-toolbar>
4
4
 
5
5
  <ion-buttons slot="start">
6
- <!-- (click)="pushPage('conversations-list')" -->
7
- <ion-back-button text="" *ngIf="isMobile"
8
- defaultHref="/conversations-list"
9
- >
6
+ <!-- (click)="pushPage('conversations-list')" defaultHref="/conversations-list" -->
7
+ <ion-back-button style="display: block;" text="" *ngIf="isMobile" (click)="goBackToConversationList()">
10
8
  </ion-back-button>
11
9
  </ion-buttons>
12
10
 
@@ -1,5 +1,5 @@
1
1
  import { Component, OnInit, Input, Output, EventEmitter, OnChanges } from '@angular/core';
2
- import { ActivatedRoute } from '@angular/router';
2
+ import { ActivatedRoute, Router } from '@angular/router';
3
3
  import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service';
4
4
 
5
5
  // Logger
@@ -43,7 +43,8 @@ export class HeaderConversationDetailComponent implements OnInit, OnChanges {
43
43
  constructor(
44
44
  public imageRepoService: ImageRepoService,
45
45
  private route: ActivatedRoute,
46
- public platform: Platform
46
+ public platform: Platform,
47
+ private router: Router
47
48
  ) {
48
49
  this.route.paramMap.subscribe(params => {
49
50
 
@@ -125,4 +126,8 @@ export class HeaderConversationDetailComponent implements OnInit, OnChanges {
125
126
  /** */
126
127
  pushPage(event) { }
127
128
 
129
+ goBackToConversationList() {
130
+ this.router.navigateByUrl('/conversations-list');
131
+ }
132
+
128
133
  }
@@ -106,7 +106,28 @@ export class ConversationListPage implements OnInit {
106
106
  this.listenGoOnline();
107
107
  this.listenGoOffline();
108
108
  this.listenToSwPostMessage();
109
+ this.listenSupportConvIdHasChanged();
110
+ this.listenDirectConvIdHasChanged();
111
+ }
112
+
113
+ listenSupportConvIdHasChanged() {
114
+ this.events.subscribe('supportconvid:haschanged', (convId) => {
115
+ // console.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', convId);
116
+ if (convId) {
117
+ const conversationSelected = this.conversations.find(item => item.uid === convId);
118
+ // console.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - conversationSelected', conversationSelected);
119
+ this.onConversationSelected(conversationSelected)
120
+ }
121
+ });
122
+ }
109
123
 
124
+ listenDirectConvIdHasChanged() {
125
+ this.events.subscribe('directconvid:haschanged', (contact_id) => {
126
+ // console.log('[CONVS-LIST-PAGE] - listen To directconvid:haschanged - contact_id', contact_id);
127
+ if (contact_id) {
128
+ this.uidConvSelected = contact_id
129
+ }
130
+ });
110
131
  }
111
132
 
112
133
 
@@ -119,41 +140,41 @@ export class ConversationListPage implements OnInit {
119
140
 
120
141
  const currentUrl = this.router.url;
121
142
  this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
122
- this.route.queryParams.subscribe(params => {
123
- 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
- }
143
+ // this.route.queryParams.subscribe(params => {
144
+ // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params', params);
145
+ // if (params && params.convselected) {
146
+ // console.log('[CONVS-LIST-PAGE] ngOnInit params convselected:', params.convselected);
147
+
148
+ // const conversationSelected = this.conversations.find(item => item.uid === params.convselected);
149
+ // if (conversationSelected) {
150
+ // this.conversationSelected = conversationSelected;
151
+ // console.log('[CONVS-LIST-PAGE] ngOnInit params convselected - conversationSelected: ', this.conversationSelected);
152
+ // this.navigateByUrl('active', params.convselected)
153
+ // }
154
+
155
+ // } else {
156
+ // console.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
157
+ // }
158
+ // if (params && params.contact_id && params.contact_fullname) {
159
+ // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params contact_id:', params.contact_id, 'contact_fullname ', params.contact_fullname);
160
+ // this.router.navigateByUrl('conversation-detail/' + params.contact_id + '/' + params.contact_fullname + '/new');
161
+ // this.uidConvSelected = params.contact_id
162
+ // } else {
163
+ // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
164
+ // }
165
+
166
+ // if (params && params.conversation_detail) {
167
+ // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params conversation_detail:', params.conversation_detail);
168
+ // this.router.navigateByUrl('conversation-detail/');
169
+
170
+ // } else {
171
+ // this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
172
+ // }
133
173
 
134
- } else {
135
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
136
- }
137
- if (params && params.contact_id && params.contact_fullname) {
138
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params contact_id:', params.contact_id, 'contact_fullname ', params.contact_fullname);
139
- this.router.navigateByUrl('conversation-detail/' + params.contact_id + '/' + params.contact_fullname + '/new');
140
- this.uidConvSelected = params.contact_id
141
- } else {
142
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
143
- }
144
-
145
- if (params && params.conversation_detail) {
146
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params conversation_detail:', params.conversation_detail);
147
- this.router.navigateByUrl('conversation-detail/');
148
-
149
- } else {
150
- this.logger.log('[CONVS-LIST-PAGE] ngOnInit params NoParams ');
151
- }
152
-
153
- });
174
+ // });
154
175
  }
155
176
 
156
-
177
+
157
178
 
158
179
  getSupportMode() {
159
180
  this.supportMode = this.appConfigProvider.getConfig().supportMode;
@@ -335,7 +356,6 @@ export class ConversationListPage implements OnInit {
335
356
  }
336
357
 
337
358
  listenGoOnline() {
338
-
339
359
  this.events.subscribe('go:online', (goonline) => {
340
360
  this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline', goonline);
341
361
  // this.events.unsubscribe('profileInfoButtonClick:logout')
@@ -471,8 +491,11 @@ export class ConversationListPage implements OnInit {
471
491
  * evento richiamato quando si seleziona un utente nell'elenco degli user
472
492
  * apro dettaglio conversazione
473
493
  */
494
+ // --------------------------------
495
+ // !!!!!! IS USED? ?????
496
+ // ------------------------------
474
497
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
475
- this.logger.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
498
+ console.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
476
499
  this.uidConvSelected = user.uid;
477
500
  this.logger.log('[CONVS-LIST-PAGE] ************** uidConvSelected ', this.uidConvSelected);
478
501
  // this.conversationsHandlerService.uidConvSelected = user.uid;
@@ -561,6 +584,7 @@ export class ConversationListPage implements OnInit {
561
584
  this.initConversationsHandler();
562
585
  this.initVariables();
563
586
  this.initSubscriptions();
587
+
564
588
  // this.initHandlerEventEmitter();
565
589
  }
566
590
 
@@ -615,7 +639,7 @@ export class ConversationListPage implements OnInit {
615
639
  }
616
640
  if (conversationSelected) {
617
641
  this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected);
618
- this.logger.log('[CONVS-LIST-PAGE] la conv ', this.conversationSelected, ' has already been loaded');
642
+ this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded');
619
643
  this.conversationSelected = conversationSelected;
620
644
  this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected);
621
645
  }
@@ -623,7 +647,7 @@ export class ConversationListPage implements OnInit {
623
647
  }
624
648
 
625
649
  onConversationSelected(conversation: ConversationModel) {
626
- //console.log('returnSelectedConversation::', conversation)
650
+ this.logger.log('onConversationSelected conversation', conversation)
627
651
  if (conversation.archived) {
628
652
  this.navigateByUrl('archived', conversation.uid)
629
653
  this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid)
@@ -720,6 +744,7 @@ export class ConversationListPage implements OnInit {
720
744
 
721
745
 
722
746
  navigateByUrl(converationType: string, uidConvSelected: string) {
747
+ this.logger.log('[CONVS-LIST-PAGE] calling navigateByUrl: ');
723
748
  this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
724
749
  this.logger.log('[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected');
725
750
  this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected);
@@ -727,12 +752,14 @@ export class ConversationListPage implements OnInit {
727
752
 
728
753
  this.setUidConvSelected(uidConvSelected, converationType);
729
754
  if (checkPlatformIsMobile()) {
730
- this.logger.log('[CONVS-LIST-PAGE] PLATFORM_MOBILE 1', this.navService);
755
+ this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
756
+ this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window >= 768)', this.navService);
731
757
  let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
732
758
  this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
733
759
  this.router.navigateByUrl(pageUrl);
734
760
  } else {
735
- this.logger.log('[CONVS-LIST-PAGE] PLATFORM_DESKTOP 2', this.navService);
761
+ console.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
762
+ this.logger.log('[CONVS-LIST-PAGE] MOBILE (window < 768) ', this.navService);
736
763
  let pageUrl = 'conversation-detail/' + this.uidConvSelected;
737
764
  if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
738
765
  pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
@@ -18,18 +18,90 @@ 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
+
63
+
64
+ // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL !!! IS RELATIVE - window.location ', window.location);
65
+
66
+ // console.log(window.location)
67
+
68
+ if (window.location.protocol === 'http:') {
69
+ allconfig.wsUrl = 'ws://' + window.location.hostname + allconfig.wsUrlRel
70
+
71
+ } else if (window.location.protocol === 'https:') {
72
+
73
+ allconfig.wsUrl = 'wss://' + window.location.hostname + allconfig.wsUrlRel
74
+ } else {
75
+
76
+ allconfig.wsUrl = 'ws://' + window.location.hostname + allconfig.wsUrlRel
77
+ }
78
+ // }
79
+
80
+ } else {
81
+ // console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! exist wsUrlRel but IS EMPTY');
82
+ }
83
+
84
+ } else {
85
+
86
+ // console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! does not exist wsUrlRel');
87
+ }
88
+
89
+ this.appConfig = allconfig;
90
+
91
+
24
92
  }).catch(err => {
25
- // console.log('error loadAppConfig' + err);
93
+ console.error('error loadAppConfig' + err);
26
94
  });
27
95
  }
28
96
 
97
+ isEmpty(wsUrlRel: string) {
98
+ return (wsUrlRel === undefined || wsUrlRel == null || wsUrlRel.length <= 0) ? true : false;
99
+ }
100
+
29
101
  /** */
30
102
  getConfig() {
31
103
  return this.appConfig;
32
104
  }
33
-
105
+
34
106
 
35
107
  }
@@ -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) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Chat21Client
3
3
 
4
- v0.1.8
4
+ v0.1.9
5
5
 
6
6
  @Author Andrea Sponziello
7
7
  (c) Tiledesk 2020
@@ -22,6 +22,7 @@ class Chat21Client {
22
22
  this.client = null;
23
23
  this.reconnections = 0 // just to check how many reconnections
24
24
  this.client_id = this.uuidv4();
25
+ this.log = options._log ? true : false;
25
26
  if (options && options.MQTTendpoint) {
26
27
  if (options.MQTTendpoint.startsWith('/')) {
27
28
  if (this.log) {
@@ -48,7 +49,6 @@ class Chat21Client {
48
49
  else {
49
50
  this.endpoint = "ws://34.253.207.0:15675/ws"
50
51
  }
51
- this.log = options.log ? true : false;
52
52
  this.APIendpoint = options.APIendpoint;
53
53
  this.appid = options.appId;
54
54
  if (this.log) {
@@ -90,21 +90,9 @@ class Chat21Client {
90
90
  });
91
91
  }
92
92
 
93
- // subscribeToMyMessages() {
94
- // // this subscription because in /conversations I receive my messages
95
- // // 'apps/tilechat/users/ME/messages/TO/outgoing'
96
- // // 'apps/tilechat/users/ME/messages/FROM/incoming'
97
- // let messages_inbox = 'apps/tilechat/users/' + this.user_id + '/messages/+'
98
- // console.log("subscribing to inbox of:", this.user_id, "topic", messages_inbox)
99
- // this.client.subscribe(messages_inbox, (err) => {
100
- // console.log("subscribed to:", messages_inbox, " with err", err)
101
- // })
102
- // }
103
-
104
93
  sendMessage(text, type, recipient_id, recipient_fullname, sender_fullname, attributes, metadata, channel_type, callback) {
105
- // callback - function (err)
106
- // console.log("recipient_id:", recipient_id)
107
- let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${recipient_id}/outgoing`
94
+ // console.log("sendMessage:",text, recipient_id)
95
+ let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
108
96
  // console.log("dest_topic:", dest_topic)
109
97
  let outgoing_message = {
110
98
  text: text,
@@ -138,7 +126,7 @@ class Chat21Client {
138
126
  sendMessageRaw(outgoing_message, recipient_id, callback) {
139
127
  // callback - function (err)
140
128
  // console.log("recipient_id:", recipient_id)
141
- let dest_topic = `apps/${this.appid}/users/${this.user_id}/messages/${recipient_id}/outgoing`
129
+ let dest_topic = `apps/${this.appid}/outgoing/users/${this.user_id}/messages/${recipient_id}/outgoing`
142
130
  // console.log("dest_topic:", dest_topic)
143
131
  // let outgoing_message = {
144
132
  // text: text,
@@ -957,7 +945,7 @@ class Chat21Client {
957
945
  clientId: this.client_id,
958
946
  username: 'JWT',
959
947
  password: jwt,
960
- rejectUnauthorized: true
948
+ rejectUnauthorized: false
961
949
  }
962
950
  if (this.log) {console.log("starting mqtt connection with LWT on:", presence_topic, this.endpoint)}
963
951
  // client = mqtt.connect('mqtt://127.0.0.1:15675/ws',options)
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
  }
@@ -34,29 +34,37 @@ export class FirebaseNotifications extends NotificationsService {
34
34
  this.logger.error("[FIREBASE-NOTIFICATIONS] initialize - Service Worker isn't supported on this browser", navigator)
35
35
  return;
36
36
  }
37
- if (('serviceWorker' in navigator)) {
38
- // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser ", navigator)
39
- navigator.serviceWorker.getRegistrations().then((serviceWorkerRegistrations) => {
40
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser serviceWorkerRegistrations", serviceWorkerRegistrations)
41
- if (serviceWorkerRegistrations.length > 0) {
42
- serviceWorkerRegistrations.forEach(registration => {
43
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registration ", registration)
44
- // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
45
- // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
46
-
47
- });
48
- } else {
49
- this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser - !not registered",)
50
- // navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js')
51
- // .then(function (registration) {
52
- // console.log('Service worker successfully registered.');
53
- // return registration;
54
- // }).catch(function (err) {
55
- // console.error('Unable to register service worker.', err);
56
- // });
57
- }
58
- });
59
- }
37
+ // if (('serviceWorker' in navigator)) {
38
+ // navigator.serviceWorker.register('firebase-messaging-sw.js')
39
+ // .then(function (registration) {
40
+ // console.log('[FIREBASE-NOTIFICATIONS] initialize serviceWorker Registration successful, scope is:', registration.scope);
41
+
42
+
43
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser ", navigator)
44
+ // // navigator.serviceWorker.getRegistrations().then((serviceWorkerRegistrations) => {
45
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser serviceWorkerRegistrations", serviceWorkerRegistrations)
46
+ // // if (serviceWorkerRegistrations.length > 0) {
47
+ // // serviceWorkerRegistrations.forEach(registration => {
48
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registration ", registration)
49
+ // // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations scriptURL", registrations.active.scriptURL)
50
+ // // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser registrations state", registrations.active.state)
51
+
52
+ // // });
53
+ // // } else {
54
+ // // this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser - !not registered",)
55
+ // // // navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js')
56
+ // // // .then(function (registration) {
57
+ // // // console.log('Service worker successfully registered.');
58
+ // // // return registration;
59
+ // // // }).catch(function (err) {
60
+ // // // console.error('Unable to register service worker.', err);
61
+ // // // });
62
+ // // }
63
+ // // });
64
+ // }).catch(function (err) {
65
+ // console.log('Service worker registration failed, error:', err);
66
+ // });
67
+ // }
60
68
  }
61
69
 
62
70
 
@@ -180,13 +180,11 @@ export class MQTTConversationHandler extends ConversationHandlerService {
180
180
  channelType,
181
181
  // language,
182
182
  (err, message) => {
183
- this.logger.log('[MQTTConversationHandler] message: ' + JSON.stringify(message) + ' sent with err: ' + err);
184
183
  if (err) {
185
- // cambio lo stato in rosso: invio nn riuscito!!!
186
- message.status = '-100';
187
- this.logger.log('[MQTTConversationHandler] ERROR', err);
184
+ message.status = '-100';
185
+ this.logger.log('[MQTTConversationHandler] ERROR', err);
188
186
  } else {
189
- message.status = '150';
187
+ message.status = '150';
190
188
  }
191
189
  }
192
190
  );
@@ -19,7 +19,7 @@ export function isFirstMessage(i: number) {
19
19
  }
20
20
  return false;
21
21
  } catch (err) {
22
- console.log('error: ', err);
22
+ console.error('error: ', err);
23
23
  }
24
24
  }
25
25
  }
@@ -103,7 +103,7 @@ export function getSizeImg(message: any, maxWidthImage?: number): any {
103
103
  }
104
104
  return sizeImage;
105
105
  } catch (err) {
106
- console.log('error: ', err);
106
+ console.error('error: ', err);
107
107
  return;
108
108
  }
109
109
  }