@chat21/chat21-web-widget 5.0.79 → 5.0.80-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@
5
5
  *Dario De Pascalis*
6
6
  ### **Copyrigth**: *Tiledesk SRL*
7
7
 
8
+ ### 5.0.80-rc.1
9
+ - added: network-offline component to manage network connection/disconnection
10
+ - added: onDisconnect MQTT method to subscribe and manage reconnect/close/offline event
11
+ - changed: v0.1.12.8 chat21client.js
12
+
13
+
8
14
  ### 5.0.79 in PROD
9
15
 
10
16
  ### 5.0.79-rc.3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.0.79",
4
+ "version": "5.0.80-rc.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -96,6 +96,16 @@
96
96
 
97
97
  </div>
98
98
 
99
+
100
+ <!--
101
+ ****************************************
102
+ ******* MODALE OFFLINE NETWORK *********
103
+ ****************************************
104
+ -->
105
+ <div *ngIf="g.isOpen && !isOnline" class="modal-page star-rating-widget active">
106
+ <chat-network-offline></chat-network-offline>
107
+ </div>
108
+
99
109
  </div>
100
110
 
101
111
 
@@ -699,6 +699,21 @@ chat-root {
699
699
 
700
700
  }
701
701
 
702
+ /***************************
703
+ ***** NETWORK OFFLINE ******
704
+ ****************************/
705
+ chat-network-offline {
706
+ position: absolute;
707
+ width: 100%;
708
+ height: 100%;
709
+ background: rgba(0, 0, 0, .32);
710
+ justify-content: center;
711
+ align-items: flex-end;
712
+ display: flex;
713
+ }
714
+
715
+
716
+
702
717
 
703
718
  }
704
719
 
@@ -858,6 +873,9 @@ chat-root {
858
873
  }
859
874
  // ========= END: CSS STANDARD PAGE ========= //
860
875
 
876
+
877
+
878
+
861
879
  /**************
862
880
  // nk: .chat21-sheet CUSTOM DIMENSIONS WHEN THE WINDOW WIDTH IS < 451PX
863
881
  ***************/
@@ -37,7 +37,7 @@ import { TranslatorService } from './providers/translator.service';
37
37
  // UTILS
38
38
  import * as dayjs from 'dayjs';
39
39
  import { MessageModel } from 'src/chat21-core/models/message';
40
- import { AUTH_STATE_OFFLINE, AUTH_STATE_ONLINE, CHANNEL_TYPE, TYPE_MSG_FILE, TYPE_MSG_IMAGE, URL_SOUND_LIST_CONVERSATION } from 'src/chat21-core/utils/constants';
40
+ import { AUTH_STATE_CLOSE, AUTH_STATE_OFFLINE, AUTH_STATE_ONLINE, CHANNEL_TYPE, TYPE_MSG_FILE, TYPE_MSG_IMAGE, URL_SOUND_LIST_CONVERSATION } from 'src/chat21-core/utils/constants';
41
41
  import { supports_html5_storage } from 'src/chat21-core/utils/utils';
42
42
  import { UID_SUPPORT_GROUP_MESSAGES } from './utils/constants';
43
43
  import { Globals } from './utils/globals';
@@ -103,6 +103,10 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
103
103
  marginBottom: number;
104
104
 
105
105
  forceDisconnect: boolean = false;
106
+
107
+ //network status
108
+ isOnline: boolean = true;
109
+
106
110
  private logger: LoggerService = LoggerInstance.getInstance();
107
111
  constructor(
108
112
  private el: ElementRef,
@@ -358,6 +362,10 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
358
362
  this.triggerLoadParamsEvent(); // first trigger
359
363
  //this.setAvailableAgentsStatus();
360
364
 
365
+
366
+ /** NETWORK STATUS */
367
+ this.listenToNetworkStatus()
368
+
361
369
  }
362
370
 
363
371
  // ========= begin:: SUBSCRIPTIONS ============//
@@ -435,6 +443,12 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
435
443
  if (autoStart) {
436
444
  that.authenticate();
437
445
  }
446
+ }else if(state && state === AUTH_STATE_CLOSE ){
447
+ that.logger.info('[APP-COMP] CLOSE - CHANNEL CLOSED: ', this.chatManager);
448
+ if(this.g.recipientId){
449
+ this.chatManager.removeConversationHandler(this.g.recipientId)
450
+ this.g.recipientId = null;
451
+ }
438
452
  }
439
453
 
440
454
 
@@ -2121,6 +2135,11 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
2121
2135
  })
2122
2136
  }
2123
2137
 
2138
+ private listenToNetworkStatus(){
2139
+ window.addEventListener('online', () => this.isOnline = true);
2140
+ window.addEventListener('offline', () => this.isOnline = false);
2141
+ }
2142
+
2124
2143
  // ========= begin:: DESTROY ALL SUBSCRIPTIONS ============//
2125
2144
  /** elimino tutte le sottoscrizioni */
2126
2145
  ngOnDestroy() {
@@ -133,6 +133,7 @@ import { Rules } from './utils/rules';
133
133
  import { ScriptService } from 'src/chat21-core/providers/scripts/script.service';
134
134
  import { CarouselComponent } from './component/message/carousel/carousel.component';
135
135
  import { BrandService } from './providers/brand.service';
136
+ import { NetworkOfflineComponent } from './component/network-offline/network-offline.component';
136
137
 
137
138
 
138
139
 
@@ -294,7 +295,8 @@ export function uploadFactory(http: HttpClient, appConfig: AppConfigService, app
294
295
  LikeUnlikeComponent,
295
296
  TooltipDirective,
296
297
  AudioComponent,
297
- CarouselComponent
298
+ CarouselComponent,
299
+ NetworkOfflineComponent
298
300
  ],
299
301
  imports: [
300
302
  BrowserModule,
@@ -300,9 +300,13 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
300
300
  // this.scrollToBottom();
301
301
  }
302
302
  // CHECK if conversationId is changed and re-build component
303
- if(changes && changes['conversationId'] && changes['conversationId'].previousValue !== undefined && (changes['conversationId'].previousValue !== changes['conversationId'].currentValue)){
303
+ if(changes &&
304
+ changes['conversationId'] &&
305
+ changes['conversationId'].previousValue !== undefined &&
306
+ (changes['conversationId'].previousValue !== changes['conversationId'].currentValue) &&
307
+ changes['conversationId'].currentValue
308
+ ){
304
309
  this.logger.debug("[CONV-COMP] UID CHANGESSSS", changes['conversationId'])
305
-
306
310
  this.ngOnDestroy();
307
311
  this.ngOnInit();
308
312
  this.ngAfterViewInit();
@@ -446,7 +450,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
446
450
  private setConversation() {
447
451
  const recipientId = this.g.recipientId;
448
452
  const channelType = this.g.channelType;
449
- this.logger.debug('[CONV-COMP] setConversation recipientId::: ', recipientId, channelType);
453
+ this.logger.debug('[CONV-COMP] setConversation recipientId::: ', recipientId, channelType, this.g.recipientId);
450
454
  if ( !recipientId ) { this.g.setParameter('recipientId', this.setRecipientId()); }
451
455
  if ( !channelType ) { this.g.setParameter('channelType', this.setChannelType()); }
452
456
  this.conversationWith = recipientId as string;
@@ -0,0 +1,8 @@
1
+ <div id="alert-container">
2
+ <svg xmlns="http://www.w3.org/2000/svg" height="20px" width="20px" viewBox="0 -960 960 960" fill="#e8eaed">
3
+ <path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"/>
4
+ </svg>
5
+ <div class="alert-content">
6
+ {{ translationMap.get('CONNECTION_NETWORK_ERROR')}}
7
+ </div>
8
+ </div>
@@ -0,0 +1,31 @@
1
+ #alert-container{
2
+ /* // z-index: 1051;
3
+ // position: fixed; */
4
+ position: relative;
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ gap: 5px;
9
+ border-radius: 3px;
10
+ box-shadow: rgba(0, 27, 71, .24) 0px 1px 3px;
11
+ background: rgb(14 14 14);
12
+ padding: 7px 10px;
13
+ bottom: 10px;
14
+ width: 90%;
15
+ }
16
+
17
+ span.material-icons,
18
+ span.material-icons-outlined{
19
+ color: rgb(242, 247, 247);
20
+ font-size: 20px;
21
+ }
22
+
23
+
24
+ .alert-content{
25
+ color: rgb(242, 247, 247);
26
+ text-align: center;
27
+ transition: all 0.15s ease-in-out 0s;
28
+ font-size: 11px;
29
+ line-height: 18px;
30
+ /* // letter-spacing: -0.01em; */
31
+ }
@@ -0,0 +1,23 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { NetworkOfflineComponent } from './network-offline.component';
4
+
5
+ describe('NetworkOfflineComponent', () => {
6
+ let component: NetworkOfflineComponent;
7
+ let fixture: ComponentFixture<NetworkOfflineComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ declarations: [ NetworkOfflineComponent ]
12
+ })
13
+ .compileComponents();
14
+
15
+ fixture = TestBed.createComponent(NetworkOfflineComponent);
16
+ component = fixture.componentInstance;
17
+ fixture.detectChanges();
18
+ });
19
+
20
+ it('should create', () => {
21
+ expect(component).toBeTruthy();
22
+ });
23
+ });
@@ -0,0 +1,24 @@
1
+ import { Component, OnInit } from '@angular/core';
2
+ import { CustomTranslateService } from 'src/chat21-core/providers/custom-translate.service';
3
+
4
+ @Component({
5
+ selector: 'chat-network-offline',
6
+ templateUrl: './network-offline.component.html',
7
+ styleUrls: ['./network-offline.component.scss']
8
+ })
9
+ export class NetworkOfflineComponent implements OnInit {
10
+
11
+ translationMap: Map< string, string>;
12
+
13
+ constructor(
14
+ private customTranslateService: CustomTranslateService
15
+ ){}
16
+
17
+ ngOnInit(): void {
18
+ let keys = [
19
+ 'CONNECTION_NETWORK_ERROR'
20
+ ]
21
+ this.translationMap = this.customTranslateService.translateLanguage(keys)
22
+ }
23
+
24
+ }
@@ -77,6 +77,8 @@
77
77
  "LABEL_PRECHAT_ACCEPT_TERMS_PRIVACY": "I agree",
78
78
  "PRECHAT_REQUIRED_ERROR": "This field is required",
79
79
 
80
+ "TICKET_TAKING":"The request has been received and the assistance staff is dealing with it.\nTo add more comments, reply to this email.",
81
+
80
82
  "LABEL_TODAY": "today",
81
83
  "LABEL_TOMORROW": "yesterday",
82
84
  "LABEL_LAST_ACCESS": "last access",
@@ -87,5 +89,6 @@
87
89
  "SENT_AN_IMAGE":"sent an image",
88
90
 
89
91
  "LABEL_PREVIEW": "Preview",
90
- "SWITCH_TO": "Or switch to:"
92
+ "SWITCH_TO": "Or switch to:",
93
+ "CONNECTION_NETWORK_ERROR": "Our apologies. There was some trouble connecting to network"
91
94
  }
@@ -77,6 +77,8 @@
77
77
  "LABEL_PRECHAT_ACCEPT_TERMS_PRIVACY": "Acepto",
78
78
  "PRECHAT_REQUIRED_ERROR": "Este campo es obligatorio",
79
79
 
80
+ "TICKET_TAKING":"La solicitud ha sido recibida y el personal de asistencia está tratando con ella. \nPara agregar más comentarios, responda a este correo electrónico.",
81
+
80
82
  "LABEL_TODAY": "hoy",
81
83
  "LABEL_TOMORROW": "ayer",
82
84
  "LABEL_LAST_ACCESS": "ultimo acceso",
@@ -87,5 +89,6 @@
87
89
  "SENT_AN_IMAGE": "envió una imagen",
88
90
 
89
91
  "LABEL_PREVIEW": "Avance",
90
- "SWITCH_TO":"O cambiar a:"
92
+ "SWITCH_TO":"O cambiar a:",
93
+ "CONNECTION_NETWORK_ERROR": "Nuestras disculpas. Hubo algunos problemas para conectarse a la red"
91
94
  }
@@ -77,6 +77,8 @@
77
77
  "LABEL_PRECHAT_ACCEPT_TERMS_PRIVACY": "Je suis d'accord",
78
78
  "PRECHAT_REQUIRED_ERROR": "Ce champ est obligatoire",
79
79
 
80
+ "TICKET_TAKING":"La demande a été reçue et le personnel d'assistance la traite.\nPour ajouter d'autres commentaires, répondez à cet e-mail.",
81
+
80
82
  "LABEL_TODAY": "aujourd'hui",
81
83
  "LABEL_TOMORROW": "hier",
82
84
  "LABEL_LAST_ACCESS": "dernier accès",
@@ -87,5 +89,6 @@
87
89
  "SENT_AN_IMAGE": "envoyé une image",
88
90
 
89
91
  "LABEL_PREVIEW": "Aperçu",
90
- "SWITCH_TO":"Ou passer à:"
92
+ "SWITCH_TO":"Ou passer à:",
93
+ "CONNECTION_NETWORK_ERROR": "Nos excuses. Il y a eu des problèmes de connexion au réseau"
91
94
  }
@@ -77,6 +77,8 @@
77
77
  "LABEL_PRECHAT_ACCEPT_TERMS_PRIVACY": "Sono d'accordo",
78
78
  "PRECHAT_REQUIRED_ERROR": "Questo campo è obbligatorio",
79
79
 
80
+ "TICKET_TAKING":"La richiesta è stata ricevuta e il personale di assistenza se ne sta occupando.\nPer aggiungere ulteriori commenti, rispondi a questa email.",
81
+
80
82
  "LABEL_TODAY": "oggi",
81
83
  "LABEL_TOMORROW": "ieri",
82
84
  "LABEL_LAST_ACCESS": "ultimo accesso",
@@ -87,5 +89,6 @@
87
89
  "SENT_AN_IMAGE":"ha inviato un'immagine",
88
90
 
89
91
  "LABEL_PREVIEW": "Anteprima",
90
- "SWITCH_TO":"Oppure passa a:"
92
+ "SWITCH_TO":"Oppure passa a:",
93
+ "CONNECTION_NETWORK_ERROR": "Ci scusiamo. Si sono verificati problemi di connessione di rete"
91
94
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  Chat21Client
3
3
 
4
- v0.1.12.7
4
+ v0.1.12.8
5
5
 
6
6
  @Author Andrea Sponziello
7
7
  @Member Gabriele Panico
@@ -1022,25 +1022,31 @@ class Chat21Client {
1022
1022
  );
1023
1023
  }
1024
1024
  );
1025
+ this.client.on('error',
1026
+ (error) => {
1027
+ console.error("Chat client error event", error);
1028
+ }
1029
+ );
1030
+ }
1031
+
1032
+ onDisconnect(callback){
1025
1033
  this.client.on('reconnect',
1026
1034
  () => {
1027
1035
  if (this.log) {console.log("Chat client reconnect event");}
1036
+ // callback('reconnect')
1028
1037
  }
1029
1038
  );
1030
1039
  this.client.on('close',
1031
1040
  () => {
1032
1041
  this.connected = false
1033
1042
  if (this.log) {console.log("Chat client close event");}
1043
+ callback('close')
1034
1044
  }
1035
1045
  );
1036
1046
  this.client.on('offline',
1037
1047
  () => {
1038
1048
  if (this.log) {console.log("Chat client offline event");}
1039
- }
1040
- );
1041
- this.client.on('error',
1042
- (error) => {
1043
- console.error("Chat client error event", error);
1049
+ // callback('offline')
1044
1050
  }
1045
1051
  );
1046
1052
  }
@@ -265,9 +265,17 @@ z
265
265
  this.chat21Service.chatClient.connect(userid, credentials.token, () => {
266
266
  this.logger.debug('[MQTTAuthService] connectMQTT: Chat connected');
267
267
  this.BSAuthStateChanged.next('online');
268
+ this.onDisconnectMQTT();
268
269
  });
269
270
  }
270
271
 
272
+ onDisconnectMQTT(): any{
273
+ this.chat21Service.chatClient.onDisconnect((state)=> {
274
+ this.logger.debug('[MQTTAuthService] onDisconnect --> ', state)
275
+ this.BSAuthStateChanged.next('close');
276
+ })
277
+ }
278
+
271
279
  // /**
272
280
  // * createCompleteUser
273
281
  // * @param user
@@ -13,6 +13,7 @@ export const PUSH_ENGINE_FIREBASE = 'firebase';
13
13
  // AUTH
14
14
  export const AUTH_STATE_OFFLINE = 'offline';
15
15
  export const AUTH_STATE_ONLINE = 'online'
16
+ export const AUTH_STATE_CLOSE = 'close'
16
17
 
17
18
 
18
19
  // MESSAGES STATUS