@chat21/chat21-ionic 3.0.55-RC12 → 3.0.55-RC20

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 (26) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +1 -1
  3. package/src/app/app.component.ts +137 -88
  4. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +13 -6
  5. package/src/app/chatlib/conversation-detail/message/image/image.component.html +10 -8
  6. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +34 -2
  7. package/src/app/chatlib/conversation-detail/message/text/text.component.html +2 -2
  8. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +36 -15
  9. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +142 -1
  10. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +41 -17
  11. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +2 -0
  12. package/src/app/components/conversation-info/advanced-info-accordion/advanced-info-accordion.component.html +2 -2
  13. package/src/app/components/conversation-info/info-group/info-group.component.ts +2 -2
  14. package/src/app/components/utils/user-presence/user-presence.component.ts +8 -6
  15. package/src/app/pages/conversation-detail/conversation-detail.page.html +4 -1
  16. package/src/app/pages/conversation-detail/conversation-detail.page.ts +42 -6
  17. package/src/app/pages/conversations-list/conversations-list.page.ts +43 -20
  18. package/src/app/pages/loader-preview/loader-preview.page.html +1 -1
  19. package/src/app/pages/loader-preview/loader-preview.page.ts +18 -5
  20. package/src/app/services/network-service/network.service.spec.ts +12 -0
  21. package/src/app/services/network-service/network.service.ts +46 -0
  22. package/src/chat-config-pre-test.json +1 -1
  23. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +2 -2
  24. package/src/chat21-core/providers/firebase/firebase-notifications.ts +19 -14
  25. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +30 -10
  26. package/src/index.html +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.55-RC20
4
+ - Improve the method that solves the bug: if the chat is open on more than one tab, the previous ones disconnect
5
+ - Displays the message "sent an image" when the sender sends an image
6
+ - Removes the "setTimeout" set on the onStorageChanged event
7
+
8
+ ### 3.0.55-RC19
9
+ - Fixes the bug: opening the "conversations info" side panel for support type conversations causes the chat to log out
10
+
11
+ ### 3.0.55-RC18
12
+ - Fixes the bug: if the chat is open on more than one tab, the previous ones logging out
13
+
14
+ ### 3.0.55-RC16
15
+ - Removes the image name displayed at the bottom of the image
16
+ - Removes the adaptation of the image caption width to the image size
17
+
18
+ ### 3.0.55-RC15
19
+ - Fixes the bug: "ion-spinner" throws an error when the chat is offline
20
+ - Fixes the bug: in the component "info-group-component" if groupDetail is not defined throws the error "Cannot read hasOwnProperty of undefined"
21
+ - Fixes the bug: in the "advanced-info-accordion" component if translationMap is not defined throws the error "Cannot read properties of undefined (reading 'get')"
22
+ - Fixes the bug: in the component "user-presence.component" if translationMap is not defined throws the error "Cannot read properties of undefined (reading 'get')"
23
+ - Fixes the bug: if the image name is longer than the image width when uploading, it is displayed on the right side of the image
24
+ - Fixes the bug: if the user logs out of the dashboard and then logs in, the user in the chat is not logged in again
25
+ - Fixes the bug: if the file upload preview window is closed without sending the file, the windows does not reopen if the same file is selected
26
+ - Adds autofocus in the "caption" text area in the file upload preview window
27
+
28
+ ### 3.0.55-RC14
29
+ - Implements Network service
30
+ - Displays, when the chat loses connection, the message "Waiting for network" at the top of the conversation list
31
+ - Displays, when the chat loses connection, the message "Internet is slow or not working" on the conversation details page
32
+ - Set the "user" variable to null when the user logs out of chat
33
+
3
34
  ### 3.0.55-RC12
4
35
  - Fixes the bug: when a file is uploaded via drag & drop, the message "Failed to upload: the format is not supported" is displayed even if fileUploadAccept is set to "* / *" (accept all)
5
36
  - Fixes the bug: the left side panel "conversation list" is not displayed on Safari
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
- "version": "3.0.55-RC12",
3
+ "version": "3.0.55-RC20",
4
4
  "author": "Tiledesk SRL",
5
5
  "homepage": "https://ionicframework.com/",
6
6
  "scripts": {
@@ -5,7 +5,7 @@ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storag
5
5
  import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, } from '@angular/core';
6
6
  import { Config, Platform, IonRouterOutlet, IonSplitPane, NavController, MenuController, AlertController, IonNav, ToastController } from '@ionic/angular';
7
7
  import { ActivatedRoute, Router } from '@angular/router';
8
- import { Subscription } from 'rxjs';
8
+ import { Subscription, VirtualTimeScheduler } from 'rxjs';
9
9
  import { ModalController } from '@ionic/angular';
10
10
 
11
11
  // import * as firebase from 'firebase/app';
@@ -49,9 +49,12 @@ import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk
49
49
  import { NotificationsService } from 'src/chat21-core/providers/abstract/notifications.service';
50
50
  import { getImageUrlThumbFromFirebasestorage } from 'src/chat21-core/utils/utils-user';
51
51
 
52
- import { Network } from '@ionic-native/network/ngx';
53
- import { Observable, Observer, fromEvent, merge, of } from 'rxjs';
54
- import { mapTo } from 'rxjs/operators';
52
+ // import { Network } from '@ionic-native/network/ngx';
53
+ // import { Observable, Observer, fromEvent, merge, of } from 'rxjs';
54
+ // import { mapTo } from 'rxjs/operators';
55
+ import { TiledeskService } from './services/tiledesk/tiledesk.service';
56
+ import { NetworkService } from './services/network-service/network.service';
57
+ import * as PACKAGE from 'package.json';
55
58
 
56
59
  @Component({
57
60
  selector: 'app-root',
@@ -63,7 +66,7 @@ export class AppComponent implements OnInit {
63
66
  @ViewChild('sidebarNav', { static: false }) sidebarNav: IonNav;
64
67
  @ViewChild('detailNav', { static: false }) detailNav: IonRouterOutlet;
65
68
 
66
- public appIsOnline$: Observable<boolean> = undefined;
69
+ // public appIsOnline$: Observable<boolean> = undefined;
67
70
  checkInternet: boolean;
68
71
 
69
72
  private subscription: Subscription;
@@ -89,6 +92,8 @@ export class AppComponent implements OnInit {
89
92
  private modalOpen: boolean = false;
90
93
  private hadBeenCalledOpenModal: boolean = false;
91
94
  public missingConnectionToast: any
95
+ public executedInitializeAppByWatchConnection: boolean = false;
96
+ private version: string;
92
97
 
93
98
  constructor(
94
99
  private platform: Platform,
@@ -122,30 +127,37 @@ export class AppComponent implements OnInit {
122
127
  private translateService: CustomTranslateService,
123
128
  public notificationsService: NotificationsService,
124
129
  public toastController: ToastController,
125
- private network: Network
130
+ // private network: Network,
131
+ // private tiledeskService: TiledeskService,
132
+ private networkService: NetworkService
126
133
  ) {
127
- console.log('[APP-COMP] HELLO Constuctor !!!!!!!')
134
+ this.logger.log('[APP-COMP] HELLO Constuctor !!!!!!!')
128
135
  // HACK: fix toast not presented when offline, due to lazy loading the toast controller.
129
- this.toastController.create({ animated: false }).then(t => {
130
- console.log('[APP-COMP] toastController create')
131
- t.present();
132
- t.dismiss();
133
- });
136
+ // this.toastController.create({ animated: false }).then(t => {
137
+ // console.log('[APP-COMP] toastController create')
138
+ // t.present();
139
+ // t.dismiss();
140
+ // });
134
141
  }
135
142
 
136
143
 
137
144
  /**
138
145
  */
139
146
  ngOnInit() {
140
- console.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
147
+ this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
141
148
  this.logger.info('[APP-COMP] ngOnInit -->', this.route.snapshot.params);
142
149
 
143
150
  this.initializeApp();
151
+
144
152
  }
145
153
 
146
154
 
155
+
147
156
  /** */
148
157
  initializeApp() {
158
+
159
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - initializeApp');
160
+ this.logger.log('[APP-COMP] HELLO initializeApp !!!!!!!')
149
161
  this.logger.info('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
150
162
 
151
163
  if (!this.platform.is('cordova')) {
@@ -157,6 +169,8 @@ export class AppComponent implements OnInit {
157
169
 
158
170
  const appconfig = this.appConfigProvider.getConfig();
159
171
  this.logger.info('[APP-COMP] appconfig: ', appconfig)
172
+ this.version = PACKAGE.version;
173
+ this.logger.info('[APP-COMP] version: ', this.version)
160
174
 
161
175
  this.logger.setLoggerConfig(true, appconfig.logLevel)
162
176
  this.logger.info('[APP-COMP] logLevel: ', appconfig.logLevel);
@@ -166,7 +180,7 @@ export class AppComponent implements OnInit {
166
180
 
167
181
  this.persistence = appconfig.authPersistence;
168
182
 
169
- console.log('[APP-COMP] HELLO initializeApp !!!!!!!')
183
+
170
184
  this.notificationsEnabled = true;
171
185
  this.zone = new NgZone({}); // a cosa serve?
172
186
 
@@ -206,94 +220,86 @@ export class AppComponent implements OnInit {
206
220
  // ---------------------------------------
207
221
  // Watch to network status
208
222
  // ---------------------------------------
209
- // if (!checkPlatformIsMobile()) {
210
- // this.watchToConnectionStatus();
211
- // }
223
+ this.watchToConnectionStatus();
212
224
  });
213
225
  }
214
226
 
215
227
 
216
228
 
217
229
  watchToConnectionStatus() {
218
- this.checkInternetFunc().subscribe(isOnline => {
230
+ this.networkService.checkInternetFunc().subscribe(isOnline => {
219
231
  this.checkInternet = isOnline
220
- console.log('[APP-COMP] - watchToConnectionStatus - isOnline', this.checkInternet)
232
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - isOnline', this.checkInternet)
221
233
 
222
234
  // checking internet connection
223
235
  if (this.checkInternet == true) {
236
+ // this.events.publish('internetisonline', true);
224
237
  // show success alert if internet is working
225
238
  // alert('Internet is working.')
226
239
  this.logger.log('[APP-COMP] - watchToConnectionStatus - Internet is working.')
227
- this.logger.log('[APP-COMP] - watchToConnectionStatus - this.missingConnectionToast', this.missingConnectionToast)
228
-
229
- const elemIonNav = <HTMLElement>document.querySelector('ion-nav');
230
- this.logger.log('[APP-COMP] - watchToConnectionStatus - * elemIonNav *', elemIonNav)
231
-
232
- setTimeout(() => {
233
- const elemIonNavchildNodes = elemIonNav.childNodes;
234
- this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes ', elemIonNavchildNodes);
235
- if (elemIonNavchildNodes.length === 0) {
236
- this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes HERE YES', elemIonNavchildNodes);
237
- this.initializeApp()
240
+ // this.logger.log('[APP-COMP] - watchToConnectionStatus - this.missingConnectionToast', this.missingConnectionToast)
241
+ if (!checkPlatformIsMobile()) {
242
+ const elemIonNav = <HTMLElement>document.querySelector('ion-nav');
243
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - desktop * elemIonNav *', elemIonNav)
244
+
245
+ if (this.executedInitializeAppByWatchConnection === false) {
246
+ setTimeout(() => {
247
+ const elemIonNavchildNodes = elemIonNav.childNodes;
248
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes ', elemIonNavchildNodes);
249
+
250
+ if (elemIonNavchildNodes.length === 0) {
251
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - elemIonNavchildNodes HERE YES', elemIonNavchildNodes);
252
+
253
+ this.initializeApp();
254
+ this.executedInitializeAppByWatchConnection = true;
255
+ }
256
+ }, 2000);
238
257
  }
239
- }, 2000);
240
-
241
-
242
-
243
- this.logger.log("[APP-COMP] missingConnectionToast", this.missingConnectionToast)
244
-
245
- // --------------------------------------------------
246
- // Publish event
247
- // --------------------------------------------------
248
- // this.events.publish('internetisonline', true);
249
-
250
- // if (this.missingConnectionToast !== undefined) {
251
- // this.dismissMissingConnectionToast();
252
- // }
258
+ } else if (checkPlatformIsMobile()) {
259
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - mobile ')
260
+ const elemIonRouterOutlet = <HTMLElement>document.querySelector('ion-router-outlet');
261
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - mobile * elemIonRouterOutlet *', elemIonRouterOutlet)
262
+ if (this.executedInitializeAppByWatchConnection === false) {
263
+ setTimeout(() => {
264
+ const childElementCount = elemIonRouterOutlet.childElementCount;
265
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - mobile * childElementCount *', childElementCount)
266
+ if (childElementCount === 1) {
267
+ this.initializeApp();
268
+ this.executedInitializeAppByWatchConnection = true;
269
+ }
270
+ }, 2000);
271
+ }
272
+ }
253
273
  }
254
274
  else {
255
-
256
- // --------------------------------------------------
257
- // Publish event
258
- // --------------------------------------------------
259
- // this.events.publish('internetisonline', false);
260
-
261
- // show danger alert if net internet not working
262
- // alert('Internet is slow or not working.')
263
- // this.presentMissingConnectionToast();
264
-
265
- this.logger.log('[APP-COMP] - watchToConnectionStatus - Internet is slow or not working.')
266
- // --------------------------------------------------
267
- // Publish event
268
- // --------------------------------------------------
269
- // this.events.publish('internetisonline', false);
275
+ this.logger.log('[APP-COMP] - watchToConnectionStatus - Internet is slow or not working.');
270
276
  }
271
277
  });
272
278
  }
273
279
 
274
- checkInternetFunc() {
275
- if (!window || !navigator || !('onLine' in navigator)) return;
276
-
277
- this.appIsOnline$ = Observable.create(observer => {
278
- observer.next(true);
279
- }).pipe(mapTo(true));
280
-
281
- if (this.platform.is('cordova')) {
282
- // on Device - when platform is cordova
283
- this.appIsOnline$ = merge(
284
- this.network.onConnect().pipe(mapTo(true)),
285
- this.network.onDisconnect().pipe(mapTo(false))
286
- );
287
- } else {
288
- // on Browser - when platform is Browser
289
- this.appIsOnline$ = merge(
290
- of(navigator.onLine),
291
- fromEvent(window, 'online').pipe(mapTo(true)),
292
- fromEvent(window, 'offline').pipe(mapTo(false))
293
- );
294
- }
295
- return this.appIsOnline$
296
- }
280
+ // checkInternetFunc() {
281
+ // if (!window || !navigator || !('onLine' in navigator)) return;
282
+
283
+ // this.appIsOnline$ = Observable.create(observer => {
284
+ // observer.next(true);
285
+ // }).pipe(mapTo(true));
286
+
287
+ // if (this.platform.is('cordova')) {
288
+ // // on Device - when platform is cordova
289
+ // this.appIsOnline$ = merge(
290
+ // this.network.onConnect().pipe(mapTo(true)),
291
+ // this.network.onDisconnect().pipe(mapTo(false))
292
+ // );
293
+ // } else {
294
+ // // on Browser - when platform is Browser
295
+ // this.appIsOnline$ = merge(
296
+ // of(navigator.onLine),
297
+ // fromEvent(window, 'online').pipe(mapTo(true)),
298
+ // fromEvent(window, 'offline').pipe(mapTo(false))
299
+ // );
300
+ // }
301
+ // return this.appIsOnline$
302
+ // }
297
303
 
298
304
  getRouteParamsAndSetLoggerConfig() {
299
305
  const appconfig = this.appConfigProvider.getConfig();
@@ -501,6 +507,7 @@ export class AppComponent implements OnInit {
501
507
  } else {
502
508
  this.platformIs = PLATFORM_DESKTOP;
503
509
  this.logger.debug('[APP-COMP] PLATFORM_DESKTOP ', this.navService);
510
+
504
511
  this.navService.setRoot(ConversationListPage, {});
505
512
 
506
513
  const IDConv = this.route.snapshot.firstChild.paramMap.get('IDConv');
@@ -685,7 +692,7 @@ export class AppComponent implements OnInit {
685
692
  that.removePresenceAndLogout();
686
693
  } else {
687
694
  that.removePresenceAndLogout();
688
- that.presentToast();
695
+ // that.presentToast();
689
696
  }
690
697
  })
691
698
  }
@@ -844,13 +851,55 @@ export class AppComponent implements OnInit {
844
851
  }
845
852
  }
846
853
 
854
+ // Storage event not firing: This won't work on the same page that is making the changes
855
+ // https://stackoverflow.com/questions/35865481/storage-event-not-firing
856
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
847
857
  @HostListener('window:storage', ['$event'])
848
858
  onStorageChanged(event: any) {
849
- this.logger.log('[APP-COMP] - onStorageChanged')
850
- if (this.appStorageService.getItem('tiledeskToken') === null) {
851
- this.tiledeskAuthService.logOut()
852
- this.messagingAuthService.logout();
853
- }
859
+ // console.log('[APP-COMP] - onStorageChanged event', event)
860
+ // console.log('[APP-COMP] - onStorageChanged tiledeskToken', this.appStorageService.getItem('tiledeskToken'))
861
+ // const storage = event.storageArea;
862
+ // console.log('[APP-COMP] - onStorageChanged event storage', storage)
863
+
864
+ // setTimeout(() => {
865
+ // if (storage && storage['chat_sv5__tiledeskToken'] === undefined) {
866
+ // this.logger.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken', storage['chat_sv5__tiledeskToken'])
867
+ // this.tiledeskAuthService.logOut()
868
+ // this.messagingAuthService.logout();
869
+ // // this.events.publish('profileInfoButtonClick:logout', true);
870
+ // this.conversationsHandlerService.conversations = [];
871
+ // } else if (storage && storage['chat_sv5__tiledeskToken']) {
872
+
873
+ // this.logger.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken * IS DEFINED *')
874
+ // const currentUser = this.tiledeskAuthService.getCurrentUser();
875
+
876
+ // if (!currentUser) {
877
+ // window.location.reload();
878
+ // }
879
+
880
+ // }
881
+ // }, 1000);
882
+
883
+ // else {
884
+ // console.log('[APP-COMP] - onStorageChanged event storage chat_sv5__tiledeskToken', storage['chat_sv5__tiledeskToken'])
885
+ // }
886
+
887
+ // setTimeout(() => {
888
+ if (this.appStorageService.getItem('tiledeskToken') === null) {
889
+ this.tiledeskAuthService.logOut()
890
+ this.messagingAuthService.logout();
891
+ }
892
+ else {
893
+
894
+ const currentUser = this.tiledeskAuthService.getCurrentUser();
895
+ if (currentUser) {
896
+ console.log('[APP-COMP] - onStorageChanged currentUser', currentUser)
897
+ } else {
898
+ // this.initializeApp();
899
+ window.location.reload();
900
+ }
901
+ }
902
+ // }, 1000);
854
903
  }
855
904
 
856
905
  }
@@ -58,7 +58,8 @@
58
58
 
59
59
  <div class="align-center" class="ion-text-center" *ngIf="messageType(MESSAGE_TYPE_INFO, message)"
60
60
  class="msg_info_container">
61
- <chat-info-message class="messages" [message]="message">
61
+ <chat-info-message class="messages"
62
+ [message]="message">
62
63
  </chat-info-message>
63
64
  </div>
64
65
 
@@ -66,10 +67,13 @@
66
67
  <div role="messaggio" *ngIf="messageType(MESSAGE_TYPE_MINE, message)" class="msg_container base_sent">
67
68
 
68
69
  <!--backgroundColor non viene ancora usato -->
69
- <chat-bubble-message class="messages msg_sent" id="{{'message'+'_'+ i}}"
70
+ <chat-bubble-message
71
+ class="messages msg_sent" id="{{'message'+'_'+ i}}"
70
72
  [ngClass]="{'button-in-msg' : message.metadata && message.metadata.button}" [message]="message"
71
- [textColor]="'col-msg-sent'" (onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
72
- (onAfterMessageRender)="returnOnAfterMessageRender($event)" (onImageRendered)="onImageRenderedFN($event)">
73
+ [textColor]="'col-msg-sent'"
74
+ (onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
75
+ (onAfterMessageRender)="returnOnAfterMessageRender($event)"
76
+ (onImageRendered)="onImageRenderedFN($event)">
73
77
  </chat-bubble-message>
74
78
 
75
79
  <!-- icon status message -->
@@ -95,9 +99,12 @@
95
99
 
96
100
  <!--backgroundColor non viene ancora usato -->
97
101
 
98
- <chat-bubble-message class="messages msg_receive" [message]="message" [textColor]="'black'"
102
+ <chat-bubble-message class="messages msg_receive"
103
+ [message]="message"
104
+ [textColor]="'black'"
99
105
  (onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
100
- (onAfterMessageRender)="returnOnAfterMessageRender($event)" (onImageRendered)="onImageRenderedFN($event)">
106
+ (onAfterMessageRender)="returnOnAfterMessageRender($event)"
107
+ (onImageRendered)="onImageRenderedFN($event)">
101
108
  </chat-bubble-message>
102
109
  </div>
103
110
 
@@ -1,8 +1,10 @@
1
- <div [ngStyle] = "{ 'max-width': width +'px', 'max-height': height +'px' }" style="position: relative;">
2
- <div *ngIf="loading" class="loader" [ngStyle] = "{ 'width': width +'px', 'height': height +'px' }"></div>
3
- <img
4
- class="message-contentX message-content-imageX"
5
- [ngClass]="{'isLoadingImage': loading}"
6
- [src]="metadata.src"
7
- (load)="onLoaded($event)"/>
8
- </div>
1
+ <div [ngStyle]="{ 'max-width': width +'px', 'max-height': height +'px' }" style="position: relative; ">
2
+ <div *ngIf="loading" class="loader" [ngStyle]="{ 'width': width +'px', 'height': height +'px' }"></div>
3
+ <img style="cursor:pointer" [tooltip]="timeTooltipRight" [options]="tooltipOptions" placement="bottom"
4
+ content-type="template" class="message-contentX message-content-imageX" [ngClass]="{'isLoadingImage': loading}"
5
+ [src]="metadata.src" (load)="onLoaded($event)" (click)="downloadImage(metadata.src, metadata.name)" />
6
+
7
+ <ng-template #timeTooltipRight>
8
+ <span>{{ tooltipMessage }}</span>
9
+ </ng-template>
10
+ </div>
@@ -11,17 +11,49 @@ export class ImageComponent implements OnInit {
11
11
  @Input() width: string;
12
12
  @Input() height: number;
13
13
  @Output() onImageRendered = new EventEmitter<boolean>();
14
+
14
15
  loading: boolean = true
16
+ tooltipMessage: string;
17
+
18
+ tooltipOptions = {
19
+ 'show-delay': 0,
20
+ 'tooltip-class': 'chat-tooltip',
21
+ 'theme': 'light',
22
+ 'shadow': false,
23
+ 'hide-delay-mobile': 0,
24
+ 'hideDelayAfterClick': 3000,
25
+ 'hide-delay': 200
26
+ };
15
27
 
16
28
  constructor() { }
17
29
 
18
30
  ngOnInit() {
31
+ this.getBrowserLanguageAndTranslateTooltipMsg()
32
+ }
33
+ getBrowserLanguageAndTranslateTooltipMsg() {
34
+ var userLang = navigator.language;
35
+ console.log('Image COMP - userLang ', userLang)
36
+ if (userLang === 'en') {
37
+ this.tooltipMessage = "Click to download"
38
+ } else {
39
+ this.tooltipMessage = "Clicca per scaricare"
40
+ }
19
41
  }
20
42
 
21
- onLoaded(event){
43
+ onLoaded(event) {
22
44
  this.loading = false
23
45
  this.onImageRendered.emit(true)
24
46
  }
25
47
 
26
-
48
+ downloadImage(url: string, fileName: string) {
49
+ // console.log('Image COMP - IMAGE URL ', url)
50
+ // console.log('Image COMP - IMAGE FILENAME ', fileName)
51
+ const a: any = document.createElement('a');
52
+ a.href = url;
53
+ a.download = fileName;
54
+ document.body.appendChild(a);
55
+ a.style = 'display: none';
56
+ a.click();
57
+ a.remove();
58
+ }
27
59
  }
@@ -1,5 +1,5 @@
1
- <!-- [ngStyle] = "{ 'width': media_width +'px' }" -->
2
- <p #messageEl class="message_innerhtml marked"
1
+ <!-- [ngStyle] = "{ 'width': message.type === 'image' ? media_width +'px' : '' }" -->
2
+ <p #messageEl class="message_innerhtml marked"
3
3
  [innerHTML]="printMessage(text, messageEl, this) | htmlEntiesEncode | marked"
4
4
  [ngStyle]="{'color': '$'+ color }">
5
5
  </p>
@@ -23,20 +23,37 @@
23
23
  </div> -->
24
24
 
25
25
  <!-- -------------------------------------------------------------------------- -->
26
- <!-- New -->
26
+ <!-- New <ion-spinner class="spinner-middle" style="margin-left: 19px;"></ion-spinner> -->
27
27
  <!-- -------------------------------------------------------------------------- -->
28
- <!-- <ion-item *ngIf="isOnline === false" button="true" lines="none" class="ion-no-padding waiting-for-connection" >
29
- <ion-spinner class="spinner-middle" style="margin-left: 19px;"></ion-spinner> <span part="message-text" class="waiting-for-network-msg">&nbsp;&nbsp; Waiting for network</span>
30
- </ion-item> -->
28
+ <ion-item *ngIf="isOnline === false" button="true" lines="none" class="ion-no-padding waiting-for-connection">
29
+ <ion-avatar item-start>
30
+ <div class="sk-fading-circle">
31
+ <div class="sk-circle1 sk-circle"></div>
32
+ <div class="sk-circle2 sk-circle"></div>
33
+ <div class="sk-circle3 sk-circle"></div>
34
+ <div class="sk-circle4 sk-circle"></div>
35
+ <div class="sk-circle5 sk-circle"></div>
36
+ <div class="sk-circle6 sk-circle"></div>
37
+ <div class="sk-circle7 sk-circle"></div>
38
+ <div class="sk-circle8 sk-circle"></div>
39
+ <div class="sk-circle9 sk-circle"></div>
40
+ <div class="sk-circle10 sk-circle"></div>
41
+ <div class="sk-circle11 sk-circle"></div>
42
+ <div class="sk-circle12 sk-circle"></div>
43
+ </div>
44
+ </ion-avatar>
45
+ <ion-label part="message-text" class="waiting-for-network-msg"> Waiting for network</ion-label>
46
+ </ion-item>
31
47
 
32
- <ion-item button="true" lines="none" class="ion-no-padding" [class.ion-selected]="conversation.uid === uidConvSelected" *ngFor="let conversation of listConversations"
33
- (click)="openConversationByID(conversation)">
48
+ <ion-item button="true" lines="none" class="ion-no-padding" [class.ion-selected]="conversation.uid === uidConvSelected"
49
+ *ngFor="let conversation of listConversations" (click)="openConversationByID(conversation)">
34
50
  <div tabindex="0"></div>
35
51
 
36
52
  <!-- <div [class.selected]="conversation.uid === uidConvSelected"></div> -->
37
53
  <ion-avatar item-start>
38
54
  <!-- [style.background-color]="conversation.color" -->
39
- <div #avatarPlaceholder class="avatar-placeholder" [ngStyle]="{'background': 'linear-gradient(rgb(255,255,255) -125%,' + conversation.color + ')'}"
55
+ <div #avatarPlaceholder class="avatar-placeholder"
56
+ [ngStyle]="{'background': 'linear-gradient(rgb(255,255,255) -125%,' + conversation.color + ')'}"
40
57
  [innerHTML]="conversation.avatar"></div>
41
58
  <div *ngIf="conversation.image" #avatarImage class="avatar-profile"
42
59
  [style.background-image]="'url(' + conversation.image + ')'"></div>
@@ -56,12 +73,14 @@
56
73
  [innerHTML]="conversation.last_message_text"></p> -->
57
74
 
58
75
  <!-- <div *ngIf="conversation.type === 'image'" class="icon-image-before-msg-wpr"> -->
59
- <ion-icon *ngIf="conversation.type === 'image' && conversation.type !== 'file' " name="image-outline" class="icon-image-before-msg"></ion-icon>
60
- <ion-icon *ngIf="conversation.type === 'file' && conversation.type !== 'image'" name="attach-outline" class="icon-attach-before-msg"></ion-icon>
76
+ <ion-icon *ngIf="conversation.type === 'image' && conversation.type !== 'file' " name="image-outline"
77
+ class="icon-image-before-msg"></ion-icon>
78
+ <ion-icon *ngIf="conversation.type === 'file' && conversation.type !== 'image'" name="attach-outline"
79
+ class="icon-attach-before-msg"></ion-icon>
61
80
  <!-- </div> -->
62
81
  <!-- [innerHTML]="conversation.last_message_text" -->
63
82
  <span [class.not-read]="conversation.is_new">
64
- {{ conversation.last_message_text }}
83
+ {{ conversation.last_message_text }}
65
84
  </span>
66
85
  </div>
67
86
  </ion-label>
@@ -84,20 +103,22 @@
84
103
 
85
104
  <div item-end *ngIf="conversation?.archived" class="achived-icon-wpr">
86
105
  <span *ngIf="(conversation.timestamp | amDateFormat:'YYYY') === currentYear" class="time-in-archived">
87
- {{browserLang === 'it' ? (conversation.timestamp| amDateFormat:'DD MMM') : (conversation.timestamp | amDateFormat:'MMM DD')}}
88
-
106
+ {{browserLang === 'it' ? (conversation.timestamp| amDateFormat:'DD MMM') : (conversation.timestamp |
107
+ amDateFormat:'MMM DD')}}
108
+
89
109
  <!-- {{conversation.timestamp | amDateFormat:'DD MMM'}} -->
90
110
  </span>
91
111
  <span *ngIf="(conversation.timestamp | amDateFormat:'YYYY') !== currentYear" class="time-in-archived">
92
- {{browserLang === 'it' ? (conversation.timestamp| amDateFormat:'DD MMM') : (conversation.timestamp | amDateFormat:'MMM DD YYYY')}}
112
+ {{browserLang === 'it' ? (conversation.timestamp| amDateFormat:'DD MMM') : (conversation.timestamp |
113
+ amDateFormat:'MMM DD YYYY')}}
93
114
  <!-- {{conversation.timestamp | amDateFormat:'DD MMM YYYY'}} -->
94
115
  </span>
95
116
  <i class="material-icons" item-end style="font-size: 15px;font-weight: 400;color: #666666;"> history </i>
96
117
  </div>
97
118
 
98
119
  <!-- && !conversation?.archived -->
99
- <div item-end class="notification_point"
100
- [ngClass]="{'notification_point-on-desktop': !isApp }" *ngIf="conversation.is_new">
120
+ <div item-end class="notification_point" [ngClass]="{'notification_point-on-desktop': !isApp }"
121
+ *ngIf="conversation.is_new">
101
122
  </div>
102
123
 
103
124
  </ion-item>