vtb-appit 0.0.42 → 0.0.45
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/appit.js +41 -16
- package/package.json +1 -1
package/appit.js
CHANGED
|
@@ -102,6 +102,9 @@ class Appit {
|
|
|
102
102
|
let model = await this.createExcursion({...excursion, ...images, workspace_id: this.transformer.workspace_id});
|
|
103
103
|
this.history.excursionId = model.data.id;
|
|
104
104
|
} else {
|
|
105
|
+
if(excursion.hasOwnProperty('code'))
|
|
106
|
+
delete excursion.code;
|
|
107
|
+
|
|
105
108
|
await this.updateExcursion(this.history.excursionId, {...excursion, ...images, workspace_id: this.transformer.workspace_id});
|
|
106
109
|
}
|
|
107
110
|
}
|
|
@@ -270,9 +273,9 @@ class Appit {
|
|
|
270
273
|
return [];
|
|
271
274
|
}
|
|
272
275
|
|
|
273
|
-
getImages(media, crop)
|
|
276
|
+
async getImages(media, crop)
|
|
274
277
|
{
|
|
275
|
-
|
|
278
|
+
let result = {
|
|
276
279
|
file_size: [],
|
|
277
280
|
file_mime_type: [],
|
|
278
281
|
file_name: [],
|
|
@@ -281,12 +284,30 @@ class Appit {
|
|
|
281
284
|
file_type: []
|
|
282
285
|
};
|
|
283
286
|
|
|
284
|
-
|
|
285
|
-
|
|
287
|
+
const parsed = await this.getImageParsed(media, crop);
|
|
288
|
+
|
|
289
|
+
parsed.forEach(image => {
|
|
290
|
+
result.file_name.push(image.file_name);
|
|
291
|
+
result.file_path.push(image.file_path);
|
|
292
|
+
result.file_mime_type.push(image.file_mime_type);
|
|
293
|
+
result.file_size.push(image.file_size);
|
|
294
|
+
result.file_active.push(image.file_active);
|
|
295
|
+
result.file_type.push(image.file_type);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
getImageParsed(media, crop)
|
|
302
|
+
{
|
|
303
|
+
let promises = []
|
|
304
|
+
|
|
305
|
+
media.forEach(image => {
|
|
306
|
+
promises.push(new Promise((resolve, reject) => {
|
|
286
307
|
const regex = (image.url.match(/amazonaws\.com/)) ? /\.com\/(.*?)\/((?:.*?)\/(?:.*?))\//g : /\.(?:nl|com|travel|io|be)\.?\/((?:.*?)\/(?:.*?))\//g;
|
|
287
308
|
const match = regex.exec(image.url);
|
|
288
309
|
|
|
289
|
-
if(match) {
|
|
310
|
+
if(match && image.url.indexOf('flightdata') === -1) {
|
|
290
311
|
let replace = (match.length == 3) ? match[2] : match[1];
|
|
291
312
|
image.url = image.url.replace(replace, crop);
|
|
292
313
|
}
|
|
@@ -296,22 +317,26 @@ class Appit {
|
|
|
296
317
|
res.on('data', chunk => {
|
|
297
318
|
body += chunk;
|
|
298
319
|
})
|
|
299
|
-
|
|
320
|
+
|
|
300
321
|
res.on('end', () => {
|
|
301
322
|
const frags = image.url.split('/');
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
323
|
+
|
|
324
|
+
resolve({
|
|
325
|
+
file_name: frags[frags.length - 1],
|
|
326
|
+
file_path: image.url,
|
|
327
|
+
file_mime_type: res.headers['content-type'],
|
|
328
|
+
file_size: res.headers['content-length'],
|
|
329
|
+
file_active: 1,
|
|
330
|
+
file_type: 1
|
|
331
|
+
});
|
|
310
332
|
})
|
|
311
333
|
});
|
|
312
334
|
req.end();
|
|
313
|
-
});
|
|
314
|
-
})
|
|
335
|
+
}));
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
return Promise.all(promises);
|
|
315
340
|
}
|
|
316
341
|
|
|
317
342
|
async mediaToBase64(media)
|