From 65221ec91f46204753a816aab86a3e78f3376417 Mon Sep 17 00:00:00 2001 From: Jed Date: Tue, 29 Aug 2023 15:01:55 +0200 Subject: [PATCH] minor changes --- lib/formats/archiver.js | 18 +++++-------- lib/methods/archive.js | 36 +++++++++++++------------- ui/apos/components/AposExportModal.vue | 4 ++- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/lib/formats/archiver.js b/lib/formats/archiver.js index 8a8ac36..b71082b 100644 --- a/lib/formats/archiver.js +++ b/lib/formats/archiver.js @@ -42,21 +42,15 @@ async function compressAttachments(apos, archive, attachments = {}) { archive.append(res.body, { name: `attachments/${name}` }); - }).catch((err) => { - reject(err); - }); + }) + .catch(reject); }); }); - const chunkedPromises = chunkPromises(promises, 2); - try { - for (const chunk of chunkedPromises) { - const res = await Promise.all(chunk); - console.log('res', res); - } - } catch (err) { - console.log('err', err); - // TODO should we stop the whole process? At least notify the user that an attachment could not be downloaded + const chunkedPromises = chunkPromises(promises, 5); + /* const failedRequests = []; */ + for (const chunk of chunkedPromises) { + await Promise.allSettled(chunk); } } diff --git a/lib/methods/archive.js b/lib/methods/archive.js index 6aece0e..96dde77 100644 --- a/lib/methods/archive.js +++ b/lib/methods/archive.js @@ -34,28 +34,28 @@ module.exports = self => { const downloadUrl = `${self.apos.attachment.uploadfs.getUrl()}${downloadPath}`; if (reporting) { - /* reporting.setResults({ */ - /* url: downloadUrl */ - /* }); */ + reporting.setResults({ + url: downloadUrl + }); } else { // No reporting means no batch operation: // We need to handle the notification manually // when exporting a single document: - /* await self.apos.notification.trigger(req, 'aposImportExport:exported', { */ - /* interpolate: { */ - /* count: req.body._ids.length, */ - /* type: req.body.type */ - /* }, */ - /* dismiss: true, */ - /* icon: 'database-export-icon', */ - /* type: 'success', */ - /* event: { */ - /* name: 'export-download', */ - /* data: { */ - /* url: downloadUrl */ - /* } */ - /* } */ - /* }); */ + await self.apos.notification.trigger(req, 'aposImportExport:exported', { + interpolate: { + count: req.body._ids.length, + type: req.body.type + }, + dismiss: true, + icon: 'database-export-icon', + type: 'success', + event: { + name: 'export-download', + data: { + url: downloadUrl + } + } + }); } await self.removeArchive(filepath); diff --git a/ui/apos/components/AposExportModal.vue b/ui/apos/components/AposExportModal.vue index a761caa..1ef20a6 100644 --- a/ui/apos/components/AposExportModal.vue +++ b/ui/apos/components/AposExportModal.vue @@ -162,7 +162,9 @@ export default { computed: { moduleLabel() { const moduleOptions = apos.modules[this.moduleName]; - const label = this.checked?.length > 1 ? moduleOptions.pluralLabel : moduleOptions.label; + const label = this.checked?.length > 1 + ? moduleOptions.pluralLabel + : moduleOptions.label; return this.$t(label).toLowerCase(); },