@chat21/chat21-ionic 3.0.105 → 3.0.107-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.
Files changed (30) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/src/app/app.component.html +11 -6
  5. package/src/app/app.component.scss +34 -11
  6. package/src/app/app.component.ts +47 -35
  7. package/src/app/app.module.ts +7 -1
  8. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.ts +0 -5
  9. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +0 -1
  10. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +4 -4
  11. package/src/app/components/conversations-list/header-conversations-list/header-conversations-list.component.html +2 -3
  12. package/src/app/components/navbar/navbar.component.scss +0 -5
  13. package/src/app/components/navbar/navbar.component.ts +1 -1
  14. package/src/app/pages/conversation-detail/conversation-detail.page.ts +20 -13
  15. package/src/app/pages/conversations-list/conversations-list.page.ts +14 -20
  16. package/src/app/services/global-settings/global-settings.service.spec.ts +16 -0
  17. package/src/app/services/global-settings/global-settings.service.ts +138 -0
  18. package/src/app/services/triggerEvents/trigerEvents.spec.ts +11 -0
  19. package/src/app/services/triggerEvents/triggerEvents.ts +92 -0
  20. package/src/app/utils/globals.ts +51 -0
  21. package/src/app/utils/toast.ts +1 -1
  22. package/src/assets/test.html +23 -0
  23. package/src/chat-config-template.json +1 -1
  24. package/src/chat-config.json +1 -1
  25. package/src/chat21-core/models/department.ts +12 -0
  26. package/src/chat21-core/providers/abstract/upload.service.ts +2 -0
  27. package/src/chat21-core/providers/chat-manager.ts +0 -20
  28. package/src/chat21-core/providers/firebase/firebase-upload.service.ts +83 -0
  29. package/src/chat21-core/providers/native/native-upload-service.ts +46 -0
  30. package/src/chat21-core/utils/utils.ts +33 -86
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.107.rc.1
4
+ - added: globals and globals-settings services to manage env and option variables globally
5
+ - added: eventTrigger service to expose custom chat event to parent chat-iframe container
6
+ - added: new UI home management for supportMode
7
+ - bug-fixed: privateMsg colors not visible
8
+
9
+ ### 3.0.106 in PROD
10
+ - changed: testsitebaseurl with widgetBaseUrl
11
+ - changed: WIDGET_TEST_LOCATION with WIDGET_LOCATION
12
+
3
13
  ### 3.0.105 in PROD
4
14
 
5
15
  ### 3.0.105.rc.1
package/README.md CHANGED
@@ -102,7 +102,7 @@ Use [Docker Compose Tiledesk installation guide](https://github.com/Tiledesk/til
102
102
  "apiUrl": "https://<YOUR-TILEDESK-API-URL>",
103
103
  "baseImageUrl": "https://<YOUR-BASE-IMAGE-URL>",
104
104
  "dashboardUrl": "https://<YOUR-DASHBOARD-URL>"
105
- "testsiteBaseUrl": "https:<YOUR-WIDGET-URL>/test_widget_page/index.html"
105
+ "widgetBaseUrl": "https:<YOUR-WIDGET-URL>/"
106
106
  "wsUrl": 'ws://' + window.location.hostname + '/ws/',
107
107
  "emailSection": true,
108
108
  "whatsappTemplatesSection": true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.0.105",
4
+ "version": "3.0.107-rc.1",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -7,28 +7,33 @@
7
7
 
8
8
 
9
9
  <app-navbar *ngIf="!IS_ON_MOBILE_DEVICE && lang"
10
+ [ngClass]="{'sidebar-hidden': IS_ON_MOBILE_DEVICE || SUPPORT_MODE === false }"
10
11
  [isSoundEnabled]="isSoundEnabled"
11
12
  (onSoundChange)="onSoundChange($event)">
12
13
  </app-navbar>
13
14
 
14
- <div class="sidebar" [ngClass]="{'hide-sidebar': IS_ONLINE === false || IS_ON_MOBILE_DEVICE === true || SUPPORT_MODE === false}">
15
+ <app-sidebar class="sidebar"
16
+ [ngClass]="{'sidebar-hidden': IS_ONLINE === false || IS_ON_MOBILE_DEVICE || SUPPORT_MODE === false}">
17
+ </app-sidebar>
18
+
19
+ <!-- <div class="sidebar" [ngClass]="{'hide-sidebar': IS_ONLINE === false || IS_ON_MOBILE_DEVICE === true || SUPPORT_MODE === false}">
15
20
  <app-sidebar></app-sidebar>
16
- </div>
21
+ </div> -->
17
22
 
18
- <div class="user-details-sidebar" [ngClass]="{'hide-sidebar': IS_ONLINE === false || IS_ON_MOBILE_DEVICE === true || SUPPORT_MODE === false}">
23
+ <div class="user-details-sidebar" [ngClass]="{'hide-sidebar': IS_ONLINE === false || IS_ON_MOBILE_DEVICE || SUPPORT_MODE === false}">
19
24
  <app-sidebar-user-details> </app-sidebar-user-details>
20
25
  </div>
21
26
 
22
- <ion-split-pane when="md" contentId="main" [ngClass]="{'mobile': IS_ON_MOBILE_DEVICE}">
27
+ <ion-split-pane when="md" contentId="main" [ngClass]="{'mobile': IS_ON_MOBILE_DEVICE, 'sidebar-hidden': IS_ON_MOBILE_DEVICE || SUPPORT_MODE === false}">
23
28
  <!-- 'sidebar-visible': IS_ONLINE === true && SUPPORT_MODE === true, -->
24
- <ion-nav #sidebarNav [root]="sidebarPage" [ngClass]="{'sidebar-hidden': IS_ON_MOBILE_DEVICE === true || SUPPORT_MODE === false}"></ion-nav>
29
+ <ion-nav #sidebarNav [root]="sidebarPage"></ion-nav>
25
30
  <!-- our side menu -->
26
31
  <!-- <ion-router-outlet id="sidebar" name='sidebar' animated="false" #masterNav> -->
27
32
  <!-- <app-conversations-list></app-conversations-list> -->
28
33
  <!-- </ion-router-outlet> -->
29
34
  <!-- the main content -->
30
35
  <!-- -->
31
- <ion-router-outlet id="main" #detailNav animated="false" [ngClass]="{'router-outlet-margin-left': platformIs === 'mobile' && SUPPORT_MODE === true && IS_ON_MOBILE_DEVICE === false}">
36
+ <ion-router-outlet id="main" #detailNav animated="false">
32
37
  </ion-router-outlet>
33
38
  </ion-split-pane>
34
39
  </div>
@@ -3,29 +3,52 @@
3
3
  .split-pane-md.split-pane-visible > .split-pane-side {
4
4
  min-width: 320px; //360px; //312px;
5
5
  display: block; // Safari bug fix
6
- margin-left: var(--sidebar-width);
7
6
  --border: 0px;
8
- background-color: var(--list-bkg-color);
7
+ // background-color: var(--list-bkg-color);
9
8
  }
10
9
 
11
- .split-pane-md:not(.mobile){
10
+ // .split-pane-md:not(.mobile){
11
+ // height: calc( 100% - var(--nav-bar-heigth));
12
+ // margin-top: var(--nav-bar-heigth);
13
+ // }
14
+
15
+ ion-split-pane:not(.mobile) {
12
16
  height: calc( 100% - var(--nav-bar-heigth));
13
17
  margin-top: var(--nav-bar-heigth);
18
+ margin-left: var(--sidebar-width);
19
+ // display: block; // Safari bug fix
20
+ // --border: 0px;
21
+ background-color: var(--list-bkg-color);
22
+ &.sidebar-hidden{
23
+ margin-left: 0px;
24
+ margin-top: 0px;
25
+ height: 100%;
26
+ }
14
27
  }
15
28
 
16
-
17
- .navbar{
18
- display: flex;
19
- position: fixed;
29
+ app-navbar{
30
+ position: absolute;
20
31
  top: 0px;
32
+ width: calc(100% - var(--sidebar-width));
33
+ margin-left: var(--sidebar-width);
34
+
35
+ &.sidebar-hidden{
36
+ width: 100%;
37
+ margin-left: 0px;
38
+ }
21
39
  }
22
40
 
23
- .sidebar-visible {
24
- margin-left: 60px;
41
+ app-sidebar{
42
+ &.sidebar-hidden{
43
+ display: none;
44
+ }
25
45
  }
26
46
 
27
- .sidebar-hidden {
28
- margin-left: 0px !important;
47
+
48
+ .navbar{
49
+ display: flex;
50
+ position: fixed;
51
+ top: 0px;
29
52
  }
30
53
 
31
54
  .hide-sidebar {
@@ -1,4 +1,4 @@
1
- import { Component, HostListener, NgZone, OnInit, ViewChild } from '@angular/core';
1
+ import { Component, ElementRef, HostListener, NgZone, OnInit, ViewChild } from '@angular/core';
2
2
 
3
3
  import { AlertController, Config, IonNav, IonRouterOutlet, ModalController, NavController, Platform, ToastController } from '@ionic/angular';
4
4
  import { SplashScreen } from '@ionic-native/splash-screen/ngx';
@@ -37,6 +37,9 @@ import { ConversationListPage } from './pages/conversations-list/conversations-l
37
37
  import { Location } from '@angular/common'
38
38
  import { FCM } from 'cordova-plugin-fcm-with-dependecy-updated/ionic/ngx'
39
39
  import { Deeplinks } from '@ionic-native/deeplinks/ngx';
40
+ import { TriggerEvents } from './services/triggerEvents/triggerEvents';
41
+ import { Globals } from './utils/globals';
42
+ import { GlobalSettingsService } from './services/global-settings/global-settings.service';
40
43
 
41
44
  @Component({
42
45
  selector: 'app-root',
@@ -98,6 +101,7 @@ export class AppComponent implements OnInit {
98
101
  private deeplinks: Deeplinks,
99
102
  private appConfigProvider: AppConfigProvider,
100
103
  public events: EventsService,
104
+ public triggerEvents: TriggerEvents,
101
105
  public config: Config,
102
106
  public chatManager: ChatManager,
103
107
  public translate: TranslateService,
@@ -129,7 +133,10 @@ export class AppComponent implements OnInit {
129
133
  public webSocketJs: WebSocketJs,
130
134
  public scriptService: ScriptService,
131
135
  public location: Location,
132
- public fcm: FCM
136
+ public fcm: FCM,
137
+ public el: ElementRef,
138
+ public g: Globals,
139
+ public globalSettingsService: GlobalSettingsService,
133
140
  ) {
134
141
 
135
142
  this.saveInStorageNumberOfOpenedChatTab();
@@ -261,19 +268,34 @@ export class AppComponent implements OnInit {
261
268
  ngOnInit(): void {
262
269
  const appconfig = this.appConfigProvider.getConfig();
263
270
  this.logger.log('[APP-COMP] ngOnInit appconfig', appconfig)
264
- if (appconfig && appconfig.supportMode && (appconfig.supportMode === true || appconfig.supportMode === 'true')) {
265
- this.SUPPORT_MODE = true;
266
- this.logger.log('[APP-COMP] appconfig > SUPPORT_MODE', this.SUPPORT_MODE)
267
- } else {
268
- this.SUPPORT_MODE = false;
269
- this.logger.log('[APP-COMP] appconfig > SUPPORT_MODE', this.SUPPORT_MODE)
270
- }
271
- this.persistence = appconfig.authPersistence;
272
- this.appStorageService.initialize(environment.storage_prefix, this.persistence, '')
273
- // this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
274
- // this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
275
- // this.initializeApp('oninit');
276
- const token = getParameterByName('jwt')
271
+
272
+ this.globalSettingsService.obsSettingsService.subscribe((resp) => {
273
+ if(resp){
274
+ this.logger.log('[APP-COMP] ngOnInit globalSettingsService', this.g)
275
+ // /** INIT */
276
+ // this.getRouteParamsAndSetLoggerConfig();
277
+
278
+ // this.logger.info('[APP-COMP] appconfig: ', appconfig)
279
+ this.version = environment.version;
280
+
281
+ this.logger.setLoggerConfig(true, this.g.logLevel)
282
+ this.logger.info('[APP-COMP] logLevel: ', this.g.logLevel);
283
+ this.tabTitle = document.title;
284
+ // this.appStorageService.initialize(environment.storage_prefix, this.persistence, '') /** moved to globals-settings.service */
285
+
286
+ this.tenant = this.g.tenant;
287
+ this.persistence = this.g.persistence
288
+ this.logger.info('[APP-COMP] appconfig firebaseConfig tenant: ', this.tenant);
289
+ this.notificationsEnabled = true;
290
+ this.zone = new NgZone({}); // a cosa serve?
291
+
292
+ this.SUPPORT_MODE = this.g.supportMode
293
+ }
294
+
295
+ });
296
+ this.globalSettingsService.initParamiters(this.g, this.el);
297
+
298
+ const token = getParameterByName(window,'jwt')
277
299
  // this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
278
300
  if (token) {
279
301
  // this.isOnline = false;
@@ -291,6 +313,7 @@ export class AppComponent implements OnInit {
291
313
  }
292
314
  }
293
315
 
316
+ this.triggerEvents.setWindowContext(window.parent)
294
317
 
295
318
  this.initializeApp('oninit');
296
319
  this.loadCustomScript(appconfig)
@@ -397,22 +420,6 @@ export class AppComponent implements OnInit {
397
420
  if (!this.platform.is('desktop')) {
398
421
  this.splashScreen.show();
399
422
  }
400
- this.tabTitle = document.title;
401
-
402
- this.getRouteParamsAndSetLoggerConfig();
403
-
404
- const appconfig = this.appConfigProvider.getConfig();
405
- // this.logger.info('[APP-COMP] appconfig: ', appconfig)
406
- this.version = environment.version;
407
- this.logger.info('[APP-COMP] version: ', this.version)
408
-
409
- this.logger.setLoggerConfig(true, appconfig.logLevel)
410
- this.logger.info('[APP-COMP] logLevel: ', appconfig.logLevel);
411
-
412
- this.tenant = appconfig.firebaseConfig.tenant;
413
- this.logger.info('[APP-COMP] appconfig firebaseConfig tenant: ', this.tenant);
414
- this.notificationsEnabled = true;
415
- this.zone = new NgZone({}); // a cosa serve?
416
423
 
417
424
  this.platform.ready().then(() => {
418
425
  let platform = this.getPlatformName();
@@ -445,7 +452,6 @@ export class AppComponent implements OnInit {
445
452
  this.initAuthentication();
446
453
  this.initSubscriptions();
447
454
  this.initAudio();
448
-
449
455
  this.logger.debug('[APP-COMP] initializeApp:: ', this.sidebarNav, this.detailNav);
450
456
 
451
457
  this.translateToastMsgs();
@@ -978,12 +984,14 @@ export class AppComponent implements OnInit {
978
984
  this.IS_ONLINE = true;
979
985
  // console.log('[APP-COMP] IS_ONLINE', this.IS_ONLINE)
980
986
  this.goOnLine();
987
+ this.triggerOnAuthStateChanged(state)
981
988
  // }
982
989
  } else if (state === AUTH_STATE_OFFLINE) {
983
990
  // this.checkTokenAndGoOffline() //se c'è un tiledeskToken salvato, allora aspetta, altrimenti vai offline
984
991
  this.IS_ONLINE = false;
985
992
  // console.log('[APP-COMP] IS_ONLINE', this.IS_ONLINE)
986
993
  this.goOffLine()
994
+ this.triggerOnAuthStateChanged(state)
987
995
  }
988
996
  }, error => {
989
997
  this.logger.error('initialize FROM [APP-COMP] - [APP-COMP] ***** BSAuthStateChanged * error * ', error)
@@ -1095,9 +1103,7 @@ export class AppComponent implements OnInit {
1095
1103
  goOffLine = () => {
1096
1104
  this.logger.log('[APP-COMP] - GO-OFFLINE');
1097
1105
  this.logger.log('[APP-COMP] - GO-OFFINE - supportmode ', this.SUPPORT_MODE);
1098
- if (this.SUPPORT_MODE === true) {
1099
- this.webSocketClose()
1100
- }
1106
+ this.webSocketClose()
1101
1107
  // this.isOnline = false;
1102
1108
  // this.conversationsHandlerService.conversations = [];
1103
1109
  this.chatManager.setTiledeskToken(null);
@@ -1571,6 +1577,12 @@ export class AppComponent implements OnInit {
1571
1577
  }
1572
1578
 
1573
1579
 
1580
+ private triggerOnAuthStateChanged(event){
1581
+ const detailOBJ = { event: event, isLogged: true, user: this.tiledeskAuthService.getCurrentUser() , appConfigs: this.appConfigProvider.getConfig() }
1582
+ this.triggerEvents.triggerOnAuthStateChanged(detailOBJ)
1583
+ }
1584
+
1585
+
1574
1586
  // @HostListener('mouseenter', ['$event'])
1575
1587
  // onMouseEnter(event: any) {
1576
1588
  // console.log('HostListener onMouseEnter-->', event)
@@ -114,6 +114,9 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
114
114
  import { MapsPageModule } from './modals/maps/maps.module';
115
115
  import { GoogleMapsModule } from '@angular/google-maps';
116
116
  import { Deeplinks } from '@ionic-native/deeplinks/ngx';
117
+ import { TriggerEvents } from './services/triggerEvents/triggerEvents';
118
+ import { Globals } from './utils/globals';
119
+ import { GlobalSettingsService } from './services/global-settings/global-settings.service';
117
120
 
118
121
  // FACTORIES
119
122
  export function createTranslateLoader(http: HttpClient) {
@@ -314,6 +317,8 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
314
317
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
315
318
  providers: [
316
319
  AppConfigProvider, // https://juristr.com/blog/2018/01/ng-app-runtime-config/
320
+ Globals,
321
+ GlobalSettingsService,
317
322
  {
318
323
  provide: APP_INITIALIZER,
319
324
  useFactory: appInitializerFn,
@@ -393,7 +398,8 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
393
398
  ScriptService,
394
399
  FCM,
395
400
  InAppBrowser,
396
- Deeplinks
401
+ Deeplinks,
402
+ TriggerEvents
397
403
  ]
398
404
  })
399
405
  export class AppModule { }
@@ -1,6 +1,5 @@
1
1
  import { ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild, SimpleChanges } from '@angular/core';
2
2
  import { MessageModel } from 'src/chat21-core/models/message';
3
- import { isPopupUrl, popupUrl, stripTags } from 'src/chat21-core/utils/utils';
4
3
  import { MSG_STATUS_SENT, MSG_STATUS_RETURN_RECEIPT, MSG_STATUS_SENT_SERVER, MAX_WIDTH_IMAGES, MESSAGE_TYPE_INFO, MESSAGE_TYPE_MINE, MESSAGE_TYPE_OTHERS } from 'src/chat21-core/utils/constants';
5
4
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
6
5
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
@@ -40,10 +39,6 @@ export class ConversationContentComponent implements OnInit {
40
39
  firstScroll = true;
41
40
  // ========= end:: gestione scroll view messaggi ======= //
42
41
 
43
- // ========= begin:: dichiarazione funzioni ======= //
44
- isPopupUrl = isPopupUrl;
45
- popupUrl = popupUrl;
46
- // ========= end:: dichiarazione funzioni ======= //
47
42
 
48
43
  // ========== begin:: set icon status message ======= //
49
44
  MSG_STATUS_SENT = MSG_STATUS_SENT;
@@ -162,7 +162,6 @@
162
162
  </chat-avatar-image> -->
163
163
 
164
164
  <div class="bubble-container">
165
-
166
165
  <!--backgroundColor non viene ancora usato -->
167
166
  <chat-bubble-message class="messages msg_receive" id="message_msg_receive"
168
167
  [ngClass]="{'has-metadata': (isImage(message) || isFrame(message)), 'privateMsg': (message?.attributes && message?.attributes?.subtype === 'private')}"
@@ -222,8 +222,8 @@ ion-item {
222
222
  border-bottom-right-radius: 0px;
223
223
 
224
224
  &.privateMsg{
225
- background-color: var(--bubble-privateMsg);
226
- color: var(--bubble-privateMsgColor)
225
+ background-color: var(--bubble-privateMsg) !important;
226
+ color: var(--bubble-privateMsgColor) !important;
227
227
  }
228
228
  }
229
229
  .no-background{
@@ -324,8 +324,8 @@ ion-item {
324
324
  border-bottom-left-radius: 0px;
325
325
 
326
326
  &.privateMsg{
327
- background-color: var(--bubble-privateMsg);
328
- color: var(--bubble-privateMsgColor)
327
+ background-color: var(--bubble-privateMsg) !important;
328
+ color: var(--bubble-privateMsgColor) !important;
329
329
  }
330
330
  }
331
331
  .no-background{
@@ -1,6 +1,6 @@
1
1
  <ion-toolbar [class.mobile]="isMobile">
2
2
 
3
- <ion-buttons *ngIf="isMobile || supportMode === false" slot="start" style="height:60px">
3
+ <ion-buttons *ngIf="isMobile || !supportMode" slot="start" style="height:60px">
4
4
  <ion-button ion-button icon-only fill="clear" (click)="onOpenProfileInfo($event)">
5
5
  <ion-icon slot="icon-only" name="reorder-three-outline"></ion-icon>
6
6
  </ion-button>
@@ -22,8 +22,7 @@
22
22
  </ion-buttons>
23
23
 
24
24
  <ion-buttons slot="end">
25
-
26
- <ion-button *ngIf="!isMobile" ion-button fill="clear" (click)="presentCreateTicketModal()"
25
+ <ion-button *ngIf="!isMobile && supportMode" ion-button fill="clear" (click)="presentCreateTicketModal()"
27
26
  tooltip="{{translationMap?.get('CreateTicket')}}" placement="bottom">
28
27
  <ion-icon slot="icon-only" name="ticket-outline"></ion-icon>
29
28
  </ion-button>
@@ -1,13 +1,8 @@
1
1
  .navbar-absolute{
2
- position: absolute;
3
- width: calc(100% - var(--sidebar-width));
4
- margin-left: var(--sidebar-width);
5
2
  padding-top: 5px;
6
3
  z-index: 1;
7
4
  padding-bottom: 5px;
8
5
  border-bottom: 1px solid #e7e7e7;
9
- top: 0;
10
-
11
6
  -webkit-font-smoothing: auto;
12
7
  }
13
8
 
@@ -159,7 +159,7 @@ export class NavbarComponent implements OnInit {
159
159
  const simulateVisitorBtnElem = <HTMLElement>document.querySelector('.simulate-visitor-btn');
160
160
  simulateVisitorBtnElem.blur();
161
161
  // + '&isOpen=true'
162
- const url = this.appConfigProvider.getConfig().testsiteBaseUrl + '?tiledesk_projectid=' + this.project.id_project.id + '&project_name=' + this.project.id_project.name + '&role=' + this.USER_ROLE
162
+ const url = this.appConfigProvider.getConfig().widgetBaseUrl + 'assets/twp/index.html?tiledesk_projectid=' + this.project.id_project.id + '&project_name=' + this.project.id_project.name + '&role=' + this.USER_ROLE
163
163
  window.open(url, '_blank');
164
164
  }
165
165
 
@@ -46,7 +46,7 @@ import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/a
46
46
  import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service'
47
47
  import { ContactsService } from 'src/app/services/contacts/contacts.service'
48
48
  import { CannedResponsesService } from '../../services/canned-responses/canned-responses.service'
49
- import { compareValues, getDateDifference, htmlEntities } from 'src/chat21-core/utils/utils'
49
+ import {getDateDifference} from 'src/chat21-core/utils/utils'
50
50
  import { ImageRepoService } from 'src/chat21-core/providers/abstract/image-repo.service'
51
51
  import { PresenceService } from 'src/chat21-core/providers/abstract/presence.service'
52
52
  import { CreateCannedResponsePage } from 'src/app/modals/create-canned-response/create-canned-response.page'
@@ -89,6 +89,9 @@ import { EventsService } from '../../services/events-service'
89
89
  import { ScrollbarThemeDirective } from 'src/app/utils/scrollbar-theme.directive'
90
90
  import { WebsocketService } from 'src/app/services/websocket/websocket.service';
91
91
  import { Project } from 'src/chat21-core/models/projects';
92
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
93
+ import { Globals } from 'src/app/utils/globals';
94
+ import { TriggerEvents } from 'src/app/services/triggerEvents/triggerEvents';
92
95
 
93
96
  @Component({
94
97
  selector: 'app-conversation-detail',
@@ -238,7 +241,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
238
241
  private networkService: NetworkService,
239
242
  private events: EventsService,
240
243
  private webSocketService: WebsocketService,
241
- private sanitizer: DomSanitizer
244
+ private sanitizer: DomSanitizer,
245
+ private g: Globals,
246
+ private triggerEvents: TriggerEvents
242
247
  ) {
243
248
  // Change list on date change
244
249
  this.route.paramMap.subscribe((params) => {
@@ -361,14 +366,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
361
366
  }
362
367
 
363
368
  getOSCODE() {
364
- this.supportMode = null
365
- if (this.appConfigProvider.getConfig().supportMode === true || this.appConfigProvider.getConfig().supportMode === 'true') {
366
- this.supportMode = true
367
- } else if (this.appConfigProvider.getConfig().supportMode === false || this.appConfigProvider.getConfig().supportMode === 'false') {
368
- this.supportMode = false
369
- } else if (!this.appConfigProvider.getConfig().supportMode) {
370
- this.supportMode = false
371
- }
369
+ this.supportMode = this.g.supportMode
372
370
  this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig supportMode', this.supportMode)
373
371
  this.public_Key = this.appConfigProvider.getConfig().t2y12PruGU9wUtEGzBJfolMIgK
374
372
  this.logger.log('[CONVS-DETAIL] AppConfigService getAppConfig public_Key', this.public_Key)
@@ -1178,10 +1176,11 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1178
1176
  subscriptionKey = 'messageAdded'
1179
1177
  subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
1180
1178
  if (!subscription) {
1181
- subscription = this.conversationHandlerService.messageAdded.subscribe((msg: any) => {
1179
+ subscription = this.conversationHandlerService.messageAdded.subscribe((msg: MessageModel) => {
1182
1180
  this.logger.log('[CONVS-DETAIL] subscribe to messageAdded - msg ', msg)
1183
1181
  if (msg) {
1184
1182
  that.newMessageAdded(msg)
1183
+ that.manageEvent(msg)
1185
1184
  // this.setHeaderContent()
1186
1185
  }
1187
1186
  })
@@ -1193,7 +1192,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1193
1192
  subscriptionKey = 'messageChanged'
1194
1193
  subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
1195
1194
  if (!subscription) {
1196
- subscription = this.conversationHandlerService.messageChanged.subscribe((msg: any) => {
1195
+ subscription = this.conversationHandlerService.messageChanged.subscribe((msg: MessageModel) => {
1197
1196
  this.logger.log('[CONVS-DETAIL] subscribe to messageChanged - msg ', msg)
1198
1197
  })
1199
1198
  const subscribe = { key: subscriptionKey, value: subscription }
@@ -1213,7 +1212,7 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1213
1212
  subscriptionKey = 'messageInfo'
1214
1213
  subscription = this.subscriptions.find((item) => item.key === subscriptionKey)
1215
1214
  if (!subscription) {
1216
- subscription = this.conversationHandlerService.messageInfo.pipe(takeUntil(this.unsubscribe$)).subscribe((msg: any) => {
1215
+ subscription = this.conversationHandlerService.messageInfo.pipe(takeUntil(this.unsubscribe$)).subscribe((msg: MessageModel) => {
1217
1216
  this.logger.log('[CONVS-DETAIL] subscribe to messageInfo - messageId ', msg, this.conversation)
1218
1217
  if (msg) {
1219
1218
  that.updateLeadInfo(msg)
@@ -1337,6 +1336,14 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1337
1336
  }
1338
1337
  }
1339
1338
 
1339
+ manageEvent(msg: MessageModel){
1340
+ if(msg.isSender){
1341
+ this.triggerEvents.triggerAfterSendMessageEvent(msg)
1342
+ }else if(!msg.isSender){
1343
+ this.triggerEvents.triggerAfterMessageReceived(msg)
1344
+ }
1345
+ }
1346
+
1340
1347
  // ----------------------------------------------------------------
1341
1348
  // @ Unsubscribe all subscribed events (called in ionViewWillLeave)
1342
1349
  // ----------------------------------------------------------------
@@ -18,8 +18,7 @@ import {
18
18
  closeModal,
19
19
  convertMessage,
20
20
  isGroup,
21
- searchIndexInArrayForUid,
22
- compareValues,
21
+ getParameterValue,
23
22
  } from '../../../chat21-core/utils/utils'
24
23
 
25
24
  import { EventsService } from '../../services/events-service'
@@ -49,6 +48,8 @@ import { skip, takeUntil } from 'rxjs/operators'
49
48
  import { REQUEST_ARCHIVED, TYPE_DIRECT } from 'src/chat21-core/utils/constants';
50
49
  import { getProjectIdSelectedConversation } from 'src/chat21-core/utils/utils-message';
51
50
  import { WebsocketService } from 'src/app/services/websocket/websocket.service';
51
+ import { Globals } from 'src/app/utils/globals';
52
+ import { TriggerEvents } from 'src/app/services/triggerEvents/triggerEvents';
52
53
 
53
54
  @Component({
54
55
  selector: 'app-conversations-list',
@@ -127,6 +128,8 @@ export class ConversationListPage implements OnInit {
127
128
  public appConfigProvider: AppConfigProvider,
128
129
  public platform: Platform,
129
130
  public wsService: WebsocketService,
131
+ private g: Globals,
132
+ private triggerEvents: TriggerEvents
130
133
  ) {
131
134
  this.checkPlatform();
132
135
  this.translations();
@@ -216,24 +219,10 @@ export class ConversationListPage implements OnInit {
216
219
  getAppConfigToHideDiplayBtns() {
217
220
  const appConfig = this.appConfigProvider.getConfig()
218
221
  // console.log('[CONVS-LIST-PAGE] - appConfig ', appConfig)
219
- this.supportMode = null
220
- if (appConfig && appConfig.supportMode === true || appConfig.supportMode === 'true') {
221
- this.supportMode = true;
222
- } else if (appConfig && appConfig.supportMode === false || appConfig.supportMode === 'false') {
223
- this.supportMode = false
224
- }
225
- this.archived_btn = null
226
- if (appConfig && appConfig.archivedButton === true || appConfig.archivedButton === 'true') {
227
- this.archived_btn = true;
228
- } else if (appConfig && appConfig.archivedButton === false || appConfig.archivedButton === 'false') {
229
- this.archived_btn = false;
230
- }
231
- this.writeto_btn = null
232
- if (appConfig && appConfig.writeToButton === true || appConfig.writeToButton === 'true') {
233
- this.writeto_btn = true;
234
- } else if (appConfig && appConfig.writeToButton === false || appConfig.writeToButton === 'false') {
235
- this.writeto_btn = false;
236
- }
222
+ this.supportMode = this.g.supportMode;
223
+ this.archived_btn = getParameterValue('archivedButton', appConfig)
224
+ this.writeto_btn = getParameterValue('writeToButton', appConfig)
225
+ this.logger.debug('[CONVS-LIST-PAGE] parameters supportMode/archived_btn/writeto_btn', this.supportMode, this.archived_btn, this.writeto_btn)
237
226
 
238
227
 
239
228
  const sound_status = localStorage.getItem('dshbrd----sound')
@@ -583,6 +572,7 @@ export class ConversationListPage implements OnInit {
583
572
  if (conversation) {
584
573
  this.onImageLoaded(conversation)
585
574
  this.onConversationLoaded(conversation)
575
+ conversation.is_new && this.isInitialized? this.manageEvent(conversation) : null
586
576
  // conversation.is_new && this.isInitialized? this.segmentNewConversationAdded(conversation) : null;
587
577
  }
588
578
  })
@@ -657,6 +647,10 @@ export class ConversationListPage implements OnInit {
657
647
  // }
658
648
  }
659
649
 
650
+ manageEvent(conversation){
651
+ this.triggerEvents.triggerOnNewConversationInit(conversation)
652
+ }
653
+
660
654
  // ------------------------------------------------------------------//
661
655
  // END SUBSCRIPTIONS
662
656
  // ------------------------------------------------------------------//
@@ -0,0 +1,16 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+
3
+ import { GlobalSettingsService } from './global-settings.service';
4
+
5
+ describe('GlobalSettingsService', () => {
6
+ let service: GlobalSettingsService;
7
+
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({});
10
+ service = TestBed.inject(GlobalSettingsService);
11
+ });
12
+
13
+ it('should be created', () => {
14
+ expect(service).toBeTruthy();
15
+ });
16
+ });