From af120f2e0b00e3357593669a6d34894da5016365 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 28 Apr 2022 15:56:37 +0200 Subject: [PATCH] Attachment uploads show's all uploading files --- client/components/cards/attachments.jade | 13 ++++++------ client/components/cards/attachments.js | 25 ++++++++++++------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index 426914879..b24558319 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -1,5 +1,5 @@ template(name="cardAttachmentsPopup") - with currentUpload + if $gt uploads.length 0 .attachment-upload {{_ 'uploading'}} table tr @@ -7,11 +7,12 @@ template(name="cardAttachmentsPopup") th.upload-progress-descr {{_ 'progress'}} th.upload-remaining-descr {{_ 'remaining_time'}} th.upload-speed-descr {{_ 'speed'}} - tr - td.upload-file-name-value {{file.name}} - td.upload-progress-value {{progress.get}}% - td.upload-remaining-value {{getEstimateTime}} - td.upload-speed-value {{getEstimateSpeed}} + each upload in uploads + tr + td.upload-file-name-value {{upload.file.name}} + td.upload-progress-value {{upload.progress.get}}% + td.upload-remaining-value {{getEstimateTime upload}} + td.upload-speed-value {{getEstimateSpeed upload}} else ul.pop-over-list li diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index a723baf23..fe97eafda 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -21,20 +21,20 @@ Template.attachmentsGalery.helpers({ }); Template.cardAttachmentsPopup.onCreated(function() { - this.currentUpload = new ReactiveVar(false); + this.uploads = new ReactiveVar([]); }); Template.cardAttachmentsPopup.helpers({ - getEstimateTime() { - const ret = prettyMilliseconds(Template.instance().currentUpload.get().estimateTime.get()); + getEstimateTime(upload) { + const ret = prettyMilliseconds(upload.estimateTime.get()); return ret; }, - getEstimateSpeed() { - const ret = filesize(Template.instance().currentUpload.get().estimateSpeed.get(), {round: 0}) + "/s"; + getEstimateSpeed(upload) { + const ret = filesize(upload.estimateSpeed.get(), {round: 0}) + "/s"; return ret; }, - currentUpload() { - return Template.instance().currentUpload.get(); + uploads() { + return Template.instance().uploads.get(); } }); @@ -43,7 +43,7 @@ Template.cardAttachmentsPopup.events({ const card = this; const files = event.currentTarget.files; if (files) { - let finished = []; + let uploads = []; for (const file of files) { const fileId = Random.id(); const config = { @@ -58,7 +58,8 @@ Template.cardAttachmentsPopup.events({ false, ); uploader.on('start', function() { - templateInstance.currentUpload.set(this); + uploads.push(this); + templateInstance.uploads.set(uploads); }); uploader.on('uploaded', (error, fileRef) => { if (!error) { @@ -68,9 +69,9 @@ Template.cardAttachmentsPopup.events({ } }); uploader.on('end', (error, fileRef) => { - templateInstance.currentUpload.set(false); - finished.push(fileRef); - if (finished.length == files.length) { + uploads = uploads.filter(_upload => _upload.config.fileId != fileRef._id); + templateInstance.uploads.set(uploads); + if (uploads.length == 0 ) { Popup.back(); } });