@chat21/chat21-ionic 3.0.59-rc4 → 3.0.59

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/README.md +5 -0
  3. package/config.xml +2 -2
  4. package/env.sample +3 -1
  5. package/package.json +1 -1
  6. package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
  7. package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
  8. package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
  9. package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
  10. package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
  11. package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
  12. package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
  13. package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
  14. package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
  15. package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
  16. package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
  17. package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
  18. package/resources/Android/splash.png +0 -0
  19. package/src/app/app.component.scss +10 -5
  20. package/src/app/app.component.ts +393 -234
  21. package/src/app/app.module.ts +12 -7
  22. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
  23. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +7 -6
  24. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +2 -1
  25. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
  26. package/src/app/components/authentication/login/login.component.html +8 -8
  27. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -4
  28. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +7 -2
  29. package/src/app/components/ddp-header/ddp-header.component.html +1 -1
  30. package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
  31. package/src/app/components/project-item/project-item.component.html +61 -16
  32. package/src/app/components/project-item/project-item.component.scss +165 -38
  33. package/src/app/components/project-item/project-item.component.ts +58 -36
  34. package/src/app/pages/authentication/login/login.page.html +1 -2
  35. package/src/app/pages/conversation-detail/conversation-detail.page.ts +2 -0
  36. package/src/app/pages/conversations-list/conversations-list.page.html +12 -7
  37. package/src/app/pages/conversations-list/conversations-list.page.scss +279 -261
  38. package/src/app/pages/conversations-list/conversations-list.page.ts +149 -17
  39. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +10 -2
  40. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
  41. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +47 -36
  42. package/src/app/services/app-config.ts +77 -5
  43. package/src/app/services/websocket/websocket-js.ts +12 -14
  44. package/src/app/services/websocket/websocket.service.ts +26 -8
  45. package/src/assets/i18n/en.json +2 -1
  46. package/src/assets/i18n/it.json +2 -1
  47. package/src/assets/js/chat21client.js +144 -82
  48. package/src/assets/logo.png +0 -0
  49. package/src/assets/transparent.png +0 -0
  50. package/src/chat-config-pre-test.json +3 -1
  51. package/src/chat-config-template.json +4 -1
  52. package/src/chat-config.json +4 -1
  53. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
  54. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -1
  55. package/src/chat21-core/providers/firebase/firebase-notifications.ts +31 -23
  56. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
  57. package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -5
  58. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
  59. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
  60. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +12 -3
  61. package/src/chat21-core/utils/utils-message.ts +2 -2
  62. package/src/firebase-messaging-sw-template.js +1 -1
  63. package/src/assets/images/tiledesk_logo_50x50.png +0 -0
@@ -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,86 +139,156 @@ 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
- // this.saveInStorageChatOpenedTab();
145
- // FOR TEST
146
- // 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" }
147
- // localStorage.setItem('last_project', JSON.stringify(last_project))
148
- }
149
- saveInStorageChatOpenedTab() {
150
- // if (+localStorage.tabCount > 0) {
151
- // alert('Already open!');
152
- // } else {
153
- // localStorage.tabCount = 0;
154
- // }
155
145
 
156
- // window.addEventListener('load', (event) => {
157
- // console.log('[CONVS-LIST-PAGE] page is fully loaded', event);
158
- // // let tab = + localStorage.getItem('tab')
159
- // // console.log('[CONVS-LIST-PAGE] page is fully loaded getItem tab', + tab);
160
- // // localStorage.setItem('tab', "1" )
161
- // localStorage.tabCount = +localStorage.tabCount + 1;
146
+ this.saveInStorageNumberOfOpenedChatTab();
147
+ this.listenChatAlreadyOpenWithoutParamsInMobileMode()
148
+
149
+ // this.listenToUrlChanges();
150
+ // this.getPageState();
151
+
152
+ // location.subscribe((val) => {
153
+
154
+ // console.log('location subscribe val', val)
155
+ // if (val.type == "hashchange") {
156
+ // const convId = getParameterByName('convId')
157
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
158
+ // const requesterFullaname = getParameterByName('requester_fullaname')
159
+ // console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', requesterFullaname);
160
+
161
+ // this.navigateToDetail(convId, requesterFullaname)
162
+
163
+ // this.events.publish('convid:haschanged', convId);
164
+ // }
162
165
  // });
166
+ }
163
167
 
164
- // // https://developers.google.com/web/updates/2018/07/page-lifecycle-api#the-beforeunload-event
165
- // const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
166
- // window.addEventListener(terminationEvent, (event) => {
167
- // console.log('[CONVS-LIST-PAGE] page is terminationEvent', event);
168
- // localStorage.tabCount = +localStorage.tabCount - 1;
169
- // }, { capture: true });
170
- const getState = () => {
171
- if (document.visibilityState === 'hidden') {
172
- return 'hidden';
168
+ listenChatAlreadyOpenWithoutParamsInMobileMode() {
169
+ this.events.subscribe('noparams:mobile', (isAlreadyOpenInMobileMode) => {
170
+ // console.log('[APP-COMP] Chat is Already Open In Mobile Mode ', isAlreadyOpenInMobileMode)
171
+ if (isAlreadyOpenInMobileMode === true) {
172
+ this.checkPlatform()
173
173
  }
174
- if (document.hasFocus()) {
175
- return 'active';
176
- }
177
- return 'passive';
178
- };
174
+ });
175
+ }
179
176
 
180
- let state = getState();
181
- console.log('[CONVS-LIST-PAGE] page state ', state)
182
- if (state === 'hidden') {
183
- localStorage.setItem('hidden', 'true')
184
- }
177
+ // listenToUrlChanges() {
178
+ // const self = this;
179
+ // // window.addEventListener('hashchange', function () {
180
+ // window.addEventListener('locationchange', function () {
185
181
 
186
- const logStateChange = (nextState) => {
187
- const prevState = state;
188
- if (nextState !== prevState) {
189
- console.log(`State change: ${prevState} >>> ${nextState}`);
190
- state = nextState;
191
- }
192
- };
182
+ // console.log('location changed!');
193
183
 
194
- ['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
195
- window.addEventListener(type, () => logStateChange(getState()), { capture: true });
196
- });
184
+ // const convId = getParameterByName('convId')
185
+ // console.log('[APP-COMP] getParameterByName convId ', convId)
186
+ // if (convId) {
187
+ // setTimeout(() => {
188
+ // self.events.publish('supportconvid:haschanged', convId);
189
+ // }, 0);
190
+ // }
197
191
 
198
- // The next two listeners, on the other hand, can determine the next
199
- // state from the event itself.
200
- window.addEventListener('freeze', () => {
201
- // In the freeze event, the next state is always frozen.
202
- logStateChange('frozen');
203
- }, { capture: true });
192
+ // const contact_id = getParameterByName('contact_id')
193
+ // console.log('[APP-COMP] getParameterByName contact_id ', contact_id)
194
+ // const contact_fullname = getParameterByName('contact_fullname')
195
+ // console.log('[APP-COMP] getParameterByName contact_fullname ', contact_fullname)
196
+ // if (contact_id && contact_fullname) {
197
+ // setTimeout(() => {
198
+ // self.router.navigateByUrl('conversation-detail/' + contact_id + '/' + contact_fullname + '/new');
199
+ // self.events.publish('directconvid:haschanged', contact_id);
200
+ // }, 0);
201
+
202
+ // } else {
203
+ // // console.log('[APP-COMP] contact_id and contact_fullname are null')
204
+ // }
204
205
 
205
- window.addEventListener('pagehide', (event) => {
206
- if (event.persisted) {
207
- // If the event's persisted property is `true` the page is about
208
- // to enter the Back-Forward Cache, which is also in the frozen state.
209
- logStateChange('frozen');
210
- localStorage.setItem('terminated', 'true')
211
- } else {
212
- // If the event's persisted property is not `true` the page is
213
- // about to be unloaded.
214
- logStateChange('terminated');
215
- localStorage.setItem('terminated', 'true')
206
+ // const conversation_detail = getParameterByName('conversation_detail')
207
+ // // console.log('[APP-COMP] getParameterByName conversation_detail ', conversation_detail)
208
+ // if (conversation_detail) {
209
+ // setTimeout(() => {
210
+ // self.router.navigate(['conversation-detail/'])
211
+ // }, 0);
212
+ // }
213
+ // });
214
+ // }
215
+
216
+ // getPageState() {
217
+ // const getState = () => {
218
+
219
+ // console.log('[APP-COMP] getState')
220
+ // // localStorage.setItem('visibilityState', document.visibilityState)
221
+ // if (document.visibilityState === 'hidden') {
222
+ // return 'hidden';
223
+ // }
224
+ // if (document.hasFocus()) {
225
+ // return 'active';
226
+ // }
227
+ // return 'passive';
228
+ // };
229
+
230
+ // let state = getState();
231
+
232
+ // const logStateChange = (nextState) => {
233
+
234
+ // const prevState = state;
235
+ // if (nextState !== prevState) {
236
+ // console.log(`State change: ${prevState} >>> ${nextState}`);
237
+ // state = nextState;
238
+
239
+ // }
240
+ // };
241
+
242
+ // ['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
243
+ // window.addEventListener(type, () => logStateChange(getState()), { capture: true });
244
+ // });
245
+
246
+ // // The next two listeners, on the other hand, can determine the next
247
+ // // state from the event itself.
248
+ // window.addEventListener('freeze', () => {
249
+ // // In the freeze event, the next state is always frozen.
250
+ // logStateChange('frozen');
251
+ // }, { capture: true });
252
+
253
+ // window.addEventListener('pagehide', (event) => {
254
+ // if (event.persisted) {
255
+ // // If the event's persisted property is `true` the page is about
256
+ // // to enter the Back-Forward Cache, which is also in the frozen state.
257
+ // logStateChange('frozen');
258
+ // localStorage.setItem('state', 'frozen')
259
+ // } else {
260
+ // // If the event's persisted property is not `true` the page is
261
+ // // about to be unloaded.
262
+ // logStateChange('terminated');
263
+ // localStorage.setItem('state', 'terminated')
264
+ // localStorage.setItem('terminated', 'true')
265
+ // }
266
+ // }, { capture: true });
267
+
268
+ // }
269
+
270
+
271
+ saveInStorageNumberOfOpenedChatTab() {
272
+ this.logger.log('Calling saveInStorageChatOpenedTab!');
273
+
274
+ // https://jsfiddle.net/jjjs5wd3/3/å
275
+ if (+localStorage.tabCount > 0) {
276
+ this.logger.log('Chat IONIC Already open!');
277
+ } else {
278
+ localStorage.tabCount = 0;
279
+
280
+ localStorage.tabCount = +localStorage.tabCount + 1;
281
+ }
282
+ const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
283
+ window.addEventListener(terminationEvent, (event) => {
284
+ if (localStorage.tabCount > 0) {
285
+ localStorage.tabCount = +localStorage.tabCount - 1;
216
286
  }
217
287
  }, { capture: true });
218
-
219
288
  }
220
289
 
221
290
 
291
+
222
292
  // param() {
223
293
  // // PARAM
224
294
  // const url: URL = new URL(window.top.location.href);
@@ -252,31 +322,54 @@ export class AppComponent implements OnInit {
252
322
  this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
253
323
  }
254
324
  }
255
- this.initializeApp('oninit');
256
325
 
326
+
327
+ this.initializeApp('oninit');
257
328
  this.listenToPostMsgs();
258
329
  }
259
330
 
260
331
 
261
-
262
332
  listenToPostMsgs() {
263
333
  window.addEventListener("message", (event) => {
264
- // console.log("[APP-COMP] message event ", event);
334
+ this.logger.log("[APP-COMP] message event ", event);
265
335
 
266
336
  if (event && event.data && event.data.action && event.data.parameter) {
267
337
  if (event.data.action === 'openJoinConversationModal') {
268
338
  // console.log("[APP-COMP] message event action ", event.data.action);
269
339
  // console.log("[APP-COMP] message event parameter ", event.data.parameter);
270
- this.presentAlertConfirmJoinRequest(event.data.parameter)
271
-
272
-
340
+ this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
341
+ }
342
+ }
343
+ // if (event && event.data && event.data.action && event.data.parameter) {
344
+ // if (event.data.action === 'hasArchived') {
345
+ // var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
346
+ // const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
347
+ // input !== null && input.tagName === 'IFRAME';
348
+ // if (isIFrame(iframeWin) && iframeWin.contentWindow) {
349
+ // const msg = { action: "hasArchived", parameter: event.data.parameter, calledBy: event.data.calledBy }
350
+ // iframeWin.contentWindow.postMessage(msg, '*');
351
+ // }
352
+
353
+ // }
354
+ // }
355
+ if (event && event.data && event.data.action && event.data.text) {
356
+ if (event.data.action === "display_toast_join_complete") {
357
+ this.presentToastJoinComplete(event.data.text)
273
358
  }
274
359
  }
275
360
  })
361
+ }
276
362
 
363
+ async presentToastJoinComplete(text) {
364
+ const toast = await this.toastController.create({
365
+ message: text,
366
+ duration: 2000,
367
+ color: "success"
368
+ });
369
+ toast.present();
277
370
  }
278
371
 
279
- async presentAlertConfirmJoinRequest(requestid) {
372
+ async presentAlertConfirmJoinRequest(requestid, calledby) {
280
373
  var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
281
374
  // console.log("[APP-COMP] message event iframeWin ", iframeWin);
282
375
 
@@ -304,7 +397,7 @@ export class AppComponent implements OnInit {
304
397
  // console.log('Confirm Okay');
305
398
 
306
399
  if (isIFrame(iframeWin) && iframeWin.contentWindow) {
307
- const msg = { action: "joinConversation", parameter: requestid }
400
+ const msg = { action: "joinConversation", parameter: requestid, calledBy: calledby }
308
401
  iframeWin.contentWindow.postMessage(msg, '*');
309
402
  }
310
403
  }
@@ -334,11 +427,11 @@ export class AppComponent implements OnInit {
334
427
  /** */
335
428
  initializeApp(calledby: string) {
336
429
  // this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
337
- // this.logger.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
430
+ // console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
338
431
 
339
- if (!this.platform.is('cordova')) {
340
- this.splashScreen.show();
341
- }
432
+ // if (!this.platform.is('cordova')) {
433
+ this.splashScreen.show();
434
+ // }
342
435
  this.tabTitle = document.title;
343
436
 
344
437
  this.getRouteParamsAndSetLoggerConfig();
@@ -356,12 +449,18 @@ export class AppComponent implements OnInit {
356
449
  this.notificationsEnabled = true;
357
450
  this.zone = new NgZone({}); // a cosa serve?
358
451
 
452
+ // ------------------------------------------
453
+ // Platform ready
454
+ // ------------------------------------------
359
455
  this.platform.ready().then(() => {
456
+ // console.log("Check platform");
457
+ this.getPlatformName();
458
+
360
459
  this.setLanguage();
361
460
 
362
- if (this.splashScreen) {
363
- this.splashScreen.hide();
364
- }
461
+ // if (this.splashScreen) {
462
+ this.splashScreen.hide();
463
+ // }
365
464
  this.statusBar.styleDefault();
366
465
  this.navService.init(this.sidebarNav, this.detailNav);
367
466
  // this.persistence = appconfig.authPersistence;
@@ -397,6 +496,59 @@ export class AppComponent implements OnInit {
397
496
  });
398
497
  }
399
498
 
499
+ getPlatformName() {
500
+ if (this.platform.is('cordova')) {
501
+ this.logger.log("the device running Cordova");
502
+ }
503
+ if (!this.platform.is('cordova')) {
504
+ this.logger.log("the device Not running Cordova");
505
+ }
506
+
507
+ if (this.platform.is('android')) {
508
+ this.logger.log("running on Android device!");
509
+ }
510
+ if (this.platform.is('ios')) {
511
+ this.logger.log("running on iOS device!");
512
+ }
513
+ if (this.platform.is('mobileweb')) {
514
+ this.logger.log("running in a browser on mobile!");
515
+ }
516
+ if (this.platform.is('desktop')) {
517
+ this.logger.log("running on desktop!");
518
+ }
519
+ }
520
+
521
+
522
+ getRouteParamsAndSetLoggerConfig() {
523
+ const appconfig = this.appConfigProvider.getConfig();
524
+ this.route.queryParams.subscribe(params => {
525
+ // this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
526
+ if (params.logLevel) {
527
+ this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
528
+ this.logger.setLoggerConfig(true, params.logLevel)
529
+ } else {
530
+ this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
531
+ this.logger.setLoggerConfig(true, appconfig.logLevel)
532
+ }
533
+ });
534
+ }
535
+
536
+ /** */
537
+ setLanguage() {
538
+ this.translate.setDefaultLang('en');
539
+ this.translate.use('en');
540
+ this.logger.debug('[APP-COMP] navigator.language: ', navigator.language);
541
+ let language;
542
+ if (navigator.language.indexOf('-') !== -1) {
543
+ language = navigator.language.substring(0, navigator.language.indexOf('-'));
544
+ } else if (navigator.language.indexOf('_') !== -1) {
545
+ language = navigator.language.substring(0, navigator.language.indexOf('_'));
546
+ } else {
547
+ language = navigator.language;
548
+ }
549
+ this.translate.use(language);
550
+ }
551
+
400
552
 
401
553
  watchToConnectionStatus() {
402
554
  this.networkService.checkInternetFunc().subscribe(isOnline => {
@@ -450,21 +602,6 @@ export class AppComponent implements OnInit {
450
602
  }
451
603
 
452
604
 
453
- getRouteParamsAndSetLoggerConfig() {
454
- const appconfig = this.appConfigProvider.getConfig();
455
- this.route.queryParams.subscribe(params => {
456
- // this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
457
- if (params.logLevel) {
458
- this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
459
- this.logger.setLoggerConfig(true, params.logLevel)
460
- } else {
461
- this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
462
- this.logger.setLoggerConfig(true, appconfig.logLevel)
463
- }
464
- });
465
- }
466
-
467
-
468
605
  translateToastMsgs() {
469
606
  this.translate.get('AnErrorOccurredWhileUnsubscribingFromNotifications')
470
607
  .subscribe((text: string) => {
@@ -519,114 +656,14 @@ export class AppComponent implements OnInit {
519
656
  // }
520
657
  // }
521
658
 
522
- connetWebsocket(tiledeskToken) {
523
- const WS_URL = 'wss://tiledesk-server-pre.herokuapp.com/' + '?token=' + tiledeskToken
524
- this.webSocketJs.init(
525
- WS_URL,
526
- undefined,
527
- undefined,
528
- undefined
529
- );
530
- }
531
-
532
- /**
533
- * goOnLine:
534
- * 1 - nascondo splashscreen
535
- * 2 - recupero il tiledeskToken e lo salvo in chat manager
536
- * 3 - carico in d
537
- * @param user
538
- */
539
- goOnLine = () => {
540
- // this.isOnline = true;
541
- // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
542
-
543
- // clearTimeout(this.timeModalLogin);
544
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
545
- this.connetWebsocket(tiledeskToken)
546
-
547
- const currentUser = this.tiledeskAuthService.getCurrentUser();
548
- // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
549
- this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
550
- this.chatManager.setTiledeskToken(tiledeskToken);
551
- this.chatManager.setCurrentUser(currentUser);
552
- // ----------------------------------------------
553
- // PUSH NOTIFICATIONS
554
- // ----------------------------------------------
555
- const pushEngine = this.appConfigProvider.getConfig().pushEngine
556
-
557
- if (currentUser) {
558
- if (pushEngine && pushEngine !== 'none') {
559
- this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
560
- }
561
- this.presenceService.setPresence(currentUser.uid);
562
-
563
- this.initConversationsHandler(currentUser.uid);
564
- this.initArchivedConversationsHandler(currentUser.uid);
565
- }
566
- this.checkPlatform();
567
- try {
568
- this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
569
- if (this.authModal) {
570
- this.closeModal();
571
- }
572
- } catch (err) {
573
- this.logger.error('[APP-COMP] -> error:', err);
574
- }
575
- this.chatManager.startApp();
576
- }
577
-
578
-
579
- webSocketClose() {
580
- this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
581
- this.webSocketJs.close()
582
- }
583
-
584
- goOffLine = () => {
585
- this.logger.log('[APP-COMP] - GO-OFFLINE');
586
659
 
587
- this.webSocketClose()
588
- // this.isOnline = false;
589
- // this.conversationsHandlerService.conversations = [];
590
-
591
- this.chatManager.setTiledeskToken(null);
592
- this.chatManager.setCurrentUser(null);
593
- this.chatManager.goOffLine();
594
-
595
- this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
596
-
597
- // clearTimeout(this.timeModalLogin);
598
- // this.timeModalLogin = setTimeout(() => {
599
- if (!this.hadBeenCalledOpenModal) {
600
- this.authModal = this.presentModal('goOffLine');
601
- this.hadBeenCalledOpenModal = true
602
- }
603
- // }, 1000);
604
-
605
- // this.unsubscribe$.next();
606
- // this.unsubscribe$.complete();
607
-
608
- }
609
660
  /**------- AUTHENTICATION FUNCTIONS --> END <--- +*/
610
661
  /***************************************************+*/
611
662
 
612
- /** */
613
- setLanguage() {
614
- this.translate.setDefaultLang('en');
615
- this.translate.use('en');
616
- this.logger.debug('[APP-COMP] navigator.language: ', navigator.language);
617
- let language;
618
- if (navigator.language.indexOf('-') !== -1) {
619
- language = navigator.language.substring(0, navigator.language.indexOf('-'));
620
- } else if (navigator.language.indexOf('_') !== -1) {
621
- language = navigator.language.substring(0, navigator.language.indexOf('_'));
622
- } else {
623
- language = navigator.language;
624
- }
625
- this.translate.use(language);
626
- }
663
+
627
664
 
628
665
  checkPlatform() {
629
- this.logger.debug('[APP-COMP] checkPlatform');
666
+ // console.log('[APP-COMP] checkPlatform');
630
667
  // let pageUrl = '';
631
668
  // try {
632
669
  // const pathPage = this.route.snapshot.firstChild.routeConfig.path;
@@ -642,21 +679,31 @@ export class AppComponent implements OnInit {
642
679
  // }
643
680
 
644
681
  if (checkPlatformIsMobile()) {
682
+ // this.chatManager.startApp()
683
+
684
+ this.logger.log('[APP-COMP] checkPlatformIsMobile', checkPlatformIsMobile());
645
685
  this.platformIs = PLATFORM_MOBILE;
646
686
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
647
- this.logger.log('[APP-COMP] PLATFORM_MOBILE2 navigateByUrl', PLATFORM_MOBILE, this.route.snapshot);
687
+
688
+ // console.log('[APP-COMP] platformIs', this.platformIs);
689
+ // console.log('[APP-COMP] PLATFORM', PLATFORM_MOBILE, 'route.snapshot', this.route.snapshot);
648
690
  if (!IDConv) {
649
691
  this.router.navigateByUrl('conversations-list')
650
692
  }
651
693
  // this.router.navigateByUrl(pageUrl);
652
694
  // this.navService.setRoot(ConversationListPage, {});
653
695
  } else {
696
+ // this.chatManager.startApp()
697
+ this.logger.log('[APP-COMP] checkPlatformIsMobile', checkPlatformIsMobile());
654
698
  this.platformIs = PLATFORM_DESKTOP;
699
+ // console.log('[APP-COMP] platformIs', this.platformIs);
700
+ // console.log('[APP-COMP] PLATFORM', PLATFORM_DESKTOP, 'route.snapshot', this.route.snapshot);
655
701
  this.logger.log('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
656
702
 
657
703
  this.navService.setRoot(ConversationListPage, {});
658
704
 
659
705
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
706
+
660
707
  const FullNameConv = this.route.snapshot.firstChild.paramMap.get('FullNameConv');
661
708
  const Convtype = this.route.snapshot.firstChild.paramMap.get('Convtype');
662
709
 
@@ -691,16 +738,23 @@ export class AppComponent implements OnInit {
691
738
  }
692
739
 
693
740
  private initAudio() {
741
+ // console.log('HERE IS initAudio ')
694
742
  // SET AUDIO
743
+ const href = window.location.href;
744
+ const hrefArray = href.split('/#/');
745
+ const chatBaseUrl = hrefArray[0]
746
+ // console.log('initAudio href', href)
747
+ // console.log('initAudio chatBaseUrl', chatBaseUrl)
748
+
695
749
  this.audio = new Audio();
696
- this.audio.src = URL_SOUND_LIST_CONVERSATION;
750
+ this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
697
751
  this.audio.load();
698
752
  }
699
753
 
700
754
  private manageTabNotification() {
701
755
  if (!this.isTabVisible) {
702
756
  // TAB IS HIDDEN --> manage title and SOUND
703
-
757
+ // console.log('HERE IS manageTabNotification ')
704
758
  let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
705
759
  badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
706
760
  document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
@@ -719,6 +773,7 @@ export class AppComponent implements OnInit {
719
773
  }
720
774
 
721
775
  soundMessage() {
776
+ // console.log('HERE IS soundMessage ')
722
777
  const that = this;
723
778
  // this.audio = new Audio();
724
779
  // // this.audio.src = '/assets/sounds/pling.mp3';
@@ -730,7 +785,7 @@ export class AppComponent implements OnInit {
730
785
  that.audio.play().then(() => {
731
786
  that.logger.debug('[APP-COMP] ****** soundMessage played *****');
732
787
  }).catch((error: any) => {
733
- that.logger.debug('[APP-COMP] ***soundMessage error*', error);
788
+ that.logger.error('[APP-COMP] ***soundMessage error*', error);
734
789
  });
735
790
  }, 1000);
736
791
  }
@@ -745,7 +800,6 @@ export class AppComponent implements OnInit {
745
800
  initSubscriptions() {
746
801
  this.logger.log('initialize FROM [APP-COMP] - initSubscriptions');
747
802
 
748
-
749
803
  // ---------------------------------------------------------------------------------------------------
750
804
  // Protecting from multiple subsciptions due to multiple app initializations (call to initializeApp())
751
805
  // Only one subscriber x application allowed
@@ -793,7 +847,7 @@ export class AppComponent implements OnInit {
793
847
 
794
848
  this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
795
849
 
796
- this.logger.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
850
+ // console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
797
851
  const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
798
852
  this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
799
853
 
@@ -806,6 +860,138 @@ export class AppComponent implements OnInit {
806
860
  });
807
861
  }
808
862
 
863
+ /**
864
+ * goOnLine:
865
+ * 1 - nascondo splashscreen
866
+ * 2 - recupero il tiledeskToken e lo salvo in chat manager
867
+ * 3 - carico in d
868
+ * @param user
869
+ */
870
+ goOnLine = () => {
871
+ // console.log('[APP-COMP] - GO-ONLINE ');
872
+ // this.isOnline = true;
873
+ // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
874
+ // clearTimeout(this.timeModalLogin);
875
+ const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
876
+
877
+ const supportmode = this.appConfigProvider.getConfig().supportMode;
878
+ this.logger.log('[APP-COMP] - GO-ONLINE - supportmode ', supportmode);
879
+ // if (supportmode === true) {
880
+ this.connetWebsocket(tiledeskToken)
881
+ // }
882
+ this.events.publish('go:online', true);
883
+ const currentUser = this.tiledeskAuthService.getCurrentUser();
884
+ // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
885
+ this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
886
+ this.chatManager.setTiledeskToken(tiledeskToken);
887
+ this.chatManager.setCurrentUser(currentUser);
888
+ this.chatManager.startApp();
889
+
890
+ // ----------------------------------------------
891
+ // PUSH NOTIFICATIONS
892
+ // ----------------------------------------------
893
+ const pushEngine = this.appConfigProvider.getConfig().pushEngine
894
+
895
+ if (currentUser) {
896
+ if (pushEngine && pushEngine !== 'none') {
897
+ this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
898
+ }
899
+ this.presenceService.setPresence(currentUser.uid);
900
+
901
+ this.initConversationsHandler(currentUser.uid);
902
+ this.initArchivedConversationsHandler(currentUser.uid);
903
+ }
904
+ this.checkPlatform();
905
+ try {
906
+ this.logger.debug('[APP-COMP] ************** closeModal', this.authModal);
907
+ if (this.authModal) {
908
+ this.closeModal();
909
+ }
910
+ } catch (err) {
911
+ this.logger.error('[APP-COMP] -> error:', err);
912
+ }
913
+ }
914
+
915
+ connetWebsocket(tiledeskToken) {
916
+ const appconfig = this.appConfigProvider.getConfig();
917
+ this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
918
+ const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
919
+ this.webSocketJs.init(
920
+ WS_URL,
921
+ undefined,
922
+ undefined,
923
+ undefined
924
+ );
925
+ }
926
+
927
+
928
+ goOffLine = () => {
929
+ console.log('[APP-COMP] - GO-OFFLINE');
930
+ const supportmode = this.appConfigProvider.getConfig().supportMode;
931
+ this.logger.log('[APP-COMP] - GO-OFFINE - supportmode ', supportmode);
932
+ // if (supportmode === true) {
933
+ this.webSocketClose()
934
+ // }
935
+ // this.isOnline = false;
936
+ // this.conversationsHandlerService.conversations = [];
937
+ this.chatManager.setTiledeskToken(null);
938
+ this.chatManager.setCurrentUser(null);
939
+ this.chatManager.goOffLine();
940
+
941
+ this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
942
+
943
+ // clearTimeout(this.timeModalLogin);
944
+ // this.timeModalLogin = setTimeout(() => {
945
+ if (!this.hadBeenCalledOpenModal) {
946
+ this.authModal = this.presentModal('goOffLine');
947
+ this.hadBeenCalledOpenModal = true
948
+ }
949
+ // }, 1000);
950
+
951
+ // this.unsubscribe$.next();
952
+ // this.unsubscribe$.complete();
953
+
954
+ }
955
+
956
+
957
+ webSocketClose() {
958
+ this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
959
+ this.webSocketJs.close()
960
+ this.events.publish('go:offline', true);
961
+ }
962
+
963
+ // BEGIN RESIZE FUNCTIONS //
964
+ @HostListener('window:resize', ['$event'])
965
+ onResize(event: any) {
966
+ const that = this;
967
+ // this.logger.debug('this.doitResize)', this.doitResize)
968
+ // clearTimeout(this.doitResize);
969
+ // this.doitResize = setTimeout(() => {
970
+ let platformIsNow = PLATFORM_DESKTOP;
971
+ if (checkPlatformIsMobile()) {
972
+ platformIsNow = PLATFORM_MOBILE;
973
+ }
974
+ if (!this.platformIs || this.platformIs === '') {
975
+ this.platformIs = platformIsNow;
976
+ }
977
+ this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
978
+ this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
979
+ this.logger.debug('[APP-COMP] onResize width:::: this.platformIs', this.platformIs);
980
+ this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
981
+ if (platformIsNow !== this.platformIs) {
982
+ window.location.reload();
983
+ // this.checkPlatform();
984
+ // this.initializeApp('onresize')
985
+ this.checkPlatform();
986
+ // this.goOnLine()
987
+ // // this.initSubscriptions();
988
+
989
+ }
990
+
991
+ // }, 0);
992
+ }
993
+ // END RESIZE FUNCTIONS //
994
+
809
995
  /**
810
996
  * ::: subscribeChangedConversationSelected :::
811
997
  * evento richiamato quando si seleziona un utente nell'elenco degli user
@@ -840,9 +1026,8 @@ export class AppComponent implements OnInit {
840
1026
  that.removePresenceAndLogout();
841
1027
  // that.presentToast();
842
1028
  }
843
- })
1029
+ });
844
1030
  }
845
-
846
1031
  }
847
1032
  }
848
1033
 
@@ -960,29 +1145,6 @@ export class AppComponent implements OnInit {
960
1145
  this.archivedConversationsHandlerService.initialize(this.tenant, userId, translationMap);
961
1146
  }
962
1147
 
963
- // BEGIN RESIZE FUNCTIONS //
964
- @HostListener('window:resize', ['$event'])
965
- onResize(event: any) {
966
- const that = this;
967
- // this.logger.debug('this.doitResize)', this.doitResize)
968
- clearTimeout(this.doitResize);
969
- this.doitResize = setTimeout(() => {
970
- let platformIsNow = PLATFORM_DESKTOP;
971
- if (checkPlatformIsMobile()) {
972
- platformIsNow = PLATFORM_MOBILE;
973
- }
974
- if (!this.platformIs || this.platformIs === '') {
975
- this.platformIs = platformIsNow;
976
- }
977
- this.logger.debug('[APP-COMP] onResize width::::', window.innerWidth);
978
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow', platformIsNow);
979
- this.logger.debug('[APP-COMP] onResize width:::: platformIsNow this.platformIs', this.platformIs);
980
- if (platformIsNow !== this.platformIs) {
981
- window.location.reload();
982
- }
983
- }, 500);
984
- }
985
- // END RESIZE FUNCTIONS //
986
1148
 
987
1149
  @HostListener('document:visibilitychange', [])
988
1150
  visibilitychange() {
@@ -1002,7 +1164,7 @@ export class AppComponent implements OnInit {
1002
1164
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
1003
1165
  @HostListener('window:storage', ['$event'])
1004
1166
  onStorageChanged(event: any) {
1005
- // console.log('[APP-COMP] - onStorageChanged event ', event)
1167
+
1006
1168
  if (event.key !== 'chat_sv5__tiledeskToken') {
1007
1169
  return;
1008
1170
  }
@@ -1041,7 +1203,4 @@ export class AppComponent implements OnInit {
1041
1203
  }
1042
1204
  }
1043
1205
  }
1044
-
1045
-
1046
-
1047
1206
  }