@chat21/chat21-ionic 3.0.59-rc9 → 3.0.59
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 +53 -0
- package/README.md +5 -0
- package/config.xml +2 -2
- package/env.sample +1 -1
- package/package.json +1 -1
- package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
- package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
- package/resources/Android/splash.png +0 -0
- package/src/app/app.component.scss +10 -5
- package/src/app/app.component.ts +377 -228
- package/src/app/app.module.ts +12 -7
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
- package/src/app/components/authentication/login/login.component.html +8 -8
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +2 -4
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +7 -2
- package/src/app/components/project-item/project-item.component.html +2 -2
- package/src/app/components/project-item/project-item.component.scss +6 -6
- package/src/app/components/project-item/project-item.component.ts +46 -32
- package/src/app/pages/authentication/login/login.page.html +1 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +2 -0
- package/src/app/pages/conversations-list/conversations-list.page.html +12 -7
- package/src/app/pages/conversations-list/conversations-list.page.scss +279 -261
- package/src/app/pages/conversations-list/conversations-list.page.ts +138 -13
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +10 -2
- package/src/app/services/app-config.ts +77 -5
- package/src/app/services/websocket/websocket-js.ts +12 -14
- package/src/app/services/websocket/websocket.service.ts +26 -8
- package/src/assets/js/chat21client.js +144 -82
- package/src/assets/logo.png +0 -0
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-template.json +1 -0
- package/src/chat-config.json +1 -0
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +31 -23
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +3 -5
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +12 -3
- package/src/chat21-core/utils/utils-message.ts +2 -2
- package/src/firebase-messaging-sw-template.js +1 -1
- package/src/assets/images/tiledesk_logo_50x50.png +0 -0
|
@@ -35,7 +35,8 @@ import { Platform } from '@ionic/angular';
|
|
|
35
35
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
36
36
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
37
37
|
import { NetworkService } from 'src/app/services/network-service/network.service';
|
|
38
|
-
|
|
38
|
+
import { Subject } from 'rxjs';
|
|
39
|
+
import { takeUntil } from 'rxjs/operators'
|
|
39
40
|
|
|
40
41
|
@Component({
|
|
41
42
|
selector: 'app-conversations-list',
|
|
@@ -43,7 +44,10 @@ import { NetworkService } from 'src/app/services/network-service/network.service
|
|
|
43
44
|
styleUrls: ['./conversations-list.page.scss'],
|
|
44
45
|
})
|
|
45
46
|
export class ConversationListPage implements OnInit {
|
|
47
|
+
|
|
46
48
|
@ViewChild('ioncontentconvlist', { static: false }) ionContentConvList: IonContent;
|
|
49
|
+
|
|
50
|
+
private unsubscribe$: Subject<any> = new Subject<any>();
|
|
47
51
|
private subscriptions: Array<string>;
|
|
48
52
|
public tenant: string;
|
|
49
53
|
public loggedUserUid: string;
|
|
@@ -72,6 +76,11 @@ export class ConversationListPage implements OnInit {
|
|
|
72
76
|
public lastProjectId: string;
|
|
73
77
|
public isOnline: boolean = true;
|
|
74
78
|
public checkInternet: boolean;
|
|
79
|
+
|
|
80
|
+
public displayNewConvsItem: boolean = true
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
75
84
|
constructor(
|
|
76
85
|
private router: Router,
|
|
77
86
|
private route: ActivatedRoute,
|
|
@@ -90,14 +99,50 @@ export class ConversationListPage implements OnInit {
|
|
|
90
99
|
public appConfigProvider: AppConfigProvider,
|
|
91
100
|
public platform: Platform,
|
|
92
101
|
private networkService: NetworkService,
|
|
93
|
-
|
|
102
|
+
|
|
94
103
|
) {
|
|
95
104
|
this.listenToAppCompConvsLengthOnInitConvs();
|
|
96
105
|
this.listenToLogoutEvent();
|
|
106
|
+
this.listenGoOnline();
|
|
107
|
+
this.listenGoOffline();
|
|
97
108
|
this.listenToSwPostMessage();
|
|
109
|
+
this.listenSupportConvIdHasChanged();
|
|
110
|
+
// this.listenDirectConvIdHasChanged();
|
|
111
|
+
}
|
|
98
112
|
|
|
113
|
+
listenSupportConvIdHasChanged() {
|
|
114
|
+
this.events.subscribe('supportconvid:haschanged', (IDConv) => {
|
|
115
|
+
this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - convId', IDConv);
|
|
116
|
+
if (IDConv) {
|
|
117
|
+
// const conversationSelected = this.conversations.find(item => item.uid === convId);
|
|
118
|
+
// this.onConversationSelected(conversationSelected)
|
|
119
|
+
this.setUidConvSelected(IDConv, 'active');
|
|
120
|
+
}
|
|
121
|
+
if (!IDConv) {
|
|
122
|
+
this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - is the page without conv select');
|
|
123
|
+
|
|
124
|
+
const chatTabCount = +localStorage.getItem('tabCount')
|
|
125
|
+
this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - chatTabCount ', chatTabCount);
|
|
126
|
+
if (chatTabCount && chatTabCount > 0) {
|
|
127
|
+
this.logger.log('[CONVS-LIST-PAGE] - listen To convid:haschanged - the chat is already open ', chatTabCount);
|
|
128
|
+
if (checkPlatformIsMobile()) {
|
|
129
|
+
this.logger.log('[CONVS-LIST-PAGE] - the chat is in mobile mode ', checkPlatformIsMobile());
|
|
130
|
+
this.events.publish('noparams:mobile', true);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
99
135
|
}
|
|
100
136
|
|
|
137
|
+
// listenDirectConvIdHasChanged() {
|
|
138
|
+
// this.events.subscribe('directconvid:haschanged', (contact_id) => {
|
|
139
|
+
// // console.log('[CONVS-LIST-PAGE] - listen To directconvid:haschanged - contact_id', contact_id);
|
|
140
|
+
// if (contact_id) {
|
|
141
|
+
// this.uidConvSelected = contact_id
|
|
142
|
+
// }
|
|
143
|
+
// });
|
|
144
|
+
// }
|
|
145
|
+
|
|
101
146
|
|
|
102
147
|
// -----------------------------------------------
|
|
103
148
|
// @ Lifehooks
|
|
@@ -105,8 +150,50 @@ export class ConversationListPage implements OnInit {
|
|
|
105
150
|
ngOnInit() {
|
|
106
151
|
this.watchToConnectionStatus();
|
|
107
152
|
this.getSupportMode();
|
|
153
|
+
|
|
154
|
+
// const currentUrl = this.router.url;
|
|
155
|
+
// this.logger.log('[CONVS-LIST-PAGE] current_url ngOnInit ', currentUrl);
|
|
156
|
+
// this.route.queryParams.subscribe(params => {
|
|
157
|
+
// this.logger.log('[CONVS-LIST-PAGE] ngOnInit params', params);
|
|
158
|
+
// if (params && params.convId) {
|
|
159
|
+
// console.log('[CONVS-LIST-PAGE] ngOnInit params convId:', params.convId);
|
|
160
|
+
|
|
161
|
+
// const conversationSelected = this.conversations.find(item => item.uid === params.convId);
|
|
162
|
+
// if (conversationSelected) {
|
|
163
|
+
// this.conversationSelected = conversationSelected;
|
|
164
|
+
// console.log('[CONVS-LIST-PAGE] ngOnInit params convselected - conversationSelected: ', this.conversationSelected);
|
|
165
|
+
// setTimeout(() => {
|
|
166
|
+
// // this.navigateByUrl('active', params.convId)
|
|
167
|
+
// }, 0);
|
|
168
|
+
// }
|
|
169
|
+
|
|
170
|
+
// } else {
|
|
171
|
+
// console.log('[CONVS-LIST-PAGE] ngOnInit params No convId Params ');
|
|
172
|
+
// }
|
|
173
|
+
// if (params && params.contact_id && params.contact_fullname) {
|
|
174
|
+
// this.logger.log('[CONVS-LIST-PAGE] ngOnInit params contact_id:', params.contact_id, 'contact_fullname ', params.contact_fullname);
|
|
175
|
+
// setTimeout(() => {
|
|
176
|
+
// this.router.navigateByUrl('conversation-detail/' + params.contact_id + '/' + params.contact_fullname + '/new');
|
|
177
|
+
// }, 0);
|
|
178
|
+
// this.uidConvSelected = params.contact_id
|
|
179
|
+
// } else {
|
|
180
|
+
// this.logger.log('[CONVS-LIST-PAGE] ngOnInit params No contact_id and contact_fullname Params ');
|
|
181
|
+
// }
|
|
182
|
+
|
|
183
|
+
// if (params && params.conversation_detail) {
|
|
184
|
+
// this.logger.log('[CONVS-LIST-PAGE] ngOnInit params conversation_detail:', params.conversation_detail);
|
|
185
|
+
// setTimeout(() => {
|
|
186
|
+
// this.router.navigateByUrl('conversation-detail/');
|
|
187
|
+
// }, 0);
|
|
188
|
+
// } else {
|
|
189
|
+
// this.logger.log('[CONVS-LIST-PAGE] ngOnInit params No conversation_detail Params ');
|
|
190
|
+
// }
|
|
191
|
+
|
|
192
|
+
// });
|
|
108
193
|
}
|
|
109
194
|
|
|
195
|
+
|
|
196
|
+
|
|
110
197
|
getSupportMode() {
|
|
111
198
|
this.supportMode = this.appConfigProvider.getConfig().supportMode;
|
|
112
199
|
// console.log('[ION-LIST-CONVS-COMP] - supportMode ', this.supportMode)
|
|
@@ -218,12 +305,20 @@ export class ConversationListPage implements OnInit {
|
|
|
218
305
|
|
|
219
306
|
private listnerStart() {
|
|
220
307
|
const that = this;
|
|
221
|
-
this.chatManager.BSStart
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
308
|
+
this.chatManager.BSStart
|
|
309
|
+
.pipe(
|
|
310
|
+
takeUntil(that.unsubscribe$)
|
|
311
|
+
)
|
|
312
|
+
.subscribe((data: any) => {
|
|
313
|
+
this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR DATA - Current user *****', data);
|
|
314
|
+
if (data) {
|
|
315
|
+
that.initialize();
|
|
316
|
+
}
|
|
317
|
+
}, error => {
|
|
318
|
+
this.logger.error('[CONVS-LIST-PAGE] - BSStart SUBSCR - ERROR: ', error);
|
|
319
|
+
}, () => {
|
|
320
|
+
this.logger.log('[CONVS-LIST-PAGE] - BSStart SUBSCR * COMPLETE *')
|
|
321
|
+
});
|
|
227
322
|
}
|
|
228
323
|
|
|
229
324
|
|
|
@@ -259,7 +354,6 @@ export class ConversationListPage implements OnInit {
|
|
|
259
354
|
if (!this.archivedConversations || this.archivedConversations.length === 0) {
|
|
260
355
|
this.loadingIsActive = false;
|
|
261
356
|
}
|
|
262
|
-
|
|
263
357
|
}
|
|
264
358
|
|
|
265
359
|
|
|
@@ -279,9 +373,32 @@ export class ConversationListPage implements OnInit {
|
|
|
279
373
|
});
|
|
280
374
|
}
|
|
281
375
|
|
|
376
|
+
listenGoOnline() {
|
|
377
|
+
this.events.subscribe('go:online', (goonline) => {
|
|
378
|
+
this.logger.info('[CONVS-LIST-PAGE] - listen To go:online - goonline', goonline);
|
|
379
|
+
// this.events.unsubscribe('profileInfoButtonClick:logout')
|
|
380
|
+
if (goonline === true) {
|
|
381
|
+
this.displayNewConvsItem = true
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
listenGoOffline() {
|
|
387
|
+
|
|
388
|
+
this.events.subscribe('go:offline', (offline) => {
|
|
389
|
+
this.logger.info('[CONVS-LIST-PAGE] - listen To go:offline - offline', offline);
|
|
390
|
+
// this.events.unsubscribe('profileInfoButtonClick:logout')
|
|
391
|
+
if (offline === true) {
|
|
392
|
+
this.displayNewConvsItem = false
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
|
|
282
397
|
listenToLogoutEvent() {
|
|
283
398
|
this.events.subscribe('profileInfoButtonClick:logout', (hasclickedlogout) => {
|
|
284
399
|
this.logger.info('[CONVS-LIST-PAGE] - listenToLogoutEvent - hasclickedlogout', hasclickedlogout);
|
|
400
|
+
|
|
401
|
+
|
|
285
402
|
this.conversations = []
|
|
286
403
|
this.conversationsHandlerService.conversations = [];
|
|
287
404
|
this.uidConvSelected = null;
|
|
@@ -392,6 +509,9 @@ export class ConversationListPage implements OnInit {
|
|
|
392
509
|
* evento richiamato quando si seleziona un utente nell'elenco degli user
|
|
393
510
|
* apro dettaglio conversazione
|
|
394
511
|
*/
|
|
512
|
+
// --------------------------------
|
|
513
|
+
// !!!!!! IS USED? ?????
|
|
514
|
+
// ------------------------------
|
|
395
515
|
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
|
|
396
516
|
this.logger.log('[CONVS-LIST-PAGE] ************** subscribeUidConvSelectedChanged navigateByUrl', user, type);
|
|
397
517
|
this.uidConvSelected = user.uid;
|
|
@@ -482,6 +602,7 @@ export class ConversationListPage implements OnInit {
|
|
|
482
602
|
this.initConversationsHandler();
|
|
483
603
|
this.initVariables();
|
|
484
604
|
this.initSubscriptions();
|
|
605
|
+
|
|
485
606
|
// this.initHandlerEventEmitter();
|
|
486
607
|
}
|
|
487
608
|
|
|
@@ -526,6 +647,7 @@ export class ConversationListPage implements OnInit {
|
|
|
526
647
|
setUidConvSelected(uidConvSelected: string, conversationType?: string,) {
|
|
527
648
|
this.logger.log('[CONVS-LIST-PAGE] setuidCOnvSelected', uidConvSelected)
|
|
528
649
|
this.uidConvSelected = uidConvSelected;
|
|
650
|
+
this.logger.log('uidConvSelected', uidConvSelected)
|
|
529
651
|
// this.conversationsHandlerService.uidConvSelected = uidConvSelected;
|
|
530
652
|
if (uidConvSelected) {
|
|
531
653
|
let conversationSelected;
|
|
@@ -536,7 +658,7 @@ export class ConversationListPage implements OnInit {
|
|
|
536
658
|
}
|
|
537
659
|
if (conversationSelected) {
|
|
538
660
|
this.logger.log('[CONVS-LIST-PAGE] conversationSelected', conversationSelected);
|
|
539
|
-
this.logger.log('[CONVS-LIST-PAGE]
|
|
661
|
+
this.logger.log('[CONVS-LIST-PAGE] the conversation ', this.conversationSelected, ' has already been loaded');
|
|
540
662
|
this.conversationSelected = conversationSelected;
|
|
541
663
|
this.logger.log('[CONVS-LIST-PAGE] setUidConvSelected: ', this.conversationSelected);
|
|
542
664
|
}
|
|
@@ -544,7 +666,7 @@ export class ConversationListPage implements OnInit {
|
|
|
544
666
|
}
|
|
545
667
|
|
|
546
668
|
onConversationSelected(conversation: ConversationModel) {
|
|
547
|
-
|
|
669
|
+
this.logger.log('onConversationSelected conversation', conversation)
|
|
548
670
|
if (conversation.archived) {
|
|
549
671
|
this.navigateByUrl('archived', conversation.uid)
|
|
550
672
|
this.logger.log('[CONVS-LIST-PAGE] onConversationSelected archived conversation.uid ', conversation.uid)
|
|
@@ -641,6 +763,7 @@ export class ConversationListPage implements OnInit {
|
|
|
641
763
|
|
|
642
764
|
|
|
643
765
|
navigateByUrl(converationType: string, uidConvSelected: string) {
|
|
766
|
+
this.logger.log('[CONVS-LIST-PAGE] calling navigateByUrl: ');
|
|
644
767
|
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl uidConvSelected: ', uidConvSelected);
|
|
645
768
|
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl run this.setUidConvSelected');
|
|
646
769
|
this.logger.log('[CONVS-LIST-PAGE] navigateByUrl this.uidConvSelected ', this.uidConvSelected);
|
|
@@ -648,12 +771,14 @@ export class ConversationListPage implements OnInit {
|
|
|
648
771
|
|
|
649
772
|
this.setUidConvSelected(uidConvSelected, converationType);
|
|
650
773
|
if (checkPlatformIsMobile()) {
|
|
651
|
-
this.logger.log('[CONVS-LIST-PAGE]
|
|
774
|
+
this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
|
|
775
|
+
this.logger.log('[CONVS-LIST-PAGE] DESKTOP (window >= 768)', this.navService);
|
|
652
776
|
let pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
|
|
653
777
|
this.logger.log('[CONVS-LIST-PAGE] pageURL', pageUrl)
|
|
654
778
|
this.router.navigateByUrl(pageUrl);
|
|
655
779
|
} else {
|
|
656
|
-
this.logger.log('[CONVS-LIST-PAGE]
|
|
780
|
+
this.logger.log('[CONVS-LIST-PAGE] checkPlatformIsMobile(): ', checkPlatformIsMobile());
|
|
781
|
+
this.logger.log('[CONVS-LIST-PAGE] MOBILE (window < 768) ', this.navService);
|
|
657
782
|
let pageUrl = 'conversation-detail/' + this.uidConvSelected;
|
|
658
783
|
if (this.conversationSelected && this.conversationSelected.conversation_with_fullname) {
|
|
659
784
|
pageUrl = 'conversation-detail/' + this.uidConvSelected + '/' + this.conversationSelected.conversation_with_fullname + '/' + converationType;
|
|
@@ -36,6 +36,14 @@ export class UnassignedConversationsPage implements OnInit {
|
|
|
36
36
|
this.translationMap = this.translateService.translateLanguage(keys);
|
|
37
37
|
this.buildIFRAME();
|
|
38
38
|
this.listenToPostMsg();
|
|
39
|
+
this.hideHotjarFeedbackBtn();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
hideHotjarFeedbackBtn() {
|
|
43
|
+
const hotjarFeedbackBtn = <HTMLElement>document.querySelector("#_hj_feedback_container > div > button")
|
|
44
|
+
if (hotjarFeedbackBtn) {
|
|
45
|
+
hotjarFeedbackBtn.style.display = "none";
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
buildIFRAME() {
|
|
@@ -55,7 +63,7 @@ export class UnassignedConversationsPage implements OnInit {
|
|
|
55
63
|
this.iframe.style.background = "white";
|
|
56
64
|
this.ion_content.appendChild(this.iframe);
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
// this.getIframeHaLoaded()
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
getIframeHaLoaded() {
|
|
@@ -66,7 +74,7 @@ export class UnassignedConversationsPage implements OnInit {
|
|
|
66
74
|
iframe.addEventListener("load", function () {
|
|
67
75
|
self.logger.log("[APP-STORE-INSTALL] GET - Finish");
|
|
68
76
|
let spinnerElem = <HTMLElement>document.querySelector('.stretchspinner-unassigned-convs')
|
|
69
|
-
|
|
77
|
+
|
|
70
78
|
self.logger.log('[APP-STORE-INSTALL] GET iframeDoc readyState spinnerElem', spinnerElem)
|
|
71
79
|
spinnerElem.classList.add("hide-stretchspinner")
|
|
72
80
|
|
|
@@ -18,18 +18,90 @@ export class AppConfigProvider {
|
|
|
18
18
|
|
|
19
19
|
/** */
|
|
20
20
|
loadAppConfig() {
|
|
21
|
-
const that = this;
|
|
22
|
-
return this.http.get(this.appConfig.remoteConfigUrl).toPromise().then(data => {
|
|
23
|
-
|
|
21
|
+
// const that = this;
|
|
22
|
+
// return this.http.get(this.appConfig.remoteConfigUrl).toPromise().then(data => {
|
|
23
|
+
// that.appConfig = data;
|
|
24
|
+
// }).catch(err => {
|
|
25
|
+
// console.log('error loadAppConfig' + err);
|
|
26
|
+
// });
|
|
27
|
+
|
|
28
|
+
// ---- new
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
return this.http.get(this.appConfig.remoteConfigUrl)
|
|
32
|
+
.toPromise().then((data: any ) => {
|
|
33
|
+
// console.log('AppConfigService loadAppConfig data: ', data);
|
|
34
|
+
|
|
35
|
+
const allconfig = data
|
|
36
|
+
// console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig: ', allconfig);
|
|
37
|
+
|
|
38
|
+
if (allconfig.hasOwnProperty('wsUrlRel')) {
|
|
39
|
+
|
|
40
|
+
// console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig !!!! exist wsUrlRel ->: ', allconfig.wsUrlRel);
|
|
41
|
+
var wsUrlRelIsEmpty = this.isEmpty(allconfig.wsUrlRel)
|
|
42
|
+
// console.log('[APP-CONFIG-SERVICE] - loadAppConfig allconfig !!!! exist wsUrlRel -> wsUrlRelIsEmpty ?', wsUrlRelIsEmpty);
|
|
43
|
+
|
|
44
|
+
if (wsUrlRelIsEmpty === false) {
|
|
45
|
+
// console.log('[APP-CONFIG-SERVICE]- loadAppConfig allconfig !!!! exist - SERVER_BASE_URL', data.apiUrl);
|
|
46
|
+
|
|
47
|
+
// if (allconfig.apiUrl.indexOf("http://") !== -1) {
|
|
48
|
+
|
|
49
|
+
// const ws_url = allconfig.apiUrl.replace("http://", "ws://").slice(0, -1) + allconfig.wsUrlRel;
|
|
50
|
+
// // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL protocol is HTTP - wsUrl', ws_url);
|
|
51
|
+
|
|
52
|
+
// allconfig.wsUrl = ws_url
|
|
53
|
+
|
|
54
|
+
// } else if (allconfig.apiUrl.indexOf("https://") !== -1) {
|
|
55
|
+
|
|
56
|
+
// const ws_url = allconfig.apiUrl.replace("https://", "wss://").slice(0, -1) + allconfig.wsUrlRel;
|
|
57
|
+
|
|
58
|
+
// allconfig.wsUrl = ws_url
|
|
59
|
+
|
|
60
|
+
// // console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL protocol is HTTPS - wsUrl', ws_url);
|
|
61
|
+
// } else {
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// console.log('AppConfigService loadAppConfig allconfig !!!! exist - SERVER_BASE_URL !!! IS RELATIVE - window.location ', window.location);
|
|
65
|
+
|
|
66
|
+
// console.log(window.location)
|
|
67
|
+
|
|
68
|
+
if (window.location.protocol === 'http:') {
|
|
69
|
+
allconfig.wsUrl = 'ws://' + window.location.hostname + allconfig.wsUrlRel
|
|
70
|
+
|
|
71
|
+
} else if (window.location.protocol === 'https:') {
|
|
72
|
+
|
|
73
|
+
allconfig.wsUrl = 'wss://' + window.location.hostname + allconfig.wsUrlRel
|
|
74
|
+
} else {
|
|
75
|
+
|
|
76
|
+
allconfig.wsUrl = 'ws://' + window.location.hostname + allconfig.wsUrlRel
|
|
77
|
+
}
|
|
78
|
+
// }
|
|
79
|
+
|
|
80
|
+
} else {
|
|
81
|
+
// console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! exist wsUrlRel but IS EMPTY');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
} else {
|
|
85
|
+
|
|
86
|
+
// console.log('[APP-CONFIG-SERVICE] loadAppConfig allconfig !!!! does not exist wsUrlRel');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.appConfig = allconfig;
|
|
90
|
+
|
|
91
|
+
|
|
24
92
|
}).catch(err => {
|
|
25
|
-
|
|
93
|
+
console.error('error loadAppConfig' + err);
|
|
26
94
|
});
|
|
27
95
|
}
|
|
28
96
|
|
|
97
|
+
isEmpty(wsUrlRel: string) {
|
|
98
|
+
return (wsUrlRel === undefined || wsUrlRel == null || wsUrlRel.length <= 0) ? true : false;
|
|
99
|
+
}
|
|
100
|
+
|
|
29
101
|
/** */
|
|
30
102
|
getConfig() {
|
|
31
103
|
return this.appConfig;
|
|
32
104
|
}
|
|
33
|
-
|
|
105
|
+
|
|
34
106
|
|
|
35
107
|
}
|
|
@@ -78,10 +78,8 @@ export class WebSocketJs {
|
|
|
78
78
|
this.callbacks.set(topic, { onCreate: onCreate, onUpdate: onUpdate, onData: onData });
|
|
79
79
|
this.logger.log('[WEBSOCKET-JS] - CALLBACK-SET - callbacks', this.callbacks);
|
|
80
80
|
|
|
81
|
-
this.logger.log('[WEBSOCKET-JS] - REF - READY STATE ', this.ws.readyState);
|
|
82
|
-
|
|
83
81
|
if (this.ws && this.ws.readyState == 1) {
|
|
84
|
-
|
|
82
|
+
this.logger.log('[WEBSOCKET-JS] - REF - READY STATE ', this.ws.readyState);
|
|
85
83
|
this.logger.log('[WEBSOCKET-JS] - REF - READY STATE = 1 > SUBSCRIBE TO TOPICS ');
|
|
86
84
|
|
|
87
85
|
this.subscribe(topic);
|
|
@@ -172,11 +170,11 @@ export class WebSocketJs {
|
|
|
172
170
|
var str = JSON.stringify(message);
|
|
173
171
|
this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE str " + str);
|
|
174
172
|
|
|
175
|
-
if (this.ws.readyState == 1) {
|
|
173
|
+
if (this.ws && this.ws.readyState == 1) {
|
|
176
174
|
this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TO TOPIC - STRING TO SEND " + str, " FOR UNSUBSCRIBE TO TOPIC: ", topic);
|
|
177
175
|
this.send(str, `UNSUSCRIBE from ${topic}`);
|
|
178
176
|
|
|
179
|
-
} else {
|
|
177
|
+
} else if (this.ws) {
|
|
180
178
|
this.logger.log("[WEBSOCKET-JS] - UN-SUBSCRIBE TRY 'SEND' BUT READY STASTE IS : ", this.ws.readyState);
|
|
181
179
|
}
|
|
182
180
|
}
|
|
@@ -196,7 +194,7 @@ export class WebSocketJs {
|
|
|
196
194
|
// -----------------------------------------------------------------------------------------------------
|
|
197
195
|
close() {
|
|
198
196
|
this.topics = [];
|
|
199
|
-
this.callbacks = [];
|
|
197
|
+
this.callbacks = [];
|
|
200
198
|
this.logger.log("[WEBSOCKET-JS] - CALLED CLOSE - TOPICS ", this.topics, ' - CALLLBACKS ', this.callbacks);
|
|
201
199
|
|
|
202
200
|
if (this.ws) {
|
|
@@ -277,13 +275,13 @@ export class WebSocketJs {
|
|
|
277
275
|
|
|
278
276
|
// Qui viene inviato un battito cardiaco Dopo averlo ricevuto, viene restituito un messaggio di battito cardiaco.
|
|
279
277
|
// onmessage Ottieni il battito cardiaco restituito per indicare che la connessione è normale
|
|
280
|
-
if (this.ws.readyState == 1) {
|
|
278
|
+
if (this.ws && this.ws.readyState == 1) {
|
|
281
279
|
|
|
282
280
|
// this.logger.log("[WEBSOCKET-JS] - HEART-START - SEND PING-MSG");
|
|
283
281
|
|
|
284
282
|
this.send(JSON.stringify(this.pingMsg), 'HEART-START')
|
|
285
283
|
|
|
286
|
-
} else {
|
|
284
|
+
} else if (this.ws) {
|
|
287
285
|
|
|
288
286
|
this.logger.log("[WEBSOCKET-JS] - HEART-START - TRY TO SEND PING-MSG BUT READY STATE IS ", this.ws.readyState);
|
|
289
287
|
|
|
@@ -442,7 +440,7 @@ export class WebSocketJs {
|
|
|
442
440
|
// @ send PONG
|
|
443
441
|
// -------------------
|
|
444
442
|
// that.logger.log('[WEBSOCKET-JS] - RECEIVED PING -> SEND PONG MSG');
|
|
445
|
-
|
|
443
|
+
|
|
446
444
|
that.send(JSON.stringify(that.pongMsg), 'ON-MESSAGE')
|
|
447
445
|
|
|
448
446
|
} else {
|
|
@@ -465,15 +463,15 @@ export class WebSocketJs {
|
|
|
465
463
|
if (json && json.payload && json.payload.message && that.isArray(json.payload.message)) {
|
|
466
464
|
|
|
467
465
|
json.payload.message.forEach(element => {
|
|
468
|
-
|
|
466
|
+
|
|
469
467
|
//let insUp = that.insertOrUpdate(element);
|
|
470
468
|
let insUp = json.payload.method;
|
|
471
|
-
|
|
469
|
+
|
|
472
470
|
var object = { event: json.payload, data: element };
|
|
473
471
|
|
|
474
472
|
var callbackObj = that.callbacks.get(object.event.topic);
|
|
475
473
|
|
|
476
|
-
|
|
474
|
+
|
|
477
475
|
if (insUp == "CREATE") {
|
|
478
476
|
if (that.onCreate) {
|
|
479
477
|
that.onCreate(element, object);
|
|
@@ -499,10 +497,10 @@ export class WebSocketJs {
|
|
|
499
497
|
} else {
|
|
500
498
|
//let insUp = that.insertOrUpdate(json.payload.message);
|
|
501
499
|
let insUp = json.payload.method;
|
|
502
|
-
|
|
500
|
+
|
|
503
501
|
var object = { event: json.payload, data: json };
|
|
504
502
|
var callbackObj = that.callbacks.get(object.event.topic);
|
|
505
|
-
|
|
503
|
+
|
|
506
504
|
|
|
507
505
|
if (insUp == "CREATE") {
|
|
508
506
|
if (that.onCreate) {
|
|
@@ -84,14 +84,14 @@ export class WebsocketService {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
subscriptionToWsConversations(project_id) {
|
|
87
|
-
|
|
87
|
+
// console.log("[WS-SERV] - CALLED SUBSC TO WS CONVS - PROJECT ID ", project_id);
|
|
88
88
|
var self = this;
|
|
89
89
|
this.wsRequestsList = [];
|
|
90
90
|
|
|
91
91
|
this.webSocketJs.ref('/' + project_id + '/requests', 'getCurrentProjectAndSubscribeTo_WsRequests',
|
|
92
92
|
|
|
93
93
|
function (data, notification) {
|
|
94
|
-
//
|
|
94
|
+
// console.log("[WS-SERV] - CONVS - CREATE DATA ", data);
|
|
95
95
|
if (data) {
|
|
96
96
|
// ------------------------------------------------
|
|
97
97
|
// @ Agents - pass in data agents get from snapshot
|
|
@@ -167,14 +167,21 @@ export class WebsocketService {
|
|
|
167
167
|
|
|
168
168
|
if (index === -1) {
|
|
169
169
|
self.addWsRequests(data)
|
|
170
|
-
//
|
|
170
|
+
// console.log("[WS-REQUESTS-SERV] - CREATE - ADD REQUESTS");
|
|
171
171
|
} else {
|
|
172
|
-
//
|
|
172
|
+
// console.log("[WS-REQUESTS-SERV] - CREATE - REQUEST ALREADY EXIST - NOT ADD AND NOT PUBLISH");
|
|
173
|
+
// if (data !== null && data !== undefined) {
|
|
174
|
+
// self.wsRequestsList.push(data);
|
|
175
|
+
// }
|
|
176
|
+
// if (self.wsRequestsList) {
|
|
177
|
+
// self.wsRequestsList$.next(self.wsRequestsList);
|
|
178
|
+
// console.log("[WS-SERV] - NOT ADD - BUT PUBLIC ANYWAY ", self.wsRequestsList);
|
|
179
|
+
// }
|
|
173
180
|
}
|
|
174
181
|
|
|
175
182
|
}, function (data, notification) {
|
|
176
183
|
|
|
177
|
-
//
|
|
184
|
+
// console.log("[WS-SERV] - CONVS - UPDATE DATA ", data);
|
|
178
185
|
|
|
179
186
|
// -------------------------------------------------------
|
|
180
187
|
// @ Agents (UPDATE) pass in data agents get from snapshot
|
|
@@ -191,8 +198,18 @@ export class WebsocketService {
|
|
|
191
198
|
|
|
192
199
|
|
|
193
200
|
}, function (data, notification) {
|
|
194
|
-
|
|
195
|
-
|
|
201
|
+
self.logger.log("[WS-SERV] CHAT - CONVS - ON-DATA - DATA ", data);
|
|
202
|
+
self.logger.log("[WS-SERV] CHAT - CONVS - ON-DATA - notification ", notification);
|
|
203
|
+
|
|
204
|
+
// console.log("[WS-SERV] CHAT - CONVS - ON-DATA - DATA notification > event > method ", notification.event.method);
|
|
205
|
+
if (notification.event.method === 'CREATE') {
|
|
206
|
+
self.wsRequestsList = [];
|
|
207
|
+
self.wsRequestsList.push(data)
|
|
208
|
+
self.logger.log("[WS-SERV] CHAT - CONVS - ON-DATA - DATA wsRequestsList ", self.wsRequestsList);
|
|
209
|
+
if (self.wsRequestsList) {
|
|
210
|
+
self.wsRequestsList$.next(self.wsRequestsList);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
196
213
|
}
|
|
197
214
|
);
|
|
198
215
|
}
|
|
@@ -211,7 +228,8 @@ export class WebsocketService {
|
|
|
211
228
|
// -----------------------------------------------------------------------------------------------------
|
|
212
229
|
// publish all REQUESTS
|
|
213
230
|
// -----------------------------------------------------------------------------------------------------
|
|
214
|
-
|
|
231
|
+
this.wsRequestsList$.next(this.wsRequestsList);
|
|
232
|
+
// this.logger.log("[WS-SERV] - ADD REQUESTS CONVS LIST ", this.wsRequestsList);
|
|
215
233
|
}
|
|
216
234
|
}
|
|
217
235
|
|