@chat21/chat21-ionic 3.0.57 → 3.0.59-rc12

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 (97) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +9 -0
  3. package/config.xml +11 -2
  4. package/env.sample +2 -0
  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-routing.module.ts +21 -17
  20. package/src/app/app.component.html +6 -3
  21. package/src/app/app.component.ts +264 -75
  22. package/src/app/app.module.ts +16 -8
  23. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
  24. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +4 -4
  25. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +8 -2
  26. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +6 -1
  27. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +7 -2
  28. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +48 -3
  29. package/src/app/chatlib/conversation-detail/message/image/image.component.html +7 -6
  30. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +20 -1
  31. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +39 -9
  32. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +8 -144
  33. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
  34. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
  35. package/src/app/components/authentication/login/login.component.html +10 -10
  36. package/src/app/components/authentication/login/login.component.ts +2 -1
  37. package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +1 -1
  38. package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.ts +1 -1
  39. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +17 -12
  40. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +12 -0
  41. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +21 -5
  42. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -2
  43. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +22 -17
  44. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -5
  45. package/src/app/components/ddp-header/ddp-header.component.html +1 -1
  46. package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
  47. package/src/app/components/image-viewer/image-viewer.component.html +23 -0
  48. package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
  49. package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
  50. package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
  51. package/src/app/components/project-item/project-item.component.html +147 -0
  52. package/src/app/components/project-item/project-item.component.scss +669 -0
  53. package/src/app/components/project-item/project-item.component.spec.ts +24 -0
  54. package/src/app/components/project-item/project-item.component.ts +317 -0
  55. package/src/app/components/utils/avatar-profile/avatar-profile.component.html +7 -0
  56. package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +22 -5
  57. package/src/app/pages/authentication/login/login.page.html +1 -2
  58. package/src/app/pages/authentication/login/login.page.ts +2 -2
  59. package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -3
  60. package/src/app/pages/conversation-detail/conversation-detail.page.ts +122 -30
  61. package/src/app/pages/conversations-list/conversations-list.page.html +44 -23
  62. package/src/app/pages/conversations-list/conversations-list.page.scss +290 -127
  63. package/src/app/pages/conversations-list/conversations-list.page.ts +131 -8
  64. package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
  65. package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
  66. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
  67. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
  68. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
  69. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +108 -0
  70. package/src/app/services/nav-proxy.service.ts +1 -1
  71. package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
  72. package/src/app/services/websocket/websocket-js.ts +557 -0
  73. package/src/app/services/websocket/websocket.service.spec.ts +12 -0
  74. package/src/app/services/websocket/websocket.service.ts +274 -0
  75. package/src/app/shared/shared.module.ts +7 -1
  76. package/src/assets/i18n/en.json +9 -1
  77. package/src/assets/i18n/it.json +10 -2
  78. package/src/assets/js/chat21client.js +141 -67
  79. package/src/assets/transparent.png +0 -0
  80. package/src/chat-config-pre-test.json +4 -2
  81. package/src/chat-config-template.json +3 -1
  82. package/src/chat-config.json +3 -1
  83. package/src/chat21-core/providers/chat-manager.ts +3 -3
  84. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
  85. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +50 -42
  86. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
  87. package/src/chat21-core/providers/firebase/firebase-notifications.ts +1 -1
  88. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +2 -2
  89. package/src/chat21-core/providers/firebase/firebase-typing.service.ts +1 -1
  90. package/src/chat21-core/providers/firebase/firebase-upload.service.ts +1 -1
  91. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
  92. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
  93. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
  94. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +13 -4
  95. package/src/chat21-core/utils/utils.ts +1 -1
  96. package/src/global.scss +2 -7
  97. package/src/index.html +1 -1
@@ -55,9 +55,8 @@ import { getImageUrlThumbFromFirebasestorage } from 'src/chat21-core/utils/utils
55
55
  import { TiledeskService } from './services/tiledesk/tiledesk.service';
56
56
  import { NetworkService } from './services/network-service/network.service';
57
57
  import * as PACKAGE from 'package.json';
58
-
59
- import { Subject } from 'rxjs';
60
- import { filter, takeUntil } from 'rxjs/operators'
58
+ import { filter } from 'rxjs/operators'
59
+ import { WebSocketJs } from './services/websocket/websocket-js';
61
60
 
62
61
  // import { filter } from 'rxjs/operators';
63
62
 
@@ -99,9 +98,11 @@ export class AppComponent implements OnInit {
99
98
  public missingConnectionToast: any
100
99
  public executedInitializeAppByWatchConnection: boolean = false;
101
100
  private version: string;
102
- private unsubscribe$: Subject<any> = new Subject<any>();
101
+
103
102
  // private isOnline: boolean = false;
104
103
 
104
+ wsService: WebSocketJs;
105
+
105
106
  constructor(
106
107
  private platform: Platform,
107
108
  private splashScreen: SplashScreen,
@@ -136,34 +137,105 @@ export class AppComponent implements OnInit {
136
137
  public toastController: ToastController,
137
138
  // private network: Network,
138
139
  // private tiledeskService: TiledeskService,
139
- private networkService: NetworkService
140
+ private networkService: NetworkService,
141
+ public webSocketJs: WebSocketJs,
140
142
  ) {
141
- this.logger.log('[APP-COMP] HELLO Constuctor !!!!!!!')
142
- // HACK: fix toast not presented when offline, due to lazy loading the toast controller.
143
- // this.toastController.create({ animated: false }).then(t => {
144
- // console.log('[APP-COMP] toastController create')
145
- // t.present();
146
- // t.dismiss();
147
- // });
143
+
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
148
  }
149
+ saveInStorageChatOpenedTab() {
150
+ // if (+localStorage.tabCount > 0) {
151
+ // alert('Already open!');
152
+ // } else {
153
+ // localStorage.tabCount = 0;
154
+ // }
155
+
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;
162
+ // });
163
+
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';
173
+ }
174
+ if (document.hasFocus()) {
175
+ return 'active';
176
+ }
177
+ return 'passive';
178
+ };
179
+
180
+ let state = getState();
181
+ console.log('[CONVS-LIST-PAGE] page state ', state)
182
+ if (state === 'hidden') {
183
+ localStorage.setItem('hidden', 'true')
184
+ }
185
+
186
+ const logStateChange = (nextState) => {
187
+ const prevState = state;
188
+ if (nextState !== prevState) {
189
+ console.log(`State change: ${prevState} >>> ${nextState}`);
190
+ state = nextState;
191
+ }
192
+ };
193
+
194
+ ['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
195
+ window.addEventListener(type, () => logStateChange(getState()), { capture: true });
196
+ });
197
+
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 });
204
+
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')
216
+ }
217
+ }, { capture: true });
149
218
 
150
- param() {
151
- // PARAM
152
- const url: URL = new URL(window.top.location.href);
153
- const params: URLSearchParams = url.searchParams;
154
- return params;
155
219
  }
220
+
221
+
222
+ // param() {
223
+ // // PARAM
224
+ // const url: URL = new URL(window.top.location.href);
225
+ // const params: URLSearchParams = url.searchParams;
226
+ // return params;
227
+ // }
156
228
  /**
157
229
  */
158
230
  ngOnInit() {
159
231
  const appconfig = this.appConfigProvider.getConfig();
160
232
  this.persistence = appconfig.authPersistence;
161
233
  this.appStorageService.initialize(environment.storage_prefix, this.persistence, '')
162
- this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
163
- this.logger.info('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
234
+ // this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
235
+ // this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
164
236
  // this.initializeApp('oninit');
165
237
  const token = getParameterByName('jwt')
166
- this.logger.info('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
238
+ // this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
167
239
 
168
240
  if (token) {
169
241
  // this.isOnline = false;
@@ -182,9 +254,81 @@ export class AppComponent implements OnInit {
182
254
  }
183
255
  this.initializeApp('oninit');
184
256
 
257
+ this.listenToPostMsgs();
185
258
  }
186
259
 
187
260
 
261
+
262
+ listenToPostMsgs() {
263
+ window.addEventListener("message", (event) => {
264
+ // console.log("[APP-COMP] message event ", event);
265
+
266
+ if (event && event.data && event.data.action && event.data.parameter) {
267
+ if (event.data.action === 'openJoinConversationModal') {
268
+ // console.log("[APP-COMP] message event action ", event.data.action);
269
+ // console.log("[APP-COMP] message event parameter ", event.data.parameter);
270
+ this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
271
+ }
272
+ }
273
+ if (event && event.data && event.data.action && event.data.text) {
274
+ if (event.data.action === "display_toast_join_complete") {
275
+ this.presentToastJoinComplete(event.data.text)
276
+ }
277
+ }
278
+ })
279
+ }
280
+
281
+ async presentToastJoinComplete(text) {
282
+ const toast = await this.toastController.create({
283
+ message: text,
284
+ duration: 2000,
285
+ color: "success"
286
+ });
287
+ toast.present();
288
+ }
289
+
290
+ async presentAlertConfirmJoinRequest(requestid, calledby) {
291
+ var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
292
+ // console.log("[APP-COMP] message event iframeWin ", iframeWin);
293
+
294
+ const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
295
+ input !== null && input.tagName === 'IFRAME';
296
+
297
+ const keys = ['YouAreAboutToJoinThisChat', 'Cancel', 'AreYouSure'];
298
+ const translationMap = this.translateService.translateLanguage(keys);
299
+
300
+ const alert = await this.alertController.create({
301
+ cssClass: 'my-custom-class',
302
+ header: translationMap.get('AreYouSure'),
303
+ message: translationMap.get('YouAreAboutToJoinThisChat'),
304
+ buttons: [
305
+ {
306
+ text: translationMap.get('Cancel'),
307
+ role: 'cancel',
308
+ cssClass: 'secondary',
309
+ handler: (blah) => {
310
+ // console.log('Confirm Cancel: blah', blah);
311
+ }
312
+ }, {
313
+ text: 'Ok',
314
+ handler: () => {
315
+ // console.log('Confirm Okay');
316
+
317
+ if (isIFrame(iframeWin) && iframeWin.contentWindow) {
318
+ const msg = { action: "joinConversation", parameter: requestid, calledBy: calledby }
319
+ iframeWin.contentWindow.postMessage(msg, '*');
320
+ }
321
+ }
322
+ }
323
+ ]
324
+ });
325
+
326
+ await alert.present();
327
+ }
328
+
329
+
330
+
331
+
188
332
  signInWithCustomToken(token) {
189
333
  // this.isOnline = false;
190
334
  this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN token', token)
@@ -196,25 +340,22 @@ export class AppComponent implements OnInit {
196
340
  .catch(error => {
197
341
  this.logger.error('[APP-COMP] SIGNINWITHCUSTOMTOKEN error::', error)
198
342
  })
199
-
200
343
  }
201
344
 
202
-
203
-
204
345
  /** */
205
346
  initializeApp(calledby: string) {
206
- console.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
207
- this.logger.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
347
+ // this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
348
+ // console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
208
349
 
209
- if (!this.platform.is('cordova')) {
210
- this.splashScreen.show();
211
- }
350
+ // if (!this.platform.is('cordova')) {
351
+ this.splashScreen.show();
352
+ // }
212
353
  this.tabTitle = document.title;
213
354
 
214
355
  this.getRouteParamsAndSetLoggerConfig();
215
356
 
216
357
  const appconfig = this.appConfigProvider.getConfig();
217
- this.logger.info('[APP-COMP] appconfig: ', appconfig)
358
+ // this.logger.info('[APP-COMP] appconfig: ', appconfig)
218
359
  this.version = PACKAGE.version;
219
360
  this.logger.info('[APP-COMP] version: ', this.version)
220
361
 
@@ -226,12 +367,39 @@ export class AppComponent implements OnInit {
226
367
  this.notificationsEnabled = true;
227
368
  this.zone = new NgZone({}); // a cosa serve?
228
369
 
370
+ // ------------------------------------------
371
+ // Platform ready
372
+ // ------------------------------------------
229
373
  this.platform.ready().then(() => {
230
- this.setLanguage();
374
+ // console.log("Check platform");
375
+ if (this.platform.is('cordova')) {
376
+ // console.log("the device running Cordova");
377
+ }
378
+ if (!this.platform.is('cordova')) {
379
+ // console.log("the device Not running Cordova");
380
+ }
231
381
 
232
- if (this.splashScreen) {
233
- this.splashScreen.hide();
382
+ if (this.platform.is('android')) {
383
+ // console.log("running on Android device!");
384
+ }
385
+ if (this.platform.is('ios')) {
386
+ // console.log("running on iOS device!");
387
+ }
388
+ if (this.platform.is('mobileweb')) {
389
+ // console.log("running in a browser on mobile!");
390
+ }
391
+ if (this.platform.is('desktop')) {
392
+ // console.log("running on desktop!");
234
393
  }
394
+
395
+
396
+
397
+
398
+ this.setLanguage();
399
+
400
+ // if (this.splashScreen) {
401
+ this.splashScreen.hide();
402
+ // }
235
403
  this.statusBar.styleDefault();
236
404
  this.navService.init(this.sidebarNav, this.detailNav);
237
405
  // this.persistence = appconfig.authPersistence;
@@ -323,9 +491,9 @@ export class AppComponent implements OnInit {
323
491
  getRouteParamsAndSetLoggerConfig() {
324
492
  const appconfig = this.appConfigProvider.getConfig();
325
493
  this.route.queryParams.subscribe(params => {
326
- this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
494
+ // this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
327
495
  if (params.logLevel) {
328
- this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
496
+ this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
329
497
  this.logger.setLoggerConfig(true, params.logLevel)
330
498
  } else {
331
499
  this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
@@ -355,7 +523,8 @@ export class AppComponent implements OnInit {
355
523
  /**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
356
524
  private initAuthentication() {
357
525
  const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
358
- console.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
526
+
527
+ this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
359
528
  this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
360
529
  // const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
361
530
  // this.logger.log('[APP-COMP] >>> initAuthentication currentUser ', currentUser)
@@ -369,23 +538,35 @@ export class AppComponent implements OnInit {
369
538
  })
370
539
  } else {
371
540
  this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
372
- const that = this;
373
- clearTimeout(this.timeModalLogin);
374
- this.timeModalLogin = setTimeout(() => {
375
- if (!this.hadBeenCalledOpenModal) {
376
- this.authModal = this.presentModal('initAuthentication');
377
- this.hadBeenCalledOpenModal = true;
378
- }
379
- }, 1000);
541
+
542
+ // clearTimeout(this.timeModalLogin);
543
+ // this.timeModalLogin = setTimeout(() => {
544
+ if (!this.hadBeenCalledOpenModal) {
545
+ this.authModal = this.presentModal('initAuthentication');
546
+ this.hadBeenCalledOpenModal = true;
547
+ }
548
+ // }, 1000);
380
549
  }
381
550
  }
382
551
 
383
- checkTokenAndGoOffline() {
384
- let token = this.appStorageService.getItem('tiledeskToken');
385
- this.logger.info('[APP-COMP] ***** checkTokenAndGoOffline - stored token *****', token);
386
- if (!token) {
387
- this.goOffLine()
388
- }
552
+ // checkTokenAndGoOffline() {
553
+ // let token = this.appStorageService.getItem('tiledeskToken');
554
+ // this.logger.info('[APP-COMP] ***** checkTokenAndGoOffline - stored token *****', token);
555
+ // if (!token) {
556
+ // this.goOffLine()
557
+ // }
558
+ // }
559
+
560
+ connetWebsocket(tiledeskToken) {
561
+ const appconfig = this.appConfigProvider.getConfig();
562
+ this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
563
+ const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
564
+ this.webSocketJs.init(
565
+ WS_URL,
566
+ undefined,
567
+ undefined,
568
+ undefined
569
+ );
389
570
  }
390
571
 
391
572
  /**
@@ -396,12 +577,14 @@ export class AppComponent implements OnInit {
396
577
  * @param user
397
578
  */
398
579
  goOnLine = () => {
580
+ console.log('[APP-COMP] - GO-ONLINE ');
399
581
  // this.isOnline = true;
400
582
  // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
401
583
 
402
-
403
- clearTimeout(this.timeModalLogin);
584
+ // clearTimeout(this.timeModalLogin);
404
585
  const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
586
+ this.connetWebsocket(tiledeskToken)
587
+ this.events.publish('go:online', true);
405
588
  const currentUser = this.tiledeskAuthService.getCurrentUser();
406
589
  // this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
407
590
  this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
@@ -416,9 +599,8 @@ export class AppComponent implements OnInit {
416
599
  if (pushEngine && pushEngine !== 'none') {
417
600
  this.notificationsService.getNotificationPermissionAndSaveToken(currentUser.uid);
418
601
  }
419
-
420
-
421
602
  this.presenceService.setPresence(currentUser.uid);
603
+
422
604
  this.initConversationsHandler(currentUser.uid);
423
605
  this.initArchivedConversationsHandler(currentUser.uid);
424
606
  }
@@ -434,8 +616,17 @@ export class AppComponent implements OnInit {
434
616
  this.chatManager.startApp();
435
617
  }
436
618
 
619
+
620
+ webSocketClose() {
621
+ this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
622
+ this.webSocketJs.close()
623
+ this.events.publish('go:offline', true);
624
+ }
625
+
437
626
  goOffLine = () => {
438
- this.logger.log('[APP-COMP] ************** goOffLine authModal:', this.authModal);
627
+ console.log('[APP-COMP] - GO-OFFLINE');
628
+
629
+ this.webSocketClose()
439
630
  // this.isOnline = false;
440
631
  // this.conversationsHandlerService.conversations = [];
441
632
 
@@ -444,14 +635,14 @@ export class AppComponent implements OnInit {
444
635
  this.chatManager.goOffLine();
445
636
 
446
637
  this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
447
- const that = this;
448
- clearTimeout(this.timeModalLogin);
449
- this.timeModalLogin = setTimeout(() => {
450
- if (!this.hadBeenCalledOpenModal) {
451
- this.authModal = this.presentModal('goOffLine');
452
- this.hadBeenCalledOpenModal = true
453
- }
454
- }, 1000);
638
+
639
+ // clearTimeout(this.timeModalLogin);
640
+ // this.timeModalLogin = setTimeout(() => {
641
+ if (!this.hadBeenCalledOpenModal) {
642
+ this.authModal = this.presentModal('goOffLine');
643
+ this.hadBeenCalledOpenModal = true
644
+ }
645
+ // }, 1000);
455
646
 
456
647
  // this.unsubscribe$.next();
457
648
  // this.unsubscribe$.complete();
@@ -607,10 +798,11 @@ export class AppComponent implements OnInit {
607
798
  }
608
799
 
609
800
  this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
801
+
610
802
  // .pipe(takeUntil(this.unsubscribe$))
611
803
  .pipe(filter((state) => state !== null))
612
804
  .subscribe((state: any) => {
613
- console.log('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged state', state);
805
+ this.logger.log('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged state', state);
614
806
  // this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged isOnline', this.isOnline);
615
807
  if (state && state === AUTH_STATE_ONLINE) {
616
808
  // const user = this.tiledeskAuthService.getCurrentUser();
@@ -619,8 +811,8 @@ export class AppComponent implements OnInit {
619
811
  this.goOnLine();
620
812
  // }
621
813
  } else if (state === AUTH_STATE_OFFLINE) {
622
- this.checkTokenAndGoOffline() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
623
- // this.goOffLine()
814
+ // this.checkTokenAndGoOffline() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
815
+ this.goOffLine()
624
816
  }
625
817
  }, error => {
626
818
  this.logger.error('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged * error * ', error)
@@ -662,7 +854,7 @@ export class AppComponent implements OnInit {
662
854
  * apro dettaglio conversazione
663
855
  */
664
856
  subscribeChangedConversationSelected = (user: UserModel, type: string) => {
665
- this.logger.info('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
857
+ this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
666
858
  // this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
667
859
  this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
668
860
  }
@@ -852,13 +1044,13 @@ export class AppComponent implements OnInit {
852
1044
  // https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
853
1045
  @HostListener('window:storage', ['$event'])
854
1046
  onStorageChanged(event: any) {
855
- // console.log('[APP-COMP] - onStorageChanged event ', event)
1047
+
856
1048
  if (event.key !== 'chat_sv5__tiledeskToken') {
857
1049
  return;
858
1050
  }
859
1051
 
860
1052
  if (this.appStorageService.getItem('tiledeskToken') === null) {
861
- console.log('[APP-COMP] - onStorageChanged tiledeskToken is null - RUN LOGOUT')
1053
+ // console.log('[APP-COMP] - onStorageChanged tiledeskToken is null - RUN LOGOUT')
862
1054
  this.tiledeskAuthService.logOut()
863
1055
  this.messagingAuthService.logout();
864
1056
  this.events.publish('profileInfoButtonClick:logout', true);
@@ -866,13 +1058,13 @@ export class AppComponent implements OnInit {
866
1058
  }
867
1059
  else {
868
1060
  const currentUser = this.tiledeskAuthService.getCurrentUser();
869
- console.log('[APP-COMP] - X - onStorageChanged currentUser', currentUser)
1061
+ // console.log('[APP-COMP] - X - onStorageChanged currentUser', currentUser)
870
1062
 
871
1063
  const currentToken = this.tiledeskAuthService.getTiledeskToken();
872
- console.log('[APP-COMP] - onStorageChanged currentToken', currentToken)
1064
+ // console.log('[APP-COMP] - onStorageChanged currentToken', currentToken)
873
1065
  if (this.appStorageService.getItem('tiledeskToken') !== null && currentToken !== this.appStorageService.getItem('tiledeskToken')) {
874
1066
 
875
- console.log('[APP-COMP] - onStorageChanged wentOnline 2')
1067
+ // console.log('[APP-COMP] - onStorageChanged wentOnline 2')
876
1068
  // DEALLOCO RISORSE OCCUPATE
877
1069
  this.messagingAuthService.logout();
878
1070
  this.appStorageService.removeItem('currentUser')
@@ -881,7 +1073,7 @@ export class AppComponent implements OnInit {
881
1073
  // this.unsubscribe$.complete();
882
1074
  this.initializeApp('onstoragechanged');
883
1075
 
884
- console.log('[APP-COMP] - that.BSAuthStateChanged ', this.messagingAuthService.BSAuthStateChanged)
1076
+
885
1077
 
886
1078
  // console.log('[APP-COMP] onAuthStateChanged HERE !!! ')
887
1079
  // firebase.auth().onAuthStateChanged(user => {
@@ -891,7 +1083,4 @@ export class AppComponent implements OnInit {
891
1083
  }
892
1084
  }
893
1085
  }
894
-
895
-
896
-
897
1086
  }
@@ -94,7 +94,8 @@ import { TooltipModule } from 'ng2-tooltip-directive';
94
94
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
95
95
  import { Network } from '@ionic-native/network/ngx';
96
96
  import { ConnectionService } from 'ng-connection-service';
97
-
97
+ import { WebSocketJs } from './services/websocket/websocket-js';
98
+ import { UnassignedConversationsPageModule } from './pages/unassigned-conversations/unassigned-conversations.module';
98
99
 
99
100
  // FACTORIES
100
101
  export function createTranslateLoader(http: HttpClient) {
@@ -102,7 +103,7 @@ export function createTranslateLoader(http: HttpClient) {
102
103
 
103
104
  }
104
105
 
105
- export function authenticationFactory(http: HttpClient, appConfig: AppConfigProvider, chat21Service: Chat21Service, appSorage: AppStorageService, network: Network, connectionService:ConnectionService) {
106
+ export function authenticationFactory(http: HttpClient, appConfig: AppConfigProvider, chat21Service: Chat21Service, appSorage: AppStorageService, network: Network, connectionService: ConnectionService) {
106
107
  const config = appConfig.getConfig()
107
108
  if (config.chatEngine === CHAT_ENGINE_MQTT) {
108
109
 
@@ -111,8 +112,13 @@ export function authenticationFactory(http: HttpClient, appConfig: AppConfigProv
111
112
 
112
113
  const auth = new MQTTAuthService(http, chat21Service, appSorage);
113
114
 
114
- auth.setBaseUrl(appConfig.getConfig().apiUrl)
115
-
115
+ auth.setBaseUrl(appConfig.getConfig().apiUrl);
116
+
117
+ if (config.pushEngine = PUSH_ENGINE_MQTT) {
118
+ // FOR PUSH NOTIFICATIONS INIT FIREBASE APP
119
+ FirebaseInitService.initFirebase(config.firebaseConfig);
120
+ }
121
+
116
122
  return auth
117
123
  } else {
118
124
 
@@ -120,7 +126,7 @@ export function authenticationFactory(http: HttpClient, appConfig: AppConfigProv
120
126
  // console.log('[APP-MOD] FirebaseInitService config ', config)
121
127
  const auth = new FirebaseAuthService(http, network, connectionService);
122
128
  auth.setBaseUrl(config.apiUrl)
123
-
129
+
124
130
  return auth
125
131
  }
126
132
  }
@@ -216,12 +222,12 @@ export function uploadFactory(http: HttpClient, appConfig: AppConfigProvider, ap
216
222
  }
217
223
  }
218
224
 
219
- export function notificationsServiceFactory(appConfig: AppConfigProvider) {
225
+ export function notificationsServiceFactory(appConfig: AppConfigProvider, chat21Service: Chat21Service) {
220
226
  const config = appConfig.getConfig()
221
227
  if (config.pushEngine === PUSH_ENGINE_FIREBASE) {
222
228
  return new FirebaseNotifications();
223
229
  } else if (config.pushEngine === PUSH_ENGINE_MQTT) {
224
- return new MQTTNotifications();
230
+ return new MQTTNotifications(chat21Service);
225
231
  } else {
226
232
  return;
227
233
  }
@@ -253,6 +259,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
253
259
  LoginPageModule,
254
260
  ConversationListPageModule,
255
261
  ConversationDetailPageModule,
262
+ UnassignedConversationsPageModule,
256
263
  TranslateModule.forRoot({
257
264
  loader: {
258
265
  provide: TranslateLoader,
@@ -338,7 +345,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
338
345
  {
339
346
  provide: NotificationsService,
340
347
  useFactory: notificationsServiceFactory,
341
- deps: [AppConfigProvider]
348
+ deps: [AppConfigProvider, Chat21Service]
342
349
  },
343
350
  {
344
351
  provide: AppStorageService,
@@ -352,6 +359,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
352
359
  EventsService,
353
360
  Chooser,
354
361
  Chat21Service,
362
+ WebSocketJs
355
363
  ]
356
364
  })
357
365
  export class AppModule { }
@@ -10,7 +10,7 @@
10
10
  <div class="chat21-bounce1" [ngStyle]="{'background-color': stylesMap.get('themeColor')}"></div>
11
11
  <div class="chat21-bounce2" [ngStyle]="{'background-color': stylesMap.get('themeColor')}"></div>
12
12
  <div class="chat21-bounce3" [ngStyle]="{'background-color': stylesMap.get('themeColor')}"></div>
13
- <span>{{translationMap.get('LABEL_LOADING')}}</span>
13
+ <span>{{translationMap?.get('LABEL_LOADING')}}</span>
14
14
  </div>
15
15
  </span>
16
16
 
@@ -67,8 +67,8 @@
67
67
  <div role="messaggio" *ngIf="messageType(MESSAGE_TYPE_MINE, message)" class="msg_container base_sent">
68
68
 
69
69
  <!--backgroundColor non viene ancora usato -->
70
- <chat-bubble-message
71
- class="messages msg_sent" id="{{'message'+'_'+ i}}"
70
+ <chat-bubble-message [ngClass]="{'has-metadata': (isImage(message) || isFrame(message))}"
71
+ class="messages msg_sent" id="message_msg_sent"
72
72
  [ngClass]="{'button-in-msg' : message.metadata && message.metadata.button}" [message]="message"
73
73
  [textColor]="'col-msg-sent'"
74
74
  (onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
@@ -98,8 +98,8 @@
98
98
  </chat-avatar-image> -->
99
99
 
100
100
  <!--backgroundColor non viene ancora usato -->
101
-
102
- <chat-bubble-message class="messages msg_receive"
101
+
102
+ <chat-bubble-message [ngClass]="{'has-metadata': (isImage(message) || isFrame(message))}" class="messages msg_receive" id="message_msg_receive"
103
103
  [message]="message"
104
104
  [textColor]="'black'"
105
105
  (onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
@@ -93,7 +93,9 @@ ion-item {
93
93
 
94
94
  }
95
95
 
96
-
96
+ .has-metadata {
97
+ max-width: 100% !important;
98
+ }
97
99
  }
98
100
 
99
101
  /** recive message **/
@@ -138,7 +140,11 @@ ion-item {
138
140
  border-top-left-radius: 8px;
139
141
  border-bottom-left-radius: 0px;
140
142
 
141
- }
143
+ }
144
+
145
+ .has-metadata {
146
+ max-width: 100% !important;
147
+ }
142
148
  }
143
149
 
144
150
  .time{