mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-19 08:21:01 +00:00
54 lines
No EOL
1.1 KiB
JavaScript
54 lines
No EOL
1.1 KiB
JavaScript
(function () {
|
|
|
|
/**
|
|
* UserCtrl is responsible for managing user settings.
|
|
*/
|
|
function UserCtrl($scope, users) {
|
|
|
|
// Gets the currently authenticated user
|
|
users.getCurrent().then(function(payload){
|
|
$scope.user = payload.data;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* UsersCtrl is responsible for managing user accounts.
|
|
* This part of the site is for administrators only.
|
|
*/
|
|
function UsersCtrl($scope, users) {
|
|
// Gets the currently authenticated user
|
|
users.getCached().then(function(payload){
|
|
$scope.user = payload.data;
|
|
});
|
|
|
|
users.list().then(function(payload){
|
|
$scope.users = payload.data;
|
|
});
|
|
|
|
$scope.login="";
|
|
$scope.add = function(login) {
|
|
users.post(login).then(function(payload){
|
|
$scope.users.push(payload.data);
|
|
$scope.login="";
|
|
});
|
|
}
|
|
|
|
$scope.toggle = function(user) {
|
|
user.admin = !user.admin;
|
|
users.put(user);
|
|
}
|
|
|
|
$scope.remove = function(user) {
|
|
users.delete(user).then(function(){
|
|
users.list().then(function(payload){
|
|
$scope.users = payload.data;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
angular
|
|
.module('drone')
|
|
.controller('UserCtrl', UserCtrl)
|
|
.controller('UsersCtrl', UsersCtrl);
|
|
})(); |