mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 07:20:12 +01:00
Increase the avatar max size and show an error if it is too big
Fixes #190
This commit is contained in:
parent
dc3cbdd20e
commit
53018baeb2
4 changed files with 33 additions and 15 deletions
|
|
@ -36,6 +36,8 @@ template(name="memberName")
|
||||||
= user.username
|
= user.username
|
||||||
|
|
||||||
template(name="changeAvatarPopup")
|
template(name="changeAvatarPopup")
|
||||||
|
if error.get
|
||||||
|
.warning {{_ error.get}}
|
||||||
ul.pop-over-list
|
ul.pop-over-list
|
||||||
each uploadedAvatars
|
each uploadedAvatars
|
||||||
li: a.js-select-avatar
|
li: a.js-select-avatar
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ BlazeComponent.extendComponent({
|
||||||
return 'changeAvatarPopup';
|
return 'changeAvatarPopup';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onCreated: function() {
|
||||||
|
this.error = new ReactiveVar('');
|
||||||
|
},
|
||||||
|
|
||||||
avatarUrlOptions: function() {
|
avatarUrlOptions: function() {
|
||||||
return {
|
return {
|
||||||
auth: false,
|
auth: false,
|
||||||
|
|
@ -79,28 +83,39 @@ BlazeComponent.extendComponent({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setError: function(error) {
|
||||||
|
this.error.set(error);
|
||||||
|
},
|
||||||
|
|
||||||
events: function() {
|
events: function() {
|
||||||
return [{
|
return [{
|
||||||
'click .js-upload-avatar': function() {
|
'click .js-upload-avatar': function() {
|
||||||
this.$('.js-upload-avatar-input').click();
|
this.$('.js-upload-avatar-input').click();
|
||||||
},
|
},
|
||||||
'change .js-upload-avatar-input': function(evt) {
|
'change .js-upload-avatar-input': function(evt) {
|
||||||
var self = this;
|
let file, fileUrl;
|
||||||
var file, fileUrl;
|
|
||||||
|
|
||||||
FS.Utility.eachFile(evt, function(f) {
|
FS.Utility.eachFile(evt, (f) => {
|
||||||
file = Avatars.insert(new FS.File(f));
|
try {
|
||||||
fileUrl = file.url(self.avatarUrlOptions());
|
file = Avatars.insert(new FS.File(f));
|
||||||
|
fileUrl = file.url(this.avatarUrlOptions());
|
||||||
|
} catch (e) {
|
||||||
|
this.setError('avatar-too-big');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var fetchAvatarInterval = window.setInterval(function() {
|
|
||||||
$.ajax({
|
if (fileUrl) {
|
||||||
url: fileUrl,
|
this.setError('');
|
||||||
success: function() {
|
let fetchAvatarInterval = window.setInterval(() => {
|
||||||
self.setAvatar(file.url(self.avatarUrlOptions()));
|
$.ajax({
|
||||||
window.clearInterval(fetchAvatarInterval);
|
url: fileUrl,
|
||||||
}
|
success: () => {
|
||||||
});
|
this.setAvatar(file.url(this.avatarUrlOptions()));
|
||||||
}, 100);
|
window.clearInterval(fetchAvatarInterval);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'click .js-select-avatar': function() {
|
'click .js-select-avatar': function() {
|
||||||
var avatarUrl = this.currentData().url(this.avatarUrlOptions());
|
var avatarUrl = this.currentData().url(this.avatarUrlOptions());
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ Avatars = new FS.Collection('avatars', {
|
||||||
new FS.Store.GridFS('avatars')
|
new FS.Store.GridFS('avatars')
|
||||||
],
|
],
|
||||||
filter: {
|
filter: {
|
||||||
maxSize: 32000,
|
maxSize: 72000,
|
||||||
allow: {
|
allow: {
|
||||||
contentTypes: ['image/*']
|
contentTypes: ['image/*']
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@
|
||||||
"editProfilePopup-title": "Edit Profile",
|
"editProfilePopup-title": "Edit Profile",
|
||||||
"changeAvatarPopup-title": "Change Avatar",
|
"changeAvatarPopup-title": "Change Avatar",
|
||||||
"changePasswordPopup-title": "Change Password",
|
"changePasswordPopup-title": "Change Password",
|
||||||
|
"avatar-too-big": "The avatar is too large (70Kb max)",
|
||||||
"cardDetailsActionsPopup-title": "Card Actions",
|
"cardDetailsActionsPopup-title": "Card Actions",
|
||||||
"disambiguateMultiLabelPopup-title": "Disambiguate Label Action",
|
"disambiguateMultiLabelPopup-title": "Disambiguate Label Action",
|
||||||
"disambiguateMultiMemberPopup-title": "Disambiguate Member Action"
|
"disambiguateMultiMemberPopup-title": "Disambiguate Member Action"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue