@chat21/chat21-ionic 3.0.105-rc1 → 3.0.105

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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.0.105 in PROD
4
+
3
5
  ### 3.0.105.rc.1
4
6
  - added: get tiledeskToken from tiledesk_token key in favour of appStorageService.getItem('tiledeskToken')
5
7
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.0.105-rc1",
4
+ "version": "3.0.105",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -338,6 +338,7 @@ export class LoaderPreviewPage implements OnInit, AfterViewInit {
338
338
  const file4Load = new Image()
339
339
  const nameImg = file.name
340
340
  const typeFile = file.type
341
+ const size = file.size
341
342
 
342
343
  file4Load.src = this.fileSelected
343
344
  file4Load.title = nameImg
@@ -349,6 +350,7 @@ export class LoaderPreviewPage implements OnInit, AfterViewInit {
349
350
  height: file4Load.height,
350
351
  type: typeFile,
351
352
  uid: uid,
353
+ size: size
352
354
  }
353
355
  this.viewCtrl.dismiss({
354
356
  fileSelected: file,
@@ -36,4 +36,5 @@ export abstract class UploadService {
36
36
  // functions
37
37
  abstract initialize(): void;
38
38
  abstract upload(userId: string, upload: UploadModel): Promise<any>;
39
+ abstract delete(userId: string, path: string): Promise<any>;
39
40
  }
@@ -103,4 +103,43 @@ export class FirebaseUploadService extends UploadService {
103
103
 
104
104
  }
105
105
 
106
+ public async delete(userId: string, path: string): Promise<any>{
107
+ const that = this;
108
+ const file_name_photo = 'photo.jpg';
109
+ const file_name_thumb_photo = 'thumb_photo.jpg';
110
+
111
+ that.logger.debug('[FIREBASEUploadSERVICE] delete image for USER', userId, path);
112
+
113
+ let uid = path.split(userId)[1].split('%2F')[1]; // get the UID of the image
114
+ let imageName = path.split(uid + '%2F')[1].split('?')[0];
115
+
116
+ // Create a root reference
117
+ const storageRef = firebase.storage().ref();
118
+ const ref = storageRef.child('public/images/' + userId + '/'+ uid + '/')
119
+ let arrayPromise = []
120
+ await ref.listAll().then((dir => {
121
+ dir.items.forEach(fileRef => arrayPromise.push(this.deleteFile(ref.fullPath, fileRef.name)));
122
+ })).catch(error => {
123
+ that.logger.error('[FIREBASEUploadSERVICE] delete: listAll error', error)
124
+ })
125
+
126
+ //AWAIT to return ALL the promise delete()
127
+ return new Promise((resolve, reject)=> {
128
+ Promise.all(arrayPromise).then(()=>{
129
+ resolve(true)
130
+ }).catch((error)=>{
131
+ reject(error)
132
+ })
133
+ })
134
+ }
135
+
136
+ // // ------------------------------------
137
+ // // Delete the file photo
138
+ // // ------------------------------------
139
+ private deleteFile(pathToFile, fileName){
140
+ const ref = firebase.storage().ref(pathToFile);
141
+ const childRef = ref.child(fileName);
142
+ return childRef.delete()
143
+ }
144
+
106
145
  }
@@ -77,4 +77,26 @@ export class NativeUploadService extends UploadService {
77
77
  }
78
78
 
79
79
  }
80
+
81
+ delete(userId: string, path: string): Promise<any>{
82
+ this.logger.log('[NATIVE UPLOAD] - delete image ... upload', userId)
83
+ const headers = new HttpHeaders({
84
+ Authorization: this.tiledeskToken,
85
+ //'Content-Type': 'multipart/form-data',
86
+ });
87
+ const requestOptions = { headers: headers };
88
+
89
+ //USE IMAGE API
90
+ const that = this;
91
+ const url = this.URL_TILEDESK_IMAGES + '/users' + '?path=' + path
92
+ return new Promise((resolve, reject) => {
93
+ that.http.delete(url, requestOptions).subscribe(data => {
94
+ // const downloadURL = this.URL_TILEDESK_IMAGES + '?path=' + data['filename'];
95
+ resolve(true)
96
+ // that.BSStateUpload.next({upload: upload});
97
+ }, (error) => {
98
+ reject(error)
99
+ });
100
+ });
101
+ }
80
102
  }