diff --git a/static/directives/manage-users-tab.html b/static/directives/manage-users-tab.html index 18d10ec84..730ebf15a 100644 --- a/static/directives/manage-users-tab.html +++ b/static/directives/manage-users-tab.html @@ -14,30 +14,40 @@ -
- - +
+ + + + +
+
- - - - + + + + -
UsernameE-mail address + Username + + E-mail address +
- + - - You - Superuser - Disabled - + + You + Superuser + Disabled + {{ current_user.username }} diff --git a/static/js/directives/ui/manage-user-tab.js b/static/js/directives/ui/manage-user-tab.js index 6193925f9..7695936b4 100644 --- a/static/js/directives/ui/manage-user-tab.js +++ b/static/js/directives/ui/manage-user-tab.js @@ -9,30 +9,61 @@ angular.module('quay').directive('manageUserTab', function () { transclude: true, restrict: 'C', scope: { - 'isEnabled': '=isEnabled' + 'isEnabled': '=isEnabled' }, - controller: function ($scope, $timeout, $location, $element, ApiService, UserService) { + controller: function ($scope, $timeout, $location, $element, ApiService, UserService, TableService) { + $scope.user = UserService.currentUser(); + $scope.users = null; + $scope.orderedUsers = []; + $scope.usersPerPage = 10; $scope.newUser = {}; $scope.createdUser = null; $scope.takeOwnershipInfo = null; - + $scope.options = { + 'predicate': 'username', + 'reverse': false, + 'filter': null, + 'page': 0 + }; $scope.showCreateUser = function () { $scope.createdUser = null; $('#createUserModal').modal('show'); }; + var sortUsers = function() { + if (!$scope.users) {return;} + $scope.orderedUsers = TableService.buildOrderedItems($scope.users, $scope.options, + ['username', 'email'], []); + }; + var loadUsersInternal = function () { ApiService.listAllUsers().then(function (resp) { $scope.users = resp['users']; + sortUsers(); $scope.showInterface = true; }, function (resp) { $scope.users = []; $scope.usersError = ApiService.getErrorMessage(resp); }); }; + $scope.tablePredicateClass = function(name, predicate, reverse) { + if (name != predicate) { + return ''; + } + return 'current ' + (reverse ? 'reversed' : ''); + }; + + $scope.orderBy = function(predicate) { + if (predicate == $scope.options.predicate) { + $scope.options.reverse = !$scope.options.reverse; + return; + } + $scope.options.reverse = false; + $scope.options.predicate = predicate; + }; $scope.createUser = function () { $scope.creatingUser = true; $scope.createdUser = null; @@ -224,6 +255,10 @@ angular.module('quay').directive('manageUserTab', function () { loadUsersInternal(); } }); + + $scope.$watch('options.predicate', sortUsers); + $scope.$watch('options.reverse', sortUsers); + $scope.$watch('options.filter', sortUsers); } }; return directiveDefinitionObject;