2016-04-19 11:58:07 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.layout.user')
|
|
|
|
.controller('UserController', UserController);
|
|
|
|
|
2016-05-12 12:30:01 +02:00
|
|
|
UserController.$inject = ['ListUserService', 'DeleteUserService'];
|
|
|
|
|
|
|
|
function UserController(ListUserService, DeleteUserService) {
|
|
|
|
var vm = this;
|
|
|
|
|
|
|
|
vm.username = '';
|
|
|
|
vm.searchUser = searchUser;
|
|
|
|
vm.deleteUser = deleteUser;
|
|
|
|
vm.retrieve = retrieve;
|
|
|
|
|
|
|
|
vm.retrieve();
|
|
|
|
|
|
|
|
function searchUser() {
|
|
|
|
vm.retrieve();
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteUser(userId) {
|
|
|
|
DeleteUserService(userId)
|
|
|
|
.success(deleteUserSuccess)
|
|
|
|
.error(deleteUserFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function retrieve() {
|
|
|
|
ListUserService(vm.username)
|
|
|
|
.success(listUserSuccess)
|
|
|
|
.error(listUserFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteUserSuccess(data, status) {
|
|
|
|
console.log('Successful delete user.');
|
|
|
|
vm.retrieve();
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteUserFailed(data, status) {
|
|
|
|
console.log('Failed delete user.');
|
|
|
|
}
|
|
|
|
|
|
|
|
function listUserSuccess(data, status) {
|
|
|
|
vm.users = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function listUserFailed(data, status) {
|
|
|
|
console.log('Failed list user:' + data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-21 12:19:51 +02:00
|
|
|
|
2016-04-19 11:58:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|