@chat21/chat21-ionic 3.4.30 → 3.4.32-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +131 -2
- package/angular.json +1 -0
- package/package.json +1 -1
- package/src/app/app.component.html +3 -1
- package/src/app/app.component.ts +72 -13
- package/src/app/chatlib/conversation-detail/message/image/image.component.html +1 -0
- package/src/app/chatlib/conversation-detail/message/image/image.component.ts +19 -0
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.html +14 -2
- package/src/app/chatlib/list-conversations-component/ion-list-conversations/ion-list-conversations.component.scss +39 -2
- package/src/app/chatlib/list-conversations-component/list-conversations.module.ts +14 -0
- package/src/app/components/canned-response/canned-response.component.html +26 -23
- package/src/app/components/canned-response/canned-response.component.scss +0 -2
- package/src/app/components/canned-response/canned-response.component.ts +3 -1
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.html +24 -1
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.scss +30 -0
- package/src/app/components/conversation-detail/message-text-area/message-text-area.component.ts +39 -9
- package/src/app/components/conversation-info/info-content/info-content.component.ts +2 -2
- package/src/app/components/conversation-info/info-group/info-group.component.ts +23 -21
- package/src/app/components/conversations-list/header-conversations-list/header-conversations-list.component.html +1 -1
- package/src/app/components/conversations-list/header-conversations-list/header-conversations-list.component.ts +5 -1
- package/src/app/components/navbar/navbar.component.html +35 -9
- package/src/app/components/navbar/navbar.component.scss +64 -0
- package/src/app/components/navbar/navbar.component.ts +100 -42
- package/src/app/components/project-item/project-item.component.ts +79 -51
- package/src/app/components/sidebar/sidebar.component.html +65 -45
- package/src/app/components/sidebar/sidebar.component.ts +110 -117
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.html +3 -3
- package/src/app/components/sidebar-user-details/sidebar-user-details.component.ts +15 -22
- package/src/app/directives/html-entities-encode.pipe.ts +20 -5
- package/src/app/modals/create-ticket/create-ticket.page.ts +4 -2
- package/src/app/pages/conversation-detail/conversation-detail.page.html +7 -3
- package/src/app/pages/conversation-detail/conversation-detail.page.ts +95 -7
- package/src/app/pages/conversations-list/conversations-list.module.ts +3 -5
- package/src/app/pages/conversations-list/conversations-list.page.html +2 -0
- package/src/app/pages/conversations-list/conversations-list.page.ts +51 -11
- package/src/app/pages/unassigned-conversations/unassigned-conversations.module.ts +16 -4
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.html +41 -17
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.scss +10 -1
- package/src/app/pages/unassigned-conversations/unassigned-conversations.page.ts +114 -9
- package/src/app/services/global-settings/global-settings.service.ts +11 -3
- package/src/app/services/nav-proxy.service.ts +0 -1
- package/src/app/services/project_users/project-users.service.spec.ts +16 -0
- package/src/app/services/project_users/project-users.service.ts +63 -0
- package/src/app/services/projects/project.service.ts +2 -1
- package/src/app/services/tiledesk/tiledesk.service.ts +21 -16
- package/src/app/services/triggerEvents/triggerEvents.ts +28 -0
- package/src/app/services/websocket/websocket-js.ts +59 -534
- package/src/app/services/websocket/websocket-js_old.ts +578 -0
- package/src/app/services/websocket/websocket.service.ts +59 -10
- package/src/app/services/websocket/websocket.worker.ts +242 -0
- package/src/app/shared/shared.module.ts +11 -2
- package/src/app/utils/globals.ts +2 -0
- package/src/app/utils/permissions.constants.ts +138 -0
- package/src/app/utils/project-utils.ts +2 -2
- package/src/app/utils/utils.ts +18 -1
- package/src/assets/i18n/ar.json +11 -1
- package/src/assets/i18n/az.json +11 -1
- package/src/assets/i18n/de.json +11 -1
- package/src/assets/i18n/en.json +11 -1
- package/src/assets/i18n/es.json +11 -1
- package/src/assets/i18n/fr.json +11 -1
- package/src/assets/i18n/it.json +13 -3
- package/src/assets/i18n/kk.json +11 -1
- package/src/assets/i18n/pt.json +11 -1
- package/src/assets/i18n/ru.json +11 -1
- package/src/assets/i18n/sr.json +11 -1
- package/src/assets/i18n/sv.json +11 -1
- package/src/assets/i18n/tr.json +11 -1
- package/src/assets/i18n/uk.json +11 -1
- package/src/assets/i18n/uz.json +12 -1
- package/src/assets/img/no_data_found.png +0 -0
- package/src/assets/js/agentDesktop-sdk.js +55 -0
- package/src/assets/js/chat21client.js +36 -0
- package/src/assets/js/mqtt-keepalive-worker.js +53 -0
- package/src/assets/test.html +5 -2
- package/src/chat-config-template.json +1 -0
- package/src/chat-config.json +1 -0
- package/src/chat21-core/models/projectUsers.ts +19 -0
- package/src/chat21-core/models/project_user.ts +2 -1
- package/src/chat21-core/providers/abstract/upload.service.ts +5 -1
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/firebase/firebase-upload.service.ts +136 -9
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +1 -1
- package/src/chat21-core/providers/native/native-image-repo.ts +1 -1
- package/src/chat21-core/providers/native/native-upload-service.ts +143 -45
- package/src/chat21-core/providers/tiledesk/tiledesk-auth.service.ts +3 -0
- package/src/chat21-core/utils/constants.ts +5 -0
- package/src/chat21-core/utils/convertRequestToConversation.ts +1 -1
- package/src/chat21-core/utils/utils.ts +53 -3
- package/src/variables.scss +3 -0
|
@@ -42,7 +42,7 @@ export class FirebaseUploadService extends UploadService {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
public initialize() {
|
|
45
|
+
public async initialize(projectId?: string) {
|
|
46
46
|
this.logger.log('[FIREBASEUploadSERVICE] initialize');
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -104,6 +104,107 @@ export class FirebaseUploadService extends UploadService {
|
|
|
104
104
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
public uploadFile(userId: string, upload: UploadModel): Promise<{downloadURL: string, src: any}> {
|
|
108
|
+
const that = this;
|
|
109
|
+
const uid = this.createGuid();
|
|
110
|
+
const urlImagesNodeFirebase = '/public/images/' + userId + '/' + uid + '/' + upload.file.name;
|
|
111
|
+
this.logger.debug('[FIREBASEUploadSERVICE] pushUpload ', urlImagesNodeFirebase, upload.file);
|
|
112
|
+
|
|
113
|
+
// Create a root reference
|
|
114
|
+
const storageRef = firebase.storage().ref();
|
|
115
|
+
this.logger.debug('[FIREBASEUploadSERVICE] storageRef', storageRef);
|
|
116
|
+
|
|
117
|
+
// Create a reference to 'mountains.jpg'
|
|
118
|
+
const mountainsRef = storageRef.child(urlImagesNodeFirebase);
|
|
119
|
+
this.logger.debug('[FIREBASEUploadSERVICE] mountainsRef ', mountainsRef);
|
|
120
|
+
|
|
121
|
+
// const metadata = {};
|
|
122
|
+
const metadata = { name: upload.file.name, contentType: upload.file.type, contentDisposition: 'attachment; filename=' + upload.file.name };
|
|
123
|
+
|
|
124
|
+
let uploadTask = mountainsRef.put(upload.file, metadata);
|
|
125
|
+
|
|
126
|
+
return new Promise((resolve, reject) => {
|
|
127
|
+
uploadTask.on('state_changed', function progress(snapshot) {
|
|
128
|
+
// Observe state change events such as progress, pause, and resume
|
|
129
|
+
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
|
|
130
|
+
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
|
131
|
+
that.logger.debug('[FIREBASEUploadSERVICE] Upload is ' + progress + '% done');
|
|
132
|
+
|
|
133
|
+
// ----------------------------------------------------------------------------------------------------------------------------------------------
|
|
134
|
+
// BehaviorSubject publish the upload progress state - the subscriber is in ion-conversastion-detail.component.ts > listenToUploadFileProgress()
|
|
135
|
+
// ----------------------------------------------------------------------------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
that.BSStateUpload.next({ upload: progress, type: upload.file.type });
|
|
138
|
+
|
|
139
|
+
switch (snapshot.state) {
|
|
140
|
+
case firebase.storage.TaskState.PAUSED: // or 'paused'
|
|
141
|
+
that.logger.debug('[FIREBASEUploadSERVICE] Upload is paused');
|
|
142
|
+
|
|
143
|
+
break;
|
|
144
|
+
case firebase.storage.TaskState.RUNNING: // or 'running'
|
|
145
|
+
that.logger.debug('[FIREBASEUploadSERVICE] Upload is running');
|
|
146
|
+
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}, function error(error) {
|
|
150
|
+
// Handle unsuccessful uploads
|
|
151
|
+
reject(error)
|
|
152
|
+
}, async function complete() {
|
|
153
|
+
// Handle successful uploads on complete
|
|
154
|
+
that.logger.debug('[FIREBASEUploadSERVICE] Upload is complete', upload);
|
|
155
|
+
|
|
156
|
+
const downloadURL = await uploadTask.snapshot.ref.getDownloadURL();
|
|
157
|
+
resolve({downloadURL: downloadURL, src: downloadURL})
|
|
158
|
+
// that.BSStateUpload.next({upload: upload});
|
|
159
|
+
|
|
160
|
+
});
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
public uploadAsset(userId: string, upload: UploadModel, expiration: number = 60): Promise<{downloadURL: string, src: any}> {
|
|
165
|
+
// expiration is ignored on Firebase, but kept for API compatibility with NativeUploadService
|
|
166
|
+
const that = this;
|
|
167
|
+
const uid = this.createGuid();
|
|
168
|
+
const urlAssetsNodeFirebase = '/public/assets/' + userId + '/' + uid + '/' + upload.file.name;
|
|
169
|
+
this.logger.debug('[FIREBASEUploadSERVICE] uploadAsset ', urlAssetsNodeFirebase, upload.file, 'expiration:', expiration);
|
|
170
|
+
|
|
171
|
+
// Create a root reference
|
|
172
|
+
const storageRef = firebase.storage().ref();
|
|
173
|
+
this.logger.debug('[FIREBASEUploadSERVICE] storageRef', storageRef);
|
|
174
|
+
|
|
175
|
+
const assetRef = storageRef.child(urlAssetsNodeFirebase);
|
|
176
|
+
this.logger.debug('[FIREBASEUploadSERVICE] assetRef ', assetRef);
|
|
177
|
+
|
|
178
|
+
const metadata = { name: upload.file.name, contentType: upload.file.type, contentDisposition: 'attachment; filename=' + upload.file.name };
|
|
179
|
+
|
|
180
|
+
let uploadTask = assetRef.put(upload.file, metadata);
|
|
181
|
+
|
|
182
|
+
return new Promise((resolve, reject) => {
|
|
183
|
+
uploadTask.on('state_changed', function progress(snapshot) {
|
|
184
|
+
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
|
|
185
|
+
that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is ' + progress + '% done');
|
|
186
|
+
|
|
187
|
+
that.BSStateUpload.next({ upload: progress, type: upload.file.type });
|
|
188
|
+
|
|
189
|
+
switch (snapshot.state) {
|
|
190
|
+
case firebase.storage.TaskState.PAUSED:
|
|
191
|
+
that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is paused');
|
|
192
|
+
break;
|
|
193
|
+
case firebase.storage.TaskState.RUNNING:
|
|
194
|
+
that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is running');
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}, function error(error) {
|
|
198
|
+
reject(error)
|
|
199
|
+
}, async function complete() {
|
|
200
|
+
that.logger.debug('[FIREBASEUploadSERVICE] uploadAsset is complete', upload);
|
|
201
|
+
|
|
202
|
+
const downloadURL = await uploadTask.snapshot.ref.getDownloadURL();
|
|
203
|
+
resolve({downloadURL: downloadURL, src: downloadURL})
|
|
204
|
+
});
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
107
208
|
public uploadProfile(userId: string, upload: UploadModel): Promise<any> {
|
|
108
209
|
const that = this;
|
|
109
210
|
const urlImagesNodeFirebase = '/profiles/' + userId + '/photo.jpg'
|
|
@@ -192,6 +293,40 @@ export class FirebaseUploadService extends UploadService {
|
|
|
192
293
|
})
|
|
193
294
|
}
|
|
194
295
|
|
|
296
|
+
public async deleteFile(userId: string, path: string): Promise<any>{
|
|
297
|
+
const that = this;
|
|
298
|
+
const file_name_photo = 'photo.jpg';
|
|
299
|
+
const file_name_thumb_photo = 'thumb_photo.jpg';
|
|
300
|
+
|
|
301
|
+
that.logger.debug('[FIREBASEUploadSERVICE] delete image for USER', userId, path);
|
|
302
|
+
|
|
303
|
+
let uid = path.split(userId)[1].split('%2F')[1]; // get the UID of the image
|
|
304
|
+
let imageName = path.split(uid + '%2F')[1].split('?')[0];
|
|
305
|
+
|
|
306
|
+
// Create a root reference
|
|
307
|
+
const storageRef = firebase.storage().ref();
|
|
308
|
+
const ref = storageRef.child('public/images/' + userId + '/'+ uid + '/')
|
|
309
|
+
let arrayPromise = []
|
|
310
|
+
await ref.listAll().then((dir => {
|
|
311
|
+
dir.items.forEach(fileRef => arrayPromise.push(this.deleteFile(ref.fullPath, fileRef.name)));
|
|
312
|
+
})).catch(error => {
|
|
313
|
+
that.logger.error('[FIREBASEUploadSERVICE] delete: listAll error', error)
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
//AWAIT to return ALL the promise delete()
|
|
317
|
+
return new Promise((resolve, reject)=> {
|
|
318
|
+
Promise.all(arrayPromise).then(()=>{
|
|
319
|
+
resolve(true)
|
|
320
|
+
}).catch((error)=>{
|
|
321
|
+
reject(error)
|
|
322
|
+
})
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
public async deleteAsset(userId: string, path: string): Promise<any>{
|
|
327
|
+
return this.deleteProfile(userId, path);
|
|
328
|
+
}
|
|
329
|
+
|
|
195
330
|
public async deleteProfile(userId: string, path: string): Promise<any>{
|
|
196
331
|
const that = this;
|
|
197
332
|
const file_name_photo = 'photo.jpg';
|
|
@@ -219,13 +354,5 @@ export class FirebaseUploadService extends UploadService {
|
|
|
219
354
|
})
|
|
220
355
|
}
|
|
221
356
|
|
|
222
|
-
// // ------------------------------------
|
|
223
|
-
// // Delete the file photo
|
|
224
|
-
// // ------------------------------------
|
|
225
|
-
private deleteFile(pathToFile, fileName){
|
|
226
|
-
const ref = firebase.storage().ref(pathToFile);
|
|
227
|
-
const childRef = ref.child(fileName);
|
|
228
|
-
return childRef.delete()
|
|
229
|
-
}
|
|
230
357
|
|
|
231
358
|
}
|
|
@@ -365,7 +365,7 @@ export class MQTTConversationHandler extends ConversationHandlerService {
|
|
|
365
365
|
complement = INFO_SUPPORT_USER_ADDED_COMPLEMENT;
|
|
366
366
|
} else {
|
|
367
367
|
if (message.attributes.messagelabel.parameters.firstname) {
|
|
368
|
-
// other user has been added to the group (and he has a
|
|
368
|
+
// other user has been added to the group (and he has a fullname)
|
|
369
369
|
subject = message.attributes.messagelabel.parameters.firstname;
|
|
370
370
|
verb = INFO_SUPPORT_USER_ADDED_VERB;
|
|
371
371
|
complement = INFO_SUPPORT_USER_ADDED_COMPLEMENT;
|
|
@@ -16,7 +16,7 @@ export class NativeImageRepoService extends ImageRepoService {
|
|
|
16
16
|
* @param uid
|
|
17
17
|
*/
|
|
18
18
|
getImagePhotoUrl(uid: string): string {
|
|
19
|
-
this.baseImageURL = this.getImageBaseUrl() + '
|
|
19
|
+
this.baseImageURL = this.getImageBaseUrl() + 'files'
|
|
20
20
|
let sender_id = '';
|
|
21
21
|
if (uid.includes('bot_')) {
|
|
22
22
|
sender_id = uid.slice(4)
|
|
@@ -6,6 +6,7 @@ import { UploadModel } from '../../models/upload';
|
|
|
6
6
|
import { AppStorageService } from '../abstract/app-storage.service';
|
|
7
7
|
import { LoggerService } from '../abstract/logger.service';
|
|
8
8
|
import { LoggerInstance } from '../logger/loggerInstance';
|
|
9
|
+
import { first } from 'rxjs/operators';
|
|
9
10
|
|
|
10
11
|
// @Injectable({ providedIn: 'root' })
|
|
11
12
|
@Injectable()
|
|
@@ -14,8 +15,8 @@ export class NativeUploadService extends UploadService {
|
|
|
14
15
|
BSStateUpload: BehaviorSubject<any> = new BehaviorSubject<any>(null)
|
|
15
16
|
|
|
16
17
|
private tiledeskToken: string;
|
|
17
|
-
private URL_TILEDESK_IMAGES: string;
|
|
18
18
|
private URL_TILEDESK_FILE: string;
|
|
19
|
+
private URL_TILEDESK_UPLOAD: string;
|
|
19
20
|
private logger: LoggerService = LoggerInstance.getInstance()
|
|
20
21
|
|
|
21
22
|
constructor(
|
|
@@ -25,15 +26,17 @@ export class NativeUploadService extends UploadService {
|
|
|
25
26
|
super();
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
initialize(): void {
|
|
29
|
-
this.logger.info('[NATIVE UPLOAD] initialize')
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
initialize(projectId?: string): void {
|
|
30
|
+
this.logger.info('[NATIVE UPLOAD] initialize', this.getBaseUrl())
|
|
31
|
+
if (projectId) {
|
|
32
|
+
this.URL_TILEDESK_FILE = this.getBaseUrl() + projectId + '/files'
|
|
33
|
+
}
|
|
34
|
+
this.URL_TILEDESK_UPLOAD = this.getBaseUrl();
|
|
32
35
|
this.tiledeskToken = this.appStorage.getItem('tiledeskToken')
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
|
|
36
|
-
upload(userId: string, upload: UploadModel): Promise<{
|
|
39
|
+
upload(userId: string, upload: UploadModel): Promise<{downloadURL: string, src: string}> {
|
|
37
40
|
this.logger.log('[NATIVE UPLOAD] - upload new image/file ... upload', upload)
|
|
38
41
|
const headers = new HttpHeaders({
|
|
39
42
|
Authorization: this.tiledeskToken,
|
|
@@ -45,37 +48,93 @@ export class NativeUploadService extends UploadService {
|
|
|
45
48
|
|
|
46
49
|
const that = this;
|
|
47
50
|
if ((upload.file.type.startsWith('image') && (!upload.file.type.includes('svg')))) {
|
|
48
|
-
this.logger.log('[NATIVE UPLOAD] - upload new image')
|
|
49
51
|
//USE IMAGE API
|
|
50
|
-
const url = this.
|
|
52
|
+
const url = this.URL_TILEDESK_UPLOAD + 'images/users'
|
|
51
53
|
return new Promise((resolve, reject) => {
|
|
52
|
-
that.http.post(url, formData, requestOptions).subscribe(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
55
|
+
next: (data) => {
|
|
56
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'images?path=' + encodeURIComponent(data?.['filename']);
|
|
57
|
+
resolve({downloadURL : downloadURL, src: downloadURL})
|
|
58
|
+
// that.BSStateUpload.next({upload: upload});
|
|
59
|
+
},
|
|
60
|
+
error: (error) => {
|
|
61
|
+
reject(error)
|
|
62
|
+
}
|
|
58
63
|
});
|
|
59
64
|
});
|
|
60
65
|
} else {
|
|
61
|
-
this.logger.log('[NATIVE UPLOAD] - upload new file')
|
|
62
66
|
//USE FILE API
|
|
63
|
-
const url = this.
|
|
67
|
+
const url = this.URL_TILEDESK_UPLOAD + 'files/users'
|
|
64
68
|
return new Promise((resolve, reject) => {
|
|
65
|
-
that.http.post(url, formData, requestOptions).subscribe(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
70
|
+
next: (data) => {
|
|
71
|
+
const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + encodeURIComponent(data['filename']);
|
|
72
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download' + '?path=' + encodeURIComponent(data['filename']);
|
|
73
|
+
resolve({downloadURL : downloadURL, src: src})
|
|
74
|
+
// that.BSStateUpload.next({upload: upload});
|
|
75
|
+
},
|
|
76
|
+
error: (error) => {
|
|
77
|
+
this.logger.error('[NATIVE UPLOAD] - ERROR upload new file ', error)
|
|
78
|
+
reject(error)
|
|
79
|
+
}
|
|
73
80
|
});
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
}
|
|
78
85
|
|
|
86
|
+
uploadFile(userId: string, upload: UploadModel): Promise<{downloadURL: string, src: string}> {
|
|
87
|
+
this.logger.log('[NATIVE UPLOAD] - upload new image/file ... upload', upload)
|
|
88
|
+
const headers = new HttpHeaders({
|
|
89
|
+
Authorization: this.tiledeskToken,
|
|
90
|
+
//'Content-Type': 'multipart/form-data',
|
|
91
|
+
});
|
|
92
|
+
const requestOptions = { headers: headers };
|
|
93
|
+
const formData = new FormData();
|
|
94
|
+
formData.append('file', upload.file);
|
|
95
|
+
|
|
96
|
+
const that = this;
|
|
97
|
+
const url = this.URL_TILEDESK_FILE + '/chat'
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
100
|
+
next: (data) => {
|
|
101
|
+
const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + encodeURIComponent(data['filename']);
|
|
102
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download?path=' + encodeURIComponent(data['filename']);
|
|
103
|
+
resolve({downloadURL : downloadURL, src: src})
|
|
104
|
+
},
|
|
105
|
+
error: (error) => {
|
|
106
|
+
reject(error)
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
uploadAsset(userId: string, upload: UploadModel, expiration: number = 60): Promise<{downloadURL: string, src: string}> {
|
|
113
|
+
this.logger.log('[NATIVE UPLOAD] - upload new asset ... upload', upload, 'expiration:', expiration)
|
|
114
|
+
const headers = new HttpHeaders({
|
|
115
|
+
Authorization: this.tiledeskToken,
|
|
116
|
+
});
|
|
117
|
+
const requestOptions = { headers: headers };
|
|
118
|
+
const formData = new FormData();
|
|
119
|
+
formData.append('file', upload.file);
|
|
120
|
+
|
|
121
|
+
const that = this;
|
|
122
|
+
const queryString = expiration !== undefined ? `?expiration=${encodeURIComponent(String(expiration))}` : ''
|
|
123
|
+
const url = this.URL_TILEDESK_FILE + `/assets${queryString}`
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
that.http.post(url, formData, requestOptions).pipe(first()).subscribe({
|
|
126
|
+
next: (data) => {
|
|
127
|
+
const src = this.URL_TILEDESK_UPLOAD + 'files?path=' + data['filename'];
|
|
128
|
+
const downloadURL = this.URL_TILEDESK_UPLOAD + 'files/download?path=' + encodeURIComponent(data['filename']);
|
|
129
|
+
resolve({downloadURL : downloadURL, src: src})
|
|
130
|
+
},
|
|
131
|
+
error: (error) => {
|
|
132
|
+
reject(error)
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
79
138
|
uploadProfile(userId: string, upload: UploadModel): Promise<any> {
|
|
80
139
|
this.logger.log('[NATIVE UPLOAD] - upload new photo profile ... upload', upload)
|
|
81
140
|
const headers = new HttpHeaders({
|
|
@@ -88,14 +147,18 @@ export class NativeUploadService extends UploadService {
|
|
|
88
147
|
|
|
89
148
|
// USE IMAGE API
|
|
90
149
|
const that = this;
|
|
91
|
-
const
|
|
150
|
+
const queryString = userId?.startsWith('bot_') ? `?bot_id=${encodeURIComponent(userId.substring('bot_'.length))}` : ''
|
|
151
|
+
const url = this.URL_TILEDESK_FILE + `/users/photo${queryString}`
|
|
92
152
|
return new Promise((resolve, reject) => {
|
|
93
|
-
that.http.put(url, formData, requestOptions).subscribe(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
153
|
+
that.http.put(url, formData, requestOptions).pipe(first()).subscribe({
|
|
154
|
+
next: (data) => {
|
|
155
|
+
const downloadURL = this.getBaseUrl() + 'files?path=' + data['thumbnail'];
|
|
156
|
+
resolve(downloadURL)
|
|
157
|
+
// that.BSStateUpload.next({upload: upload});
|
|
158
|
+
},
|
|
159
|
+
error: (error) => {
|
|
160
|
+
reject(error)
|
|
161
|
+
}
|
|
99
162
|
});
|
|
100
163
|
});
|
|
101
164
|
}
|
|
@@ -110,18 +173,50 @@ export class NativeUploadService extends UploadService {
|
|
|
110
173
|
|
|
111
174
|
//USE IMAGE API
|
|
112
175
|
const that = this;
|
|
113
|
-
const url = this.
|
|
176
|
+
const url = this.URL_TILEDESK_UPLOAD + 'images/users' + '?path=' + path.split('path=')[1]
|
|
177
|
+
return new Promise((resolve, reject) => {
|
|
178
|
+
that.http.delete(url, requestOptions).pipe(first()).subscribe({
|
|
179
|
+
next: (data) => {
|
|
180
|
+
// const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
|
|
181
|
+
resolve(true)
|
|
182
|
+
// that.BSStateUpload.next({upload: upload});
|
|
183
|
+
},
|
|
184
|
+
error: (error) => {
|
|
185
|
+
reject(error)
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
deleteFile(userId: string, path: string): Promise<any>{
|
|
192
|
+
this.logger.log('[NATIVE UPLOAD] - delete image ... upload', userId)
|
|
193
|
+
const headers = new HttpHeaders({
|
|
194
|
+
Authorization: this.tiledeskToken,
|
|
195
|
+
//'Content-Type': 'multipart/form-data',
|
|
196
|
+
});
|
|
197
|
+
const requestOptions = { headers: headers };
|
|
198
|
+
|
|
199
|
+
//USE IMAGE API
|
|
200
|
+
const that = this;
|
|
201
|
+
const url = this.URL_TILEDESK_FILE + '?path=' + path.split('path=')[1]
|
|
114
202
|
return new Promise((resolve, reject) => {
|
|
115
|
-
that.http.delete(url, requestOptions).subscribe(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
203
|
+
that.http.delete(url, requestOptions).pipe(first()).subscribe({
|
|
204
|
+
next: (data) => {
|
|
205
|
+
// const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
|
|
206
|
+
resolve(true)
|
|
207
|
+
// that.BSStateUpload.next({upload: upload});
|
|
208
|
+
},
|
|
209
|
+
error: (error) => {
|
|
210
|
+
reject(error)
|
|
211
|
+
}
|
|
121
212
|
});
|
|
122
213
|
});
|
|
123
214
|
}
|
|
124
215
|
|
|
216
|
+
deleteAsset(userId: string, path: string): Promise<any>{
|
|
217
|
+
return this.deleteFile(userId, path);
|
|
218
|
+
}
|
|
219
|
+
|
|
125
220
|
deleteProfile(userId: string, path: string): Promise<any>{
|
|
126
221
|
this.logger.log('[NATIVE UPLOAD] - delete image ... upload', userId)
|
|
127
222
|
const headers = new HttpHeaders({
|
|
@@ -132,14 +227,17 @@ export class NativeUploadService extends UploadService {
|
|
|
132
227
|
|
|
133
228
|
//USE IMAGE API
|
|
134
229
|
const that = this;
|
|
135
|
-
const url = this.
|
|
230
|
+
const url = this.URL_TILEDESK_FILE + '?path=' + "uploads/users/"+ userId + "/images/photo.jpg"
|
|
136
231
|
return new Promise((resolve, reject) => {
|
|
137
|
-
that.http.delete(url, requestOptions).subscribe(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
232
|
+
that.http.delete(url, requestOptions).pipe(first()).subscribe({
|
|
233
|
+
next: (data) => {
|
|
234
|
+
// const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
|
|
235
|
+
resolve(true)
|
|
236
|
+
// that.BSStateUpload.next({upload: upload});
|
|
237
|
+
},
|
|
238
|
+
error: (error) => {
|
|
239
|
+
reject(error)
|
|
240
|
+
}
|
|
143
241
|
});
|
|
144
242
|
});
|
|
145
243
|
}
|
|
@@ -121,6 +121,7 @@ export class TiledeskAuthService {
|
|
|
121
121
|
this.http.post(this.URL_TILEDESK_SIGNIN_WITH_CUSTOM_TOKEN, null, requestOptions).subscribe((data) => {
|
|
122
122
|
if (data['success'] && data['token']) {
|
|
123
123
|
that.tiledeskToken = data['token'];
|
|
124
|
+
data['user'].token = tiledeskToken; // mantengo il token custom nell'oggetto user
|
|
124
125
|
that.createCompleteUser(data['user']);
|
|
125
126
|
this.checkAndSetInStorageTiledeskToken(that.tiledeskToken)
|
|
126
127
|
this.BS_IsONLINE.next(true)
|
|
@@ -177,6 +178,8 @@ export class TiledeskAuthService {
|
|
|
177
178
|
this.currentUser = member;
|
|
178
179
|
this.logger.log('[TILEDESK-AUTH] - createCompleteUser member ', member);
|
|
179
180
|
this.appStorage.setItem('currentUser', JSON.stringify(this.currentUser));
|
|
181
|
+
const { iat, aud, iss, jti, ...cleanUser } = user; //destructuring and rest user object
|
|
182
|
+
localStorage.setItem('user', JSON.stringify(cleanUser));
|
|
180
183
|
|
|
181
184
|
} catch (err) {
|
|
182
185
|
this.logger.error('[TILEDESK-AUTH]- createCompleteUser ERR ', err)
|
|
@@ -148,5 +148,10 @@ export enum PLAN_NAME {
|
|
|
148
148
|
|
|
149
149
|
export const tranlatedLanguage = ['it', 'en', 'de', 'es', 'pt', 'fr', 'ru', 'tr', 'sr', 'ar', 'uk', 'sv', 'az', 'kk', 'uz']
|
|
150
150
|
|
|
151
|
+
export const TEAMMATE_STATUS = [
|
|
152
|
+
{ id: 1, name: 'Available', avatar: 'assets/img/teammate-status/avaible.svg', label: "LABEL_AVAILABLE" },
|
|
153
|
+
{ id: 2, name: 'Unavailable', avatar: 'assets/img/teammate-status/unavaible.svg', label: "LABEL_NOT_AVAILABLE" },
|
|
154
|
+
{ id: 3, name: 'Inactive', avatar: 'assets/img/teammate-status/inactive.svg', label: "LABEL_INACTIVE" },
|
|
155
|
+
];
|
|
151
156
|
|
|
152
157
|
|
|
@@ -29,7 +29,7 @@ export class ConvertRequestToConversation {
|
|
|
29
29
|
request.requester_id,
|
|
30
30
|
'',
|
|
31
31
|
request.lead && request.lead.fullname ? request.lead.fullname: null,
|
|
32
|
-
'0',
|
|
32
|
+
request.status || '0',
|
|
33
33
|
moment(request.createdAt).unix(),
|
|
34
34
|
getColorBck(request.lead.fullname),
|
|
35
35
|
avatarPlaceholder(request.lead.fullname),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as moment from 'moment/moment';
|
|
3
3
|
// import * as moment from 'moment-timezone';
|
|
4
4
|
import 'moment/locale/it.js';
|
|
5
|
-
import { CHANNEL_TYPE } from './constants';
|
|
5
|
+
import { CHANNEL_TYPE, TEAMMATE_STATUS } from './constants';
|
|
6
6
|
|
|
7
7
|
import { HttpClient } from '@angular/common/http';
|
|
8
8
|
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
|
@@ -765,6 +765,12 @@ export function isOnMobileDevice() {
|
|
|
765
765
|
return IS_ON_MOBILE_DEVICE;
|
|
766
766
|
}
|
|
767
767
|
|
|
768
|
+
|
|
769
|
+
export function checkIfIsInIframe(){
|
|
770
|
+
const isInIframe = window.self !== window.top;
|
|
771
|
+
return isInIframe;
|
|
772
|
+
}
|
|
773
|
+
|
|
768
774
|
export function checkWindowWidthIsLessThan991px() {
|
|
769
775
|
// console.log('UTILS - checkWindowWidthIsLessThan991px:: ', window.innerWidth);
|
|
770
776
|
if (window.innerWidth < 991) {
|
|
@@ -1018,6 +1024,50 @@ export function isAllowedUrlInText(text: string, allowedUrls: string[]) {
|
|
|
1018
1024
|
}
|
|
1019
1025
|
|
|
1020
1026
|
function extractUrls(text: string): string[] {
|
|
1021
|
-
|
|
1022
|
-
|
|
1027
|
+
// Rileva URL con o senza protocollo (http/https)
|
|
1028
|
+
const urlRegex = /\b((https?:\/\/)?(www\.)?[a-z0-9.-]+\.[a-z]{2,})(\/[^\s]*)?/gi;
|
|
1029
|
+
const matches = text.match(urlRegex) || [];
|
|
1030
|
+
// Normalizza: aggiunge https:// se manca, così il parsing con new URL() funziona
|
|
1031
|
+
return matches.map((url) => {
|
|
1032
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
1033
|
+
return 'https://' + url;
|
|
1034
|
+
}
|
|
1035
|
+
return url;
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Restituisce lo status dell'utente nel contesto di un project.
|
|
1041
|
+
* Basato su user_available e profileStatus dell'oggetto projectUser.
|
|
1042
|
+
*
|
|
1043
|
+
* @param projectUser - Oggetto con user_available e profileStatus (es. ProjectUser dal websocket)
|
|
1044
|
+
* @returns Oggetto da TEAMMATE_STATUS (Available, Unavailable, Inactive) o null se i dati non sono sufficienti
|
|
1045
|
+
*/
|
|
1046
|
+
export function getUserStatusFromProjectUser(projectUser: {
|
|
1047
|
+
user_available?: boolean;
|
|
1048
|
+
profileStatus?: string;
|
|
1049
|
+
}): typeof TEAMMATE_STATUS[number] | null {
|
|
1050
|
+
if (!projectUser) {
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
if (projectUser.user_available === false && projectUser.profileStatus === 'inactive') {
|
|
1055
|
+
return TEAMMATE_STATUS[2]; // Inactive
|
|
1056
|
+
}
|
|
1057
|
+
if (projectUser.user_available === false && (!projectUser.profileStatus || projectUser.profileStatus === '')) {
|
|
1058
|
+
return TEAMMATE_STATUS[1]; // Unavailable
|
|
1059
|
+
}
|
|
1060
|
+
if (projectUser.user_available === true && (!projectUser.profileStatus || projectUser.profileStatus === '')) {
|
|
1061
|
+
return TEAMMATE_STATUS[0]; // Available
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
// Fallback per casi non esplicitamente gestiti
|
|
1065
|
+
if (projectUser.user_available === true) {
|
|
1066
|
+
return TEAMMATE_STATUS[0];
|
|
1067
|
+
}
|
|
1068
|
+
if (projectUser.user_available === false) {
|
|
1069
|
+
return TEAMMATE_STATUS[1];
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
return null;
|
|
1023
1073
|
}
|
package/src/variables.scss
CHANGED
|
@@ -44,6 +44,9 @@ body {
|
|
|
44
44
|
--last-message-color: rgb(60, 72, 88);
|
|
45
45
|
|
|
46
46
|
--contact-directory-searchbar-background: rgba(0, 0, 0, 0.05);
|
|
47
|
+
|
|
48
|
+
--join-button-background: var(--basic-blue);
|
|
49
|
+
--resolve-button-background: #e4e6eb;
|
|
47
50
|
// ***** Conversation-list: end ***** //
|
|
48
51
|
|
|
49
52
|
// ***** Conversation-detail: start ***** //
|