harbor/static/resources/js/components/user/list-user.directive.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
angular
.module('harbor.user')
.directive('listUser', listUser);
2016-06-25 21:12:17 +02:00
ListUserController.$inject = ['$scope', 'ListUserService', 'DeleteUserService'];
2016-06-25 21:12:17 +02:00
function ListUserController($scope, ListUserService, DeleteUserService) {
2016-06-26 06:56:58 +02:00
$scope.subsSubPane = 226;
var vm = this;
2016-06-25 21:12:17 +02:00
vm.username = '';
vm.searchUser = searchUser;
vm.deleteUser = deleteUser;
vm.confirmToDelete = confirmToDelete;
vm.retrieve = retrieve;
vm.retrieve();
function searchUser() {
vm.retrieve();
}
function deleteUser() {
DeleteUserService(vm.selectedUserId)
.success(deleteUserSuccess)
.error(deleteUserFailed);
}
function confirmToDelete(userId) {
vm.selectedUserId = userId;
}
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);
}
}
function listUser() {
var directive = {
'restrict': 'E',
'templateUrl': '/static/resources/js/components/user/list-user.directive.html',
2016-06-25 21:12:17 +02:00
'link': link,
'controller': ListUserController,
'controllerAs': 'vm',
'bindToController': true
};
return directive;
2016-06-25 21:12:17 +02:00
function link(scope, element, attrs) {
}
}
})();