diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index 090f0c123..42728b4c5 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -162,6 +162,7 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', this._userInfo.id = userInfo.id; this._userInfo.username = userInfo.username; this._userInfo.email = userInfo.email; + this._userInfo.displayName = userInfo.displayName; this._userInfo.admin = !!userInfo.admin; this._userInfo.gravatar = 'https://www.gravatar.com/avatar/' + md5.createHash(userInfo.email.toLowerCase()) + '.jpg?s=24&d=mm'; this._userInfo.gravatarHuge = 'https://www.gravatar.com/avatar/' + md5.createHash(userInfo.email.toLowerCase()) + '.jpg?s=128&d=mm'; diff --git a/webadmin/src/views/account.html b/webadmin/src/views/account.html index ab242d9d9..8c85c1fca 100644 --- a/webadmin/src/views/account.html +++ b/webadmin/src/views/account.html @@ -71,6 +71,34 @@ + + +
@@ -89,7 +117,11 @@ - + + + + + diff --git a/webadmin/src/views/account.js b/webadmin/src/views/account.js index e49b6d190..0256fe5f8 100644 --- a/webadmin/src/views/account.js +++ b/webadmin/src/views/account.js @@ -110,6 +110,52 @@ angular.module('Application').controller('AccountController', ['$scope', '$locat } }; + $scope.displayNameChange = { + busy: false, + error: {}, + displayName: '', + + reset: function () { + $scope.displayNameChange.busy = false; + $scope.displayNameChange.error.displayName = null; + $scope.displayNameChange.displayName = ''; + + $scope.displayNameChangeForm.$setUntouched(); + $scope.displayNameChangeForm.$setPristine(); + }, + + show: function () { + $scope.displayNameChange.reset(); + $scope.displayNameChange.displayName = $scope.user.displayName; + $('#displayNameChangeModal').modal('show'); + }, + + submit: function () { + $scope.displayNameChange.error.displayName = null; + $scope.displayNameChange.busy = true; + + var user = { + id: $scope.user.id, + displayName: $scope.displayNameChange.displayName + }; + + Client.updateUser(user, function (error) { + $scope.displayNameChange.busy = false; + + if (error) { + console.error('Unable to change displayName.', error); + return; + } + + // update user info in the background + Client.refreshUserInfo(); + + $scope.displayNameChange.reset(); + $('#displayNameChangeModal').modal('hide'); + }); + } + }; + $scope.removeAccessTokens = function (client) { client.busy = true; @@ -138,7 +184,7 @@ angular.module('Application').controller('AccountController', ['$scope', '$locat }); // setup all the dialog focus handling - ['passwordChangeModal', 'emailChangeModal'].forEach(function (id) { + ['passwordChangeModal', 'emailChangeModal', 'displayNameChangeModal'].forEach(function (id) { $('#' + id).on('shown.bs.modal', function () { $(this).find("[autofocus]:first").focus(); });
Username{{ user.username }}   {{ user.username }}    
Display Name{{ user.displayName }}
Email