aboutsummaryrefslogtreecommitdiffstats
path: root/settings/js
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-07-22 13:13:39 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-30 18:05:32 +0200
commite184157684ad923d5d4107b76d6421e6ae28799d (patch)
tree41ac7f0569caf96c75657e8dd6858222db2f37b1 /settings/js
parenta07254856ce532bfe5c49c1b53247daf88dbdd4a (diff)
downloadnextcloud-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/js')
-rw-r--r--settings/js/personal.js34
1 files changed, 33 insertions, 1 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"]