From 05c53ca01d71a01a608c9ae345475abd67c9939b Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Mon, 18 Nov 2019 01:47:26 +0000 Subject: Trying to upload an attachment with Meteor-Files --- client/components/cards/attachments.js | 24 ++++++++++++++++-------- client/lib/utils.js | 28 +++++++++++++++++----------- 2 files changed, 33 insertions(+), 19 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index e4439155..604dc078 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -149,20 +149,28 @@ Template.previewClipboardImagePopup.events({ if (results && results.file) { window.oPasted = pastedResults; const card = this; - const file = new FS.File(results.file); + const settings = { + file: results.file, + streams: 'dynamic', + chunkSize: 'dynamic' + }; if (!results.name) { // 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') { - file.name(results.file.type.replace('image/', 'clipboard.')); + settings.fileName = new Date().getTime() + results.file.type.replace('.+/', ''); } } - file.updatedAt(new Date()); - file.boardId = card.boardId; - file.cardId = card._id; - file.userId = Meteor.userId(); - const attachment = Attachments.insert(file); + settings.meta = {}; + settings.meta.updatedAt = new Date().getTime(); + settings.meta.boardId = card.boardId; + settings.meta.cardId = card._id; + settings.meta.userId = Meteor.userId(); + console.log('settings', settings); + const attachment = Attachments.insert(settings, false); - if (attachment && attachment._id && attachment.isImage()) { + // TODO: Check image cover behavior + if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } diff --git a/client/lib/utils.js b/client/lib/utils.js index cc3526c0..2694396f 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -34,21 +34,27 @@ Utils = { if (!card) { return next(); } - const file = new FS.File(fileObj); + let settings = { + file: fileObj, + streams: 'dynamic', + chunkSize: 'dynamic' + }; + settings.meta = {}; if (card.isLinkedCard()) { - file.boardId = Cards.findOne(card.linkedId).boardId; - file.cardId = card.linkedId; + settings.meta.boardId = Cards.findOne(card.linkedId).boardId; + settings.meta.cardId = card.linkedId; } else { - file.boardId = card.boardId; - file.swimlaneId = card.swimlaneId; - file.listId = card.listId; - file.cardId = card._id; + settings.meta.boardId = card.boardId; + settings.meta.swimlaneId = card.swimlaneId; + settings.meta.listId = card.listId; + settings.meta.cardId = card._id; } - file.userId = Meteor.userId(); - if (file.original) { + settings.meta.userId = Meteor.userId(); + // FIXME: What is this? +/* if (file.original) { file.original.name = fileObj.name; - } - return next(Attachments.insert(file)); + }*/ + return next(Attachments.insert(settings, false)); }, shrinkImage(options) { // shrink image to certain size -- cgit v1.2.3-1-g7c22 From 4dcdec0084414e7dde9e630add01ecd2865bd941 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Wed, 20 Nov 2019 10:40:09 +0000 Subject: Attachment upload from card done, need to fix download link --- client/components/cards/attachments.js | 23 ++++++++++++++++++----- client/components/main/editor.js | 8 ++------ client/lib/utils.js | 14 +++++++++++--- 3 files changed, 31 insertions(+), 14 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 604dc078..f24a7f82 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -45,18 +45,31 @@ Template.attachmentsGalery.events({ }, }); +Template.attachmentsGalery.helpers({ + url() { + return Attachments.link(this); + } +}); + Template.previewAttachedImagePopup.events({ 'click .js-large-image-clicked'() { Popup.close(); }, }); +Template.previewAttachedImagePopup.helpers({ + url() { + return Attachments.link(this); + } +}); + Template.cardAttachmentsPopup.events({ 'change .js-attach-file'(event) { const card = this; const processFile = f => { Utils.processUploadedAttachment(card, f, attachment => { - if (attachment && attachment._id && attachment.isImage()) { + console.log('attachment', attachment); + if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } Popup.close(); @@ -152,13 +165,14 @@ Template.previewClipboardImagePopup.events({ const settings = { file: results.file, streams: 'dynamic', - chunkSize: 'dynamic' + chunkSize: 'dynamic', }; if (!results.name) { // 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') { - settings.fileName = new Date().getTime() + results.file.type.replace('.+/', ''); + settings.fileName = + new Date().getTime() + results.file.type.replace('.+/', ''); } } settings.meta = {}; @@ -166,8 +180,7 @@ Template.previewClipboardImagePopup.events({ settings.meta.boardId = card.boardId; settings.meta.cardId = card._id; settings.meta.userId = Meteor.userId(); - console.log('settings', settings); - const attachment = Attachments.insert(settings, false); + const attachment = Attachments.insert(settings); // TODO: Check image cover behavior if (attachment && attachment._id && attachment.isImage) { diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 39c03aa9..bd110868 100755 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -229,18 +229,14 @@ Template.editor.onRendered(() => { currentCard, fileObj, attachment => { - if ( - attachment && - attachment._id && - attachment.isImage() - ) { + if (attachment && attachment._id && attachment.isImage) { attachment.one('uploaded', function() { const maxTry = 3; const checkItvl = 500; let retry = 0; const checkUrl = function() { // even though uploaded event fired, attachment.url() is still null somehow //TODO - const url = attachment.url(); + const url = attachment.link(); if (url) { insertImage( `${location.protocol}//${location.host}${url}`, diff --git a/client/lib/utils.js b/client/lib/utils.js index 2694396f..d667382d 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -37,7 +37,15 @@ Utils = { let settings = { file: fileObj, 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 = {}; if (card.isLinkedCard()) { @@ -51,10 +59,10 @@ Utils = { } settings.meta.userId = Meteor.userId(); // FIXME: What is this? -/* if (file.original) { + /* if (file.original) { file.original.name = fileObj.name; }*/ - return next(Attachments.insert(settings, false)); + Attachments.insert(settings); }, shrinkImage(options) { // shrink image to certain size -- cgit v1.2.3-1-g7c22 From 6cdd464f54fca423876a27ec2a4269ae5841cdb0 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Wed, 27 Nov 2019 09:40:19 +0000 Subject: Uploaded done, but uploading not --- client/components/cards/attachments.jade | 2 +- client/components/cards/attachments.js | 26 ++++++++++++++------------ client/components/cards/minicard.jade | 2 +- client/components/cards/minicard.js | 3 +++ client/lib/utils.js | 16 ++-------------- 5 files changed, 21 insertions(+), 28 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index 2a96f4f4..3ce639bc 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -23,7 +23,7 @@ template(name="attachmentsGalery") each attachments .attachment-item a.attachment-thumbnail.swipebox(href="{{url}}" title="{{name}}") - if isUploaded + if isUploaded if isImage img.attachment-thumbnail-img(src="{{url}}") else diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index f24a7f82..7346e943 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -13,10 +13,10 @@ Template.attachmentsGalery.events({ event.stopPropagation(); }, 'click .js-add-cover'() { - Cards.findOne(this.cardId).setCover(this._id); + Cards.findOne(this.meta.cardId).setCover(this._id); }, 'click .js-remove-cover'() { - Cards.findOne(this.cardId).unsetCover(); + Cards.findOne(this.meta.cardId).unsetCover(); }, 'click .js-preview-image'(event) { Popup.open('previewAttachedImage').call(this, event); @@ -47,8 +47,11 @@ Template.attachmentsGalery.events({ Template.attachmentsGalery.helpers({ url() { - return Attachments.link(this); - } + return Attachments.link(this); + }, + isUploaded() { + return !!this.meta.uploaded; + }, }); Template.previewAttachedImagePopup.events({ @@ -67,13 +70,14 @@ Template.cardAttachmentsPopup.events({ 'change .js-attach-file'(event) { const card = this; const processFile = f => { - Utils.processUploadedAttachment(card, f, attachment => { - console.log('attachment', attachment); - if (attachment && attachment._id && attachment.isImage) { - card.setCover(attachment._id); + Utils.processUploadedAttachment(card, f, + (err, attachment) => { + if (attachment && attachment._id && attachment.isImage) { + card.setCover(attachment._id); + } + Popup.close(); } - Popup.close(); - }); + ); }; FS.Utility.eachFile(event, f => { @@ -169,7 +173,6 @@ Template.previewClipboardImagePopup.events({ }; if (!results.name) { // 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') { settings.fileName = new Date().getTime() + results.file.type.replace('.+/', ''); @@ -182,7 +185,6 @@ Template.previewClipboardImagePopup.events({ settings.meta.userId = Meteor.userId(); const attachment = Attachments.insert(settings); - // TODO: Check image cover behavior if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade index 79672f8c..0a35bd3a 100644 --- a/client/components/cards/minicard.jade +++ b/client/components/cards/minicard.jade @@ -11,7 +11,7 @@ template(name="minicard") .handle .fa.fa-arrows if cover - .minicard-cover(style="background-image: url('{{cover.url}}');") + .minicard-cover(style="background-image: url('{{coverUrl}}');") if labels .minicard-labels each labels diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js index 4c76db46..3ddb7e97 100644 --- a/client/components/cards/minicard.js +++ b/client/components/cards/minicard.js @@ -32,4 +32,7 @@ Template.minicard.helpers({ hiddenMinicardLabelText() { return Meteor.user().hasHiddenMinicardLabelText(); }, + coverUrl() { + return Attachments.findOne(this.coverId).link(); + }, }); diff --git a/client/lib/utils.js b/client/lib/utils.js index d667382d..8503b035 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -32,20 +32,12 @@ Utils = { } }; if (!card) { - return next(); + return onUploaded(); } let settings = { file: fileObj, streams: '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 = {}; if (card.isLinkedCard()) { @@ -58,11 +50,7 @@ Utils = { settings.meta.cardId = card._id; } settings.meta.userId = Meteor.userId(); - // FIXME: What is this? - /* if (file.original) { - file.original.name = fileObj.name; - }*/ - Attachments.insert(settings); + Attachments.insert(settings).on('end', next); }, shrinkImage(options) { // shrink image to certain size -- cgit v1.2.3-1-g7c22 From 93337c20f83146bb702a5af8cf9cdb37f4c53443 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Tue, 24 Dec 2019 08:57:34 +0000 Subject: Change upload routine, add upload popup --- client/components/cards/attachments.jade | 8 +++++++ client/components/cards/attachments.js | 40 ++++++++++++++++++++++++++++---- client/components/main/editor.js | 1 + client/lib/popup.js | 2 +- client/lib/utils.js | 18 ++++++++------ 5 files changed, 56 insertions(+), 13 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index 3ce639bc..04e0d04c 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -18,6 +18,13 @@ template(name="attachmentDeletePopup") p {{_ "attachment-delete-pop"}} button.js-confirm.negate.full(type="submit") {{_ 'delete'}} +template(name="uploadingPopup") + p Uploading... + p + span.upload-percentage 0% + div.upload-progress-bar + span.upload-size {{fileSize}} + template(name="attachmentsGalery") .attachments-galery each attachments @@ -53,3 +60,4 @@ template(name="attachmentsGalery") unless currentUser.isCommentOnly li.attachment-item.add-attachment a.js-add-attachment {{_ 'add-attachment' }} + diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 7346e943..026ce170 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -66,18 +66,38 @@ Template.previewAttachedImagePopup.helpers({ } }); +// For uploading popup + +let uploadFileSize = new ReactiveVar(''); +let uploadProgress = new ReactiveVar(0); + Template.cardAttachmentsPopup.events({ - 'change .js-attach-file'(event) { + 'change .js-attach-file'(event, instance) { const card = this; - const processFile = f => { - Utils.processUploadedAttachment(card, f, - (err, attachment) => { + const callbacks = { + onBeforeUpload: (err, fileData) => { + Popup.open('uploading')(this.clickEvent); + return true; + }, + onUploaded: (err, attachment) => { + console.log('onEnd'); if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } Popup.close(); + }, + onStart: (error, fileData) => { + console.log('fd', fileData); + uploadFileSize.set(`${fileData.size} bytes`); + }, + onError: (err, fileObj) => { + console.log('Error!', err); + }, + onProgress: (progress, fileData) => { } - ); + }; + const processFile = f => { + Utils.processUploadedAttachment(card, f, callbacks); }; FS.Utility.eachFile(event, f => { @@ -117,12 +137,22 @@ Template.cardAttachmentsPopup.events({ }); }, 'click .js-computer-upload'(event, templateInstance) { + this.clickEvent = event; templateInstance.find('.js-attach-file').click(); event.preventDefault(); }, 'click .js-upload-clipboard-image': Popup.open('previewClipboardImage'), }); +Template.uploadingPopup.onRendered(() => { +}); + +Template.uploadingPopup.helpers({ + fileSize: () => { + return uploadFileSize.get(); + } +}); + const MAX_IMAGE_PIXEL = Utils.MAX_IMAGE_PIXEL; const COMPRESS_RATIO = Utils.IMAGE_COMPRESS_RATIO; let pastedResults = null; diff --git a/client/components/main/editor.js b/client/components/main/editor.js index bd110868..64f24f98 100755 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -225,6 +225,7 @@ Template.editor.onRendered(() => { $summernote.summernote('insertNode', img); }; const processData = function(fileObj) { + // FIXME: Change to new API Utils.processUploadedAttachment( currentCard, fileObj, diff --git a/client/lib/popup.js b/client/lib/popup.js index 8095fbd2..cae22659 100644 --- a/client/lib/popup.js +++ b/client/lib/popup.js @@ -49,7 +49,7 @@ window.Popup = new (class { // has one. This allows us to position a sub-popup exactly at the same // position than its parent. let openerElement; - if (clickFromPopup(evt)) { + if (clickFromPopup(evt) && self._getTopStack()) { openerElement = self._getTopStack().openerElement; } else { self._stack = []; diff --git a/client/lib/utils.js b/client/lib/utils.js index 8503b035..213124f1 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -25,12 +25,7 @@ Utils = { }, MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL, COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO, - processUploadedAttachment(card, fileObj, callback) { - const next = attachment => { - if (typeof callback === 'function') { - callback(attachment); - } - }; + processUploadedAttachment(card, fileObj, callbacks) { if (!card) { return onUploaded(); } @@ -50,7 +45,16 @@ Utils = { settings.meta.cardId = card._id; } settings.meta.userId = Meteor.userId(); - Attachments.insert(settings).on('end', next); + if (typeof callbacks === 'function') { + settings.onEnd = callbacks; + } else { + for (const key in callbacks) { + if (key.substring(0, 2) === 'on') { + settings[key] = callbacks[key]; + } + } + } + Attachments.insert(settings); }, shrinkImage(options) { // shrink image to certain size -- cgit v1.2.3-1-g7c22 From 6ebd6defe917a70e84467d64a1c15ec109c73f1b Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Thu, 2 Jan 2020 09:16:28 +0000 Subject: Uploading dialog done --- client/components/cards/attachments.jade | 8 ++++---- client/components/cards/attachments.js | 25 +++++++++++++++++++------ client/components/cards/attachments.styl | 11 +++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index 04e0d04c..a5a5c00b 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -19,10 +19,10 @@ template(name="attachmentDeletePopup") button.js-confirm.negate.full(type="submit") {{_ 'delete'}} template(name="uploadingPopup") - p Uploading... - p - span.upload-percentage 0% - div.upload-progress-bar + .uploading-info + span.upload-percentage {{progress}}% + .upload-progress-frame + .upload-progress-bar(style="width: {{progress}}%;") span.upload-size {{fileSize}} template(name="attachmentsGalery") diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 026ce170..9e32825e 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -77,23 +77,24 @@ Template.cardAttachmentsPopup.events({ const callbacks = { onBeforeUpload: (err, fileData) => { Popup.open('uploading')(this.clickEvent); + uploadFileSize.set('...'); + uploadProgress.set(0); return true; }, onUploaded: (err, attachment) => { - console.log('onEnd'); if (attachment && attachment._id && attachment.isImage) { card.setCover(attachment._id); } Popup.close(); }, onStart: (error, fileData) => { - console.log('fd', fileData); - uploadFileSize.set(`${fileData.size} bytes`); + uploadFileSize.set(formatBytes(fileData.size)); }, onError: (err, fileObj) => { console.log('Error!', err); }, onProgress: (progress, fileData) => { + uploadProgress.set(progress); } }; const processFile = f => { @@ -144,12 +145,12 @@ Template.cardAttachmentsPopup.events({ 'click .js-upload-clipboard-image': Popup.open('previewClipboardImage'), }); -Template.uploadingPopup.onRendered(() => { -}); - Template.uploadingPopup.helpers({ fileSize: () => { return uploadFileSize.get(); + }, + progress: () => { + return uploadProgress.get(); } }); @@ -225,3 +226,15 @@ Template.previewClipboardImagePopup.events({ } }, }); + +function formatBytes(bytes, decimals = 2) { + if (bytes === 0) return '0 Bytes'; + + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + + const i = Math.floor(Math.log(bytes) / Math.log(k)); + + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; +} diff --git a/client/components/cards/attachments.styl b/client/components/cards/attachments.styl index 4a22fd8a..61ea8232 100644 --- a/client/components/cards/attachments.styl +++ b/client/components/cards/attachments.styl @@ -64,6 +64,17 @@ border: 1px solid black box-shadow: 0 1px 2px rgba(0,0,0,.2) +.uploading-info + .upload-progress-frame + background-color: grey; + border: 1px solid; + height: 22px; + + .upload-progress-bar + background-color: blue; + height: 20px; + padding: 1px; + @media screen and (max-width: 800px) .attachments-galery flex-direction -- cgit v1.2.3-1-g7c22 From d26bf04bfa088b770c85a895700fd704cc08e234 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Tue, 14 Jan 2020 06:29:34 +0000 Subject: Change to relative path and /var/attachments to store --- client/components/cards/attachments.js | 4 +-- client/components/cards/minicard.js | 2 +- client/components/main/editor.js | 47 +++++++++++++++++----------------- 3 files changed, 27 insertions(+), 26 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 9e32825e..82ecabcf 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -47,7 +47,7 @@ Template.attachmentsGalery.events({ Template.attachmentsGalery.helpers({ url() { - return Attachments.link(this); + return Attachments.link(this, 'original', '/'); }, isUploaded() { return !!this.meta.uploaded; @@ -62,7 +62,7 @@ Template.previewAttachedImagePopup.events({ Template.previewAttachedImagePopup.helpers({ url() { - return Attachments.link(this); + return Attachments.link(this, 'original', '/'); } }); diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js index 3ddb7e97..430042f4 100644 --- a/client/components/cards/minicard.js +++ b/client/components/cards/minicard.js @@ -33,6 +33,6 @@ Template.minicard.helpers({ return Meteor.user().hasHiddenMinicardLabelText(); }, coverUrl() { - return Attachments.findOne(this.coverId).link(); + return Attachments.findOne(this.coverId).link('original', '/'); }, }); diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 64f24f98..bc2e0bad 100755 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -225,32 +225,33 @@ Template.editor.onRendered(() => { $summernote.summernote('insertNode', img); }; const processData = function(fileObj) { - // FIXME: Change to new API Utils.processUploadedAttachment( currentCard, - fileObj, - attachment => { - if (attachment && attachment._id && attachment.isImage) { - attachment.one('uploaded', function() { - const maxTry = 3; - const checkItvl = 500; - let retry = 0; - const checkUrl = function() { - // even though uploaded event fired, attachment.url() is still null somehow //TODO - const url = attachment.link(); - if (url) { - insertImage( - `${location.protocol}//${location.host}${url}`, - ); - } else { - retry++; - if (retry < maxTry) { - setTimeout(checkUrl, checkItvl); + fileObj, + { onUploaded: + attachment => { + if (attachment && attachment._id && attachment.isImage) { + attachment.one('uploaded', function() { + const maxTry = 3; + const checkItvl = 500; + let retry = 0; + const checkUrl = function() { + // even though uploaded event fired, attachment.url() is still null somehow //TODO + const url = Attachments.link(attachment, 'original', '/'); + if (url) { + insertImage( + `${location.protocol}//${location.host}${url}`, + ); + } else { + retry++; + if (retry < maxTry) { + setTimeout(checkUrl, checkItvl); + } } - } - }; - checkUrl(); - }); + }; + checkUrl(); + }); + } } }, ); -- cgit v1.2.3-1-g7c22 From 269698ba780a0af5fe0b24fc3c2c43d1f3f1b49d Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Tue, 5 May 2020 14:18:10 +0800 Subject: Attachments download --- client/components/cards/attachments.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade index e6e50d7a..57e46e39 100644 --- a/client/components/cards/attachments.jade +++ b/client/components/cards/attachments.jade @@ -29,7 +29,7 @@ template(name="attachmentsGalery") .attachments-galery each attachments .attachment-item - a.attachment-thumbnail.swipebox(href="{{url}}" title="{{name}}") + a.attachment-thumbnail.swipebox(href="{{url}}" download="{{name}}" title="{{name}}") if isUploaded if isImage img.attachment-thumbnail-img(src="{{url}}") @@ -40,7 +40,7 @@ template(name="attachmentsGalery") p.attachment-details = name span.attachment-details-actions - a.js-download(href="{{url download=true}}") + a.js-download(href="{{url download=true}}" download="{{name}}") i.fa.fa-download | {{_ 'download'}} if currentUser.isBoardMember -- cgit v1.2.3-1-g7c22 From 444848876759173ad80203129250d2f0311f30fc Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Fri, 8 May 2020 09:32:19 +0800 Subject: Done attachments activities operating --- client/components/activities/activities.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'client') diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index b082273a..9697d28c 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -152,17 +152,18 @@ BlazeComponent.extendComponent({ attachmentLink() { const attachment = this.currentData().attachment(); + const link = attachment.link('original', '/'); // trying to display url before file is stored generates js errors return ( attachment && - attachment.url({ download: true }) && + link && Blaze.toHTML( HTML.A( { - href: attachment.url({ download: true }), + href: link, target: '_blank', }, - attachment.name(), + attachment.get('name'), ), ) ); -- cgit v1.2.3-1-g7c22 From 012ca39a8dc29517aef191e85325f3e5889daf37 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Fri, 8 May 2020 11:50:43 +0800 Subject: Attachment activities merging done --- client/components/activities/activities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client') diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index 72af4c35..186200ec 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -163,7 +163,7 @@ BlazeComponent.extendComponent({ href: link, target: '_blank', }, - attachment.name(), + attachment.name, ), )) || this.currentData().activity.attachmentName -- cgit v1.2.3-1-g7c22 From 4064f3f4063136c97aa7bcbcdc18fec923934b74 Mon Sep 17 00:00:00 2001 From: Romulus Urakagi Tsai Date: Wed, 20 May 2020 15:11:22 +0800 Subject: Fix migrated attachment not readable bug Remove reduandant files --- client/components/cards/attachments.js | 5 ++++- client/lib/utils.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js index 82ecabcf..81f6c6e1 100644 --- a/client/components/cards/attachments.js +++ b/client/components/cards/attachments.js @@ -50,7 +50,10 @@ Template.attachmentsGalery.helpers({ return Attachments.link(this, 'original', '/'); }, isUploaded() { - return !!this.meta.uploaded; + return !this.meta.uploading; + }, + isImage() { + return !!this.isImage; }, }); diff --git a/client/lib/utils.js b/client/lib/utils.js index d712cc73..e72f177e 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -70,7 +70,9 @@ Utils = { streams: 'dynamic', chunkSize: 'dynamic', }; - settings.meta = {}; + settings.meta = { + uploading: true + }; if (card.isLinkedCard()) { settings.meta.boardId = Cards.findOne(card.linkedId).boardId; settings.meta.cardId = card.linkedId; -- cgit v1.2.3-1-g7c22