@chat21/chat21-ionic 3.0.52-beta → 3.0.55-RC6

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 (54) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/LICENSE +21 -0
  3. package/config.xml +1 -0
  4. package/env.sample +1 -0
  5. package/package.json +6 -2
  6. package/resources/Android/icon/drawable-hdpi-icon.png +0 -0
  7. package/resources/Android/icon/drawable-ldpi-icon.png +0 -0
  8. package/resources/Android/icon/drawable-mdpi-icon.png +0 -0
  9. package/resources/Android/icon/drawable-xhdpi-icon.png +0 -0
  10. package/resources/Android/icon/drawable-xxhdpi-icon.png +0 -0
  11. package/resources/Android/icon/drawable-xxxhdpi-icon.png +0 -0
  12. package/resources/Android/icon.png +0 -0
  13. package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
  14. package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
  15. package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
  16. package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
  17. package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
  18. package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
  19. package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
  20. package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
  21. package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
  22. package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
  23. package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
  24. package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
  25. package/resources/Android/splash.png +0 -0
  26. package/src/app/app.component.ts +509 -434
  27. package/src/app/app.module.ts +10 -5
  28. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +4 -0
  29. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +27 -30
  30. package/src/app/chatlib/conversation-detail/message/text/text.component.html +1 -1
  31. package/src/app/chatlib/conversation-detail/message/text/text.component.ts +27 -3
  32. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +18 -5
  33. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +15 -3
  34. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +24 -6
  35. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +4 -0
  36. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +17 -4
  37. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +20 -16
  38. package/src/app/components/conversation-info/info-content/info-content.component.ts +8 -1
  39. package/src/app/pages/conversation-detail/conversation-detail.page.html +37 -16
  40. package/src/app/pages/conversation-detail/conversation-detail.page.ts +143 -53
  41. package/src/app/pages/conversations-list/conversations-list.page.html +5 -2
  42. package/src/app/pages/conversations-list/conversations-list.page.ts +19 -14
  43. package/src/chat-config-pre-test.json +4 -2
  44. package/src/chat-config-template.json +2 -1
  45. package/src/chat-config.json +2 -1
  46. package/src/chat21-core/providers/abstract/messagingAuth.service.ts +1 -1
  47. package/src/chat21-core/providers/abstract/notifications.service.ts +2 -2
  48. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +6 -4
  49. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +84 -17
  50. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +15 -10
  51. package/src/chat21-core/providers/firebase/firebase-notifications.ts +119 -18
  52. package/src/chat21-core/providers/localSessionStorage.ts +2 -1
  53. package/src/chat21-core/utils/utils-user.ts +2 -1
  54. package/src/index.html +87 -6
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
2
2
  import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
3
3
  import { BehaviorSubject } from 'rxjs';
4
4
  import { ActivatedRoute } from '@angular/router';
5
-
5
+ import { ConnectionService } from 'ng-connection-service';
6
6
  // firebase
7
7
  // import * as firebase from 'firebase/app';
8
8
  import firebase from "firebase/app";
@@ -30,6 +30,9 @@ import { LoggerInstance } from '../logger/loggerInstance';
30
30
  import { LoggerService } from '../abstract/logger.service';
31
31
 
32
32
 
33
+ import { Observable, Observer, fromEvent, merge } from 'rxjs';
34
+ import { map } from 'rxjs/operators'
35
+ import { Network } from '@ionic-native/network/ngx';
33
36
  // @Injectable({ providedIn: 'root' })
34
37
  @Injectable()
35
38
  export class FirebaseAuthService extends MessagingAuthService {
@@ -53,9 +56,15 @@ export class FirebaseAuthService extends MessagingAuthService {
53
56
  // private imageRepo: ImageRepoService = new FirebaseImageRepoService();
54
57
 
55
58
  private firebaseToken: string;
56
- private logger:LoggerService = LoggerInstance.getInstance()
59
+ private logger: LoggerService = LoggerInstance.getInstance()
60
+
61
+ status = 'ONLINE';
62
+ isConnected = true;
63
+
57
64
  constructor(
58
- public http: HttpClient
65
+ public http: HttpClient,
66
+ private network: Network,
67
+ private connectionService: ConnectionService
59
68
  ) {
60
69
  super();
61
70
  }
@@ -64,7 +73,7 @@ export class FirebaseAuthService extends MessagingAuthService {
64
73
  *
65
74
  */
66
75
  initialize() {
67
-
76
+
68
77
  this.SERVER_BASE_URL = this.getBaseUrl();
69
78
  this.URL_TILEDESK_CREATE_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'chat21/firebase/auth/createCustomToken';
70
79
  this.logger.info('[FIREBASEAuthSERVICE] - initialize URL_TILEDESK_CREATE_CUSTOM_TOKEN ', this.URL_TILEDESK_CREATE_CUSTOM_TOKEN)
@@ -72,9 +81,66 @@ export class FirebaseAuthService extends MessagingAuthService {
72
81
  // this.URL_TILEDESK_SIGNIN_ANONYMOUSLY = this.SERVER_BASE_URL + 'auth/signinAnonymously'
73
82
  // this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN = this.SERVER_BASE_URL + 'auth/signinWithCustomToken';
74
83
  // this.checkIsAuth();
84
+
85
+ // this.createOnline$().subscribe((isOnline) =>{
86
+ // console.log('FIREBASEAuthSERVICE] isOnline ', isOnline);
87
+ // if (isOnline === true ) {
88
+ // this.onAuthStateChanged();
89
+ // }
90
+ // })
91
+ this.checkInternetConnection()
92
+
75
93
  this.onAuthStateChanged();
76
94
  }
77
95
 
96
+ checkInternetConnection () {
97
+ this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection');
98
+ // let connectSubscription = this.network.onConnect().subscribe(() => {
99
+ // this.logger.log('[FIREBASEAuthSERVICE] - network connected!');
100
+ // // We just got a connection but we need to wait briefly
101
+ // // before we determine the connection type. Might need to wait.
102
+ // // prior to doing any api requests as well.
103
+ // setTimeout(() => {
104
+ // if (this.network.type === 'wifi') {
105
+ // this.logger.log('[FIREBASEAuthSERVICE] - we got a wifi connection, woohoo!');
106
+ // }
107
+ // }, 3000);
108
+ // });
109
+
110
+
111
+ this.connectionService.monitor().subscribe(isConnected => {
112
+ this.isConnected = isConnected;
113
+ this.logger.log('[FIREBASEAuthSERVICE] - checkInternetConnection isConnected', isConnected);
114
+ if (this.isConnected) {
115
+ this.status = "ONLINE";
116
+
117
+ // this.onAuthStateChanged();
118
+ firebase.auth().onAuthStateChanged(user => {
119
+ this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
120
+ })
121
+ }
122
+ else {
123
+ this.status = "OFFLINE";
124
+ // this.onAuthStateChanged();
125
+ firebase.auth().onAuthStateChanged(user => {
126
+ this.logger.log('[FIREBASEAuthSERVICE] checkInternetConnection onAuthStateChanged', user)
127
+ })
128
+ }
129
+ })
130
+
131
+
132
+ }
133
+
134
+ // createOnline$() {
135
+ // return merge<boolean>(
136
+ // fromEvent(window, 'offline').pipe(map(() => false)),
137
+ // fromEvent(window, 'online').pipe(map(() => true)),
138
+ // new Observable((sub: Observer<boolean>) => {
139
+ // sub.next(navigator.onLine);
140
+ // sub.complete();
141
+ // }));
142
+ // }
143
+
78
144
  /**
79
145
  * checkIsAuth
80
146
  */
@@ -113,12 +179,12 @@ export class FirebaseAuthService extends MessagingAuthService {
113
179
  onAuthStateChanged() {
114
180
  const that = this;
115
181
  firebase.auth().onAuthStateChanged(user => {
116
- this.logger.debug('[FIREBASEAuthSERVICE] onAuthStateChanged', user)
182
+ this.logger.log('[FIREBASEAuthSERVICE] onAuthStateChanged', user)
117
183
  if (!user) {
118
- this.logger.debug('[FIREBASEAuthSERVICE] 1 - PASSO OFFLINE AL CHAT MANAGER')
184
+ this.logger.log('[FIREBASEAuthSERVICE] 1 - PASSO OFFLINE AL CHAT MANAGER')
119
185
  that.BSAuthStateChanged.next('offline');
120
186
  } else {
121
- this.logger.debug('[FIREBASEAuthSERVICE] 2 - PASSO ONLINE AL CHAT MANAGER')
187
+ this.logger.log('[FIREBASEAuthSERVICE] 2 - PASSO ONLINE AL CHAT MANAGER')
122
188
  that.BSAuthStateChanged.next('online');
123
189
  }
124
190
  });
@@ -131,6 +197,7 @@ export class FirebaseAuthService extends MessagingAuthService {
131
197
  signInFirebaseWithCustomToken(token: string): Promise<any> {
132
198
  const that = this;
133
199
  let firebasePersistence;
200
+ console.log('FB-AUTH firebasePersistence', this.getPersistence())
134
201
  switch (this.getPersistence()) {
135
202
  case 'SESSION': {
136
203
  firebasePersistence = firebase.auth.Auth.Persistence.SESSION;
@@ -149,13 +216,13 @@ export class FirebaseAuthService extends MessagingAuthService {
149
216
  break;
150
217
  }
151
218
  }
152
- return firebase.auth().setPersistence(firebasePersistence).then( async () => {
153
- return firebase.auth().signInWithCustomToken(token).then( async () => {
154
- // that.firebaseSignInWithCustomToken.next(response);
155
- }).catch((error) => {
156
- that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
157
- // that.firebaseSignInWithCustomToken.next(null);
158
- });
219
+ return firebase.auth().setPersistence(firebasePersistence).then(async () => {
220
+ return firebase.auth().signInWithCustomToken(token).then(async () => {
221
+ // that.firebaseSignInWithCustomToken.next(response);
222
+ }).catch((error) => {
223
+ that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
224
+ // that.firebaseSignInWithCustomToken.next(null);
225
+ });
159
226
  }).catch((error) => {
160
227
  that.logger.error('[FIREBASEAuthSERVICE] signInFirebaseWithCustomToken Error: ', error);
161
228
  });
@@ -200,7 +267,7 @@ export class FirebaseAuthService extends MessagingAuthService {
200
267
  private signOut() {
201
268
  const that = this;
202
269
  firebase.auth().signOut().then(() => {
203
- that.logger.debug('[FIREBASEAuthSERVICE] firebase-sign-out');
270
+ that.logger.log('[FIREBASEAuthSERVICE] signOut firebase-sign-out');
204
271
  // cancello token
205
272
  // this.appStorage.removeItem('tiledeskToken');
206
273
  //localStorage.removeItem('firebaseToken');
@@ -244,12 +311,12 @@ export class FirebaseAuthService extends MessagingAuthService {
244
311
  //localStorage.setItem('firebaseToken', that.firebaseToken);
245
312
  that.signInFirebaseWithCustomToken(data)
246
313
  }, error => {
247
- that.logger.error('[FIREBASEAuthSERVICE] createFirebaseCustomToken ERR ', error)
314
+ that.logger.error('[FIREBASEAuthSERVICE] createFirebaseCustomToken ERR ', error)
248
315
  });
249
316
  }
250
317
 
251
318
  logout() {
252
- this.logger.debug('[FIREBASEAuthSERVICE] logout');
319
+ this.logger.log('[FIREBASEAuthSERVICE] logout');
253
320
  // cancello token firebase dal local storage e da firebase
254
321
  // dovrebbe scattare l'evento authchangeStat
255
322
  this.signOut();
@@ -47,7 +47,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
47
47
  private loggedUserId: string;
48
48
  private translationMap: Map<string, string>;
49
49
  private isConversationClosingMap: Map<string, boolean>;
50
- private logger:LoggerService = LoggerInstance.getInstance()
50
+ private logger: LoggerService = LoggerInstance.getInstance()
51
51
  private ref: firebase.database.Query;
52
52
  private BASE_URL: string;
53
53
  // private audio: any;
@@ -127,7 +127,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
127
127
  this.ref.on('child_added', (childSnapshot) => {
128
128
  that.added(childSnapshot);
129
129
  });
130
-
130
+
131
131
  setTimeout(() => {
132
132
  callback()
133
133
  }, 2000);
@@ -263,22 +263,27 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
263
263
 
264
264
  public getConversationDetail(conversationId: string, callback: (conv: ConversationModel) => void): void {
265
265
  // fare promise o callback ??
266
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] getConversationDetail *****: ', conversationId)
266
267
  const conversation = this.conversations.find(item => item.uid === conversationId);
267
- this.logger.debug('[FIREBASEConversationsHandlerSERVICE] conversations *****: ', this.conversations)
268
- this.logger.debug('[FIREBASEConversationsHandlerSERVICE] getConversationDetail *****: ', conversation)
268
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversations *****: ', this.conversations)
269
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] getConversationDetail *****: ', conversation)
269
270
  if (conversation) {
270
271
  callback(conversation)
271
272
  // return conversationSelected
272
273
  // this.BSConversationDetail.next(conversationSelected);
273
274
  } else {
275
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] getConversationDetail ***** ELSE')
274
276
  // const urlNodeFirebase = '/apps/' + this.tenant + '/users/' + this.loggedUserId + '/conversations/' + conversationId;
275
277
  const urlNodeFirebase = conversationsPathForUserId(this.tenant, this.loggedUserId) + '/' + conversationId;
276
- this.logger.debug('[FIREBASEConversationsHandlerSERVICE] conversationDetail urlNodeFirebase *****', urlNodeFirebase)
278
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail urlNodeFirebase *****', urlNodeFirebase)
277
279
  const firebaseMessages = firebase.database().ref(urlNodeFirebase);
278
280
  firebaseMessages.on('value', (childSnapshot) => {
279
281
  const childData: ConversationModel = childSnapshot.val();
280
- this.logger.debug('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot *****', childSnapshot.val())
281
- if (childSnapshot && childSnapshot.key && childData.uid) {
282
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot.val() *****', childSnapshot.val());
283
+ this.logger.log('[FIREBASEConversationsHandlerSERVICE] conversationDetail childSnapshot *****', childSnapshot)
284
+ // && childData.uid
285
+ if (childSnapshot && childSnapshot.key) {
286
+ // if (childData) {
282
287
  childData.uid = childSnapshot.key;
283
288
  const conversation = this.completeConversation(childData);
284
289
  if (conversation) {
@@ -472,7 +477,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
472
477
  conversation_with_fullname = conv.recipient_fullname;
473
478
  conv.sender_fullname = this.translationMap.get('YOU')
474
479
  // conv.last_message_text = YOU + conv.last_message_text;
475
- // } else if (conv.channel_type === TYPE_GROUP) {
480
+ // } else if (conv.channel_type === TYPE_GROUP) {
476
481
  } else if (isGroup(conv)) {
477
482
  // conversation_with_fullname = conv.sender_fullname;
478
483
  // conv.last_message_text = conv.last_message_text;
@@ -482,7 +487,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
482
487
  conv.conversation_with = conversation_with;
483
488
  conv.conversation_with_fullname = conversation_with_fullname;
484
489
  conv.status = this.setStatusConversation(conv.sender, conv.uid);
485
- conv.time_last_message = this.getTimeLastMessage(conv.timestamp);
490
+ // conv.time_last_message = this.getTimeLastMessage(conv.timestamp); // evaluate if is used
486
491
  conv.avatar = avatarPlaceholder(conversation_with_fullname);
487
492
  conv.color = getColorBck(conversation_with_fullname);
488
493
  //conv.image = this.imageRepo.getImagePhotoUrl(conversation_with);
@@ -490,7 +495,7 @@ export class FirebaseConversationsHandler extends ConversationsHandlerService {
490
495
  return conv;
491
496
  }
492
497
 
493
-
498
+
494
499
 
495
500
  /** */
496
501
  private setStatusConversation(sender: string, uid: string): string {
@@ -12,47 +12,148 @@ import 'firebase/auth';
12
12
  @Injectable({ providedIn: 'root' })
13
13
 
14
14
  export class FirebaseNotifications extends NotificationsService {
15
-
16
- public BUILD_VERSION: string;
15
+
16
+ // public BUILD_VERSION: string;
17
17
  private FCMcurrentToken: string;
18
18
  private userId: string;
19
19
  private tenant: string;
20
+ private vapidkey: string;
20
21
  private logger: LoggerService = LoggerInstance.getInstance();
21
22
  constructor() {
22
23
  super();
23
24
  }
24
25
 
25
- initialize(tenant: string): void{
26
+ initialize(tenant: string, vapId: string): void {
26
27
  this.tenant = tenant
28
+ this.vapidkey = vapId
27
29
  this.logger.info('[FIREBASE-NOTIFICATIONS] initialize - tenant ', this.tenant)
28
-
30
+
31
+
32
+ if (!('serviceWorker' in navigator)) {
33
+ // , disable or hide UI.
34
+ this.logger.error("[FIREBASE-NOTIFICATIONS] initialize - Service Worker isn't supported on this browser", navigator)
35
+ return;
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(registrations => {
43
+
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
+ }
29
60
  }
30
61
 
62
+
63
+
31
64
  getNotificationPermissionAndSaveToken(currentUserUid) {
32
65
  // this.tenant = this.getTenant();
33
66
  this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant)
34
67
  this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
35
68
  this.userId = currentUserUid;
69
+ // Service Worker explicit registration to explicitly define sw location at a path
70
+ // const swRegistration = async () => {
71
+ // try {
72
+ // await navigator.serviceWorker.register('http://localhost:8101/firebase-messaging-sw.js');
73
+ // } catch (error) {
74
+ // console.error(error);
75
+ // }
76
+ // }
77
+
78
+
36
79
  const messaging = firebase.messaging();
37
80
  if (firebase.messaging.isSupported()) {
38
81
  // messaging.requestPermission()
39
- Notification.requestPermission()
40
- .then(() => {
82
+ Notification.requestPermission().then((permission) => {
83
+ if (permission === 'granted') {
41
84
  this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> requestPermission Notification permission granted.');
42
- return messaging.getToken()
43
- })
44
- .then(FCMtoken => {
45
- this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> requestPermission FCMtoken', FCMtoken)
46
- // Save FCM Token in Firebase
47
- this.FCMcurrentToken = FCMtoken;
48
- this.updateToken(FCMtoken, currentUserUid)
49
- })
50
- .catch((err) => {
51
- this.logger.error('[FIREBASE-NOTIFICATIONS] >>>> requestPermission ERR: Unable to get permission to notify.', err);
52
- });
85
+
86
+ return messaging.getToken({ vapidKey: this.vapidkey })
87
+ }
88
+ }).then(FCMtoken => {
89
+ this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> requestPermission FCMtoken', FCMtoken)
90
+ // Save FCM Token in Firebase
91
+ this.FCMcurrentToken = FCMtoken;
92
+ this.updateToken(FCMtoken, currentUserUid)
93
+ }).catch((err) => {
94
+ this.logger.error('[FIREBASE-NOTIFICATIONS] >>>> requestPermission ERR: Unable to get permission to notify.', err);
95
+ });
96
+ } else {
97
+ this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> FIREBASE MESSAGING IS NOT SUPPORTED')
53
98
  }
54
99
  }
55
100
 
101
+
102
+ // getNotificationPermissionAndSaveToken(currentUserUid) {
103
+ // // this.tenant = this.getTenant();
104
+ // this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant)
105
+ // this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
106
+ // this.userId = currentUserUid;
107
+ // const messaging = firebase.messaging();
108
+ // if (firebase.messaging.isSupported()) {
109
+ // // messaging.requestPermission()
110
+ // Notification.requestPermission().then((permission) => {
111
+ // if (permission === 'granted') {
112
+ // this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> requestPermission Notification permission granted.');
113
+ // messaging.getToken({ vapidKey: 'BOsgS2ADwspKdWAmiFDZXEYqY1HSYADVfJT3j67wsySh3NxaViJqoabPJH8WM02wb5r8cQIm5TgM0UK047Z1D1c'}).then((currentToken) => {
114
+ // if (currentToken) {
115
+ // this.sendTokenToServer(currentToken);
116
+ // // updateUIForPushEnabled(currentToken);
117
+
118
+ // } else {
119
+ // // Show permission request UI
120
+ // console.log('No registration token available. Request permission to generate one.');
121
+ // // ...
122
+ // }
123
+ // }).catch((err) => {
124
+ // console.log('An error occurred while retrieving token. ', err);
125
+ // // ...
126
+ // });
127
+
128
+ // resetUI()
129
+
130
+ // } else {
131
+ // this.logger.error('Unable to get permission to notify.');
132
+ // }
133
+ // })
134
+
135
+ // }
136
+ // }
137
+
138
+ // sendTokenToServer(currentToken) {
139
+ // if (!this.isTokenSentToServer()) {
140
+ // console.log('Sending token to server...');
141
+ // // TODO(developer): Send the current token to your server.
142
+ // this.setTokenSentToServer(true);
143
+ // } else {
144
+ // console.log('Token already sent to server so won\'t send it again ' +
145
+ // 'unless it changes');
146
+ // }
147
+ // }
148
+
149
+ // isTokenSentToServer() {
150
+ // return window.localStorage.getItem('sentToServer') === '1';
151
+ // }
152
+
153
+ // setTokenSentToServer(sent) {
154
+ // window.localStorage.setItem('sentToServer', sent ? '1' : '0');
155
+ // }
156
+
56
157
  removeNotificationsInstance(callback: (string) => void) {
57
158
  var self = this;
58
159
  firebase.auth().onAuthStateChanged(function (user) {
@@ -72,7 +173,7 @@ export class FirebaseNotifications extends NotificationsService {
72
173
  this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRefinstancesId ', connectionsRefinstancesId);
73
174
  let connectionsRefURL = '';
74
175
  if (connectionsRefinstancesId) {
75
- connectionsRefURL = connectionsRefinstancesId + this.FCMcurrentToken;
176
+ connectionsRefURL = connectionsRefinstancesId + this.FCMcurrentToken;
76
177
  const connectionsRef = firebase.database().ref().child(connectionsRefURL);
77
178
  this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef ', connectionsRef);
78
179
  this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> connectionsRef url ', connectionsRefURL);
@@ -17,6 +17,7 @@ export class LocalSessionStorage extends AppStorageService{
17
17
  this.storagePrefix = storagePrefix;
18
18
  this.projectID = projectID;
19
19
  this.persistence = persistence;
20
+ // this.persistence = 'LOCAL';
20
21
  this.logger.info('[LocalSessionStorage] - initialize ', this.storagePrefix, this.persistence, this.projectID)
21
22
  }
22
23
 
@@ -30,7 +31,7 @@ export class LocalSessionStorage extends AppStorageService{
30
31
  // prefix = prefix + sv;
31
32
  prefix = this.storagePrefix + '_';
32
33
  } catch (e) {
33
- this.logger.error('[LocalSessionStorage] getItem >Error :' + e);
34
+ this.logger.error('[LocalSessionStorage] getItem - Error :' + e);
34
35
  }
35
36
  const newKey = prefix + this.projectID + '_' + key;
36
37
  return this.getValueForKey(newKey);
@@ -3,7 +3,8 @@
3
3
  * @param str
4
4
  */
5
5
  export function getColorBck(str: string): string {
6
- const arrayBckColor = ['#fba76f', '#80d066', '#73cdd0', '#ecd074', '#6fb1e4', '#f98bae'];
6
+ // const arrayBckColor = ['#fba76f', '#80d066', '#73cdd0', '#ecd074', '#6fb1e4', '#f98bae'];
7
+ const arrayBckColor = ['#E17076', '#7BC862', '#65aadd', '#a695e7', '#ee7aae', '#6ec9cb', '#faa774'];
7
8
  let num = 0;
8
9
  if (str) {
9
10
  const code = str.charCodeAt((str.length - 1));
package/src/index.html CHANGED
@@ -5,25 +5,105 @@
5
5
  <meta charset="utf-8" />
6
6
  <title>Tiledesk - Open Source Live Chat</title>
7
7
 
8
- <base href="./"/>
8
+ <base href="./" />
9
9
  <!-- <base href="/"/> -->
10
10
  <!-- <base href="./"/> quando rilascio in prod sostituisco questo base con quello sopra -->
11
11
 
12
12
  <!-- <meta name="color-scheme" content="light dark" /> disable dark mode: Note in theme/variable.scss is also commented all the code that referts to dark-mode -->
13
13
  <meta name="color-scheme" content="light" />
14
- <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
14
+ <meta name="viewport"
15
+ content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
15
16
  <meta name="format-detection" content="telephone=no" />
16
17
  <meta name="msapplication-tap-highlight" content="no" />
17
18
 
18
19
  <link rel="icon" type="image/png" href="assets/icon/favicon.ico" />
19
20
  <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&lang=en" />
20
-
21
+
21
22
  <link rel="manifest" href="./manifest.json">
22
23
  <!-- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> -->
23
-
24
+
24
25
  <!-- <script src="./assets/js/chat21client.js"></script> -->
25
26
  <!-- <script src="https://unpkg.com/mqtt@4.1.0/dist/mqtt.min.js"></script> -->
26
27
 
28
+ <script>
29
+ console.log('index.html script version 0.1');
30
+ // window.onload = (event) => {
31
+ // console.log('index.html page is fully loaded');
32
+ // };
33
+
34
+ // window.addEventListener('online', (event) => {
35
+ // console.log("index.html You are now connected to the network.");
36
+ // });
37
+
38
+ // // ononline version
39
+ window.ononline = (event) => {
40
+ console.log("index.html You are now connected to the network.");
41
+ };
42
+
43
+ // // addEventListener version
44
+ // window.addEventListener('offline', (event) => {
45
+ // console.log("The network connection has been lost.");
46
+ // });
47
+
48
+ // // onoffline version
49
+ window.onoffline = (event) => {
50
+ console.log("The network connection has been lost.");
51
+ };
52
+ console.log('index.html window.navigator.onLine is ' + window.navigator.onLine);
53
+
54
+ if (window.navigator.onLine === false) {
55
+ let app_root_el = document.getElementsByTagName('app-root');
56
+ console.log('index.html app_root_el ', app_root_el);
57
+
58
+ setTimeout(function () {
59
+ console.log('index.html app_root_el > childNodes ', app_root_el[0].childNodes);
60
+ if (app_root_el[0].childNodes.length > 0) { // Or just `if (element.childNodes.length)`
61
+ console.log('index.html app_root_el has child', app_root_el[0].childNodes);
62
+ // window.ononline = (event) => {
63
+ // console.log("index.html You are now connected to the network.");
64
+ // location.reload(true);
65
+ // };
66
+ } else {
67
+ console.log('index.html app_root_el not has child', app_root_el[0].childNodes);
68
+ // if (window.navigator.onLine === true) {
69
+ // location.reload(true);
70
+ // }
71
+ window.ononline = (event) => {
72
+ console.log("index.html You are now connected to the network.");
73
+ location.reload(true);
74
+ };
75
+ }
76
+
77
+ }, 3000);
78
+
79
+
80
+ }
81
+
82
+
83
+ // document.addEventListener('DOMContentLoaded', (event) => {
84
+ // // log.textContent = log.textContent + `DOMContentLoaded\n`;
85
+ // console.log("index.html DOMContentLoaded event ", event);
86
+ // console.log('index.html window.navigator.onLine is ' + window.navigator.onLine);
87
+ // let app_root_el = document.getElementsByTagName('app-root');
88
+ // console.log('index.html app_root_el ', app_root_el);
89
+
90
+ // setTimeout(function () {
91
+ // console.log('index.html app_root_el > childNodes ', app_root_el[0].childNodes);
92
+ // if (app_root_el[0].childNodes.length > 0) { // Or just `if (element.childNodes.length)`
93
+ // console.log('index.html app_root_el has child', app_root_el[0].childNodes);
94
+ // } else {
95
+ // console.log('index.html app_root_el not has child', app_root_el[0].childNodes);
96
+ // if (window.navigator.onLine === true) {
97
+ // location.reload(true);
98
+ // }
99
+ // }
100
+
101
+ // }, 3000);
102
+
103
+ // });
104
+
105
+ </script>
106
+
27
107
 
28
108
 
29
109
 
@@ -37,5 +117,6 @@
37
117
  <app-root></app-root>
38
118
  </body>
39
119
 
40
- </script>
41
- </html>
120
+ </script>
121
+
122
+ </html>