summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2020-05-25 17:54:51 +0300
committerLauri Ojansivu <x@xet7.org>2020-05-25 17:54:51 +0300
commitd52affe65893f17bab59bb43aa9f5afbb54993d3 (patch)
tree82b88066d4fb8efb6610ed77177d3747d34f0480 /client
parent23dcd084a49de4e6568527d8f97ed25adb04dafd (diff)
downloadwekan-d52affe65893f17bab59bb43aa9f5afbb54993d3.tar.gz
wekan-d52affe65893f17bab59bb43aa9f5afbb54993d3.tar.bz2
wekan-d52affe65893f17bab59bb43aa9f5afbb54993d3.zip
Move In Progress ostrio-files changes to separate branch, and revert ostrio-files changes, so that:
- Export to CSV/TSV with custom fields works - Attachments are not exported to disk - It is possible to build arm64/s390x versions again. Thanks to xet7 ! Related #3110
Diffstat (limited to 'client')
-rw-r--r--client/components/activities/activities.js12
-rw-r--r--client/components/cards/attachments.jade13
-rw-r--r--client/components/cards/attachments.js103
-rw-r--r--client/components/cards/attachments.styl11
-rw-r--r--client/components/cards/minicard.jade2
-rw-r--r--client/components/cards/minicard.js3
-rwxr-xr-xclient/components/main/editor.js50
-rw-r--r--client/lib/utils.js44
8 files changed, 70 insertions, 168 deletions
diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js
index 4f15d421..5d356f6e 100644
--- a/client/components/activities/activities.js
+++ b/client/components/activities/activities.js
@@ -151,23 +151,21 @@ BlazeComponent.extendComponent({
},
attachmentLink() {
- const activity = this.currentData().activity;
- const attachment = activity.attachment();
- const link = attachment ? attachment.link('original', '/') : null;
+ const attachment = this.currentData().activity.attachment();
// trying to display url before file is stored generates js errors
return (
(attachment &&
- link &&
+ attachment.url({ download: true }) &&
Blaze.toHTML(
HTML.A(
{
- href: link,
+ href: attachment.url({ download: true }),
target: '_blank',
},
- attachment.name,
+ attachment.name(),
),
)) ||
- activity.attachmentName
+ this.currentData().activity.attachmentName
);
},
diff --git a/client/components/cards/attachments.jade b/client/components/cards/attachments.jade
index eda6d118..61454fa7 100644
--- a/client/components/cards/attachments.jade
+++ b/client/components/cards/attachments.jade
@@ -18,19 +18,12 @@ template(name="attachmentDeletePopup")
p {{_ "attachment-delete-pop"}}
button.js-confirm.negate.full(type="submit") {{_ 'delete'}}
-template(name="uploadingPopup")
- .uploading-info
- span.upload-percentage {{progress}}%
- .upload-progress-frame
- .upload-progress-bar(style="width: {{progress}}%;")
- span.upload-size {{fileSize}}
-
template(name="attachmentsGalery")
.attachments-galery
each attachments
.attachment-item
- a.attachment-thumbnail.swipebox(href="{{url}}" download="{{name}}" title="{{name}}")
- if isUploaded
+ a.attachment-thumbnail.swipebox(href="{{url}}" title="{{name}}")
+ if isUploaded
if isImage
img.attachment-thumbnail-img(src="{{url}}")
else
@@ -40,7 +33,7 @@ template(name="attachmentsGalery")
p.attachment-details
= name
span.attachment-details-actions
- a.js-download(href="{{url download=true}}" download="{{name}}")
+ a.js-download(href="{{url download=true}}")
i.fa.fa-download
| {{_ 'download'}}
if currentUser.isBoardMember
diff --git a/client/components/cards/attachments.js b/client/components/cards/attachments.js
index 81f6c6e1..e4439155 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.meta.cardId).setCover(this._id);
+ Cards.findOne(this.cardId).setCover(this._id);
},
'click .js-remove-cover'() {
- Cards.findOne(this.meta.cardId).unsetCover();
+ Cards.findOne(this.cardId).unsetCover();
},
'click .js-preview-image'(event) {
Popup.open('previewAttachedImage').call(this, event);
@@ -45,63 +45,22 @@ Template.attachmentsGalery.events({
},
});
-Template.attachmentsGalery.helpers({
- url() {
- return Attachments.link(this, 'original', '/');
- },
- isUploaded() {
- return !this.meta.uploading;
- },
- isImage() {
- return !!this.isImage;
- },
-});
-
Template.previewAttachedImagePopup.events({
'click .js-large-image-clicked'() {
Popup.close();
},
});
-Template.previewAttachedImagePopup.helpers({
- url() {
- return Attachments.link(this, 'original', '/');
- }
-});
-
-// For uploading popup
-
-let uploadFileSize = new ReactiveVar('');
-let uploadProgress = new ReactiveVar(0);
-
Template.cardAttachmentsPopup.events({
- 'change .js-attach-file'(event, instance) {
+ 'change .js-attach-file'(event) {
const card = this;
- const callbacks = {
- onBeforeUpload: (err, fileData) => {
- Popup.open('uploading')(this.clickEvent);
- uploadFileSize.set('...');
- uploadProgress.set(0);
- return true;
- },
- onUploaded: (err, attachment) => {
- if (attachment && attachment._id && attachment.isImage) {
- card.setCover(attachment._id);
- }
- Popup.close();
- },
- onStart: (error, fileData) => {
- uploadFileSize.set(formatBytes(fileData.size));
- },
- onError: (err, fileObj) => {
- console.log('Error!', err);
- },
- onProgress: (progress, fileData) => {
- uploadProgress.set(progress);
- }
- };
const processFile = f => {
- Utils.processUploadedAttachment(card, f, callbacks);
+ Utils.processUploadedAttachment(card, f, attachment => {
+ if (attachment && attachment._id && attachment.isImage()) {
+ card.setCover(attachment._id);
+ }
+ Popup.close();
+ });
};
FS.Utility.eachFile(event, f => {
@@ -141,22 +100,12 @@ 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.helpers({
- fileSize: () => {
- return uploadFileSize.get();
- },
- progress: () => {
- return uploadProgress.get();
- }
-});
-
const MAX_IMAGE_PIXEL = Utils.MAX_IMAGE_PIXEL;
const COMPRESS_RATIO = Utils.IMAGE_COMPRESS_RATIO;
let pastedResults = null;
@@ -200,26 +149,20 @@ Template.previewClipboardImagePopup.events({
if (results && results.file) {
window.oPasted = pastedResults;
const card = this;
- const settings = {
- file: results.file,
- streams: 'dynamic',
- chunkSize: 'dynamic',
- };
+ const file = new FS.File(results.file);
if (!results.name) {
// if no filename, it's from clipboard. then we give it a name, with ext name from MIME type
if (typeof results.file.type === 'string') {
- settings.fileName =
- new Date().getTime() + results.file.type.replace('.+/', '');
+ file.name(results.file.type.replace('image/', 'clipboard.'));
}
}
- settings.meta = {};
- settings.meta.updatedAt = new Date().getTime();
- settings.meta.boardId = card.boardId;
- settings.meta.cardId = card._id;
- settings.meta.userId = Meteor.userId();
- const attachment = Attachments.insert(settings);
+ file.updatedAt(new Date());
+ file.boardId = card.boardId;
+ file.cardId = card._id;
+ file.userId = Meteor.userId();
+ const attachment = Attachments.insert(file);
- if (attachment && attachment._id && attachment.isImage) {
+ if (attachment && attachment._id && attachment.isImage()) {
card.setCover(attachment._id);
}
@@ -229,15 +172,3 @@ 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 61ea8232..4a22fd8a 100644
--- a/client/components/cards/attachments.styl
+++ b/client/components/cards/attachments.styl
@@ -64,17 +64,6 @@
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
diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade
index e9de2fea..79dd9127 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('{{coverUrl}}');")
+ .minicard-cover(style="background-image: url('{{cover.url}}');")
if labels
.minicard-labels
each labels
diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js
index 200e019d..da36b87f 100644
--- a/client/components/cards/minicard.js
+++ b/client/components/cards/minicard.js
@@ -52,7 +52,4 @@ Template.minicard.helpers({
return false;
}
},
- coverUrl() {
- return Attachments.findOne(this.coverId).link('original', '/');
- },
});
diff --git a/client/components/main/editor.js b/client/components/main/editor.js
index abe4160f..0c2e3186 100755
--- a/client/components/main/editor.js
+++ b/client/components/main/editor.js
@@ -152,31 +152,33 @@ Template.editor.onRendered(() => {
const processData = function(fileObj) {
Utils.processUploadedAttachment(
currentCard,
- 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);
- }
+ 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.url();
+ if (url) {
+ insertImage(
+ `${location.protocol}//${location.host}${url}`,
+ );
+ } else {
+ retry++;
+ if (retry < maxTry) {
+ setTimeout(checkUrl, checkItvl);
}
- };
- checkUrl();
- });
- }
+ }
+ };
+ checkUrl();
+ });
}
},
);
diff --git a/client/lib/utils.js b/client/lib/utils.js
index e72f177e..c921fddc 100644
--- a/client/lib/utils.js
+++ b/client/lib/utils.js
@@ -61,38 +61,30 @@ Utils = {
},
MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL,
COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO,
- processUploadedAttachment(card, fileObj, callbacks) {
+ processUploadedAttachment(card, fileObj, callback) {
+ const next = attachment => {
+ if (typeof callback === 'function') {
+ callback(attachment);
+ }
+ };
if (!card) {
- return onUploaded();
+ return next();
}
- let settings = {
- file: fileObj,
- streams: 'dynamic',
- chunkSize: 'dynamic',
- };
- settings.meta = {
- uploading: true
- };
+ const file = new FS.File(fileObj);
if (card.isLinkedCard()) {
- settings.meta.boardId = Cards.findOne(card.linkedId).boardId;
- settings.meta.cardId = card.linkedId;
+ file.boardId = Cards.findOne(card.linkedId).boardId;
+ file.cardId = card.linkedId;
} else {
- settings.meta.boardId = card.boardId;
- settings.meta.swimlaneId = card.swimlaneId;
- settings.meta.listId = card.listId;
- settings.meta.cardId = card._id;
+ file.boardId = card.boardId;
+ file.swimlaneId = card.swimlaneId;
+ file.listId = card.listId;
+ file.cardId = card._id;
}
- settings.meta.userId = Meteor.userId();
- if (typeof callbacks === 'function') {
- settings.onEnd = callbacks;
- } else {
- for (const key in callbacks) {
- if (key.substring(0, 2) === 'on') {
- settings[key] = callbacks[key];
- }
- }
+ file.userId = Meteor.userId();
+ if (file.original) {
+ file.original.name = fileObj.name;
}
- Attachments.insert(settings);
+ return next(Attachments.insert(file));
},
shrinkImage(options) {
// shrink image to certain size