@chat21/chat21-web-widget 5.0.55 → 5.0.56-rc.2
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/.github/workflows/build.yml +1 -0
- package/CHANGELOG.md +16 -0
- package/angular.json +6 -7
- package/package.json +5 -4
- package/src/app/app.component.html +1 -11
- package/src/app/app.component.scss +12 -13
- package/src/app/app.component.spec.ts +0 -2
- package/src/app/app.component.ts +29 -35
- package/src/app/app.module.ts +4 -5
- package/src/app/component/conversation-detail/conversation/conversation.component.html +1 -10
- package/src/app/component/conversation-detail/conversation/conversation.component.scss +5 -428
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +23 -25
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +7 -66
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +11 -81
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +0 -3
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +6 -6
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +7 -32
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +11 -11
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +8 -8
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.html +4 -25
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.scss +5 -5
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.ts +4 -88
- package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.html +7 -16
- package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.ts +2 -26
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.html +1 -11
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.scss +5 -5
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +2 -19
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +10 -42
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.scss +1 -2
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.ts +2 -3
- package/src/app/component/form/form-builder/form-builder.component.html +0 -1
- package/src/app/component/form/form-builder/form-builder.component.scss +1 -1
- package/src/app/component/form/form-builder/form-builder.component.ts +4 -5
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.scss +1 -2
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.ts +2 -3
- package/src/app/component/form/inputs/form-label/form-label.component.ts +0 -1
- package/src/app/component/form/inputs/form-text/form-text.component.scss +3 -13
- package/src/app/component/form/inputs/form-text/form-text.component.ts +1 -2
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.html +0 -13
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +4 -4
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.ts +0 -10
- package/src/app/component/form/prechat-form/prechat-form.component.html +0 -2
- package/src/app/component/form/prechat-form/prechat-form.component.scss +2 -2
- package/src/app/component/form/prechat-form/prechat-form.component.ts +2 -2
- package/src/app/component/home/home.component.scss +7 -7
- package/src/app/component/home/home.component.ts +1 -4
- package/src/app/component/home-conversations/home-conversations.component.scss +7 -7
- package/src/app/component/home-conversations/home-conversations.component.ts +9 -12
- package/src/app/component/last-message/last-message.component.scss +4 -4
- package/src/app/component/last-message/last-message.component.ts +4 -7
- package/src/app/component/launcher-button/launcher-button.component.ts +3 -3
- package/src/app/component/list-all-conversations/list-all-conversations.component.scss +2 -2
- package/src/app/component/list-all-conversations/list-all-conversations.component.ts +3 -3
- package/src/app/component/list-conversations/list-conversations.component.html +1 -1
- package/src/app/component/list-conversations/list-conversations.component.scss +3 -3
- package/src/app/component/list-conversations/list-conversations.component.ts +3 -6
- package/src/app/component/menu-options/menu-options.component.html +1 -8
- package/src/app/component/menu-options/menu-options.component.scss +4 -4
- package/src/app/component/menu-options/menu-options.component.ts +1 -1
- package/src/app/component/message/bubble-message/bubble-message.component.html +3 -4
- package/src/app/component/message/bubble-message/bubble-message.component.scss +3 -3
- package/src/app/component/message/bubble-message/bubble-message.component.spec.ts +0 -2
- package/src/app/component/message/bubble-message/bubble-message.component.ts +10 -15
- package/src/app/component/message/buttons/action-button/action-button.component.scss +6 -6
- package/src/app/component/message/buttons/link-button/link-button.component.scss +7 -7
- package/src/app/component/message/buttons/text-button/text-button.component.scss +8 -8
- package/src/app/component/message/frame/frame.component.scss +1 -1
- package/src/app/component/message/frame/frame.component.ts +1 -1
- package/src/app/component/message/html/html.component.scss +4 -4
- package/src/app/component/message/html/html.component.ts +1 -2
- package/src/app/component/message/image/image.component.scss +1 -1
- package/src/app/component/message/image/image.component.ts +2 -3
- package/src/app/component/message/info-message/info-message.component.html +2 -1
- package/src/app/component/message/info-message/info-message.component.scss +6 -6
- package/src/app/component/message/like-unlike/like-unlike.component.scss +1 -1
- package/src/app/component/message/like-unlike/like-unlike.component.ts +2 -2
- package/src/app/component/message/text/text.component.scss +2 -2
- package/src/app/component/message/text/text.component.ts +1 -1
- package/src/app/component/message-attachment/message-attachment.component.ts +1 -1
- package/src/app/component/selection-department/selection-department.component.scss +6 -6
- package/src/app/component/selection-department/selection-department.component.ts +2 -2
- package/src/app/component/send-button/send-button.component.ts +1 -2
- package/src/app/component/star-rating-widget/star-rating-widget.component.scss +6 -6
- package/src/app/component/star-rating-widget/star-rating-widget.component.ts +2 -2
- package/src/app/pipe/date-ago.pipe.spec.ts +8 -0
- package/src/app/pipe/date-ago.pipe.ts +42 -0
- package/src/app/providers/app-config.service.ts +0 -1
- package/src/app/providers/global-settings.service.ts +3 -31
- package/src/app/providers/star-rating-widget.service.ts +4 -4
- package/src/app/providers/translator.service.ts +3 -11
- package/src/app/providers/waiting.service.ts +2 -2
- package/src/app/sass/_variables.scss +29 -26
- package/src/app/utils/globals.ts +4 -34
- package/src/app/utils/rules.ts +5 -7
- package/src/app/utils/utils.ts +47 -37
- package/src/assets/i18n/en.json +0 -2
- package/src/assets/i18n/es.json +0 -2
- package/src/assets/i18n/fr.json +0 -2
- package/src/assets/i18n/it.json +0 -2
- package/src/assets/twp/index.html +6 -60
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +15 -23
- package/src/chat21-core/providers/firebase/firebase-auth-service.ts +21 -20
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +15 -13
- package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +16 -23
- package/src/chat21-core/providers/firebase/firebase-groups-handler.ts +15 -11
- package/src/chat21-core/providers/firebase/firebase-image-repo.ts +13 -4
- package/src/chat21-core/providers/firebase/firebase-init-service.ts +3 -3
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +11 -9
- package/src/chat21-core/providers/firebase/firebase-presence.service.ts +14 -11
- package/src/chat21-core/providers/firebase/firebase-typing.service.ts +17 -11
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +12 -9
- package/src/chat21-core/providers/localSessionStorage.ts +2 -15
- package/src/chat21-core/providers/mqtt/chat-service.ts +12 -2
- package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +1 -34
- package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +4 -6
- package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +1 -11
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +13 -7
- package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +3 -3
- package/src/chat21-core/providers/mqtt/mqtt-typing.service.ts +3 -3
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +0 -1
- package/src/chat21-core/utils/user-typing/user-typing.component.scss +3 -3
- package/src/chat21-core/utils/utils.ts +47 -163
- package/src/launch.js +42 -12
- package/src/models/message.ts +0 -23
- package/src/test-new.html +0 -6
- package/src/app/providers/settings-saver.service.spec.ts +0 -17
- package/src/app/providers/settings-saver.service.ts +0 -56
- package/src/app/providers/storage.service.spec.ts +0 -16
- package/src/app/providers/storage.service.ts +0 -220
- package/src/app/utils/translations.ts +0 -122
|
@@ -26,8 +26,6 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
26
26
|
getItem(key: string) {
|
|
27
27
|
let prefix;
|
|
28
28
|
try {
|
|
29
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
30
|
-
// prefix = prefix + sv;
|
|
31
29
|
prefix = this.storagePrefix + '_';
|
|
32
30
|
} catch (e) {
|
|
33
31
|
this.logger.error('[LocalSessionStorage] getItem >Error :', e);
|
|
@@ -41,11 +39,8 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
41
39
|
* @param value
|
|
42
40
|
*/
|
|
43
41
|
setItem(key: string, value: any): void {
|
|
44
|
-
// this.removeItem(key);
|
|
45
42
|
let prefix;
|
|
46
43
|
try {
|
|
47
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
48
|
-
// prefix = prefix + sv;
|
|
49
44
|
prefix = this.storagePrefix + '_';
|
|
50
45
|
} catch (e) {
|
|
51
46
|
this.logger.error('[LocalSessionStorage] setItem > Error :', e);
|
|
@@ -61,8 +56,6 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
61
56
|
getItemWithoutProjectID(key: string) {
|
|
62
57
|
let prefix;
|
|
63
58
|
try {
|
|
64
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
65
|
-
// prefix = prefix + sv;
|
|
66
59
|
prefix = this.storagePrefix + '_';
|
|
67
60
|
} catch (e) {
|
|
68
61
|
this.logger.error('[LocalSessionStorage] getItemWithoutProjectID > Error :', e);
|
|
@@ -80,8 +73,6 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
80
73
|
this.removeItem(key);
|
|
81
74
|
let prefix = STORAGE_PREFIX;
|
|
82
75
|
try {
|
|
83
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
84
|
-
// prefix = prefix + sv;
|
|
85
76
|
prefix = this.storagePrefix + '_';
|
|
86
77
|
} catch (e) {
|
|
87
78
|
this.logger.error('[LocalSessionStorage] setItemWithoutProjectID > Error :', e);
|
|
@@ -93,8 +84,6 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
93
84
|
removeItem(key: string): void {
|
|
94
85
|
let prefix;
|
|
95
86
|
try {
|
|
96
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
97
|
-
// prefix = prefix + sv;
|
|
98
87
|
prefix = this.storagePrefix + '_';
|
|
99
88
|
} catch (e) {
|
|
100
89
|
this.logger.error('[LocalSessionStorage] removeItem > Error :', e);
|
|
@@ -106,8 +95,6 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
106
95
|
clear(): void {
|
|
107
96
|
let prefix;
|
|
108
97
|
try {
|
|
109
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
110
|
-
// prefix = prefix + sv;
|
|
111
98
|
prefix = this.storagePrefix + '_';
|
|
112
99
|
} catch (e) {
|
|
113
100
|
this.logger.error('[LocalSessionStorage] clear > Error :', e);
|
|
@@ -121,9 +108,9 @@ export class LocalSessionStorage extends AppStorageService{
|
|
|
121
108
|
}
|
|
122
109
|
}
|
|
123
110
|
|
|
124
|
-
for (
|
|
111
|
+
for (const key of arrayKey) {
|
|
125
112
|
// localStorage.removeItem(arrayKey[i]);
|
|
126
|
-
this.removeItemForKey(
|
|
113
|
+
this.removeItemForKey(key);
|
|
127
114
|
}
|
|
128
115
|
|
|
129
116
|
}
|
|
@@ -14,7 +14,7 @@ import { Chat21Client } from '../../../assets/js/chat21client';
|
|
|
14
14
|
*/
|
|
15
15
|
export class Chat21Service {
|
|
16
16
|
|
|
17
|
-
public
|
|
17
|
+
public _chatClient: any;
|
|
18
18
|
private _config: any;
|
|
19
19
|
|
|
20
20
|
constructor() {
|
|
@@ -28,11 +28,21 @@ export class Chat21Service {
|
|
|
28
28
|
return this._config;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
public get chatClient(){
|
|
32
|
+
return this._chatClient
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public set chatClient(chatClient){
|
|
36
|
+
this._chatClient =chatClient
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public initChat() {
|
|
40
|
+
|
|
32
41
|
if (!this._config || this._config.appId === 'CHANGEIT') {
|
|
33
42
|
throw new Error('chat21Config is not defined. Please setup your environment');
|
|
34
43
|
}
|
|
35
44
|
if (!this.chatClient) {
|
|
45
|
+
// const { Chat21Client} = await import("../../../assets/js/chat21client");
|
|
36
46
|
this.chatClient = new Chat21Client(this._config);
|
|
37
47
|
} else {
|
|
38
48
|
console.log("Did you try again to create a Chat21Client istance?");
|
|
@@ -10,7 +10,7 @@ import { ConversationModel } from '../../models/conversation';
|
|
|
10
10
|
// utils
|
|
11
11
|
import { TYPE_GROUP } from '../../utils/constants';
|
|
12
12
|
import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
|
|
13
|
-
import { compareValues,
|
|
13
|
+
import { compareValues, searchIndexInArrayForUid } from '../../utils/utils';
|
|
14
14
|
import { ArchivedConversationsHandlerService } from '../abstract/archivedconversations-handler.service';
|
|
15
15
|
import { LoggerService } from '../abstract/logger.service';
|
|
16
16
|
import { LoggerInstance } from '../logger/loggerInstance';
|
|
@@ -363,39 +363,6 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
363
363
|
return status;
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
/**
|
|
367
|
-
* calcolo il tempo trascorso da ora al timestamp passato
|
|
368
|
-
* @param timestamp
|
|
369
|
-
*/
|
|
370
|
-
private getTimeLastMessage(timestamp: string) {
|
|
371
|
-
const timestampNumber = parseInt(timestamp) / 1000;
|
|
372
|
-
const time = getFromNow(timestampNumber);
|
|
373
|
-
return time;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// removeByUid(uid) {
|
|
377
|
-
// const index = searchIndexInArrayForUid(this.conversations, uid);
|
|
378
|
-
// if (index > -1) {
|
|
379
|
-
// this.conversations.splice(index, 1);
|
|
380
|
-
// // this.events.publish('conversationsChanged', this.conversations);
|
|
381
|
-
// this.conversationsChanged.next(this.conversations);
|
|
382
|
-
// }
|
|
383
|
-
// }
|
|
384
|
-
|
|
385
|
-
// addConversationListener(uidUser, conversationId) {
|
|
386
|
-
// var that = this;
|
|
387
|
-
// this.tenant = environment.tenant;
|
|
388
|
-
// // const tenant = this.chatManager.getTenant();
|
|
389
|
-
// const url = '/apps/' + this.tenant + '/users/' + uidUser + '/conversations/' + conversationId;
|
|
390
|
-
// const reference = firebase.database().ref(url);
|
|
391
|
-
// console.log("ChatConversationsHandler::addConversationListener::reference:",url, reference.toString());
|
|
392
|
-
// reference.on('value', function (snapshot) {
|
|
393
|
-
// setTimeout(function () {
|
|
394
|
-
// // that.events.publish(conversationId + '-listener', snapshot);
|
|
395
|
-
// }, 100);
|
|
396
|
-
// });
|
|
397
|
-
// }
|
|
398
|
-
|
|
399
366
|
/**
|
|
400
367
|
* restituisce il numero di conversazioni nuove
|
|
401
368
|
*/
|
|
@@ -4,18 +4,16 @@ import { BehaviorSubject } from 'rxjs';
|
|
|
4
4
|
import { environment } from '../../../environments/environment';
|
|
5
5
|
|
|
6
6
|
// firebase
|
|
7
|
-
import * as firebase from 'firebase/app';
|
|
8
|
-
import 'firebase/messaging';
|
|
9
|
-
import 'firebase/database';
|
|
10
|
-
import 'firebase/auth';
|
|
7
|
+
// import * as firebase from 'firebase/app';
|
|
8
|
+
// import 'firebase/messaging';
|
|
9
|
+
// import 'firebase/database';
|
|
10
|
+
// import 'firebase/auth';
|
|
11
11
|
|
|
12
12
|
// services
|
|
13
13
|
// import { EventsService } from '../events-service';
|
|
14
14
|
import { MessagingAuthService } from '../abstract/messagingAuth.service';
|
|
15
15
|
import { Chat21Service } from './chat-service';
|
|
16
16
|
// models
|
|
17
|
-
import { UserModel } from '../../models/user';
|
|
18
|
-
import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
|
|
19
17
|
import { AppStorageService } from '../abstract/app-storage.service';
|
|
20
18
|
import { LoggerService } from '../abstract/logger.service';
|
|
21
19
|
import { LoggerInstance } from '../logger/loggerInstance';
|
|
@@ -12,7 +12,7 @@ import { ConversationsHandlerService } from '../abstract/conversations-handler.s
|
|
|
12
12
|
|
|
13
13
|
// utils
|
|
14
14
|
import { avatarPlaceholder, getColorBck } from '../../utils/utils-user';
|
|
15
|
-
import { compareValues,
|
|
15
|
+
import { compareValues, searchIndexInArrayForUid } from '../../utils/utils';
|
|
16
16
|
import { LoggerService } from '../abstract/logger.service';
|
|
17
17
|
import { LoggerInstance } from '../logger/loggerInstance';
|
|
18
18
|
|
|
@@ -426,16 +426,6 @@ export class MQTTConversationsHandler extends ConversationsHandlerService {
|
|
|
426
426
|
return status;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
/**
|
|
430
|
-
* calcolo il tempo trascorso da ora al timestamp passato
|
|
431
|
-
* @param timestamp
|
|
432
|
-
*/
|
|
433
|
-
private getTimeLastMessage(timestamp: string) {
|
|
434
|
-
const timestampNumber = parseInt(timestamp) / 1000;
|
|
435
|
-
const time = getFromNow(timestampNumber);
|
|
436
|
-
return time;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
429
|
/**
|
|
440
430
|
* restituisce il numero di conversazioni nuove
|
|
441
431
|
*/
|
|
@@ -4,10 +4,10 @@ import { Injectable } from '@angular/core';
|
|
|
4
4
|
import { NotificationsService } from '../abstract/notifications.service';
|
|
5
5
|
import { LoggerInstance } from '../logger/loggerInstance';
|
|
6
6
|
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
7
|
+
|
|
7
8
|
// firebase
|
|
8
|
-
import firebase from "firebase/app";
|
|
9
|
-
|
|
10
|
-
import 'firebase/auth';
|
|
9
|
+
// import firebase from "firebase/app";
|
|
10
|
+
|
|
11
11
|
// chat21
|
|
12
12
|
import { Chat21Service } from './chat-service';
|
|
13
13
|
|
|
@@ -20,6 +20,8 @@ export class MQTTNotifications extends NotificationsService {
|
|
|
20
20
|
private userId: string;
|
|
21
21
|
private tenant: string;
|
|
22
22
|
private vapidkey: string;
|
|
23
|
+
private firebase: any;
|
|
24
|
+
|
|
23
25
|
private logger: LoggerService = LoggerInstance.getInstance();
|
|
24
26
|
|
|
25
27
|
constructor(
|
|
@@ -28,16 +30,20 @@ export class MQTTNotifications extends NotificationsService {
|
|
|
28
30
|
super();
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
initialize(tenant: string, vapId: string)
|
|
33
|
+
async initialize(tenant: string, vapId: string) {
|
|
32
34
|
this.tenant = tenant;
|
|
33
35
|
this.vapidkey = vapId;
|
|
36
|
+
|
|
37
|
+
const { default: firebase} = await import("firebase/app");
|
|
38
|
+
this.firebase = firebase
|
|
39
|
+
|
|
34
40
|
return;
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
getNotificationPermissionAndSaveToken(currentUserUid) {
|
|
38
44
|
this.userId = currentUserUid;
|
|
39
|
-
if (firebase.messaging.isSupported()) {
|
|
40
|
-
const messaging = firebase.messaging();
|
|
45
|
+
if (this.firebase.messaging.isSupported()) {
|
|
46
|
+
const messaging = this.firebase.messaging();
|
|
41
47
|
// messaging.requestPermission()
|
|
42
48
|
Notification.requestPermission().then((permission) => {
|
|
43
49
|
if (permission === 'granted') {
|
|
@@ -77,7 +83,7 @@ export class MQTTNotifications extends NotificationsService {
|
|
|
77
83
|
let connectionsRefURL = '';
|
|
78
84
|
if (connectionsRefinstancesId) {
|
|
79
85
|
connectionsRefURL = connectionsRefinstancesId + self.FCMcurrentToken;
|
|
80
|
-
const connectionsRef = firebase.database().ref().child(connectionsRefURL);
|
|
86
|
+
const connectionsRef = this.firebase.database().ref().child(connectionsRefURL);
|
|
81
87
|
self.logger.log('[MQTTNotificationService] >>>> connectionsRef ', connectionsRef);
|
|
82
88
|
self.logger.log('[MQTTNotificationService] >>>> connectionsRef url ', connectionsRefURL);
|
|
83
89
|
connectionsRef.off()
|
|
@@ -3,9 +3,9 @@ import { Injectable } from '@angular/core';
|
|
|
3
3
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
// firebase
|
|
6
|
-
import * as firebase from 'firebase/app';
|
|
7
|
-
import 'firebase/messaging';
|
|
8
|
-
import 'firebase/database';
|
|
6
|
+
// import * as firebase from 'firebase/app';
|
|
7
|
+
// import 'firebase/messaging';
|
|
8
|
+
// import 'firebase/database';
|
|
9
9
|
|
|
10
10
|
// services
|
|
11
11
|
// import { EventsService } from '../events-service';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
// firebase
|
|
4
|
-
import * as firebase from 'firebase/app';
|
|
5
|
-
import 'firebase/messaging';
|
|
6
|
-
import 'firebase/database';
|
|
4
|
+
// import * as firebase from 'firebase/app';
|
|
5
|
+
// import 'firebase/messaging';
|
|
6
|
+
// import 'firebase/database';
|
|
7
7
|
|
|
8
8
|
// services
|
|
9
9
|
// import { EventsService } from './abstract/events-service';
|
|
@@ -112,7 +112,6 @@ export class TiledeskAuthService {
|
|
|
112
112
|
if (data['success'] && data['token']) {
|
|
113
113
|
that.tiledeskToken = data['token'];
|
|
114
114
|
that.createCompleteUser(data['user']);
|
|
115
|
-
// that.appStorage.setItem('tiledeskToken', that.tiledeskToken); // salvarlo esternamente nell'app.component
|
|
116
115
|
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
117
116
|
resolve(this.currentUser)
|
|
118
117
|
}
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import '
|
|
3
|
-
|
|
4
|
-
// firebase
|
|
5
|
-
import * as firebase from 'firebase/app';
|
|
6
|
-
import 'firebase/storage';
|
|
7
|
-
|
|
8
|
-
import { environment } from '../../environments/environment';
|
|
1
|
+
import * as dayjs from 'dayjs'
|
|
2
|
+
import * as duration from 'dayjs/plugin/duration'
|
|
3
|
+
dayjs.extend(duration)
|
|
9
4
|
// tslint:disable-next-line:max-line-length
|
|
10
|
-
|
|
11
|
-
MAX_WIDTH_IMAGES,
|
|
12
|
-
STORAGE_PREFIX,
|
|
13
|
-
TYPE_DIRECT,
|
|
14
|
-
TYPE_SUPPORT_GROUP
|
|
15
|
-
} from './constants';
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
avatarPlaceholder,
|
|
19
|
-
getColorBck,
|
|
20
|
-
getImageUrlThumbFromFirebasestorage
|
|
21
|
-
} from './utils-user';
|
|
22
|
-
import { time } from 'console';
|
|
5
|
+
|
|
23
6
|
import { ConversationModel } from '../models/conversation';
|
|
24
7
|
/**
|
|
25
8
|
* Shortest description for phone and tablet
|
|
@@ -103,38 +86,38 @@ export function contactsRef(tenant) {
|
|
|
103
86
|
/**
|
|
104
87
|
* @deprecated
|
|
105
88
|
*/
|
|
106
|
-
export function setHeaderDate(translate, timestamp): string {
|
|
107
|
-
|
|
108
|
-
|
|
89
|
+
// export function setHeaderDate(translate, timestamp): string {
|
|
90
|
+
// // const LABEL_TODAY = translate.get('LABEL_TODAY');
|
|
91
|
+
// // const LABEL_TOMORROW = translate.get('LABEL_TOMORROW');
|
|
109
92
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
93
|
+
// const date = new Date(timestamp);
|
|
94
|
+
// const now: Date = new Date();
|
|
95
|
+
// let labelDays = '';
|
|
96
|
+
// if (now.getFullYear() !== date.getFullYear()) {
|
|
97
|
+
// // quest'anno: data esatta
|
|
98
|
+
// const month = date.getMonth() + 1;
|
|
99
|
+
// labelDays = date.getDay() + '/' + month + '/' + date.getFullYear();
|
|
100
|
+
// } else if (now.getMonth() !== date.getMonth()) {
|
|
101
|
+
// // questo mese: data esatta
|
|
102
|
+
// const month = date.getMonth() + 1;
|
|
103
|
+
// labelDays = date.getDay() + '/' + month + '/' + date.getFullYear();
|
|
104
|
+
// } else if (now.getDay() === date.getDay()) {
|
|
105
|
+
// // oggi: oggi
|
|
106
|
+
// labelDays = moment().calendar(timestamp).split(' ')[0].toLocaleLowerCase();
|
|
107
|
+
// // labelDays = LABEL_TODAY;
|
|
108
|
+
// } else if (now.getDay() - date.getDay() === 1) {
|
|
109
|
+
// // ieri: ieri
|
|
110
|
+
// labelDays = moment().calendar(timestamp).split(' ')[0].toLocaleLowerCase();
|
|
111
|
+
// // labelDays = LABEL_TOMORROW;
|
|
112
|
+
// } else {
|
|
113
|
+
// // questa settimana: giorno
|
|
114
|
+
// labelDays = convertDayToString(translate, date.getDay());
|
|
115
|
+
// }
|
|
116
|
+
// // se le date sono diverse o la data di riferimento non è impostata
|
|
117
|
+
// // ritorna la data calcolata
|
|
118
|
+
// // altrimenti torna null
|
|
119
|
+
// return labelDays;
|
|
120
|
+
// }
|
|
138
121
|
|
|
139
122
|
|
|
140
123
|
|
|
@@ -150,9 +133,9 @@ export function setLastDate(translate, timestamp): string {
|
|
|
150
133
|
const LABEL_TO = translate.get('LABEL_TO');
|
|
151
134
|
const LABEL_LAST_ACCESS = translate.get('LABEL_LAST_ACCESS');
|
|
152
135
|
|
|
153
|
-
|
|
136
|
+
let date = new Date(timestamp);
|
|
154
137
|
let now: Date = new Date();
|
|
155
|
-
|
|
138
|
+
let labelDays = '';
|
|
156
139
|
if (now.getFullYear() !== date.getFullYear()) {
|
|
157
140
|
const month = date.getMonth() + 1;
|
|
158
141
|
labelDays = date.getDay() + '/' + month + '/' + date.getFullYear();
|
|
@@ -226,19 +209,6 @@ export function supports_html5_session() {
|
|
|
226
209
|
}
|
|
227
210
|
}
|
|
228
211
|
|
|
229
|
-
export function setStoragePrefix(): string{
|
|
230
|
-
let prefix = STORAGE_PREFIX;
|
|
231
|
-
try {
|
|
232
|
-
// const sv = 'sv' + environment.shemaVersion + '_';
|
|
233
|
-
// prefix = prefix + sv;
|
|
234
|
-
prefix = environment.storage_prefix + '_';
|
|
235
|
-
} catch (e) {
|
|
236
|
-
this.g.wdLog(['> Error :' + e]);
|
|
237
|
-
}
|
|
238
|
-
return prefix + this.g.projectid + '_';
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
212
|
export function convertMessage(messageText) {
|
|
243
213
|
if (messageText) {
|
|
244
214
|
messageText = convert(messageText);
|
|
@@ -480,112 +450,26 @@ export function compareValues(key, order = 'asc') {
|
|
|
480
450
|
};
|
|
481
451
|
}
|
|
482
452
|
|
|
483
|
-
/** */
|
|
484
|
-
export function getNowTimestamp() {
|
|
485
|
-
//console.log("timestamp:", moment().valueOf());
|
|
486
|
-
return moment().valueOf();
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
export function getFormatData(timestamp): string {
|
|
490
|
-
var dateString = moment.unix(timestamp / 1000).format('L');
|
|
491
|
-
// const date = new Date(timestamp);
|
|
492
|
-
// const labelDays = date.getDay()+"/"+date.getMonth()+"/"+date.getFullYear();
|
|
493
|
-
return dateString;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
export function getTimeLastMessage(timestamp: string) {
|
|
497
|
-
const timestampNumber = parseInt(timestamp, null) / 1000;
|
|
498
|
-
const time = getFromNow(timestampNumber);
|
|
499
|
-
return time;
|
|
500
|
-
}
|
|
501
453
|
|
|
502
|
-
// export function
|
|
503
|
-
//
|
|
504
|
-
//
|
|
505
|
-
//
|
|
506
|
-
//
|
|
507
|
-
// moment.locale(browserLang);
|
|
508
|
-
// // console.log('getFromNow - browserLang: ', browserLang);
|
|
509
|
-
// const date_as_string = moment.unix(timestamp).fromNow();
|
|
510
|
-
// return date_as_string;
|
|
454
|
+
// export function getFormatData(timestamp): string {
|
|
455
|
+
// var dateString = moment.unix(timestamp / 1000).format('L');
|
|
456
|
+
// // const date = new Date(timestamp);
|
|
457
|
+
// // const labelDays = date.getDay()+"/"+date.getMonth()+"/"+date.getFullYear();
|
|
458
|
+
// return dateString;
|
|
511
459
|
// }
|
|
512
460
|
|
|
513
|
-
export function getFromNow(timestamp): string {
|
|
514
|
-
// var fullDate = new Date(this.news.date.$date)
|
|
515
|
-
// console.log('FULL DATE: ', fullDate);
|
|
516
|
-
// var month = '' + (fullDate.getMonth() + 1)
|
|
517
|
-
// var day = '' + fullDate.getDate()
|
|
518
|
-
// var year = fullDate.getFullYear()
|
|
519
|
-
// var hour = '' + fullDate.getHours()
|
|
520
|
-
// var min = fullDate.getMinutes()
|
|
521
|
-
// var sec = fullDate.getSeconds()
|
|
522
|
-
// if (month.length < 2) month = '0' + month;
|
|
523
|
-
// if (day.length < 2) day = '0' + day;
|
|
524
|
-
// if (hour.length < 2) hour = '0' + hour;
|
|
525
|
-
// console.log('Giorno ', day)
|
|
526
|
-
// console.log('Mese ', month)
|
|
527
|
-
// console.log('Anno ', year)
|
|
528
|
-
// console.log('Ora ', hour)
|
|
529
|
-
// console.log('Min ', min)
|
|
530
|
-
// console.log('Sec', sec)
|
|
531
|
-
|
|
532
|
-
// this.dateFromNow = moment(year + month + day, "YYYYMMDD").fromNow()
|
|
533
|
-
// let date_as_string = moment(year + month + day, "YYYYMMDD").fromNow()
|
|
534
|
-
|
|
535
|
-
// let date_as_string = moment(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec).fromNow()
|
|
536
|
-
// let date_as_string = moment("2017-07-03 08:33:37").fromNow()
|
|
537
|
-
//var day = new Date(2017, 8, 16);
|
|
538
|
-
//let date_as_string = moment(day);
|
|
539
|
-
|
|
540
|
-
// var dateString = moment.unix(timestamp).format("MM/DD/YYYY");
|
|
541
|
-
// console.log(moment(dateString).fromNow(), dateString);
|
|
542
|
-
// var date = "Thu Aug 19 2017 19:58:03 GMT+0000 (GMT)";
|
|
543
|
-
// console.log(moment(date).fromNow()); // 1 hour ago
|
|
544
|
-
// console.log(moment.unix(1483228800).fromNow());
|
|
545
|
-
// console.log(moment.unix(1501545600).fromNow());
|
|
546
|
-
//console.log("timestamp: ",timestamp, " - 1483228800 - ", moment.unix(1483228800).fromNow());
|
|
547
|
-
// console.log();
|
|
548
|
-
|
|
549
|
-
//console.log("window.navigator.language: ", window.navigator.language);
|
|
550
|
-
|
|
551
|
-
moment.locale(window.navigator.language);
|
|
552
|
-
let date_as_string = moment.unix(timestamp).fromNow();
|
|
553
|
-
return date_as_string;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
461
|
export function getDateDifference(startTimestampDate, endTimestampDate){
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
const endTime = moment(endTimestampDate);
|
|
563
|
-
const duration = moment.duration(endTime.diff(startTime));
|
|
462
|
+
|
|
463
|
+
const startTime = dayjs(startTimestampDate);
|
|
464
|
+
const endTime = dayjs(endTimestampDate);
|
|
465
|
+
const duration = dayjs.duration(endTime.diff(startTime, null, true));
|
|
564
466
|
const days = duration.asDays()
|
|
565
467
|
const hours = duration.asHours();
|
|
566
468
|
const minutes = duration.asMinutes();
|
|
567
|
-
|
|
469
|
+
|
|
568
470
|
return {days, hours, minutes}
|
|
569
471
|
}
|
|
570
472
|
|
|
571
|
-
|
|
572
|
-
// export function getUrlImgProfile(uid: string) {
|
|
573
|
-
// const baseLocation = this.g.baseLocation;
|
|
574
|
-
// if (!uid || uid === 'system' ) {
|
|
575
|
-
// return baseLocation + IMG_PROFILE_BOT;
|
|
576
|
-
// } else if ( uid === 'error') {
|
|
577
|
-
// return baseLocation + IMG_PROFILE_DEFAULT;
|
|
578
|
-
// } else {
|
|
579
|
-
// return getImageUrlThumb(uid);
|
|
580
|
-
// }
|
|
581
|
-
// }
|
|
582
|
-
|
|
583
|
-
export function getImageUrlThumb(FIREBASESTORAGE_BASE_URL_IMAGE: string, uid: string) {
|
|
584
|
-
let imageurl = FIREBASESTORAGE_BASE_URL_IMAGE + environment['firebaseConfig'].storageBucket + '/o/profiles%2F' + uid + '%2Fthumb_photo.jpg?alt=media';
|
|
585
|
-
return imageurl;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
|
|
589
473
|
/**
|
|
590
474
|
*
|
|
591
475
|
* @param string
|
package/src/launch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** */
|
|
2
2
|
ready(function() {
|
|
3
|
-
|
|
3
|
+
console.log('DOM is ready, call initWidget');
|
|
4
4
|
if(!window.tileDeskAsyncInit){
|
|
5
5
|
initAysncEvents();
|
|
6
6
|
}
|
|
@@ -9,10 +9,37 @@ ready(function() {
|
|
|
9
9
|
|
|
10
10
|
/** */
|
|
11
11
|
function ready(callbackFunction){
|
|
12
|
-
if(document.readyState != 'loading')
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
// if(document.readyState != 'loading'){
|
|
13
|
+
// console.log('in ifffffff', document.readyState)
|
|
14
|
+
// callbackFunction()
|
|
15
|
+
// }
|
|
16
|
+
// else{
|
|
17
|
+
// document.addEventListener("DOMContentLoaded", callbackFunction)
|
|
18
|
+
// }
|
|
19
|
+
document.addEventListener('scroll', start);
|
|
20
|
+
document.addEventListener('mousedown', start);
|
|
21
|
+
document.addEventListener('mousemove', start);
|
|
22
|
+
document.addEventListener('touchstart', start);
|
|
23
|
+
document.addEventListener('keydown', start);
|
|
24
|
+
|
|
25
|
+
function start(){
|
|
26
|
+
if(document.readyState==='complete'){
|
|
27
|
+
callbackFunction()
|
|
28
|
+
}else if(window.attachEvent){
|
|
29
|
+
window.attachEvent('onload',callbackFunction);
|
|
30
|
+
}else{
|
|
31
|
+
window.addEventListener('load',callbackFunction,false);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
document.removeEventListener('scroll', start);
|
|
35
|
+
document.removeEventListener('mousedown', start);
|
|
36
|
+
document.removeEventListener('mousemove', start);
|
|
37
|
+
document.removeEventListener('touchstart', start);
|
|
38
|
+
document.removeEventListener('scroll', start);
|
|
39
|
+
document.removeEventListener('keydown', start);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
16
43
|
}
|
|
17
44
|
|
|
18
45
|
|
|
@@ -39,17 +66,17 @@ function loadIframe(tiledeskScriptBaseLocation) {
|
|
|
39
66
|
srcTileDesk += '<meta charset="utf-8">';
|
|
40
67
|
srcTileDesk += '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />';
|
|
41
68
|
srcTileDesk += '<title>Tilechat Widget</title>';
|
|
42
|
-
srcTileDesk += '<base href="
|
|
69
|
+
srcTileDesk += '<base href="'+tiledeskScriptBaseLocation+ '">';
|
|
43
70
|
srcTileDesk += '<link rel="icon" type="image/x-icon" href="favicon.ico">';
|
|
44
71
|
srcTileDesk += '<link rel="stylesheet" type="text/css" href="' + tiledeskScriptBaseLocation +'/assets/styles/tiledesk_v1.scss" media="all">';
|
|
45
72
|
srcTileDesk += '</head>';
|
|
46
73
|
srcTileDesk += '<body>';
|
|
47
74
|
srcTileDesk += '<chat-root></chat-root>';
|
|
48
|
-
srcTileDesk += '<script type="text/javascript" src="'+tiledeskScriptBaseLocation+'/runtime.js"></script>';
|
|
49
|
-
srcTileDesk += '<script type="text/javascript" src="'+tiledeskScriptBaseLocation+'/polyfills.js"></script>';
|
|
75
|
+
srcTileDesk += '<script async type="text/javascript" src="'+tiledeskScriptBaseLocation+'/runtime.js"></script>';
|
|
76
|
+
srcTileDesk += '<script async type="text/javascript" src="'+tiledeskScriptBaseLocation+'/polyfills.js"></script>';
|
|
77
|
+
srcTileDesk += '<script async type="text/javascript" src="'+tiledeskScriptBaseLocation+'/vendor.js"></script>';
|
|
78
|
+
srcTileDesk += '<script async type="text/javascript" src="'+tiledeskScriptBaseLocation+'/main.js"></script>';
|
|
50
79
|
srcTileDesk += '<link type="text/css" rel="stylesheet" href="'+tiledeskScriptBaseLocation+'/styles.css" media="all"></link>';
|
|
51
|
-
srcTileDesk += '<script type="text/javascript" src="'+tiledeskScriptBaseLocation+'/vendor.js"></script>';
|
|
52
|
-
srcTileDesk += '<script type="text/javascript" src="'+tiledeskScriptBaseLocation+'/main.js"></script>';
|
|
53
80
|
srcTileDesk += '</body>';
|
|
54
81
|
srcTileDesk += '</html>';
|
|
55
82
|
|
|
@@ -171,7 +198,7 @@ function loadIframe(tiledeskScriptBaseLocation) {
|
|
|
171
198
|
}else {
|
|
172
199
|
ifrm.srcdoc = srcTileDesk
|
|
173
200
|
}
|
|
174
|
-
|
|
201
|
+
|
|
175
202
|
|
|
176
203
|
}
|
|
177
204
|
|
|
@@ -321,7 +348,10 @@ function initCSSWidget(tiledeskScriptBaseLocation) {
|
|
|
321
348
|
link.rel = 'stylesheet';
|
|
322
349
|
link.type = 'text/css';
|
|
323
350
|
link.href = tiledeskScriptBaseLocation+'/iframe-style.css';
|
|
324
|
-
link.media = '
|
|
351
|
+
link.media = 'print';
|
|
352
|
+
link.onload = function(){
|
|
353
|
+
link.media = 'all'
|
|
354
|
+
}
|
|
325
355
|
head.appendChild(link);
|
|
326
356
|
// }
|
|
327
357
|
}
|