mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
Uploaded done, but uploading not
This commit is contained in:
parent
4dcdec0084
commit
6cdd464f54
7 changed files with 27 additions and 31 deletions
|
|
@ -23,7 +23,7 @@ template(name="attachmentsGalery")
|
||||||
each attachments
|
each attachments
|
||||||
.attachment-item
|
.attachment-item
|
||||||
a.attachment-thumbnail.swipebox(href="{{url}}" title="{{name}}")
|
a.attachment-thumbnail.swipebox(href="{{url}}" title="{{name}}")
|
||||||
if isUploaded
|
if isUploaded
|
||||||
if isImage
|
if isImage
|
||||||
img.attachment-thumbnail-img(src="{{url}}")
|
img.attachment-thumbnail-img(src="{{url}}")
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ Template.attachmentsGalery.events({
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
},
|
},
|
||||||
'click .js-add-cover'() {
|
'click .js-add-cover'() {
|
||||||
Cards.findOne(this.cardId).setCover(this._id);
|
Cards.findOne(this.meta.cardId).setCover(this._id);
|
||||||
},
|
},
|
||||||
'click .js-remove-cover'() {
|
'click .js-remove-cover'() {
|
||||||
Cards.findOne(this.cardId).unsetCover();
|
Cards.findOne(this.meta.cardId).unsetCover();
|
||||||
},
|
},
|
||||||
'click .js-preview-image'(event) {
|
'click .js-preview-image'(event) {
|
||||||
Popup.open('previewAttachedImage').call(this, event);
|
Popup.open('previewAttachedImage').call(this, event);
|
||||||
|
|
@ -47,8 +47,11 @@ Template.attachmentsGalery.events({
|
||||||
|
|
||||||
Template.attachmentsGalery.helpers({
|
Template.attachmentsGalery.helpers({
|
||||||
url() {
|
url() {
|
||||||
return Attachments.link(this);
|
return Attachments.link(this);
|
||||||
}
|
},
|
||||||
|
isUploaded() {
|
||||||
|
return !!this.meta.uploaded;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.previewAttachedImagePopup.events({
|
Template.previewAttachedImagePopup.events({
|
||||||
|
|
@ -67,13 +70,14 @@ Template.cardAttachmentsPopup.events({
|
||||||
'change .js-attach-file'(event) {
|
'change .js-attach-file'(event) {
|
||||||
const card = this;
|
const card = this;
|
||||||
const processFile = f => {
|
const processFile = f => {
|
||||||
Utils.processUploadedAttachment(card, f, attachment => {
|
Utils.processUploadedAttachment(card, f,
|
||||||
console.log('attachment', attachment);
|
(err, attachment) => {
|
||||||
if (attachment && attachment._id && attachment.isImage) {
|
if (attachment && attachment._id && attachment.isImage) {
|
||||||
card.setCover(attachment._id);
|
card.setCover(attachment._id);
|
||||||
|
}
|
||||||
|
Popup.close();
|
||||||
}
|
}
|
||||||
Popup.close();
|
);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FS.Utility.eachFile(event, f => {
|
FS.Utility.eachFile(event, f => {
|
||||||
|
|
@ -169,7 +173,6 @@ Template.previewClipboardImagePopup.events({
|
||||||
};
|
};
|
||||||
if (!results.name) {
|
if (!results.name) {
|
||||||
// if no filename, it's from clipboard. then we give it a name, with ext name from MIME type
|
// if no filename, it's from clipboard. then we give it a name, with ext name from MIME type
|
||||||
// FIXME: Check this behavior
|
|
||||||
if (typeof results.file.type === 'string') {
|
if (typeof results.file.type === 'string') {
|
||||||
settings.fileName =
|
settings.fileName =
|
||||||
new Date().getTime() + results.file.type.replace('.+/', '');
|
new Date().getTime() + results.file.type.replace('.+/', '');
|
||||||
|
|
@ -182,7 +185,6 @@ Template.previewClipboardImagePopup.events({
|
||||||
settings.meta.userId = Meteor.userId();
|
settings.meta.userId = Meteor.userId();
|
||||||
const attachment = Attachments.insert(settings);
|
const attachment = Attachments.insert(settings);
|
||||||
|
|
||||||
// TODO: Check image cover behavior
|
|
||||||
if (attachment && attachment._id && attachment.isImage) {
|
if (attachment && attachment._id && attachment.isImage) {
|
||||||
card.setCover(attachment._id);
|
card.setCover(attachment._id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ template(name="minicard")
|
||||||
.handle
|
.handle
|
||||||
.fa.fa-arrows
|
.fa.fa-arrows
|
||||||
if cover
|
if cover
|
||||||
.minicard-cover(style="background-image: url('{{cover.url}}');")
|
.minicard-cover(style="background-image: url('{{coverUrl}}');")
|
||||||
if labels
|
if labels
|
||||||
.minicard-labels
|
.minicard-labels
|
||||||
each labels
|
each labels
|
||||||
|
|
|
||||||
|
|
@ -32,4 +32,7 @@ Template.minicard.helpers({
|
||||||
hiddenMinicardLabelText() {
|
hiddenMinicardLabelText() {
|
||||||
return Meteor.user().hasHiddenMinicardLabelText();
|
return Meteor.user().hasHiddenMinicardLabelText();
|
||||||
},
|
},
|
||||||
|
coverUrl() {
|
||||||
|
return Attachments.findOne(this.coverId).link();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,20 +32,12 @@ Utils = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!card) {
|
if (!card) {
|
||||||
return next();
|
return onUploaded();
|
||||||
}
|
}
|
||||||
let settings = {
|
let settings = {
|
||||||
file: fileObj,
|
file: fileObj,
|
||||||
streams: 'dynamic',
|
streams: 'dynamic',
|
||||||
chunkSize: 'dynamic',
|
chunkSize: 'dynamic',
|
||||||
onUploaded: function(error, fileObj) {
|
|
||||||
console.log('after insert', Attachments.find({}).fetch());
|
|
||||||
if (error) {
|
|
||||||
console.log('Error while upload', error);
|
|
||||||
} else {
|
|
||||||
next(fileObj);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
settings.meta = {};
|
settings.meta = {};
|
||||||
if (card.isLinkedCard()) {
|
if (card.isLinkedCard()) {
|
||||||
|
|
@ -58,11 +50,7 @@ Utils = {
|
||||||
settings.meta.cardId = card._id;
|
settings.meta.cardId = card._id;
|
||||||
}
|
}
|
||||||
settings.meta.userId = Meteor.userId();
|
settings.meta.userId = Meteor.userId();
|
||||||
// FIXME: What is this?
|
Attachments.insert(settings).on('end', next);
|
||||||
/* if (file.original) {
|
|
||||||
file.original.name = fileObj.name;
|
|
||||||
}*/
|
|
||||||
Attachments.insert(settings);
|
|
||||||
},
|
},
|
||||||
shrinkImage(options) {
|
shrinkImage(options) {
|
||||||
// shrink image to certain size
|
// shrink image to certain size
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@ import { FilesCollection } from 'meteor/ostrio:files';
|
||||||
|
|
||||||
Attachments = new FilesCollection({
|
Attachments = new FilesCollection({
|
||||||
storagePath: storagePath(),
|
storagePath: storagePath(),
|
||||||
debug: true, // FIXME: Remove debug mode
|
debug: false, // FIXME: Remove debug mode
|
||||||
collectionName: 'attachments2',
|
collectionName: 'attachments2',
|
||||||
allowClientCode: true, // FIXME: Permissions
|
allowClientCode: true, // FIXME: Permissions
|
||||||
|
onAfterUpload: (fileRef) => {
|
||||||
|
Attachments.update({_id:fileRef._id}, {$set: {"meta.uploaded": true}});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
@ -15,6 +18,7 @@ if (Meteor.isServer) {
|
||||||
// TODO: Permission related
|
// TODO: Permission related
|
||||||
// TODO: Add Activity update
|
// TODO: Add Activity update
|
||||||
// TODO: publish and subscribe
|
// TODO: publish and subscribe
|
||||||
|
|
||||||
Meteor.publish('attachments', function() {
|
Meteor.publish('attachments', function() {
|
||||||
return Attachments.find().cursor;
|
return Attachments.find().cursor;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -460,11 +460,10 @@ Cards.helpers({
|
||||||
{ sort: { uploadedAt: -1 } },
|
{ sort: { uploadedAt: -1 } },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const ret = Attachments.find(
|
let ret = Attachments.find(
|
||||||
{ 'meta.cardId': this._id },
|
{ 'meta.cardId': this._id },
|
||||||
{ sort: { uploadedAt: -1 } },
|
{ sort: { uploadedAt: -1 } },
|
||||||
);
|
);
|
||||||
if (ret.first()) console.log('link', Attachments.link(ret.first()));
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue