diff --git a/webadmin/src/views/users.html b/webadmin/src/views/users.html index c39324fd7..13dbc5cb3 100644 --- a/webadmin/src/views/users.html +++ b/webadmin/src/views/users.html @@ -60,7 +60,7 @@ @@ -316,7 +316,7 @@ - + diff --git a/webadmin/src/views/users.js b/webadmin/src/views/users.js index 28bc2ae42..e69006e14 100644 --- a/webadmin/src/views/users.js +++ b/webadmin/src/views/users.js @@ -15,7 +15,59 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio error: {}, userInfo: {}, username: '', - password: '' + password: '', + + show: function (userInfo) { + $scope.userremove.error.username = null; + $scope.userremove.error.password = null; + $scope.userremove.username = ''; + $scope.userremove.password = ''; + $scope.userremove.userInfo = userInfo; + + $scope.userremove_form.$setPristine(); + $scope.userremove_form.$setUntouched(); + + $('#userRemoveModal').modal('show'); + }, + + submit: function () { + $scope.userremove.error.username = null; + $scope.userremove.error.password = null; + + if ($scope.userremove.username !== $scope.userremove.userInfo.username && $scope.userremove.username !== $scope.userremove.userInfo.email && $scope.userremove.username !== $scope.userremove.userInfo.alternateEmail) { + $scope.userremove.error.username = true; + $scope.userremove.username = ''; + $scope.userremove_form.username.$setPristine(); + $('#inputUserRemoveUsername').focus(); + return; + } + + $scope.userremove.busy = true; + + Client.removeUser($scope.userremove.userInfo.id, $scope.userremove.password, function (error) { + $scope.userremove.busy = false; + + if (error && error.statusCode === 403) { + $scope.userremove.error.password = 'Wrong password'; + $scope.userremove.password = ''; + $scope.userremove_form.password.$setPristine(); + $('#inputUserRemovePassword').focus(); + return; + } + if (error) return console.error('Unable to delete user.', error); + + $scope.userremove.userInfo = {}; + $scope.userremove.username = ''; + $scope.userremove.password = ''; + + $scope.userremove_form.$setPristine(); + $scope.userremove_form.$setUntouched(); + + refresh(); + + $('#userRemoveModal').modal('hide'); + }); + } }; $scope.useradd = { @@ -326,58 +378,6 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio }); }; - $scope.showUserRemove = function (userInfo) { - $scope.userremove.error.username = null; - $scope.userremove.error.password = null; - $scope.userremove.username = ''; - $scope.userremove.password = ''; - $scope.userremove.userInfo = userInfo; - - $scope.userremove_form.$setPristine(); - $scope.userremove_form.$setUntouched(); - - $('#userRemoveModal').modal('show'); - }; - - $scope.doUserRemove = function () { - $scope.userremove.error.username = null; - $scope.userremove.error.password = null; - - if ($scope.userremove.username !== $scope.userremove.userInfo.username && $scope.userremove.username !== $scope.userremove.userInfo.email && $scope.userremove.username !== $scope.userremove.userInfo.alternateEmail) { - $scope.userremove.error.username = true; - $scope.userremove.username = ''; - $scope.userremove_form.username.$setPristine(); - $('#inputUserRemoveUsername').focus(); - return; - } - - $scope.userremove.busy = true; - - Client.removeUser($scope.userremove.userInfo.id, $scope.userremove.password, function (error) { - $scope.userremove.busy = false; - - if (error && error.statusCode === 403) { - $scope.userremove.error.password = 'Wrong password'; - $scope.userremove.password = ''; - $scope.userremove_form.password.$setPristine(); - $('#inputUserRemovePassword').focus(); - return; - } - if (error) return console.error('Unable to delete user.', error); - - $scope.userremove.userInfo = {}; - $scope.userremove.username = ''; - $scope.userremove.password = ''; - - $scope.userremove_form.$setPristine(); - $scope.userremove_form.$setUntouched(); - - refresh(); - - $('#userRemoveModal').modal('hide'); - }); - }; - $scope.showUserHelp = function () { $('#userHelpModal').modal('show'); };