Semaphore/public/js/controllers/users.js
Matej Kramny 0b417594a4 Improve setup, upgrade, new API
- Improve upgrade process (fixes #106)
- Improve upgrade UI
- Delete Users API
- Get user API
- User update API
- Security improvement (does not spill secret over api)
- Improve setup (fixes #100)
2016-05-23 20:29:38 +01:00

26 lines
775 B
JavaScript

define(function () {
app.registerController('UsersCtrl', ['$scope', '$http', '$uibModal', function ($scope, $http, $modal) {
$http.get('/users').success(function (users) {
$scope.users = users;
});
$scope.addUser = function () {
$modal.open({
templateUrl: '/tpl/users/add.html'
}).result.then(function (_user) {
$http.post('/users', _user).success(function (user) {
$scope.users.push(user);
$http.post('/users/' + user.id + '/password', {
password: _user.password
}).error(function (_, status) {
swal('Error', 'Setting password failed, API responded with HTTP ' + status, 'error');
});
}).error(function (_, status) {
swal('Error', 'API responded with HTTP ' + status, 'error');
});
});
}
}]);
});