@chat21/chat21-web-widget 5.0.56-rc.1 → 5.0.56-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.github/workflows/build.yml +1 -0
  2. package/CHANGELOG.md +13 -0
  3. package/angular.json +6 -7
  4. package/package.json +5 -4
  5. package/src/app/app.component.html +1 -11
  6. package/src/app/app.component.scss +12 -13
  7. package/src/app/app.component.spec.ts +0 -2
  8. package/src/app/app.component.ts +29 -35
  9. package/src/app/app.module.ts +4 -5
  10. package/src/app/component/conversation-detail/conversation/conversation.component.html +1 -10
  11. package/src/app/component/conversation-detail/conversation/conversation.component.scss +5 -428
  12. package/src/app/component/conversation-detail/conversation/conversation.component.ts +23 -25
  13. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +4 -63
  14. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +11 -81
  15. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +0 -3
  16. package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +6 -6
  17. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +7 -32
  18. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +11 -11
  19. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +8 -8
  20. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.html +4 -25
  21. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.scss +5 -5
  22. package/src/app/component/conversation-detail/conversation-header/conversation-header.component.ts +4 -88
  23. package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.html +7 -16
  24. package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.ts +2 -26
  25. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.html +1 -11
  26. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.scss +5 -5
  27. package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +2 -19
  28. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +10 -42
  29. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.scss +1 -2
  30. package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.ts +2 -3
  31. package/src/app/component/form/form-builder/form-builder.component.html +0 -1
  32. package/src/app/component/form/form-builder/form-builder.component.scss +1 -1
  33. package/src/app/component/form/form-builder/form-builder.component.ts +4 -5
  34. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.scss +1 -2
  35. package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.ts +2 -3
  36. package/src/app/component/form/inputs/form-label/form-label.component.ts +0 -1
  37. package/src/app/component/form/inputs/form-text/form-text.component.scss +3 -13
  38. package/src/app/component/form/inputs/form-text/form-text.component.ts +1 -2
  39. package/src/app/component/form/inputs/form-textarea/form-textarea.component.html +0 -13
  40. package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +4 -4
  41. package/src/app/component/form/inputs/form-textarea/form-textarea.component.ts +0 -10
  42. package/src/app/component/form/prechat-form/prechat-form.component.html +0 -2
  43. package/src/app/component/form/prechat-form/prechat-form.component.scss +2 -2
  44. package/src/app/component/form/prechat-form/prechat-form.component.ts +2 -2
  45. package/src/app/component/home/home.component.scss +7 -7
  46. package/src/app/component/home/home.component.ts +1 -4
  47. package/src/app/component/home-conversations/home-conversations.component.scss +7 -7
  48. package/src/app/component/home-conversations/home-conversations.component.ts +9 -12
  49. package/src/app/component/last-message/last-message.component.scss +4 -4
  50. package/src/app/component/last-message/last-message.component.ts +4 -7
  51. package/src/app/component/launcher-button/launcher-button.component.ts +3 -3
  52. package/src/app/component/list-all-conversations/list-all-conversations.component.scss +2 -2
  53. package/src/app/component/list-all-conversations/list-all-conversations.component.ts +3 -3
  54. package/src/app/component/list-conversations/list-conversations.component.html +1 -1
  55. package/src/app/component/list-conversations/list-conversations.component.scss +3 -3
  56. package/src/app/component/list-conversations/list-conversations.component.ts +3 -6
  57. package/src/app/component/menu-options/menu-options.component.html +1 -8
  58. package/src/app/component/menu-options/menu-options.component.scss +4 -4
  59. package/src/app/component/menu-options/menu-options.component.ts +1 -1
  60. package/src/app/component/message/bubble-message/bubble-message.component.html +1 -2
  61. package/src/app/component/message/bubble-message/bubble-message.component.scss +3 -3
  62. package/src/app/component/message/bubble-message/bubble-message.component.spec.ts +0 -2
  63. package/src/app/component/message/bubble-message/bubble-message.component.ts +1 -14
  64. package/src/app/component/message/buttons/action-button/action-button.component.scss +6 -6
  65. package/src/app/component/message/buttons/link-button/link-button.component.scss +7 -7
  66. package/src/app/component/message/buttons/text-button/text-button.component.scss +8 -8
  67. package/src/app/component/message/frame/frame.component.scss +1 -1
  68. package/src/app/component/message/frame/frame.component.ts +1 -1
  69. package/src/app/component/message/html/html.component.scss +4 -4
  70. package/src/app/component/message/html/html.component.ts +1 -2
  71. package/src/app/component/message/image/image.component.scss +1 -1
  72. package/src/app/component/message/image/image.component.ts +2 -3
  73. package/src/app/component/message/info-message/info-message.component.html +2 -1
  74. package/src/app/component/message/info-message/info-message.component.scss +6 -6
  75. package/src/app/component/message/like-unlike/like-unlike.component.scss +1 -1
  76. package/src/app/component/message/like-unlike/like-unlike.component.ts +2 -2
  77. package/src/app/component/message/text/text.component.scss +1 -1
  78. package/src/app/component/message/text/text.component.ts +1 -1
  79. package/src/app/component/message-attachment/message-attachment.component.ts +1 -1
  80. package/src/app/component/selection-department/selection-department.component.scss +6 -6
  81. package/src/app/component/selection-department/selection-department.component.ts +2 -2
  82. package/src/app/component/send-button/send-button.component.ts +1 -2
  83. package/src/app/component/star-rating-widget/star-rating-widget.component.scss +6 -6
  84. package/src/app/component/star-rating-widget/star-rating-widget.component.ts +2 -2
  85. package/src/app/pipe/date-ago.pipe.spec.ts +8 -0
  86. package/src/app/pipe/date-ago.pipe.ts +42 -0
  87. package/src/app/providers/app-config.service.ts +0 -1
  88. package/src/app/providers/global-settings.service.ts +3 -31
  89. package/src/app/providers/star-rating-widget.service.ts +4 -4
  90. package/src/app/providers/translator.service.ts +3 -11
  91. package/src/app/providers/waiting.service.ts +2 -2
  92. package/src/app/sass/_variables.scss +29 -26
  93. package/src/app/utils/globals.ts +4 -34
  94. package/src/app/utils/rules.ts +5 -7
  95. package/src/app/utils/utils.ts +47 -37
  96. package/src/assets/i18n/en.json +0 -2
  97. package/src/assets/i18n/es.json +0 -2
  98. package/src/assets/i18n/fr.json +0 -2
  99. package/src/assets/i18n/it.json +0 -2
  100. package/src/assets/twp/chatbot-panel.html +4 -0
  101. package/src/assets/twp/index.html +2 -57
  102. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +15 -23
  103. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +21 -20
  104. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +15 -13
  105. package/src/chat21-core/providers/firebase/firebase-conversations-handler.ts +16 -23
  106. package/src/chat21-core/providers/firebase/firebase-groups-handler.ts +15 -11
  107. package/src/chat21-core/providers/firebase/firebase-image-repo.ts +13 -4
  108. package/src/chat21-core/providers/firebase/firebase-init-service.ts +3 -3
  109. package/src/chat21-core/providers/firebase/firebase-notifications.ts +11 -9
  110. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +14 -11
  111. package/src/chat21-core/providers/firebase/firebase-typing.service.ts +17 -11
  112. package/src/chat21-core/providers/firebase/firebase-upload.service.ts +12 -9
  113. package/src/chat21-core/providers/localSessionStorage.ts +2 -15
  114. package/src/chat21-core/providers/mqtt/chat-service.ts +12 -2
  115. package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +1 -34
  116. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +4 -6
  117. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +1 -11
  118. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +13 -7
  119. package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +3 -3
  120. package/src/chat21-core/providers/mqtt/mqtt-typing.service.ts +3 -3
  121. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +0 -1
  122. package/src/chat21-core/utils/user-typing/user-typing.component.scss +3 -3
  123. package/src/chat21-core/utils/utils.ts +46 -118
  124. package/src/launch.js +42 -12
  125. package/src/models/message.ts +0 -23
  126. package/src/test-new.html +0 -6
  127. package/src/app/providers/settings-saver.service.spec.ts +0 -17
  128. package/src/app/providers/settings-saver.service.ts +0 -56
  129. package/src/app/providers/storage.service.spec.ts +0 -16
  130. package/src/app/providers/storage.service.ts +0 -220
  131. package/src/app/utils/translations.ts +0 -122
@@ -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, getFromNow, searchIndexInArrayForUid } from '../../utils/utils';
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, getFromNow, searchIndexInArrayForUid } from '../../utils/utils';
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
- import 'firebase/messaging';
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): void {
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,7 +1,7 @@
1
- @import 'src/app/sass/variables';
1
+ // @import 'src/app/sass/variables';
2
2
  :root {
3
- --bubbleReceivedBackgroundColor: $blue;
4
- --foregroundColor: $bck-msg-sent;
3
+ --bubbleReceivedBackgroundColor: var(--blue);
4
+ --foregroundColor: var(--bck-msg-sent);
5
5
  }
6
6
 
7
7
 
@@ -1,10 +1,6 @@
1
- import * as moment from 'moment';
2
- import 'moment/locale/it.js';
3
-
4
- // firebase
5
- import * as firebase from 'firebase/app';
6
- import 'firebase/storage';
7
-
1
+ import * as dayjs from 'dayjs'
2
+ import * as duration from 'dayjs/plugin/duration'
3
+ dayjs.extend(duration)
8
4
  // tslint:disable-next-line:max-line-length
9
5
 
10
6
  import { ConversationModel } from '../models/conversation';
@@ -90,38 +86,38 @@ export function contactsRef(tenant) {
90
86
  /**
91
87
  * @deprecated
92
88
  */
93
- export function setHeaderDate(translate, timestamp): string {
94
- // const LABEL_TODAY = translate.get('LABEL_TODAY');
95
- // const LABEL_TOMORROW = translate.get('LABEL_TOMORROW');
89
+ // export function setHeaderDate(translate, timestamp): string {
90
+ // // const LABEL_TODAY = translate.get('LABEL_TODAY');
91
+ // // const LABEL_TOMORROW = translate.get('LABEL_TOMORROW');
96
92
 
97
- const date = new Date(timestamp);
98
- const now: Date = new Date();
99
- let labelDays = '';
100
- if (now.getFullYear() !== date.getFullYear()) {
101
- // quest'anno: data esatta
102
- const month = date.getMonth() + 1;
103
- labelDays = date.getDay() + '/' + month + '/' + date.getFullYear();
104
- } else if (now.getMonth() !== date.getMonth()) {
105
- // questo mese: data esatta
106
- const month = date.getMonth() + 1;
107
- labelDays = date.getDay() + '/' + month + '/' + date.getFullYear();
108
- } else if (now.getDay() === date.getDay()) {
109
- // oggi: oggi
110
- labelDays = moment().calendar(timestamp).split(' ')[0].toLocaleLowerCase();
111
- // labelDays = LABEL_TODAY;
112
- } else if (now.getDay() - date.getDay() === 1) {
113
- // ieri: ieri
114
- labelDays = moment().calendar(timestamp).split(' ')[0].toLocaleLowerCase();
115
- // labelDays = LABEL_TOMORROW;
116
- } else {
117
- // questa settimana: giorno
118
- labelDays = convertDayToString(translate, date.getDay());
119
- }
120
- // se le date sono diverse o la data di riferimento non è impostata
121
- // ritorna la data calcolata
122
- // altrimenti torna null
123
- return labelDays;
124
- }
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
+ // }
125
121
 
126
122
 
127
123
 
@@ -137,9 +133,9 @@ export function setLastDate(translate, timestamp): string {
137
133
  const LABEL_TO = translate.get('LABEL_TO');
138
134
  const LABEL_LAST_ACCESS = translate.get('LABEL_LAST_ACCESS');
139
135
 
140
- var date = new Date(timestamp);
136
+ let date = new Date(timestamp);
141
137
  let now: Date = new Date();
142
- var labelDays = '';
138
+ let labelDays = '';
143
139
  if (now.getFullYear() !== date.getFullYear()) {
144
140
  const month = date.getMonth() + 1;
145
141
  labelDays = date.getDay() + '/' + month + '/' + date.getFullYear();
@@ -454,91 +450,23 @@ export function compareValues(key, order = 'asc') {
454
450
  };
455
451
  }
456
452
 
457
- /** */
458
- export function getNowTimestamp() {
459
- //console.log("timestamp:", moment().valueOf());
460
- return moment().valueOf();
461
- }
462
-
463
- export function getFormatData(timestamp): string {
464
- var dateString = moment.unix(timestamp / 1000).format('L');
465
- // const date = new Date(timestamp);
466
- // const labelDays = date.getDay()+"/"+date.getMonth()+"/"+date.getFullYear();
467
- return dateString;
468
- }
469
453
 
470
- export function getTimeLastMessage(timestamp: string) {
471
- const timestampNumber = parseInt(timestamp, null) / 1000;
472
- const time = getFromNow(timestampNumber);
473
- return time;
474
- }
475
-
476
- // export function getFromNow(windowContext, timestamp) {
477
- // let browserLang = windowContext.navigator.language;
478
- // if (this.g.lang && this.g.lang !== '') {
479
- // browserLang = this.g.lang;
480
- // }
481
- // moment.locale(browserLang);
482
- // // console.log('getFromNow - browserLang: ', browserLang);
483
- // const date_as_string = moment.unix(timestamp).fromNow();
484
- // 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;
485
459
  // }
486
460
 
487
- export function getFromNow(timestamp): string {
488
- // var fullDate = new Date(this.news.date.$date)
489
- // console.log('FULL DATE: ', fullDate);
490
- // var month = '' + (fullDate.getMonth() + 1)
491
- // var day = '' + fullDate.getDate()
492
- // var year = fullDate.getFullYear()
493
- // var hour = '' + fullDate.getHours()
494
- // var min = fullDate.getMinutes()
495
- // var sec = fullDate.getSeconds()
496
- // if (month.length < 2) month = '0' + month;
497
- // if (day.length < 2) day = '0' + day;
498
- // if (hour.length < 2) hour = '0' + hour;
499
- // console.log('Giorno ', day)
500
- // console.log('Mese ', month)
501
- // console.log('Anno ', year)
502
- // console.log('Ora ', hour)
503
- // console.log('Min ', min)
504
- // console.log('Sec', sec)
505
-
506
- // this.dateFromNow = moment(year + month + day, "YYYYMMDD").fromNow()
507
- // let date_as_string = moment(year + month + day, "YYYYMMDD").fromNow()
508
-
509
- // let date_as_string = moment(year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec).fromNow()
510
- // let date_as_string = moment("2017-07-03 08:33:37").fromNow()
511
- //var day = new Date(2017, 8, 16);
512
- //let date_as_string = moment(day);
513
-
514
- // var dateString = moment.unix(timestamp).format("MM/DD/YYYY");
515
- // console.log(moment(dateString).fromNow(), dateString);
516
- // var date = "Thu Aug 19 2017 19:58:03 GMT+0000 (GMT)";
517
- // console.log(moment(date).fromNow()); // 1 hour ago
518
- // console.log(moment.unix(1483228800).fromNow());
519
- // console.log(moment.unix(1501545600).fromNow());
520
- //console.log("timestamp: ",timestamp, " - 1483228800 - ", moment.unix(1483228800).fromNow());
521
- // console.log();
522
-
523
- //console.log("window.navigator.language: ", window.navigator.language);
524
-
525
- moment.locale(window.navigator.language);
526
- let date_as_string = moment.unix(timestamp).fromNow();
527
- return date_as_string;
528
- }
529
-
530
-
531
461
  export function getDateDifference(startTimestampDate, endTimestampDate){
532
- // var startTime = moment.unix(startTimestampDate);
533
- // var endTime = moment.unix(endTimestampDate);
534
-
535
- const startTime = moment(startTimestampDate);
536
- const endTime = moment(endTimestampDate);
537
- 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));
538
466
  const days = duration.asDays()
539
467
  const hours = duration.asHours();
540
468
  const minutes = duration.asMinutes();
541
-
469
+
542
470
  return {days, hours, minutes}
543
471
  }
544
472
 
package/src/launch.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** */
2
2
  ready(function() {
3
- // console.log('DOM is ready, call initWidget');
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
- callbackFunction()
14
- else
15
- document.addEventListener("DOMContentLoaded", callbackFunction)
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 = 'all';
351
+ link.media = 'print';
352
+ link.onload = function(){
353
+ link.media = 'all'
354
+ }
325
355
  head.appendChild(link);
326
356
  // }
327
357
  }
@@ -1,7 +1,4 @@
1
1
  // firebase
2
- import * as firebase from 'firebase/app';
3
- import 'firebase/database';
4
-
5
2
  export class MessageModel {
6
3
  public sender_urlImage: string;
7
4
  constructor(
@@ -21,24 +18,4 @@ export class MessageModel {
21
18
  public projectid: string,
22
19
  public emoticon?: boolean
23
20
  ) { }
24
-
25
- // asFirebaseMessage(): Object {
26
- // const message = {
27
- // language: this.language,
28
- // recipient: this.recipient,
29
- // recipient_fullname: this.recipient_fullname,
30
- // sender: this.sender,
31
- // sender_fullname: this.sender_fullname,
32
- // status: this.status,
33
- // metadata: this.metadata,
34
- // text: this.text,
35
- // timestamp: firebase.database.ServerValue.TIMESTAMP,
36
- // type: this.type,
37
- // attributes: this.attributes,
38
- // channel_type: this.channel_type
39
- // // projectid: this.projectid // removed by sponziello
40
- // };
41
-
42
- // return message;
43
- // }
44
21
  }
package/src/test-new.html CHANGED
@@ -70,12 +70,6 @@
70
70
  window.Tiledesk('open');
71
71
 
72
72
 
73
- setTimeout(function() {
74
- console.log("window.Tiledesk", window.Tiledesk);
75
- // window.Tiledesk('close')
76
- // window.Tiledesk('signInWithCustomToken', 'TOKENNNNN');
77
- },10000);
78
-
79
73
 
80
74
 
81
75
  // window.tileDeskAsyncInit = function() {
@@ -1,17 +0,0 @@
1
- import { Globals } from './../utils/globals';
2
- import { TestBed, inject } from '@angular/core/testing';
3
-
4
- import { SettingsSaverService } from './settings-saver.service';
5
- import { AppStorageService } from '../../chat21-core/providers/abstract/app-storage.service';
6
-
7
- describe('SettingsSaverService', () => {
8
- beforeEach(() => {
9
- TestBed.configureTestingModule({
10
- providers: [SettingsSaverService, Globals, AppStorageService]
11
- });
12
- });
13
-
14
- it('should be created', inject([SettingsSaverService], (service: SettingsSaverService) => {
15
- expect(service).toBeTruthy();
16
- }));
17
- });
@@ -1,56 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { AppStorageService } from '../../chat21-core/providers/abstract/app-storage.service';
3
- import { Globals } from '../utils/globals';
4
- import { stringToBoolean } from '../utils/utils';
5
-
6
-
7
- @Injectable()
8
- export class SettingsSaverService {
9
-
10
- constructor(
11
- private g: Globals,
12
- private appStorageService: AppStorageService
13
- ) {}
14
-
15
- /**
16
- * recupero dallo storage globals e lo assegno a globalsParameters
17
- * ogni successiva modifica di globals verrà salvata in appStorageService
18
- */
19
- initialize() {
20
- // if (this.appStorageService.getItem('globals')) {
21
- // this.globalsParameters = this.appStorageService.getItem('globals');
22
- // }
23
- this.setGlobalsSubscription();
24
- }
25
-
26
- /**
27
- *
28
- */
29
- public setGlobalsSubscription() {
30
- const that = this;
31
- this.g.obsObjChanged.subscribe((obj) => {
32
- if (obj) {
33
- that.setVariable(obj.key, obj.val);
34
- }
35
- });
36
- }
37
-
38
- /**
39
- * modifico il valore di un parametro e lo salvo nel dizionario
40
- * pubblico il dizionario modificato
41
- * salvo il dictionary in local
42
- * @param key
43
- * @param value
44
- */
45
- public setVariable(key: string, value: any) {
46
- const val = JSON.stringify(value);
47
- // console.log('========================================');
48
- // console.log('key: ', key);
49
- // console.log('val: ', val);
50
- // console.log('========================================');
51
- // this.appStorageService.setItem(key, stringToBoolean(value));
52
-
53
- //this.g.wdLog(['SET key: ', key, ' - VAL: ', stringToBoolean(value), ' ---------->', JSON.stringify(value) ]);
54
- }
55
-
56
- }
@@ -1,16 +0,0 @@
1
- import { Globals } from './../utils/globals';
2
- import { TestBed, inject } from '@angular/core/testing';
3
-
4
- import { StorageService } from './storage.service';
5
-
6
- describe('StorageService', () => {
7
- beforeEach(() => {
8
- TestBed.configureTestingModule({
9
- providers: [StorageService, Globals]
10
- });
11
- });
12
-
13
- it('should be created', inject([StorageService], (service: StorageService) => {
14
- expect(service).toBeTruthy();
15
- }));
16
- });