From d292d5d419596d99dcc4aeb1128f4a9d5d0cac02 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Wed, 7 Jul 2021 14:39:17 +0200 Subject: [PATCH] Have 3 explicit avatar options custom image, gravatar or none --- src/img/avatar-default-symbolic.svg | 133 ++++++++++++++++++++++++++++ src/js/client.js | 41 ++++----- src/views/profile.html | 35 +++++--- src/views/profile.js | 28 +++--- 4 files changed, 192 insertions(+), 45 deletions(-) create mode 100644 src/img/avatar-default-symbolic.svg diff --git a/src/img/avatar-default-symbolic.svg b/src/img/avatar-default-symbolic.svg new file mode 100644 index 000000000..ee7e8c6b0 --- /dev/null +++ b/src/img/avatar-default-symbolic.svg @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/src/js/client.js b/src/js/client.js index 40f9723a1..2440839c0 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -1805,28 +1805,29 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; - Client.prototype.clearAvatar = function (callback) { - del('/api/v1/profile/avatar', {}, function (error, data, status) { - if (error) return callback(error); - if (status !== 202) return callback(new ClientError(status, data)); - callback(null); - }); - }; + Client.prototype.changeAvatar = function (avatarFileOrType, callback) { + // Blob type if object + if (typeof avatarFileOrType === 'object') { + var fd = new FormData(); + fd.append('avatar', avatarFileOrType); - Client.prototype.changeAvatar = function (avatarFile, callback) { - var fd = new FormData(); - fd.append('avatar', avatarFile); + var config = { + headers: { 'Content-Type': undefined }, + transformRequest: angular.identity + }; - var config = { - headers: { 'Content-Type': undefined }, - transformRequest: angular.identity - }; - - post('/api/v1/profile/avatar', fd, config, function (error, data, status) { - if (error) return callback(error); - if (status !== 202) return callback(new ClientError(status, data)); - callback(null); - }); + post('/api/v1/profile/avatar', fd, config, function (error, data, status) { + if (error) return callback(error); + if (status !== 202) return callback(new ClientError(status, data)); + callback(null); + }); + } else { + post('/api/v1/profile/avatar', { avatar: avatarFileOrType === 'gravatar' ? 'gravatar' : '' }, null, function (error, data, status) { + if (error) return callback(error); + if (status !== 202) return callback(new ClientError(status, data)); + callback(null); + }); + } }; Client.prototype.changePassword = function (currentPassword, newPassword, callback) { diff --git a/src/views/profile.html b/src/views/profile.html index b09e6b0c8..66bc77343 100644 --- a/src/views/profile.html +++ b/src/views/profile.html @@ -7,32 +7,39 @@ -