diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-22 13:13:39 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-30 18:05:32 +0200 |
commit | e184157684ad923d5d4107b76d6421e6ae28799d (patch) | |
tree | 41ac7f0569caf96c75657e8dd6858222db2f37b1 /settings | |
parent | a07254856ce532bfe5c49c1b53247daf88dbdd4a (diff) | |
download | nextcloud-server-e184157684ad923d5d4107b76d6421e6ae28799d.tar.gz nextcloud-server-e184157684ad923d5d4107b76d6421e6ae28799d.zip |
[avatar] add error handlers for avatar setup
add colon to translated string
use placeholder in t()
Adding a size limitation for avatar upload
Unit test for file size
Fix typo & display server side error message
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/personal.js | 34 | ||||
-rw-r--r-- | settings/templates/personal.php | 2 |
2 files changed, 34 insertions, 2 deletions
diff --git a/settings/js/personal.js b/settings/js/personal.js index ac18f525809..9e4dd54090d 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -234,6 +234,20 @@ $(document).ready(function () { var uploadparms = { done: function (e, data) { avatarResponseHandler(data.result); + }, + fail: function (e, data){ + var msg = data.jqXHR.statusText + ' (' + data.jqXHR.status + ')'; + if (!_.isUndefined(data.jqXHR.responseJSON) && + !_.isUndefined(data.jqXHR.responseJSON.data) && + !_.isUndefined(data.jqXHR.responseJSON.data.message) + ) { + msg = data.jqXHR.responseJSON.data.message; + } + avatarResponseHandler({ + data: { + message: t('settings', 'An error occurred: {message}', { message: msg }) + } + }); } }; @@ -247,7 +261,25 @@ $(document).ready(function () { OC.dialogs.filepicker( t('settings', "Select a profile picture"), function (path) { - $.post(OC.generateUrl('/avatar/'), {path: path}, avatarResponseHandler); + $.ajax({ + type: "POST", + url: OC.generateUrl('/avatar/'), + data: { path: path } + }).done(avatarResponseHandler) + .fail(function(jqXHR, status){ + var msg = jqXHR.statusText + ' (' + jqXHR.status + ')'; + if (!_.isUndefined(jqXHR.responseJSON) && + !_.isUndefined(jqXHR.responseJSON.data) && + !_.isUndefined(jqXHR.responseJSON.data.message) + ) { + msg = jqXHR.responseJSON.data.message; + } + avatarResponseHandler({ + data: { + message: t('settings', 'An error occurred: {message}', { message: msg }) + } + }); + }); }, false, ["image/png", "image/jpeg"] diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 02ee261cd1d..e7832b85ebd 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -159,7 +159,7 @@ if($_['passwordChangeSupported']) { <input type="file" class="hidden" name="files[]" id="uploadavatar"> <div class="inlineblock button" id="selectavatar"><?php p($l->t('Select new from Files')); ?></div> <div class="inlineblock button" id="removeavatar"><?php p($l->t('Remove image')); ?></div><br> - <?php p($l->t('Either png or jpg. Ideally square but you will be able to crop it.')); ?> + <?php p($l->t('Either png or jpg. Ideally square but you will be able to crop it. The file is not allowed to exceed the maximum size of 20 MB.')); ?> <?php else: ?> <?php p($l->t('Your avatar is provided by your original account.')); ?> <?php endif; ?> |