2
0
Эх сурвалжийг харах

Attachment uploads show's all uploading files

Martin Filser 3 жил өмнө
parent
commit
af120f2e0b

+ 7 - 6
client/components/cards/attachments.jade

@@ -1,5 +1,5 @@
 template(name="cardAttachmentsPopup")
 template(name="cardAttachmentsPopup")
-  with currentUpload
+  if $gt uploads.length 0
     .attachment-upload {{_ 'uploading'}}
     .attachment-upload {{_ 'uploading'}}
       table
       table
         tr
         tr
@@ -7,11 +7,12 @@ template(name="cardAttachmentsPopup")
           th.upload-progress-descr {{_ 'progress'}}
           th.upload-progress-descr {{_ 'progress'}}
           th.upload-remaining-descr {{_ 'remaining_time'}}
           th.upload-remaining-descr {{_ 'remaining_time'}}
           th.upload-speed-descr {{_ 'speed'}}
           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
   else
     ul.pop-over-list
     ul.pop-over-list
       li
       li

+ 13 - 12
client/components/cards/attachments.js

@@ -21,20 +21,20 @@ Template.attachmentsGalery.helpers({
 });
 });
 
 
 Template.cardAttachmentsPopup.onCreated(function() {
 Template.cardAttachmentsPopup.onCreated(function() {
-  this.currentUpload = new ReactiveVar(false);
+  this.uploads = new ReactiveVar([]);
 });
 });
 
 
 Template.cardAttachmentsPopup.helpers({
 Template.cardAttachmentsPopup.helpers({
-  getEstimateTime() {
-    const ret = prettyMilliseconds(Template.instance().currentUpload.get().estimateTime.get());
+  getEstimateTime(upload) {
+    const ret = prettyMilliseconds(upload.estimateTime.get());
     return ret;
     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;
     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 card = this;
     const files = event.currentTarget.files;
     const files = event.currentTarget.files;
     if (files) {
     if (files) {
-      let finished = [];
+      let uploads = [];
       for (const file of files) {
       for (const file of files) {
         const fileId = Random.id();
         const fileId = Random.id();
         const config = {
         const config = {
@@ -58,7 +58,8 @@ Template.cardAttachmentsPopup.events({
           false,
           false,
         );
         );
         uploader.on('start', function() {
         uploader.on('start', function() {
-          templateInstance.currentUpload.set(this);
+          uploads.push(this);
+          templateInstance.uploads.set(uploads);
         });
         });
         uploader.on('uploaded', (error, fileRef) => {
         uploader.on('uploaded', (error, fileRef) => {
           if (!error) {
           if (!error) {
@@ -68,9 +69,9 @@ Template.cardAttachmentsPopup.events({
           }
           }
         });
         });
         uploader.on('end', (error, fileRef) => {
         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();
             Popup.back();
           }
           }
         });
         });