|
|
@@ -11,10 +11,7 @@ function (angular) {
|
|
|
|
|
|
$scope.init = function() {
|
|
|
if ($routeParams.id) {
|
|
|
- $scope.createMode = false;
|
|
|
$scope.getUser($routeParams.id);
|
|
|
- } else {
|
|
|
- $scope.createMode = true;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -25,17 +22,29 @@ function (angular) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ $scope.setPassword = function () {
|
|
|
+ if (!$scope.passwordForm.$valid) { return; }
|
|
|
+
|
|
|
+ var payload = { password: $scope.password };
|
|
|
+ backendSrv.put('/api/admin/users/' + $scope.user_id + '/password', payload).then(function() {
|
|
|
+ $location.path('/admin/users');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.create = function() {
|
|
|
+ if (!$scope.userForm.$valid) { return; }
|
|
|
+
|
|
|
+ backendSrv.post('/api/admin/users', $scope.user).then(function() {
|
|
|
+ $location.path('/admin/users');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
$scope.update = function() {
|
|
|
if (!$scope.userForm.$valid) { return; }
|
|
|
- if ($scope.createMode) {
|
|
|
- backendSrv.post('/api/admin/users', $scope.user).then(function() {
|
|
|
- $location.path('/admin/users');
|
|
|
- });
|
|
|
- } else {
|
|
|
- backendSrv.put('/api/admin/users/' + $scope.user_id, $scope.user).then(function() {
|
|
|
- $location.path('/admin/users');
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
+ backendSrv.put('/api/admin/users/' + $scope.user_id + '/details', $scope.user).then(function() {
|
|
|
+ $location.path('/admin/users');
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
$scope.init();
|