@chat21/chat21-ionic 3.0.58 → 3.0.59-rc15
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 +69 -0
- package/README.md +9 -0
- package/config.xml +11 -2
- package/env.sample +2 -0
- 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 +259 -55
- 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 +7 -2
- package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +47 -2
- 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/bubble-others-message/bubble-others-message.component.ts +1 -1
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +17 -12
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +12 -0
- package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +21 -5
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -2
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +22 -17
- 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 +7 -0
- package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +22 -5
- 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 +172 -12
- 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/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/transparent.png +0 -0
- package/src/chat-config-pre-test.json +3 -1
- package/src/chat-config-template.json +3 -1
- package/src/chat-config.json +3 -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 +6 -6
- 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/app/app.component.ts
CHANGED
|
@@ -55,9 +55,8 @@ 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 { filter, takeUntil } from 'rxjs/operators'
|
|
58
|
+
import { filter } from 'rxjs/operators'
|
|
59
|
+
import { WebSocketJs } from './services/websocket/websocket-js';
|
|
61
60
|
|
|
62
61
|
// import { filter } from 'rxjs/operators';
|
|
63
62
|
|
|
@@ -99,9 +98,11 @@ 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,
|
|
@@ -136,34 +137,108 @@ 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,
|
|
140
142
|
) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// });
|
|
143
|
+
|
|
144
|
+
this.saveInStorageNumberOfOpenedChatTab();
|
|
145
|
+
this.getPageState();
|
|
146
|
+
// FOR TEST
|
|
147
|
+
// 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" }
|
|
148
|
+
// localStorage.setItem('last_project', JSON.stringify(last_project))
|
|
148
149
|
}
|
|
150
|
+
saveInStorageNumberOfOpenedChatTab() {
|
|
151
|
+
this.logger.log('Calling saveInStorageChatOpenedTab!');
|
|
152
|
+
|
|
153
|
+
// https://jsfiddle.net/jjjs5wd3/3/å
|
|
154
|
+
if (+localStorage.tabCount > 0) {
|
|
155
|
+
this.logger.log('Chat IONIC Already open!');
|
|
156
|
+
} else {
|
|
157
|
+
localStorage.tabCount = 0;
|
|
149
158
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
localStorage.tabCount = +localStorage.tabCount + 1;
|
|
160
|
+
}
|
|
161
|
+
const terminationEvent = 'onpagehide' in self ? 'pagehide' : 'unload';
|
|
162
|
+
window.addEventListener(terminationEvent, (event) => {
|
|
163
|
+
localStorage.tabCount = +localStorage.tabCount - 1;
|
|
164
|
+
}, { capture: true });
|
|
155
165
|
}
|
|
166
|
+
|
|
167
|
+
getPageState() {
|
|
168
|
+
const getState = () => {
|
|
169
|
+
localStorage.setItem('visibilityState', document.visibilityState)
|
|
170
|
+
if (document.visibilityState === 'hidden') {
|
|
171
|
+
return 'hidden';
|
|
172
|
+
}
|
|
173
|
+
if (document.hasFocus()) {
|
|
174
|
+
return 'active';
|
|
175
|
+
}
|
|
176
|
+
return 'passive';
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
let state = getState();
|
|
180
|
+
// console.log('[CONVS-LIST-PAGE] page state ', state)
|
|
181
|
+
// if (state === 'hidden') {
|
|
182
|
+
// console.log(`State change: state ${state}`);
|
|
183
|
+
// localStorage.setItem('hidden', 'true')
|
|
184
|
+
// }
|
|
185
|
+
|
|
186
|
+
const logStateChange = (nextState) => {
|
|
187
|
+
const prevState = state;
|
|
188
|
+
if (nextState !== prevState) {
|
|
189
|
+
console.log(`State change: ${prevState} >>> ${nextState}`);
|
|
190
|
+
state = nextState;
|
|
191
|
+
localStorage.setItem('state', nextState)
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
['pageshow', 'focus', 'blur', 'visibilitychange', 'resume'].forEach((type) => {
|
|
197
|
+
window.addEventListener(type, () => logStateChange(getState()), { capture: true });
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// The next two listeners, on the other hand, can determine the next
|
|
201
|
+
// state from the event itself.
|
|
202
|
+
window.addEventListener('freeze', () => {
|
|
203
|
+
// In the freeze event, the next state is always frozen.
|
|
204
|
+
logStateChange('frozen');
|
|
205
|
+
}, { capture: true });
|
|
206
|
+
|
|
207
|
+
window.addEventListener('pagehide', (event) => {
|
|
208
|
+
if (event.persisted) {
|
|
209
|
+
// If the event's persisted property is `true` the page is about
|
|
210
|
+
// to enter the Back-Forward Cache, which is also in the frozen state.
|
|
211
|
+
logStateChange('frozen');
|
|
212
|
+
localStorage.setItem('state', 'frozen')
|
|
213
|
+
} else {
|
|
214
|
+
// If the event's persisted property is not `true` the page is
|
|
215
|
+
// about to be unloaded.
|
|
216
|
+
logStateChange('terminated');
|
|
217
|
+
localStorage.setItem('state', 'terminated')
|
|
218
|
+
localStorage.setItem('terminated', 'true')
|
|
219
|
+
}
|
|
220
|
+
}, { capture: true });
|
|
221
|
+
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
// param() {
|
|
226
|
+
// // PARAM
|
|
227
|
+
// const url: URL = new URL(window.top.location.href);
|
|
228
|
+
// const params: URLSearchParams = url.searchParams;
|
|
229
|
+
// return params;
|
|
230
|
+
// }
|
|
156
231
|
/**
|
|
157
232
|
*/
|
|
158
233
|
ngOnInit() {
|
|
159
234
|
const appconfig = this.appConfigProvider.getConfig();
|
|
160
235
|
this.persistence = appconfig.authPersistence;
|
|
161
236
|
this.appStorageService.initialize(environment.storage_prefix, this.persistence, '')
|
|
162
|
-
this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
163
|
-
this.logger.
|
|
237
|
+
// this.logger.log('[APP-COMP] HELLO ngOnInit !!!!!!!')
|
|
238
|
+
// this.logger.log('[APP-COMP] ngOnInit this.route.snapshot.params -->', this.route.snapshot.params);
|
|
164
239
|
// this.initializeApp('oninit');
|
|
165
240
|
const token = getParameterByName('jwt')
|
|
166
|
-
this.logger.
|
|
241
|
+
// this.logger.log('[APP-COMP] ngOnInit AUTOLOGIN token get with getParameterByName -->', token);
|
|
167
242
|
|
|
168
243
|
if (token) {
|
|
169
244
|
// this.isOnline = false;
|
|
@@ -182,9 +257,81 @@ export class AppComponent implements OnInit {
|
|
|
182
257
|
}
|
|
183
258
|
this.initializeApp('oninit');
|
|
184
259
|
|
|
260
|
+
this.listenToPostMsgs();
|
|
185
261
|
}
|
|
186
262
|
|
|
187
263
|
|
|
264
|
+
|
|
265
|
+
listenToPostMsgs() {
|
|
266
|
+
window.addEventListener("message", (event) => {
|
|
267
|
+
// console.log("[APP-COMP] message event ", event);
|
|
268
|
+
|
|
269
|
+
if (event && event.data && event.data.action && event.data.parameter) {
|
|
270
|
+
if (event.data.action === 'openJoinConversationModal') {
|
|
271
|
+
// console.log("[APP-COMP] message event action ", event.data.action);
|
|
272
|
+
// console.log("[APP-COMP] message event parameter ", event.data.parameter);
|
|
273
|
+
this.presentAlertConfirmJoinRequest(event.data.parameter, event.data.calledBy)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (event && event.data && event.data.action && event.data.text) {
|
|
277
|
+
if (event.data.action === "display_toast_join_complete") {
|
|
278
|
+
this.presentToastJoinComplete(event.data.text)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async presentToastJoinComplete(text) {
|
|
285
|
+
const toast = await this.toastController.create({
|
|
286
|
+
message: text,
|
|
287
|
+
duration: 2000,
|
|
288
|
+
color: "success"
|
|
289
|
+
});
|
|
290
|
+
toast.present();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async presentAlertConfirmJoinRequest(requestid, calledby) {
|
|
294
|
+
var iframeWin = <HTMLIFrameElement>document.getElementById("unassigned-convs-iframe")
|
|
295
|
+
// console.log("[APP-COMP] message event iframeWin ", iframeWin);
|
|
296
|
+
|
|
297
|
+
const isIFrame = (input: HTMLElement | null): input is HTMLIFrameElement =>
|
|
298
|
+
input !== null && input.tagName === 'IFRAME';
|
|
299
|
+
|
|
300
|
+
const keys = ['YouAreAboutToJoinThisChat', 'Cancel', 'AreYouSure'];
|
|
301
|
+
const translationMap = this.translateService.translateLanguage(keys);
|
|
302
|
+
|
|
303
|
+
const alert = await this.alertController.create({
|
|
304
|
+
cssClass: 'my-custom-class',
|
|
305
|
+
header: translationMap.get('AreYouSure'),
|
|
306
|
+
message: translationMap.get('YouAreAboutToJoinThisChat'),
|
|
307
|
+
buttons: [
|
|
308
|
+
{
|
|
309
|
+
text: translationMap.get('Cancel'),
|
|
310
|
+
role: 'cancel',
|
|
311
|
+
cssClass: 'secondary',
|
|
312
|
+
handler: (blah) => {
|
|
313
|
+
// console.log('Confirm Cancel: blah', blah);
|
|
314
|
+
}
|
|
315
|
+
}, {
|
|
316
|
+
text: 'Ok',
|
|
317
|
+
handler: () => {
|
|
318
|
+
// console.log('Confirm Okay');
|
|
319
|
+
|
|
320
|
+
if (isIFrame(iframeWin) && iframeWin.contentWindow) {
|
|
321
|
+
const msg = { action: "joinConversation", parameter: requestid, calledBy: calledby }
|
|
322
|
+
iframeWin.contentWindow.postMessage(msg, '*');
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
await alert.present();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
|
|
188
335
|
signInWithCustomToken(token) {
|
|
189
336
|
// this.isOnline = false;
|
|
190
337
|
this.logger.log('[APP-COMP] SIGNINWITHCUSTOMTOKEN token', token)
|
|
@@ -200,18 +347,18 @@ export class AppComponent implements OnInit {
|
|
|
200
347
|
|
|
201
348
|
/** */
|
|
202
349
|
initializeApp(calledby: string) {
|
|
203
|
-
this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
204
|
-
|
|
350
|
+
// this.logger.log('[APP-COMP] - X - initializeApp !!! CALLED-BY: ', calledby);
|
|
351
|
+
// console.log('[APP-COMP] appconfig platform is cordova: ', this.platform.is('cordova'))
|
|
205
352
|
|
|
206
|
-
if (!this.platform.is('cordova')) {
|
|
207
|
-
|
|
208
|
-
}
|
|
353
|
+
// if (!this.platform.is('cordova')) {
|
|
354
|
+
this.splashScreen.show();
|
|
355
|
+
// }
|
|
209
356
|
this.tabTitle = document.title;
|
|
210
357
|
|
|
211
358
|
this.getRouteParamsAndSetLoggerConfig();
|
|
212
359
|
|
|
213
360
|
const appconfig = this.appConfigProvider.getConfig();
|
|
214
|
-
this.logger.info('[APP-COMP] appconfig: ', appconfig)
|
|
361
|
+
// this.logger.info('[APP-COMP] appconfig: ', appconfig)
|
|
215
362
|
this.version = PACKAGE.version;
|
|
216
363
|
this.logger.info('[APP-COMP] version: ', this.version)
|
|
217
364
|
|
|
@@ -223,12 +370,39 @@ export class AppComponent implements OnInit {
|
|
|
223
370
|
this.notificationsEnabled = true;
|
|
224
371
|
this.zone = new NgZone({}); // a cosa serve?
|
|
225
372
|
|
|
373
|
+
// ------------------------------------------
|
|
374
|
+
// Platform ready
|
|
375
|
+
// ------------------------------------------
|
|
226
376
|
this.platform.ready().then(() => {
|
|
227
|
-
|
|
377
|
+
// console.log("Check platform");
|
|
378
|
+
if (this.platform.is('cordova')) {
|
|
379
|
+
// console.log("the device running Cordova");
|
|
380
|
+
}
|
|
381
|
+
if (!this.platform.is('cordova')) {
|
|
382
|
+
// console.log("the device Not running Cordova");
|
|
383
|
+
}
|
|
228
384
|
|
|
229
|
-
if (this.
|
|
230
|
-
|
|
385
|
+
if (this.platform.is('android')) {
|
|
386
|
+
// console.log("running on Android device!");
|
|
387
|
+
}
|
|
388
|
+
if (this.platform.is('ios')) {
|
|
389
|
+
// console.log("running on iOS device!");
|
|
231
390
|
}
|
|
391
|
+
if (this.platform.is('mobileweb')) {
|
|
392
|
+
// console.log("running in a browser on mobile!");
|
|
393
|
+
}
|
|
394
|
+
if (this.platform.is('desktop')) {
|
|
395
|
+
// console.log("running on desktop!");
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
this.setLanguage();
|
|
402
|
+
|
|
403
|
+
// if (this.splashScreen) {
|
|
404
|
+
this.splashScreen.hide();
|
|
405
|
+
// }
|
|
232
406
|
this.statusBar.styleDefault();
|
|
233
407
|
this.navService.init(this.sidebarNav, this.detailNav);
|
|
234
408
|
// this.persistence = appconfig.authPersistence;
|
|
@@ -320,9 +494,9 @@ export class AppComponent implements OnInit {
|
|
|
320
494
|
getRouteParamsAndSetLoggerConfig() {
|
|
321
495
|
const appconfig = this.appConfigProvider.getConfig();
|
|
322
496
|
this.route.queryParams.subscribe(params => {
|
|
323
|
-
this.logger.
|
|
497
|
+
// this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - queryParams params: ', params)
|
|
324
498
|
if (params.logLevel) {
|
|
325
|
-
this.logger.
|
|
499
|
+
this.logger.log('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from queryParams: ', params.logLevel)
|
|
326
500
|
this.logger.setLoggerConfig(true, params.logLevel)
|
|
327
501
|
} else {
|
|
328
502
|
this.logger.info('[APP-COMP] getRouteParamsAndSetLoggerConfig - log level get from appconfig: ', appconfig.logLevel)
|
|
@@ -352,6 +526,7 @@ export class AppComponent implements OnInit {
|
|
|
352
526
|
/**------- AUTHENTICATION FUNCTIONS --> START <--- +*/
|
|
353
527
|
private initAuthentication() {
|
|
354
528
|
const tiledeskToken = this.appStorageService.getItem('tiledeskToken')
|
|
529
|
+
|
|
355
530
|
this.logger.log('[APP-COMP] >>> INIT-AUTHENTICATION !!! ')
|
|
356
531
|
this.logger.log('[APP-COMP] >>> initAuthentication tiledeskToken ', tiledeskToken)
|
|
357
532
|
// const currentUser = JSON.parse(this.appStorageService.getItem('currentUser'));
|
|
@@ -360,19 +535,19 @@ export class AppComponent implements OnInit {
|
|
|
360
535
|
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
536
|
this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
|
|
362
537
|
this.logger.log('[APP-COMP] >>> initAuthentication user ', user)
|
|
363
|
-
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
538
|
+
this.messagingAuthService.createCustomToken(tiledeskToken)
|
|
364
539
|
}).catch(error => {
|
|
365
540
|
this.logger.error('[APP-COMP] initAuthentication SIGNINWITHCUSTOMTOKEN error::', error)
|
|
366
541
|
})
|
|
367
542
|
} else {
|
|
368
543
|
this.logger.warn('[APP-COMP] >>> I AM NOT LOGGED IN <<<')
|
|
369
|
-
|
|
544
|
+
|
|
370
545
|
// clearTimeout(this.timeModalLogin);
|
|
371
546
|
// this.timeModalLogin = setTimeout(() => {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
547
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
548
|
+
this.authModal = this.presentModal('initAuthentication');
|
|
549
|
+
this.hadBeenCalledOpenModal = true;
|
|
550
|
+
}
|
|
376
551
|
// }, 1000);
|
|
377
552
|
}
|
|
378
553
|
}
|
|
@@ -385,6 +560,18 @@ export class AppComponent implements OnInit {
|
|
|
385
560
|
// }
|
|
386
561
|
// }
|
|
387
562
|
|
|
563
|
+
connetWebsocket(tiledeskToken) {
|
|
564
|
+
const appconfig = this.appConfigProvider.getConfig();
|
|
565
|
+
this.logger.log('connetWebsocket appconfig wsUrl ', appconfig.wsUrl)
|
|
566
|
+
const WS_URL = appconfig.wsUrl + '?token=' + tiledeskToken
|
|
567
|
+
this.webSocketJs.init(
|
|
568
|
+
WS_URL,
|
|
569
|
+
undefined,
|
|
570
|
+
undefined,
|
|
571
|
+
undefined
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
|
|
388
575
|
/**
|
|
389
576
|
* goOnLine:
|
|
390
577
|
* 1 - nascondo splashscreen
|
|
@@ -393,11 +580,14 @@ export class AppComponent implements OnInit {
|
|
|
393
580
|
* @param user
|
|
394
581
|
*/
|
|
395
582
|
goOnLine = () => {
|
|
583
|
+
// console.log('[APP-COMP] - GO-ONLINE ');
|
|
396
584
|
// this.isOnline = true;
|
|
397
585
|
// this.logger.info('initialize FROM [APP-COMP] - [APP-COMP] - GO-ONLINE isOnline ', this.isOnline);
|
|
398
586
|
|
|
399
|
-
clearTimeout(this.timeModalLogin);
|
|
587
|
+
// clearTimeout(this.timeModalLogin);
|
|
400
588
|
const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
|
|
589
|
+
this.connetWebsocket(tiledeskToken)
|
|
590
|
+
this.events.publish('go:online', true);
|
|
401
591
|
const currentUser = this.tiledeskAuthService.getCurrentUser();
|
|
402
592
|
// this.logger.printDebug('APP-COMP - goOnLine****', currentUser);
|
|
403
593
|
this.logger.log('[APP-COMP] - GO-ONLINE - currentUser ', currentUser);
|
|
@@ -429,8 +619,17 @@ export class AppComponent implements OnInit {
|
|
|
429
619
|
this.chatManager.startApp();
|
|
430
620
|
}
|
|
431
621
|
|
|
622
|
+
|
|
623
|
+
webSocketClose() {
|
|
624
|
+
this.logger.log('[APP-COMP] - GO-OFFLINE - webSocketClose');
|
|
625
|
+
this.webSocketJs.close()
|
|
626
|
+
this.events.publish('go:offline', true);
|
|
627
|
+
}
|
|
628
|
+
|
|
432
629
|
goOffLine = () => {
|
|
433
|
-
|
|
630
|
+
// console.log('[APP-COMP] - GO-OFFLINE');
|
|
631
|
+
|
|
632
|
+
this.webSocketClose()
|
|
434
633
|
// this.isOnline = false;
|
|
435
634
|
// this.conversationsHandlerService.conversations = [];
|
|
436
635
|
|
|
@@ -439,13 +638,13 @@ export class AppComponent implements OnInit {
|
|
|
439
638
|
this.chatManager.goOffLine();
|
|
440
639
|
|
|
441
640
|
this.router.navigateByUrl('conversation-detail/'); //redirect to basePage
|
|
442
|
-
|
|
641
|
+
|
|
443
642
|
// clearTimeout(this.timeModalLogin);
|
|
444
643
|
// this.timeModalLogin = setTimeout(() => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
644
|
+
if (!this.hadBeenCalledOpenModal) {
|
|
645
|
+
this.authModal = this.presentModal('goOffLine');
|
|
646
|
+
this.hadBeenCalledOpenModal = true
|
|
647
|
+
}
|
|
449
648
|
// }, 1000);
|
|
450
649
|
|
|
451
650
|
// this.unsubscribe$.next();
|
|
@@ -537,16 +736,23 @@ export class AppComponent implements OnInit {
|
|
|
537
736
|
}
|
|
538
737
|
|
|
539
738
|
private initAudio() {
|
|
739
|
+
// console.log('HERE IS initAudio ')
|
|
540
740
|
// SET AUDIO
|
|
741
|
+
const href = window.location.href;
|
|
742
|
+
const hrefArray = href.split('/#/');
|
|
743
|
+
const chatBaseUrl = hrefArray[0]
|
|
744
|
+
// console.log('initAudio href', href)
|
|
745
|
+
// console.log('initAudio chatBaseUrl', chatBaseUrl)
|
|
746
|
+
|
|
541
747
|
this.audio = new Audio();
|
|
542
|
-
this.audio.src = URL_SOUND_LIST_CONVERSATION;
|
|
748
|
+
this.audio.src = chatBaseUrl + URL_SOUND_LIST_CONVERSATION;
|
|
543
749
|
this.audio.load();
|
|
544
750
|
}
|
|
545
751
|
|
|
546
752
|
private manageTabNotification() {
|
|
547
753
|
if (!this.isTabVisible) {
|
|
548
754
|
// TAB IS HIDDEN --> manage title and SOUND
|
|
549
|
-
|
|
755
|
+
// console.log('HERE IS manageTabNotification ')
|
|
550
756
|
let badgeNewConverstionNumber = this.conversationsHandlerService.countIsNew()
|
|
551
757
|
badgeNewConverstionNumber > 0 ? badgeNewConverstionNumber : badgeNewConverstionNumber = 1
|
|
552
758
|
document.title = "(" + badgeNewConverstionNumber + ") " + this.tabTitle
|
|
@@ -565,6 +771,7 @@ export class AppComponent implements OnInit {
|
|
|
565
771
|
}
|
|
566
772
|
|
|
567
773
|
soundMessage() {
|
|
774
|
+
// console.log('HERE IS soundMessage ')
|
|
568
775
|
const that = this;
|
|
569
776
|
// this.audio = new Audio();
|
|
570
777
|
// // this.audio.src = '/assets/sounds/pling.mp3';
|
|
@@ -576,7 +783,7 @@ export class AppComponent implements OnInit {
|
|
|
576
783
|
that.audio.play().then(() => {
|
|
577
784
|
that.logger.debug('[APP-COMP] ****** soundMessage played *****');
|
|
578
785
|
}).catch((error: any) => {
|
|
579
|
-
that.logger.
|
|
786
|
+
that.logger.error('[APP-COMP] ***soundMessage error*', error);
|
|
580
787
|
});
|
|
581
788
|
}, 1000);
|
|
582
789
|
}
|
|
@@ -601,8 +808,8 @@ export class AppComponent implements OnInit {
|
|
|
601
808
|
return;
|
|
602
809
|
}
|
|
603
810
|
|
|
604
|
-
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
605
|
-
|
|
811
|
+
this.BSAuthStateChangedSubscriptionRef = this.messagingAuthService.BSAuthStateChanged
|
|
812
|
+
|
|
606
813
|
// .pipe(takeUntil(this.unsubscribe$))
|
|
607
814
|
.pipe(filter((state) => state !== null))
|
|
608
815
|
.subscribe((state: any) => {
|
|
@@ -658,7 +865,7 @@ export class AppComponent implements OnInit {
|
|
|
658
865
|
* apro dettaglio conversazione
|
|
659
866
|
*/
|
|
660
867
|
subscribeChangedConversationSelected = (user: UserModel, type: string) => {
|
|
661
|
-
this.logger.
|
|
868
|
+
this.logger.log('[APP-COMP] subscribeUidConvSelectedChanged navigateByUrl', user, type);
|
|
662
869
|
// this.router.navigateByUrl('conversation-detail/' + user.uid + '?conversationWithFullname=' + user.fullname);
|
|
663
870
|
this.router.navigateByUrl('conversation-detail/' + user.uid + '/' + user.fullname + '/' + type);
|
|
664
871
|
}
|
|
@@ -848,7 +1055,7 @@ export class AppComponent implements OnInit {
|
|
|
848
1055
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
|
|
849
1056
|
@HostListener('window:storage', ['$event'])
|
|
850
1057
|
onStorageChanged(event: any) {
|
|
851
|
-
|
|
1058
|
+
|
|
852
1059
|
if (event.key !== 'chat_sv5__tiledeskToken') {
|
|
853
1060
|
return;
|
|
854
1061
|
}
|
|
@@ -877,7 +1084,7 @@ export class AppComponent implements OnInit {
|
|
|
877
1084
|
// this.unsubscribe$.complete();
|
|
878
1085
|
this.initializeApp('onstoragechanged');
|
|
879
1086
|
|
|
880
|
-
|
|
1087
|
+
|
|
881
1088
|
|
|
882
1089
|
// console.log('[APP-COMP] onAuthStateChanged HERE !!! ')
|
|
883
1090
|
// firebase.auth().onAuthStateChanged(user => {
|
|
@@ -887,7 +1094,4 @@ export class AppComponent implements OnInit {
|
|
|
887
1094
|
}
|
|
888
1095
|
}
|
|
889
1096
|
}
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
1097
|
}
|
package/src/app/app.module.ts
CHANGED
|
@@ -94,7 +94,8 @@ import { TooltipModule } from 'ng2-tooltip-directive';
|
|
|
94
94
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
95
95
|
import { Network } from '@ionic-native/network/ngx';
|
|
96
96
|
import { ConnectionService } from 'ng-connection-service';
|
|
97
|
-
|
|
97
|
+
import { WebSocketJs } from './services/websocket/websocket-js';
|
|
98
|
+
import { UnassignedConversationsPageModule } from './pages/unassigned-conversations/unassigned-conversations.module';
|
|
98
99
|
|
|
99
100
|
// FACTORIES
|
|
100
101
|
export function createTranslateLoader(http: HttpClient) {
|
|
@@ -102,7 +103,7 @@ export function createTranslateLoader(http: HttpClient) {
|
|
|
102
103
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
export function authenticationFactory(http: HttpClient, appConfig: AppConfigProvider, chat21Service: Chat21Service, appSorage: AppStorageService, network: Network, connectionService:ConnectionService) {
|
|
106
|
+
export function authenticationFactory(http: HttpClient, appConfig: AppConfigProvider, chat21Service: Chat21Service, appSorage: AppStorageService, network: Network, connectionService: ConnectionService) {
|
|
106
107
|
const config = appConfig.getConfig()
|
|
107
108
|
if (config.chatEngine === CHAT_ENGINE_MQTT) {
|
|
108
109
|
|
|
@@ -111,8 +112,13 @@ export function authenticationFactory(http: HttpClient, appConfig: AppConfigProv
|
|
|
111
112
|
|
|
112
113
|
const auth = new MQTTAuthService(http, chat21Service, appSorage);
|
|
113
114
|
|
|
114
|
-
auth.setBaseUrl(appConfig.getConfig().apiUrl)
|
|
115
|
-
|
|
115
|
+
auth.setBaseUrl(appConfig.getConfig().apiUrl);
|
|
116
|
+
|
|
117
|
+
if (config.pushEngine = PUSH_ENGINE_MQTT) {
|
|
118
|
+
// FOR PUSH NOTIFICATIONS INIT FIREBASE APP
|
|
119
|
+
FirebaseInitService.initFirebase(config.firebaseConfig);
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
return auth
|
|
117
123
|
} else {
|
|
118
124
|
|
|
@@ -120,7 +126,7 @@ export function authenticationFactory(http: HttpClient, appConfig: AppConfigProv
|
|
|
120
126
|
// console.log('[APP-MOD] FirebaseInitService config ', config)
|
|
121
127
|
const auth = new FirebaseAuthService(http, network, connectionService);
|
|
122
128
|
auth.setBaseUrl(config.apiUrl)
|
|
123
|
-
|
|
129
|
+
|
|
124
130
|
return auth
|
|
125
131
|
}
|
|
126
132
|
}
|
|
@@ -216,12 +222,12 @@ export function uploadFactory(http: HttpClient, appConfig: AppConfigProvider, ap
|
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
224
|
|
|
219
|
-
export function notificationsServiceFactory(appConfig: AppConfigProvider) {
|
|
225
|
+
export function notificationsServiceFactory(appConfig: AppConfigProvider, chat21Service: Chat21Service) {
|
|
220
226
|
const config = appConfig.getConfig()
|
|
221
227
|
if (config.pushEngine === PUSH_ENGINE_FIREBASE) {
|
|
222
228
|
return new FirebaseNotifications();
|
|
223
229
|
} else if (config.pushEngine === PUSH_ENGINE_MQTT) {
|
|
224
|
-
return new MQTTNotifications();
|
|
230
|
+
return new MQTTNotifications(chat21Service);
|
|
225
231
|
} else {
|
|
226
232
|
return;
|
|
227
233
|
}
|
|
@@ -253,6 +259,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
|
|
|
253
259
|
LoginPageModule,
|
|
254
260
|
ConversationListPageModule,
|
|
255
261
|
ConversationDetailPageModule,
|
|
262
|
+
UnassignedConversationsPageModule,
|
|
256
263
|
TranslateModule.forRoot({
|
|
257
264
|
loader: {
|
|
258
265
|
provide: TranslateLoader,
|
|
@@ -338,7 +345,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
|
|
|
338
345
|
{
|
|
339
346
|
provide: NotificationsService,
|
|
340
347
|
useFactory: notificationsServiceFactory,
|
|
341
|
-
deps: [AppConfigProvider]
|
|
348
|
+
deps: [AppConfigProvider, Chat21Service]
|
|
342
349
|
},
|
|
343
350
|
{
|
|
344
351
|
provide: AppStorageService,
|
|
@@ -352,6 +359,7 @@ const appInitializerFn = (appConfig: AppConfigProvider, logger: NGXLogger) => {
|
|
|
352
359
|
EventsService,
|
|
353
360
|
Chooser,
|
|
354
361
|
Chat21Service,
|
|
362
|
+
WebSocketJs
|
|
355
363
|
]
|
|
356
364
|
})
|
|
357
365
|
export class AppModule { }
|
package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<div class="chat21-bounce1" [ngStyle]="{'background-color': stylesMap.get('themeColor')}"></div>
|
|
11
11
|
<div class="chat21-bounce2" [ngStyle]="{'background-color': stylesMap.get('themeColor')}"></div>
|
|
12
12
|
<div class="chat21-bounce3" [ngStyle]="{'background-color': stylesMap.get('themeColor')}"></div>
|
|
13
|
-
<span>{{translationMap
|
|
13
|
+
<span>{{translationMap?.get('LABEL_LOADING')}}</span>
|
|
14
14
|
</div>
|
|
15
15
|
</span>
|
|
16
16
|
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
<div role="messaggio" *ngIf="messageType(MESSAGE_TYPE_MINE, message)" class="msg_container base_sent">
|
|
68
68
|
|
|
69
69
|
<!--backgroundColor non viene ancora usato -->
|
|
70
|
-
<chat-bubble-message
|
|
71
|
-
|
|
70
|
+
<chat-bubble-message [ngClass]="{'has-metadata': (isImage(message) || isFrame(message))}"
|
|
71
|
+
class="messages msg_sent" id="message_msg_sent"
|
|
72
72
|
[ngClass]="{'button-in-msg' : message.metadata && message.metadata.button}" [message]="message"
|
|
73
73
|
[textColor]="'col-msg-sent'"
|
|
74
74
|
(onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
</chat-avatar-image> -->
|
|
99
99
|
|
|
100
100
|
<!--backgroundColor non viene ancora usato -->
|
|
101
|
-
|
|
102
|
-
<chat-bubble-message class="messages msg_receive"
|
|
101
|
+
|
|
102
|
+
<chat-bubble-message [ngClass]="{'has-metadata': (isImage(message) || isFrame(message))}" class="messages msg_receive" id="message_msg_receive"
|
|
103
103
|
[message]="message"
|
|
104
104
|
[textColor]="'black'"
|
|
105
105
|
(onBeforeMessageRender)="returnOnBeforeMessageRender($event)"
|
|
@@ -93,7 +93,9 @@ ion-item {
|
|
|
93
93
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
.has-metadata {
|
|
97
|
+
max-width: 100% !important;
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
/** recive message **/
|
|
@@ -138,7 +140,11 @@ ion-item {
|
|
|
138
140
|
border-top-left-radius: 8px;
|
|
139
141
|
border-bottom-left-radius: 0px;
|
|
140
142
|
|
|
141
|
-
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.has-metadata {
|
|
146
|
+
max-width: 100% !important;
|
|
147
|
+
}
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
.time{
|
|
@@ -5,6 +5,7 @@ import { ChangeDetectorRef, Component, Input, OnInit, Output, EventEmitter} from
|
|
|
5
5
|
import { MESSAGE_TYPE_INFO, MESSAGE_TYPE_MINE, MESSAGE_TYPE_OTHERS } from 'src/chat21-core/utils/constants';
|
|
6
6
|
import { isChannelTypeGroup, isFirstMessage, isInfo, isMine, messageType } from 'src/chat21-core/utils/utils-message';
|
|
7
7
|
import { UploadService } from 'src/chat21-core/providers/abstract/upload.service';
|
|
8
|
+
import { isFile, isFrame, isImage } from 'src/chat21-core/utils/utils-message';
|
|
8
9
|
|
|
9
10
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
10
11
|
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
@@ -25,6 +26,10 @@ export class IonConversationDetailComponent extends ConversationContentComponent
|
|
|
25
26
|
public uploadProgress: number = 100
|
|
26
27
|
public fileType: any
|
|
27
28
|
|
|
29
|
+
isImage = isImage;
|
|
30
|
+
isFile = isFile;
|
|
31
|
+
isFrame = isFrame;
|
|
32
|
+
|
|
28
33
|
isMine = isMine;
|
|
29
34
|
isInfo = isInfo;
|
|
30
35
|
isFirstMessage = isFirstMessage;
|
|
@@ -34,7 +39,7 @@ export class IonConversationDetailComponent extends ConversationContentComponent
|
|
|
34
39
|
MESSAGE_TYPE_INFO = MESSAGE_TYPE_INFO;
|
|
35
40
|
MESSAGE_TYPE_MINE = MESSAGE_TYPE_MINE;
|
|
36
41
|
MESSAGE_TYPE_OTHERS = MESSAGE_TYPE_OTHERS;
|
|
37
|
-
|
|
42
|
+
logger: LoggerService = LoggerInstance.getInstance()
|
|
38
43
|
/**
|
|
39
44
|
* Constructor
|
|
40
45
|
* @param cdref
|