@chat21/chat21-ionic 3.0.59-rc1 → 3.0.59-rc16
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 +67 -0
- package/README.md +9 -0
- package/config.xml +2 -2
- package/env.sample +3 -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-routing.module.ts +21 -17
- package/src/app/app.component.html +6 -3
- package/src/app/app.component.ts +328 -59
- package/src/app/app.module.ts +16 -8
- package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +4 -4
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +8 -2
- package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +6 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +1 -1
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +1 -1
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +7 -6
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +20 -1
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +39 -9
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +8 -144
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
- package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
- package/src/app/components/authentication/login/login.component.html +10 -10
- package/src/app/components/authentication/login/login.component.ts +2 -1
- package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +1 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +3 -2
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +3 -3
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -5
- package/src/app/components/ddp-header/ddp-header.component.html +1 -1
- package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
- package/src/app/components/image-viewer/image-viewer.component.html +23 -0
- package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
- package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
- package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
- package/src/app/components/project-item/project-item.component.html +147 -0
- package/src/app/components/project-item/project-item.component.scss +669 -0
- package/src/app/components/project-item/project-item.component.spec.ts +24 -0
- package/src/app/components/project-item/project-item.component.ts +317 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.html +9 -3
- package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +6 -4
- package/src/app/pages/authentication/login/login.page.html +1 -2
- package/src/app/pages/authentication/login/login.page.ts +1 -1
- package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +122 -30
- package/src/app/pages/conversations-list/conversations-list.page.html +44 -23
- package/src/app/pages/conversations-list/conversations-list.page.scss +290 -127
- package/src/app/pages/conversations-list/conversations-list.page.ts +205 -23
- package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +108 -0
- package/src/app/services/app-config.ts +75 -5
- package/src/app/services/nav-proxy.service.ts +1 -1
- package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
- package/src/app/services/websocket/websocket-js.ts +557 -0
- package/src/app/services/websocket/websocket.service.spec.ts +12 -0
- package/src/app/services/websocket/websocket.service.ts +274 -0
- package/src/app/shared/shared.module.ts +7 -1
- package/src/assets/i18n/en.json +9 -1
- package/src/assets/i18n/it.json +9 -1
- package/src/assets/js/chat21client.js +141 -67
- package/src/assets/logo.png +0 -0
- package/src/assets/transparent.png +0 -0
- package/src/chat-config-pre-test.json +3 -1
- package/src/chat-config-template.json +4 -1
- package/src/chat-config.json +4 -1
- package/src/chat21-core/providers/chat-manager.ts +3 -3
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +3 -3
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +2 -2
- package/src/chat21-core/providers/firebase/firebase-typing.service.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +1 -1
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
- 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 +13 -4
- package/src/chat21-core/utils/utils.ts +1 -1
- package/src/firebase-messaging-sw-template.js +1 -1
- package/src/assets/images/tiledesk_logo_50x50.png +0 -0
package/src/app/app.component.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { URL_SOUND_LIST_CONVERSATION } from './../chat21-core/utils/constants';
|
|
|
2
2
|
import { ArchivedConversationsHandlerService } from 'src/chat21-core/providers/abstract/archivedconversations-handler.service';
|
|
3
3
|
import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
|
|
4
4
|
|
|
5
|
-
import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, } from '@angular/core';
|
|
5
|
+
import { Component, ViewChild, NgZone, OnInit, HostListener, ElementRef, Renderer2, AfterViewInit, } from '@angular/core';
|
|
6
6
|
import { Config, Platform, IonRouterOutlet, IonSplitPane, NavController, MenuController, AlertController, IonNav, ToastController } from '@ionic/angular';
|
|
7
7
|
import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
|
|
8
8
|
import { Subscription, VirtualTimeScheduler } from 'rxjs';
|
|
@@ -55,10 +55,9 @@ import { getImageUrlThumbFromFirebasestorage } from 'src/chat21-core/utils/utils
|
|
|
55
55
|
import { TiledeskService } from './services/tiledesk/tiledesk.service';
|
|
56
56
|
import { NetworkService } from './services/network-service/network.service';
|
|
57
57
|
import * as PACKAGE from 'package.json';
|
|
58
|
-
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
|
|
58
|
+
import { filter } from 'rxjs/operators'
|
|
59
|
+
import { WebSocketJs } from './services/websocket/websocket-js';
|
|
60
|
+
import { Location } from '@angular/common'
|
|
62
61
|
// import { filter } from 'rxjs/operators';
|
|
63
62
|
|
|
64
63
|
@Component({
|
|
@@ -99,15 +98,17 @@ export class AppComponent implements OnInit {
|
|
|
99
98
|
public missingConnectionToast: any
|
|
100
99
|
public executedInitializeAppByWatchConnection: boolean = false;
|
|
101
100
|
private version: string;
|
|
102
|
-
|
|
101
|
+
|
|
103
102
|
// private isOnline: boolean = false;
|
|
104
103
|
|
|
104
|
+
wsService: WebSocketJs;
|
|
105
|
+
|
|
105
106
|
constructor(
|
|
106
107
|
private platform: Platform,
|
|
107
108
|
private splashScreen: SplashScreen,
|
|
108
109
|
private statusBar: StatusBar,
|
|
109
110
|
private appConfigProvider: AppConfigProvider,
|
|
110
|
-
|
|
111
|
+
public events: EventsService,
|
|
111
112
|
public config: Config,
|
|
112
113
|
public chatManager: ChatManager,
|
|
113
114
|
public translate: TranslateService,
|
|
@@ -136,39 +137,168 @@ export class AppComponent implements OnInit {
|
|
|
136
137
|
public toastController: ToastController,
|
|
137
138
|
// private network: Network,
|
|
138
139
|
// private tiledeskService: TiledeskService,
|
|
139
|
-
private networkService: NetworkService
|
|
140
|
+
private networkService: NetworkService,
|
|
141
|
+
public webSocketJs: WebSocketJs,
|
|
142
|
+
public location: Location
|
|
140
143
|
) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
144
|
+
|
|
145
|
+
this.saveInStorageNumberOfOpenedChatTab();
|
|
146
|
+
this.getPageState();
|
|
147
|
+
|
|
148
|
+
// location.subscribe((val) => {
|
|
149
|
+
|
|
150
|
+
// console.log('location subscribe val', val)
|
|
151
|
+
// if (val.type == "hashchange") {
|
|
152
|
+
// const convId = getParameterByName('convId')
|
|
153
|
+
// console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
|
|
154
|
+
// const requesterFullaname = getParameterByName('requester_fullaname')
|
|
155
|
+
// console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', requesterFullaname);
|
|
156
|
+
|
|
157
|
+
// this.navigateToDetail(convId, requesterFullaname)
|
|
158
|
+
|
|
159
|
+
// this.events.publish('convid:haschanged', convId);
|
|
160
|
+
// }
|
|
147
161
|
// });
|
|
162
|
+
|
|
163
|
+
window.addEventListener('hashchange', function () {
|
|
164
|
+
console.log('location changed!');
|
|
165
|
+
const convId = getParameterByName('convId')
|
|
166
|
+
console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
|
|
167
|
+
|
|
168
|
+
if (convId) {
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
events.publish('convid:haschanged', convId);
|
|
171
|
+
}, 0);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
// this.navigateToDetail(convId, requesterFullaname)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
// router.events.subscribe((val) => {
|
|
183
|
+
// this.checkCurrentURL();
|
|
184
|
+
// });
|
|
185
|
+
// FOR TEST
|
|
186
|
+
// const last_project = { "user_available": true, "number_assigned_requests": 59, "last_login_at": "2021-08-09T17:30:55.234Z", "status": "active", "_id": "6112bc8f58c958003495a2cb", "id_project": { "status": 100, "_id": "60ffe291f725db00347661ef", "name": "27-LUGLIO-21-STRIPE-TEST", "activeOperatingHours": false, "createdBy": "608ad02d3a4dc000344ade17", "profile": { "name": "pro", "trialDays": 30, "agents": 5, "type": "payment", "subStart": "2021-11-18T10:42:41.000Z", "subEnd": "2021-11-19T10:42:41.000Z", "subscriptionId": "sub_Jvf4kABe9t8JvX", "last_stripe_event": "invoice.payment_succeeded" }, "versions": 20115, "channels": [{ "name": "chat21" }], "createdAt": "2021-07-27T10:40:17.752Z", "updatedAt": "2021-11-18T11:55:01.346Z", "__v": 0, "widget": { "preChatForm": true, "preChatFormJson": [{ "name": "userFullname", "type": "text", "mandatory": true, "label": { "en": "Your name", "it": "Il tuo nome" } }, { "name": "userEmail", "type": "text", "mandatory": true, "regex": "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/", "label": { "en": "Your email", "it": "La tua email" }, "errorLabel": { "en": "Invalid email address", "it": "Indirizzo email non valido" } }, { "name": "tel", "mandatory": true, "label": { "en": "Your phone number", "it": "Il tuo numero di telefono" } }], "preChatFormCustomFieldsEnabled": true }, "trialExpired": true, "trialDaysLeft": 84, "isActiveSubscription": true, "id": "60ffe291f725db00347661ef" }, "id_user": "60aa0fef1482fe00346854a7", "role": "admin", "createdBy": "608ad02d3a4dc000344ade17", "createdAt": "2021-08-10T17:51:11.318Z", "updatedAt": "2021-11-19T08:08:21.437Z", "__v": 0, "presence": { "status": "online", "changedAt": "2021-11-19T08:08:21.432Z" }, "isAuthenticated": true, "id": "6112bc8f58c958003495a2cb" }
|
|
187
|
+
// localStorage.setItem('last_project', JSON.stringify(last_project))
|
|
148
188
|
}
|
|
189
|
+
navigateToDetail(convId, requesterFullaname) {
|
|
190
|
+
console.log('[APP-COMP] navigateToDetail ');
|
|
191
|
+
let pageUrl = 'conversation-detail/' + convId + '/' + requesterFullaname + '/active';
|
|
192
|
+
this.router.navigateByUrl(pageUrl);
|
|
193
|
+
this.location.replaceState('conversation-detail/' + convId + '/' + requesterFullaname + '/active');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
// private checkCurrentURL() {
|
|
198
|
+
// console.log("location : " + window.location.pathname)
|
|
199
|
+
// const convId = getParameterByName('convId')
|
|
200
|
+
// console.log('[APP-COMP] ngOnInit convId get with getParameterByName ', convId)
|
|
201
|
+
// this.events.publish('convid:haschanged', convId);
|
|
202
|
+
// }
|
|
203
|
+
saveInStorageNumberOfOpenedChatTab() {
|
|
204
|
+
this.logger.log('Calling saveInStorageChatOpenedTab!');
|
|
205
|
+
|
|
206
|
+
// https://jsfiddle.net/jjjs5wd3/3/å
|
|
207
|
+
if (+localStorage.tabCount > 0) {
|
|
208
|
+
this.logger.log('Chat IONIC Already open!');
|
|
209
|
+
} else {
|
|
210
|
+
localStorage.tabCount = 0;
|
|
149
211
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
212
|
+
localStorage.tabCount = +localStorage.tabCount + 1;
|
|
213
|
+
}
|
|
214
|
+
const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
|
|
215
|
+
window.addEventListener(terminationEvent, (event) => {
|
|
216
|
+
localStorage.tabCount = +localStorage.tabCount - 1;
|
|
217
|
+
}, { capture: true });
|
|
155
218
|
}
|
|
219
|
+
|
|
220
|
+
getPageState() {
|
|
221
|
+
|
|
222
|
+
const getState = () => {
|
|
223
|
+
localStorage.setItem('visibilityState', document.visibilityState)
|
|
224
|
+
if (document.visibilityState === 'hidden') {
|
|
225
|
+
return 'hidden';
|
|
226
|
+
}
|
|
227
|
+
if (document.hasFocus()) {
|
|
228
|
+
return 'active';
|
|
229
|
+
}
|
|
230
|
+
return 'passive';
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
let state = getState();
|
|
234
|
+
// console.log('[CONVS-LIST-PAGE] page state ', state)
|
|
235
|
+
// if (state === 'hidden') {
|
|
236
|
+
// console.log(`State change: state ${state}`);
|
|
237
|
+
// localStorage.setItem('hidden', 'true')
|
|
238
|
+
// }
|
|
239
|
+
|
|
240
|
+
const logStateChange = (nextState) => {
|
|
241
|
+
|
|
242
|
+
const prevState = state;
|
|
243
|
+
if (nextState !== prevState) {
|
|
244
|
+
console.log(`State change: ${prevState} >>> ${nextState}`);
|
|
245
|
+
state = nextState;
|
|
246
|
+
localStorage.setItem('state', nextState)
|
|
247
|
+
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
|
|
252
|
+
window.addEventListener(type, () => logStateChange(getState()), { capture: true });
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// The next two listeners, on the other hand, can determine the next
|
|
256
|
+
// state from the event itself.
|
|
257
|
+
window.addEventListener('freeze', () => {
|
|
258
|
+
// In the freeze event, the next state is always frozen.
|
|
259
|
+
logStateChange('frozen');
|
|
260
|
+
}, { capture: true });
|
|
261
|
+
|
|
262
|
+
window.addEventListener('pagehide', (event) => {
|
|
263
|
+
if (event.persisted) {
|
|
264
|
+
// If the event's persisted property is `true` the page is about
|
|
265
|
+
// to enter the Back-Forward Cache, which is also in the frozen state.
|
|
266
|
+
logStateChange('frozen');
|
|
267
|
+
localStorage.setItem('state', 'frozen')
|
|
268
|
+
} else {
|
|
269
|
+
// If the event's persisted property is not `true` the page is
|
|
270
|
+
// about to be unloaded.
|
|
271
|
+
logStateChange('terminated');
|
|
272
|
+
localStorage.setItem('state', 'terminated')
|
|
273
|
+
localStorage.setItem('terminated', 'true')
|
|
274
|
+
}
|
|
275
|
+
}, { capture: true });
|
|
276
|
+
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
// param() {
|
|
281
|
+
// // PARAM
|
|
282
|
+
// const url: URL = new URL(window.top.location.href);
|
|
283
|
+
// const params: URLSearchParams = url.searchParams;
|
|
284
|
+
// return params;
|
|
285
|
+
// }
|
|
156
286
|
/**
|
|
157
287
|
*/
|
|
158
288
|
ngOnInit() {
|
|
159
289
|
const appconfig = this.appConfigProvider.getConfig();
|
|
160
290
|
this.persistence = appconfig.authPersistence;
|
|
161
291
|
this.appStorageService.initialize(environment.storage_prefix, this.persistence, '')
|
|
162
|
-
this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
163
|
-
this.logger.
|
|
292
|
+
// this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
293
|
+
// this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
|
|
164
294
|
// this.initializeApp('oninit');
|
|
165
295
|
const token = getParameterByName('jwt')
|
|
166
|
-
this.logger.
|
|
296
|
+
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
|
|
167
297
|
|
|
168
298
|
if (token) {
|
|
169
299
|
// this.isOnline = false;
|
|
170
300
|
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with this.isOnline ', this.isOnline)
|
|
171
|
-
|
|
301
|
+
console.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName ', token)
|
|
172
302
|
// save token in local storage then
|
|
173
303
|
|
|
174
304
|
const storedToken = this.appStorageService.getItem('tiledeskToken');
|
|
@@ -180,11 +310,93 @@ export class AppComponent implements OnInit {
|
|
|
180
310
|
this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN the current user already exist DON\'T SAVE ')
|
|
181
311
|
}
|
|
182
312
|
}
|
|
313
|
+
|
|
314
|
+
|
|
183
315
|
this.initializeApp('oninit');
|
|
316
|
+
this.listenToPostMsgs();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ngAfterViewInit() {
|
|
320
|
+
// console.log('[APP-COMP] ngAfterViewInit')
|
|
321
|
+
// }
|
|
322
|
+
|
|
323
|
+
// ngDoCheck(){
|
|
324
|
+
// console.log('[APP-COMP] ngDoCheck')
|
|
325
|
+
// }
|
|
326
|
+
|
|
327
|
+
|
|
184
328
|
|
|
329
|
+
|
|
330
|
+
listenToPostMsgs() {
|
|
331
|
+
window.addEventListener("message", (event) => {
|
|
332
|
+
// console.log("[APP-COMP] message event ", event);
|
|
333
|
+
|
|
334
|
+
if (event && event.data && event.data.action && event.data.parameter) {
|
|
335
|
+
if (event.data.action === 'openJoinConversationModal') {
|
|
336
|
+
// console.log("[APP-COMP] message event action ", event.data.action);
|
|
337
|
+
// console.log("[APP-COMP] message event parameter ", event.data.parameter);
|
|
338
|
+
this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (event && event.data && event.data.action && event.data.text) {
|
|
342
|
+
if (event.data.action === "display_toast_join_complete") {
|
|
343
|
+
this.presentToastJoinComplete(event.data.text)
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
async presentToastJoinComplete(text) {
|
|
350
|
+
const toast = await this.toastController.create({
|
|
351
|
+
message: text,
|
|
352
|
+
duration: 2000,
|
|
353
|
+
color: "success"
|
|
354
|
+
});
|
|
355
|
+
toast.present();
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async presentAlertConfirmJoinRequest(requestid, calledby) {
|
|
359
|
+
var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
|
|
360
|
+
// console.log("[APP-COMP] message event iframeWin ", iframeWin);
|
|
361
|
+
|
|
362
|
+
const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
|
|
363
|
+
input !== null && input.tagName === 'IFRAME';
|
|
364
|
+
|
|
365
|
+
const keys = ['YouAreAboutToJoinThisChat', 'Cancel', 'AreYouSure'];
|
|
366
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
367
|
+
|
|
368
|
+
const alert = await this.alertController.create({
|
|
369
|
+
cssClass: 'my-custom-class',
|
|
370
|
+
header: translationMap.get('AreYouSure'),
|
|
371
|
+
message: translationMap.get('YouAreAboutToJoinThisChat'),
|
|
372
|
+
buttons: [
|
|
373
|
+
{
|
|
374
|
+
text: translationMap.get('Cancel'),
|
|
375
|
+
role: 'cancel',
|
|
376
|
+
cssClass: 'secondary',
|
|
377
|
+
handler: (blah) => {
|
|
378
|
+
// console.log('Confirm Cancel: blah', blah);
|
|
379
|
+
}
|
|
380
|
+
}, {
|
|
381
|
+
text: 'Ok',
|
|
382
|
+
handler: () => {
|
|
383
|
+
// console.log('Confirm Okay');
|
|
384
|
+
|
|
385
|
+
if (isIFrame(iframeWin) && iframeWin.contentWindow) {
|
|
386
|
+
const msg = { action: "joinConversation", parameter: requestid, calledBy: calledby }
|
|
387
|
+
iframeWin.contentWindow.postMessage(msg, '*');
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
await alert.present();
|
|
185
395
|
}
|
|
186
396
|
|
|
187
397
|
|
|
398
|
+
|
|
399
|
+
|
|
188
400
|
signInWithCustomToken(token) {
|
|
189
401
|
// this.isOnline = false;
|
|
190
402
|
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN token', token)
|
|
@@ -200,18 +412,18 @@ export class AppComponent implements OnInit {
|
|
|
200
412
|
|
|
201
413
|
/** */
|
|
202
414
|
initializeApp(calledby: string) {
|
|
203
|
-
this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
204
|
-
|
|
415
|
+
// this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
416
|
+
// console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
|
|
205
417
|
|
|
206
|
-
if (!this.platform.is('cordova')) {
|
|
207
|
-
|
|
208
|
-
}
|
|
418
|
+
// if (!this.platform.is('cordova')) {
|
|
419
|
+
this.splashScreen.show();
|
|
420
|
+
// }
|
|
209
421
|
this.tabTitle = document.title;
|
|
210
422
|
|
|
211
423
|
this.getRouteParamsAndSetLoggerConfig();
|
|
212
424
|
|
|
213
425
|
const appconfig = this.appConfigProvider.getConfig();
|
|
214
|
-
this.logger.info('[APP-COMP] appconfig: ', appconfig)
|
|
426
|
+
// this.logger.info('[APP-COMP] appconfig: ', appconfig)
|
|
215
427
|
this.version = PACKAGE.version;
|
|
216
428
|
this.logger.info('[APP-COMP] version: ', this.version)
|
|
217
429
|
|
|
@@ -223,12 +435,39 @@ export class AppComponent implements OnInit {
|
|
|
223
435
|
this.notificationsEnabled = true;
|
|
224
436
|
this.zone = new NgZone({}); // a cosa serve?
|
|
225
437
|
|
|
438
|
+
// ------------------------------------------
|
|
439
|
+
// Platform ready
|
|
440
|
+
// ------------------------------------------
|
|
226
441
|
this.platform.ready().then(() => {
|
|
227
|
-
|
|
442
|
+
// console.log("Check platform");
|
|
443
|
+
if (this.platform.is('cordova')) {
|
|
444
|
+
// console.log("the device running Cordova");
|
|
445
|
+
}
|
|
446
|
+
if (!this.platform.is('cordova')) {
|
|
447
|
+
// console.log("the device Not running Cordova");
|
|
448
|
+
}
|
|
228
449
|
|
|
229
|
-
if (this.
|
|
230
|
-
|
|
450
|
+
if (this.platform.is('android')) {
|
|
451
|
+
// console.log("running on Android device!");
|
|
231
452
|
}
|
|
453
|
+
if (this.platform.is('ios')) {
|
|
454
|
+
// console.log("running on iOS device!");
|
|
455
|
+
}
|
|
456
|
+
if (this.platform.is('mobileweb')) {
|
|
457
|
+
// console.log("running in a browser on mobile!");
|
|
458
|
+
}
|
|
459
|
+
if (this.platform.is('desktop')) {
|
|
460
|
+
// console.log("running on desktop!");
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
this.setLanguage();
|
|
467
|
+
|
|
468
|
+
// if (this.splashScreen) {
|
|
469
|
+
this.splashScreen.hide();
|
|
470
|
+
// }
|
|
232
471
|
this.statusBar.styleDefault();
|
|
233
472
|
this.navService.init(this.sidebarNav, this.detailNav);
|
|
234
473
|
// this.persistence = appconfig.authPersistence;
|
|
@@ -320,9 +559,9 @@ export class AppComponent implements OnInit {
|
|
|
320
559
|
getRouteParamsAndSetLoggerConfig() {
|
|
321
560
|
const appconfig = this.appConfigProvider.getConfig();
|
|
322
561
|
this.route.queryParams.subscribe(params => {
|
|
323
|
-
this.logger.
|
|
562
|
+
// this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
|
|
324
563
|
if (params.logLevel) {
|
|
325
|
-
this.logger.
|
|
564
|
+
this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
|
|
326
565
|
this.logger.setLoggerConfig(true, params.logLevel)
|
|
327
566
|
} else {
|
|
328
567
|
this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
|
|
@@ -352,6 +591,7 @@ export class AppComponent implements OnInit {
|
|
|
352
591
|
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
353
592
|
private initAuthentication() {
|
|
354
593
|
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
594
|
+
|
|
355
595
|
this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
|
|
356
596
|
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
357
597
|
// const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
@@ -360,19 +600,19 @@ export class AppComponent implements OnInit {
|
|
|
360
600
|
this.logger.log('[APP-COMP] >>> initAuthentication I LOG IN WITH A TOKEN EXISTING IN THE LOCAL STORAGE OR WITH A TOKEN PASSED IN THE URL PARAMETERS <<<')
|
|
361
601
|
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
362
602
|
this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
|
|
363
|
-
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
603
|
+
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
364
604
|
}).catch(error => {
|
|
365
605
|
this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::', error)
|
|
366
606
|
})
|
|
367
607
|
} else {
|
|
368
608
|
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
369
|
-
|
|
609
|
+
|
|
370
610
|
// clearTimeout(this.timeModalLogin);
|
|
371
611
|
// this.timeModalLogin = setTimeout(() => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
612
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
613
|
+
this.authModal = this.presentModal('initAuthentication');
|
|
614
|
+
this.hadBeenCalledOpenModal = true;
|
|
615
|
+
}
|
|
376
616
|
// }, 1000);
|
|
377
617
|
}
|
|
378
618
|
}
|
|
@@ -385,6 +625,18 @@ export class AppComponent implements OnInit {
|
|
|
385
625
|
// }
|
|
386
626
|
// }
|
|
387
627
|
|
|
628
|
+
connetWebsocket(tiledeskToken) {
|
|
629
|
+
const appconfig = this.appConfigProvider.getConfig();
|
|
630
|
+
this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
|
|
631
|
+
const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
|
|
632
|
+
this.webSocketJs.init(
|
|
633
|
+
WS_URL,
|
|
634
|
+
undefined,
|
|
635
|
+
undefined,
|
|
636
|
+
undefined
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
|
|
388
640
|
/**
|
|
389
641
|
* goOnLine:
|
|
390
642
|
* 1 - nascondo splashscreen
|
|
@@ -393,11 +645,14 @@ export class AppComponent implements OnInit {
|
|
|
393
645
|
* @param user
|
|
394
646
|
*/
|
|
395
647
|
goOnLine = () => {
|
|
648
|
+
// console.log('[APP-COMP] - GO-ONLINE ');
|
|
396
649
|
// this.isOnline = true;
|
|
397
650
|
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
|
|
398
651
|
|
|
399
|
-
clearTimeout(this.timeModalLogin);
|
|
652
|
+
// clearTimeout(this.timeModalLogin);
|
|
400
653
|
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
654
|
+
this.connetWebsocket(tiledeskToken)
|
|
655
|
+
this.events.publish('go:online', true);
|
|
401
656
|
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
402
657
|
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
403
658
|
this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
|
|
@@ -429,8 +684,17 @@ export class AppComponent implements OnInit {
|
|
|
429
684
|
this.chatManager.startApp();
|
|
430
685
|
}
|
|
431
686
|
|
|
687
|
+
|
|
688
|
+
webSocketClose() {
|
|
689
|
+
this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
|
|
690
|
+
this.webSocketJs.close()
|
|
691
|
+
this.events.publish('go:offline', true);
|
|
692
|
+
}
|
|
693
|
+
|
|
432
694
|
goOffLine = () => {
|
|
433
|
-
|
|
695
|
+
// console.log('[APP-COMP] - GO-OFFLINE');
|
|
696
|
+
|
|
697
|
+
this.webSocketClose()
|
|
434
698
|
// this.isOnline = false;
|
|
435
699
|
// this.conversationsHandlerService.conversations = [];
|
|
436
700
|
|
|
@@ -439,13 +703,13 @@ export class AppComponent implements OnInit {
|
|
|
439
703
|
this.chatManager.goOffLine();
|
|
440
704
|
|
|
441
705
|
this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
|
|
442
|
-
|
|
706
|
+
|
|
443
707
|
// clearTimeout(this.timeModalLogin);
|
|
444
708
|
// this.timeModalLogin = setTimeout(() => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
709
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
710
|
+
this.authModal = this.presentModal('goOffLine');
|
|
711
|
+
this.hadBeenCalledOpenModal = true
|
|
712
|
+
}
|
|
449
713
|
// }, 1000);
|
|
450
714
|
|
|
451
715
|
// this.unsubscribe$.next();
|
|
@@ -537,16 +801,23 @@ export class AppComponent implements OnInit {
|
|
|
537
801
|
}
|
|
538
802
|
|
|
539
803
|
private initAudio() {
|
|
804
|
+
// console.log('HERE IS initAudio ')
|
|
540
805
|
// SET AUDIO
|
|
806
|
+
const href = window.location.href;
|
|
807
|
+
const hrefArray = href.split('/#/');
|
|
808
|
+
const chatBaseUrl = hrefArray[0]
|
|
809
|
+
// console.log('initAudio href', href)
|
|
810
|
+
// console.log('initAudio chatBaseUrl', chatBaseUrl)
|
|
811
|
+
|
|
541
812
|
this.audio = new Audio();
|
|
542
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
813
|
+
this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
|
|
543
814
|
this.audio.load();
|
|
544
815
|
}
|
|
545
816
|
|
|
546
817
|
private manageTabNotification() {
|
|
547
818
|
if (!this.isTabVisible) {
|
|
548
819
|
// TAB IS HIDDEN --> manage title and SOUND
|
|
549
|
-
|
|
820
|
+
// console.log('HERE IS manageTabNotification ')
|
|
550
821
|
let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
|
|
551
822
|
badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
|
|
552
823
|
document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
|
|
@@ -565,6 +836,7 @@ export class AppComponent implements OnInit {
|
|
|
565
836
|
}
|
|
566
837
|
|
|
567
838
|
soundMessage() {
|
|
839
|
+
// console.log('HERE IS soundMessage ')
|
|
568
840
|
const that = this;
|
|
569
841
|
// this.audio = new Audio();
|
|
570
842
|
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
@@ -576,7 +848,7 @@ export class AppComponent implements OnInit {
|
|
|
576
848
|
that.audio.play().then(() => {
|
|
577
849
|
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
578
850
|
}).catch((error: any) => {
|
|
579
|
-
that.logger.
|
|
851
|
+
that.logger.error('[APP-COMP] ***soundMessage error*', error);
|
|
580
852
|
});
|
|
581
853
|
}, 1000);
|
|
582
854
|
}
|
|
@@ -601,8 +873,8 @@ export class AppComponent implements OnInit {
|
|
|
601
873
|
return;
|
|
602
874
|
}
|
|
603
875
|
|
|
604
|
-
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
605
|
-
|
|
876
|
+
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
877
|
+
|
|
606
878
|
// .pipe(takeUntil(this.unsubscribe$))
|
|
607
879
|
.pipe(filter((state) => state !== null))
|
|
608
880
|
.subscribe((state: any) => {
|
|
@@ -639,7 +911,7 @@ export class AppComponent implements OnInit {
|
|
|
639
911
|
|
|
640
912
|
this.conversationsHandlerService.conversationChanged.subscribe((conversation: ConversationModel) => {
|
|
641
913
|
|
|
642
|
-
|
|
914
|
+
console.log('[APP-COMP] ***** subscribeConversationChanged conversation: ', conversation);
|
|
643
915
|
const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
644
916
|
this.logger.log('[APP-COMP] ***** subscribeConversationChanged current_user: ', currentUser);
|
|
645
917
|
|
|
@@ -658,7 +930,7 @@ export class AppComponent implements OnInit {
|
|
|
658
930
|
* apro dettaglio conversazione
|
|
659
931
|
*/
|
|
660
932
|
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
|
|
661
|
-
|
|
933
|
+
console.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
|
|
662
934
|
// this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
|
|
663
935
|
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
|
|
664
936
|
}
|
|
@@ -848,7 +1120,7 @@ export class AppComponent implements OnInit {
|
|
|
848
1120
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
|
|
849
1121
|
@HostListener('window:storage', ['$event'])
|
|
850
1122
|
onStorageChanged(event: any) {
|
|
851
|
-
|
|
1123
|
+
|
|
852
1124
|
if (event.key !== 'chat_sv5__tiledeskToken') {
|
|
853
1125
|
return;
|
|
854
1126
|
}
|
|
@@ -877,7 +1149,7 @@ export class AppComponent implements OnInit {
|
|
|
877
1149
|
// this.unsubscribe$.complete();
|
|
878
1150
|
this.initializeApp('onstoragechanged');
|
|
879
1151
|
|
|
880
|
-
|
|
1152
|
+
|
|
881
1153
|
|
|
882
1154
|
// console.log('[APP-COMP] onAuthStateChanged HERE !!! ')
|
|
883
1155
|
// firebase.auth().onAuthStateChanged(user => {
|
|
@@ -887,7 +1159,4 @@ export class AppComponent implements OnInit {
|
|
|
887
1159
|
}
|
|
888
1160
|
}
|
|
889
1161
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
1162
|
}
|