@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.
Files changed (96) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +9 -0
  3. package/config.xml +11 -2
  4. package/env.sample +2 -0
  5. package/package.json +1 -1
  6. package/resources/Android/splash/drawable-land-hdpi-screen.png +0 -0
  7. package/resources/Android/splash/drawable-land-ldpi-screen.png +0 -0
  8. package/resources/Android/splash/drawable-land-mdpi-screen.png +0 -0
  9. package/resources/Android/splash/drawable-land-xhdpi-screen.png +0 -0
  10. package/resources/Android/splash/drawable-land-xxhdpi-screen.png +0 -0
  11. package/resources/Android/splash/drawable-land-xxxhdpi-screen.png +0 -0
  12. package/resources/Android/splash/drawable-port-hdpi-screen.png +0 -0
  13. package/resources/Android/splash/drawable-port-ldpi-screen.png +0 -0
  14. package/resources/Android/splash/drawable-port-mdpi-screen.png +0 -0
  15. package/resources/Android/splash/drawable-port-xhdpi-screen.png +0 -0
  16. package/resources/Android/splash/drawable-port-xxhdpi-screen.png +0 -0
  17. package/resources/Android/splash/drawable-port-xxxhdpi-screen.png +0 -0
  18. package/resources/Android/splash.png +0 -0
  19. package/src/app/app-routing.module.ts +21 -17
  20. package/src/app/app.component.html +6 -3
  21. package/src/app/app.component.ts +259 -55
  22. package/src/app/app.module.ts +16 -8
  23. package/src/app/chatlib/conversation-detail/conversation-content/conversation-content.component.html +1 -1
  24. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.html +4 -4
  25. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.scss +8 -2
  26. package/src/app/chatlib/conversation-detail/ion-conversation-detail/ion-conversation-detail.component.ts +6 -1
  27. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.html +7 -2
  28. package/src/app/chatlib/conversation-detail/message/bubble-message/bubble-message.component.ts +47 -2
  29. package/src/app/chatlib/conversation-detail/message/image/image.component.html +7 -6
  30. package/src/app/chatlib/conversation-detail/message/image/image.component.ts +20 -1
  31. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +39 -9
  32. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +8 -144
  33. package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.ts +14 -17
  34. package/src/app/chatlib/list-conversations-component/list-conversations/list-conversations.component.html +1 -1
  35. package/src/app/components/authentication/login/login.component.html +10 -10
  36. package/src/app/components/authentication/login/login.component.ts +2 -1
  37. package/src/app/components/conversation-detail/bubble-my-message/bubble-my-message.component.ts +1 -1
  38. package/src/app/components/conversation-detail/bubble-others-message/bubble-others-message.component.ts +1 -1
  39. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.html +17 -12
  40. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.scss +12 -0
  41. package/src/app/components/conversation-detail/header-conversation-detail/header-conversation-detail.component.ts +21 -5
  42. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +3 -2
  43. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +22 -17
  44. package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +46 -5
  45. package/src/app/components/ddp-header/ddp-header.component.html +1 -1
  46. package/src/app/components/ddp-header/ddp-header.component.ts +4 -2
  47. package/src/app/components/image-viewer/image-viewer.component.html +23 -0
  48. package/src/app/components/image-viewer/image-viewer.component.scss +107 -0
  49. package/src/app/components/image-viewer/image-viewer.component.spec.ts +24 -0
  50. package/src/app/components/image-viewer/image-viewer.component.ts +38 -0
  51. package/src/app/components/project-item/project-item.component.html +147 -0
  52. package/src/app/components/project-item/project-item.component.scss +669 -0
  53. package/src/app/components/project-item/project-item.component.spec.ts +24 -0
  54. package/src/app/components/project-item/project-item.component.ts +317 -0
  55. package/src/app/components/utils/avatar-profile/avatar-profile.component.html +7 -0
  56. package/src/app/components/utils/avatar-profile/avatar-profile.component.ts +22 -5
  57. package/src/app/pages/authentication/login/login.page.html +1 -2
  58. package/src/app/pages/authentication/login/login.page.ts +1 -1
  59. package/src/app/pages/conversation-detail/conversation-detail.page.html +5 -3
  60. package/src/app/pages/conversation-detail/conversation-detail.page.ts +122 -30
  61. package/src/app/pages/conversations-list/conversations-list.page.html +44 -23
  62. package/src/app/pages/conversations-list/conversations-list.page.scss +290 -127
  63. package/src/app/pages/conversations-list/conversations-list.page.ts +172 -12
  64. package/src/app/pages/unassigned-conversations/unassigned-conversations-routing.module.ts +17 -0
  65. package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +22 -0
  66. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +22 -0
  67. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +79 -0
  68. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.spec.ts +24 -0
  69. package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +108 -0
  70. package/src/app/services/nav-proxy.service.ts +1 -1
  71. package/src/app/services/tiledesk/tiledesk.service.ts +22 -1
  72. package/src/app/services/websocket/websocket-js.ts +557 -0
  73. package/src/app/services/websocket/websocket.service.spec.ts +12 -0
  74. package/src/app/services/websocket/websocket.service.ts +274 -0
  75. package/src/app/shared/shared.module.ts +7 -1
  76. package/src/assets/i18n/en.json +9 -1
  77. package/src/assets/i18n/it.json +9 -1
  78. package/src/assets/js/chat21client.js +141 -67
  79. package/src/assets/transparent.png +0 -0
  80. package/src/chat-config-pre-test.json +3 -1
  81. package/src/chat-config-template.json +3 -1
  82. package/src/chat-config.json +3 -1
  83. package/src/chat21-core/providers/chat-manager.ts +3 -3
  84. package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +1 -1
  85. package/src/chat21-core/providers/firebase/firebase-auth-service.ts +6 -6
  86. package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
  87. package/src/chat21-core/providers/firebase/firebase-notifications.ts +1 -1
  88. package/src/chat21-core/providers/firebase/firebase-presence.service.ts +2 -2
  89. package/src/chat21-core/providers/firebase/firebase-typing.service.ts +1 -1
  90. package/src/chat21-core/providers/firebase/firebase-upload.service.ts +1 -1
  91. package/src/chat21-core/providers/mqtt/mqtt-auth-service.ts +27 -27
  92. package/src/chat21-core/providers/mqtt/mqtt-conversations-handler.ts +13 -5
  93. package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +101 -11
  94. package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +13 -4
  95. package/src/chat21-core/utils/utils.ts +1 -1
  96. package/src/firebase-messaging-sw-template.js +1 -1
@@ -0,0 +1,274 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ import { WebSocketJs } from "./websocket-js";
4
+ import { AppConfigProvider } from '../app-config';
5
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
6
+ import { map } from 'rxjs/operators';
7
+ import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
+ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
+
10
+ @Injectable({
11
+ providedIn: 'root'
12
+ })
13
+ export class WebsocketService {
14
+ private apiUrl: string;
15
+ public currentProjectUserAvailability$: BehaviorSubject<[]> = new BehaviorSubject<[]>([])
16
+
17
+ wsService: WebSocketJs;
18
+ wsRequestsList: any;
19
+ public wsRequestsList$: BehaviorSubject<Request[]> = new BehaviorSubject<Request[]>([]);
20
+
21
+ private logger: LoggerService = LoggerInstance.getInstance();
22
+
23
+ constructor(
24
+ public webSocketJs: WebSocketJs,
25
+ public http: HttpClient,
26
+ public appConfigProvider: AppConfigProvider
27
+
28
+ ) {
29
+ this.apiUrl = appConfigProvider.getConfig().apiUrl;
30
+ // SERVER_BASE_URL: 'https://tiledesk-server-pre.herokuapp.com/'
31
+ // CHAT IONIC API URL https://tiledesk-server-pre.herokuapp.com/"
32
+ }
33
+
34
+
35
+ subscriptionToWsCurrentProjectUserAvailability(projectid, prjctuserid) {
36
+ var self = this;
37
+ const path = '/' + projectid + '/project_users/' + prjctuserid
38
+ this.logger.log('[WS-SERV] - SUBSCR (REF) TO WS CURRENT USERS PATH: ', path);
39
+
40
+ return new Promise(function (resolve, reject) {
41
+
42
+ self.webSocketJs.ref(path, 'subscriptionToWsCurrentUser_allProject',
43
+ function (data, notification) {
44
+ // console.log("[WS-SERV] SUBSCR TO WS CURRENT PROJECT-USER AVAILABILITY - CREATE - data ", data);
45
+ resolve(data)
46
+ // self.currentUserWsAvailability$.next(data.user_available);
47
+ self.currentProjectUserAvailability$.next(data)
48
+
49
+ }, function (data, notification) {
50
+ resolve(data)
51
+ // console.log("[WS-SERV] SUBSCR TO WS CURRENT PROJECT-USER AVAILABILITY - UPDATE - data ", data);
52
+ self.currentProjectUserAvailability$.next(data)
53
+
54
+ }, function (data, notification) {
55
+ resolve(data)
56
+ if (data) {
57
+ // console.log("[WS-SERV] SUBSCR TO WS CURRENT PROJECT-USER AVAILABILITY - UPDATE - data", data);
58
+ }
59
+ });
60
+
61
+ })
62
+ }
63
+
64
+ public updateCurrentUserAvailability(token: string, projectId: string, user_is_available: boolean) {
65
+ const httpOptions = {
66
+ headers: new HttpHeaders({
67
+ 'Accept': 'application/json',
68
+ 'Content-Type': 'application/json',
69
+ Authorization: token
70
+ })
71
+ };
72
+
73
+ const body = { 'user_available': user_is_available };
74
+
75
+ const url = this.apiUrl + projectId + '/project_users/';
76
+
77
+ this.logger.log('[WS-SERV] - UPDATE CURRENT PROJECT-USER AVAILABILITY (PUT) URL ', url);
78
+ return this.http
79
+ .put(url, body, httpOptions)
80
+ .pipe(map((res: any) => {
81
+ this.logger.log('[WS-SERV] - UPDATE CURRENT PROJECT-USER AVAILABILITY (PUT) ', res);
82
+ return res
83
+ }))
84
+ }
85
+
86
+ subscriptionToWsConversations(project_id) {
87
+ this.logger.log("[WS-SERV] - CALLED SUBSC TO WS CONVS - PROJECT ID ", project_id);
88
+ var self = this;
89
+ this.wsRequestsList = [];
90
+
91
+ this.webSocketJs.ref('/' + project_id + '/requests', 'getCurrentProjectAndSubscribeTo_WsRequests',
92
+
93
+ function (data, notification) {
94
+ // self.logger.log("[WS-SERV] - CONVS - CREATE DATA ", data);
95
+ if (data) {
96
+ // ------------------------------------------------
97
+ // @ Agents - pass in data agents get from snapshot
98
+ // ------------------------------------------------
99
+ if (data.snapshot && data.snapshot.agents) {
100
+
101
+ data.agents = data['snapshot']["agents"]
102
+ } else if (data.agents) {
103
+ // ---------------------------------------------------------------
104
+ // @ Agents - else (if exist agents in data) pass agents from data
105
+ // ---------------------------------------------------------------
106
+ data.agents = data.agents
107
+ }
108
+
109
+ // ---------------------------------------------
110
+ // @ Lead - pass in data lead get from snapshot
111
+ // ----------------------------------------------
112
+ if (data.snapshot && data.snapshot.lead) {
113
+
114
+ data.lead = data['snapshot']["lead"];
115
+
116
+ } else {
117
+ // ---------------------------------------------------------------------
118
+ // @ Lead - else (if exist lead in attributes) pass lead from attributes
119
+ // ---------------------------------------------------------------------
120
+ if (data['attributes'] && data['attributes'] !== undefined) {
121
+
122
+ if (data['attributes']['userFullname'] && data['attributes']['userEmail'] && data['attributes']['requester_id']) {
123
+ data.lead = { 'fullname': data['attributes']['userFullname'], 'email': data['attributes']['userEmail'], 'lead_id': data['attributes']['requester_id'] }
124
+ }
125
+ // ---------------------------------------------------------
126
+ // @ Lead - else (if exist lead in data) pass lead from data
127
+ // ---------------------------------------------------------
128
+ else if (data.lead) {
129
+ data.lead = data.lead
130
+ }
131
+ } else if (data.lead) {
132
+ data.lead = data.lead;
133
+ }
134
+ }
135
+
136
+ // -----------------------------------------------------
137
+ // @ Requester pass in data requester get from snapshot
138
+ // -----------------------------------------------------
139
+ if (data.snapshot && data.snapshot.requester) {
140
+
141
+ data.requester = data['snapshot']["requester"]
142
+
143
+ } else if (data.requester) {
144
+ // ---------------------------------------------------------------------
145
+ // @ Lead - else (if exist requester in data) pass requester from data
146
+ // ---------------------------------------------------------------------
147
+ data.requester = data.requester
148
+ }
149
+
150
+ // ------------------------------------------------------
151
+ // @ Department pass in data department get from snapshot
152
+ // ------------------------------------------------------
153
+ if (data.snapshot && data.snapshot.department) {
154
+
155
+ data.department = data['snapshot']["department"]
156
+
157
+ } else if (data.department) {
158
+ // ----------------------------------------------------------------------------
159
+ // @ Department - else (if exist department in data) pass department from data
160
+ // ----------------------------------------------------------------------------
161
+ data.department = data.department
162
+ }
163
+ }
164
+
165
+ // https://stackoverflow.com/questions/36719477/array-push-and-unique-items
166
+ const index = self.wsRequestsList.findIndex((e) => e.id === data.id);
167
+
168
+ if (index === -1) {
169
+ self.addWsRequests(data)
170
+ // self.logger.log("[WS-REQUESTS-SERV] - CREATE - ADD REQUESTS");
171
+ } else {
172
+ // self.logger.log("[WS-REQUESTS-SERV] - CREATE - REQUEST ALREADY EXIST - NOT ADD");
173
+ }
174
+
175
+ }, function (data, notification) {
176
+
177
+ // self.logger.log("[WS-SERV] - CONVS - UPDATE DATA ", data);
178
+
179
+ // -------------------------------------------------------
180
+ // @ Agents (UPDATE) pass in data agents get from snapshot
181
+ // -------------------------------------------------------
182
+ if (data.snapshot && data.snapshot.agents) {
183
+ data.agents = data['snapshot']["agents"]
184
+ } else if (data.agents) {
185
+ // ---------------------------------------------------------------
186
+ // @ Agents - else (if exist agents in data) pass agents from data
187
+ // ---------------------------------------------------------------
188
+ data.agents = data.agents
189
+ }
190
+ self.updateWsRequests(data)
191
+
192
+
193
+ }, function (data, notification) {
194
+ // self.logger.log("[WS-SERV] - CONVS - ON-DATA - DATA ", data);
195
+
196
+ }
197
+ );
198
+ }
199
+
200
+ /**
201
+ * REQUESTS publish @ the CREATE
202
+ *
203
+ * @param request
204
+ */
205
+ addWsRequests(request: Request) {
206
+ if (request !== null && request !== undefined) {
207
+ this.wsRequestsList.push(request);
208
+ }
209
+
210
+ if (this.wsRequestsList) {
211
+ // -----------------------------------------------------------------------------------------------------
212
+ // publish all REQUESTS
213
+ // -----------------------------------------------------------------------------------------------------
214
+ this.wsRequestsList$.next(this.wsRequestsList);
215
+ }
216
+ }
217
+
218
+ /**
219
+ * REQUESTS - publish @ the UPDATE
220
+ * overwrite the request in the requests-list with the upcoming request if the id is the same
221
+ * remove the request from the requests-list if the status is === 1000 (i.e. archived request)
222
+ *
223
+ * @param request
224
+ */
225
+ updateWsRequests(request: any) {
226
+
227
+ // QUANDO UNA RICHIESTA VIENE EMESSA CON preflight = true non passa dal ON CREATE
228
+ // sull ON UPDATE VENGONO AGGIORNATE SOLO LE RICHIESTE CHE VERIFICANO LA condizione request._id === this.wsRequestsList[i]._id
229
+ // PER PUBBLICARE LE RICHIESTE CHE LA CUI PROPRIETà preflight = true E AGGIORNATA A FALSE (E CHE QUINDI è DA VISUALIZZARE) CERCO
230
+ // L'ESISTENZA DELL'ID NELLA wsRequestsList
231
+ // const hasFound = this.wsRequestsList.filter((obj: any) => {
232
+ // return obj._id === request._id;
233
+ // });
234
+ // this.logger.log("% »»» WebSocketJs WF +++++ ws-requests--- service ON-UPATE hasFound IN wsRequestsList: ", hasFound , 'THE REQUEST ID', request._id);
235
+
236
+ const index = this.wsRequestsList.findIndex((e) => e.id === request.id);
237
+ if (index === -1) {
238
+
239
+ this.wsRequestsList.push(request);
240
+ this.wsRequestsList$.next(this.wsRequestsList);
241
+
242
+ } else {
243
+ this.logger.log("[WS-SERV] - ON-UPATE - THE CONV NOT EXIST ");
244
+ }
245
+
246
+
247
+ for (let i = 0; i < this.wsRequestsList.length; i++) {
248
+ if (request._id === this.wsRequestsList[i]._id) {
249
+
250
+ if (request.status !== 1000) {
251
+
252
+ // --------------------------
253
+ // UPATE AN EXISTING REQUESTS
254
+ // --------------------------
255
+ this.logger.log("[WS-SERV] - UPDATE AN EXISTING CONV ");
256
+
257
+ this.wsRequestsList[i] = request
258
+
259
+ } else if (request.status === 1000) {
260
+
261
+ this.wsRequestsList.splice(i, 1);
262
+
263
+ }
264
+
265
+ if (this.wsRequestsList) {
266
+ this.wsRequestsList$.next(this.wsRequestsList);
267
+ this.logger.log("[WS-SERV] - ON-UPATE CONVS LIST ", this.wsRequestsList);
268
+ }
269
+ }
270
+ }
271
+ }
272
+
273
+
274
+ }
@@ -17,6 +17,7 @@ import { IonicModule } from '@ionic/angular';
17
17
 
18
18
  import { AvatarProfileComponent } from 'src/app/components/utils/avatar-profile/avatar-profile.component';
19
19
  import { DdpHeaderComponent } from 'src/app/components/ddp-header/ddp-header.component';
20
+
20
21
  import { UserPresenceComponent } from 'src/app/components/utils/user-presence/user-presence.component';
21
22
  import { UserTypingComponent } from 'src/chat21-core/utils/user-typing/user-typing.component';
22
23
  import { ListConversationsComponent } from '../chatlib/list-conversations-component/list-conversations/list-conversations.component';
@@ -37,6 +38,8 @@ import { InfoGroupComponent } from '../components/conversation-info/info-group/i
37
38
  import { TooltipModule } from 'ng2-tooltip-directive';
38
39
  import { OptionHeaderComponent } from '../components/conversation-detail/option-header/option-header.component';
39
40
  import { MessageAttachmentComponent } from '../chatlib/conversation-detail/message/message-attachment/message-attachment.component';
41
+ import { ImageViewerComponent } from '../components/image-viewer/image-viewer.component';
42
+ import { ProjectItemComponent } from '../components/project-item/project-item.component';
40
43
 
41
44
  @NgModule({
42
45
  declarations: [
@@ -46,7 +49,8 @@ import { MessageAttachmentComponent } from '../chatlib/conversation-detail/messa
46
49
  UserTypingComponent,
47
50
  ListConversationsComponent,
48
51
  IonListConversationsComponent,
49
-
52
+ ImageViewerComponent,
53
+ ProjectItemComponent,
50
54
  IonConversationDetailComponent,
51
55
  ConversationContentComponent,
52
56
  AvatarComponent,
@@ -79,6 +83,8 @@ import { MessageAttachmentComponent } from '../chatlib/conversation-detail/messa
79
83
  AutofocusDirective,
80
84
  AvatarProfileComponent,
81
85
  DdpHeaderComponent,
86
+ ImageViewerComponent,
87
+ ProjectItemComponent,
82
88
  UserPresenceComponent,
83
89
  UserTypingComponent,
84
90
  ListConversationsComponent,
@@ -179,5 +179,13 @@
179
179
  "CONTACT_ID": "Contact ID",
180
180
  "USER_ID": "User ID",
181
181
  "CLOSE_TOAST": "Close",
182
- "WAITING_FOR_NETWORK": "Waiting for network"
182
+ "WAITING_FOR_NETWORK": "Waiting for network",
183
+ "Available": "Available",
184
+ "Unavailable": "Unavailable",
185
+ "Busy": "Busy",
186
+ "YouAreAboutToJoinThisChat":"You are about to join this chat",
187
+ "Cancel": "Cancel",
188
+ "AreYouSure":"Are you sure?",
189
+ "UnassignedConversations":"Unassigned Conversations",
190
+ "NewConversations": "Nuove conversazioni"
183
191
  }
@@ -187,5 +187,13 @@
187
187
  "CONTACT_ID": "ID contatto",
188
188
  "USER_ID": "ID utente",
189
189
  "CLOSE_TOAST": "Chiudi",
190
- "WAITING_FOR_NETWORK": "In attesa di rete"
190
+ "WAITING_FOR_NETWORK": "In attesa di rete",
191
+ "Available": "Disponibile",
192
+ "Unavailable": "Non disponibile",
193
+ "Busy": "Occupato",
194
+ "YouAreAboutToJoinThisChat":"Stai per entrare in questa chat",
195
+ "Cancel": "Annulla",
196
+ "AreYouSure":"Sei sicuro?",
197
+ "UnassignedConversations":"Conversazioni non assegnate",
198
+ "NewConversations": "New conversations"
191
199
  }