mirror of
https://github.com/wekan/wekan.git
synced 2025-04-22 04:57:07 -04:00
Attachment uploads show's all uploading files
This commit is contained in:
parent
ea937810f2
commit
af120f2e0b
2 changed files with 20 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue