mirror of
https://github.com/wekan/wekan.git
synced 2026-03-04 12:50:16 +01:00
Ref: original & and use fileObj.meta
fileObj.meta is part of the ostrio:files API and be passed to the constructor. This is less hacky than trying tu update a persistet object after the fact.
This commit is contained in:
parent
6e1dce94f0
commit
00d8d7f9fe
10 changed files with 127 additions and 164 deletions
|
|
@ -58,20 +58,20 @@ Template.cardAttachmentsPopup.events({
|
|||
const uploader = Attachments.insert(
|
||||
{
|
||||
file: event.currentTarget.files[0],
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
streams: 'dynamic',
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
card.setCover(fileObj._id);
|
||||
if (fileRef.isImage) {
|
||||
card.setCover(fileRef._id);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(card, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.on('end', (error, fileObj) => {
|
||||
uploader.on('end', (error, fileRef) => {
|
||||
Popup.close();
|
||||
});
|
||||
uploader.start();
|
||||
|
|
@ -123,29 +123,28 @@ Template.previewClipboardImagePopup.onRendered(() => {
|
|||
|
||||
Template.previewClipboardImagePopup.events({
|
||||
'click .js-upload-pasted-image'() {
|
||||
const results = pastedResults;
|
||||
if (results && results.file) {
|
||||
const card = this;
|
||||
if (pastedResults && pastedResults.file) {
|
||||
const file = pastedResults.file;
|
||||
window.oPasted = pastedResults;
|
||||
const card = this;
|
||||
const uploader = Attachments.insert(
|
||||
{
|
||||
file: results.file,
|
||||
fileName:
|
||||
results.name || results.file.type.replace('image/', 'clipboard.'),
|
||||
file,
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
fileName: file.name || file.type.replace('image/', 'clipboard.'),
|
||||
streams: 'dynamic',
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
card.setCover(fileObj._id);
|
||||
if (fileRef.isImage) {
|
||||
card.setCover(fileRef._id);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(card, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.on('end', (error, fileObj) => {
|
||||
uploader.on('end', (error, fileRef) => {
|
||||
pastedResults = null;
|
||||
$(document.body).pasteImageReader(() => {});
|
||||
Popup.close();
|
||||
|
|
|
|||
|
|
@ -140,37 +140,30 @@ Template.editor.onRendered(() => {
|
|||
const $summernote = getSummernote(this);
|
||||
if (files && files.length > 0) {
|
||||
const image = files[0];
|
||||
const currentCard = Cards.findOne(Session.get('currentCard'));
|
||||
const MAX_IMAGE_PIXEL = Utils.MAX_IMAGE_PIXEL;
|
||||
const COMPRESS_RATIO = Utils.IMAGE_COMPRESS_RATIO;
|
||||
const insertImage = src => {
|
||||
const img = document.createElement('img');
|
||||
img.src = src;
|
||||
img.setAttribute('width', '100%');
|
||||
$summernote.summernote('insertNode', img);
|
||||
};
|
||||
const card = Cards.findOne(Session.get('currentCard'));
|
||||
const processUpload = function(file) {
|
||||
const uploader = Attachments.insert(
|
||||
{
|
||||
file,
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
streams: 'dynamic',
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
insertImage(
|
||||
`${location.protocol}//${location.host}${fileObj.path}`,
|
||||
);
|
||||
if (fileRef.isImage) {
|
||||
const img = document.createElement('img');
|
||||
img.src = fileRef.link();
|
||||
img.setAttribute('width', '100%');
|
||||
$summernote.summernote('insertNode', img);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(currentCard, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.start();
|
||||
};
|
||||
if (MAX_IMAGE_PIXEL) {
|
||||
if (Utils.MAX_IMAGE_PIXEL) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
const dataurl = e && e.target && e.target.result;
|
||||
|
|
@ -178,8 +171,8 @@ Template.editor.onRendered(() => {
|
|||
// need to shrink image
|
||||
Utils.shrinkImage({
|
||||
dataurl,
|
||||
maxSize: MAX_IMAGE_PIXEL,
|
||||
ratio: COMPRESS_RATIO,
|
||||
maxSize: Utils.MAX_IMAGE_PIXEL,
|
||||
ratio: Utils.IMAGE_COMPRESS_RATIO,
|
||||
toBlob: true,
|
||||
callback(blob) {
|
||||
if (blob !== false) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ template(name="changeAvatarPopup")
|
|||
unless isSelected
|
||||
a.js-delete-avatar {{_ 'delete'}}
|
||||
| -
|
||||
= original.name
|
||||
= name
|
||||
li: a.js-select-initials
|
||||
.member
|
||||
+userAvatarInitials(userId=currentUser._id)
|
||||
|
|
|
|||
|
|
@ -102,13 +102,13 @@ BlazeComponent.extendComponent({
|
|||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
self.setAvatar(fileObj.path);
|
||||
self.setAvatar(fileRef.path);
|
||||
// self.setAvatar(this.currentData().url(this.avatarUrlOptions()));
|
||||
}
|
||||
});
|
||||
uploader.on('error', (error, fileObj) => {
|
||||
uploader.on('error', (error, fileData) => {
|
||||
// XXX check for actually returned error
|
||||
self.setError('avatar-too-big');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue