From 577db4abc39e64ab691d2f457dfb17f54277c12c Mon Sep 17 00:00:00 2001 From: EvB Date: Tue, 20 Dec 2016 18:29:30 -0500 Subject: [PATCH] feat(super-user): paginate orgs --- static/js/pages/superuser.js | 36 ++++++++++++++++++++++++++++++++- static/partials/super-user.html | 22 +++++++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/static/js/pages/superuser.js b/static/js/pages/superuser.js index 91bee789a..4751c0b67 100644 --- a/static/js/pages/superuser.js +++ b/static/js/pages/superuser.js @@ -10,7 +10,7 @@ }) }]); - function SuperuserCtrl($scope, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog) { + function SuperuserCtrl($scope, ApiService, Features, UserService, ContainerService, AngularPollChannel, CoreDialog, TableService) { if (!Features.SUPER_USERS) { return; } @@ -31,6 +31,14 @@ $scope.serviceKeysActive = false; $scope.globalMessagesActive = false; $scope.manageUsersActive = false; + $scope.orderedOrgs = []; + $scope.orgsPerPage = 10; + $scope.options = { + 'predicate': 'name', + 'reverse': false, + 'filter': null, + 'page': 0, + } $scope.loadMessageOfTheDay = function () { $scope.globalMessagesActive = true; @@ -106,9 +114,16 @@ $scope.loadOrganizationsInternal(); }; + var sortOrgs = function() { + if (!$scope.organizations) {return;} + $scope.orderedOrgs = TableService.buildOrderedItems($scope.organizations, $scope.options, + ['name', 'email'], []); + }; + $scope.loadOrganizationsInternal = function() { $scope.organizationsResource = ApiService.listAllOrganizationsAsResource().get(function(resp) { $scope.organizations = resp['organizations']; + sortOrgs(); return $scope.organizations; }); }; @@ -117,6 +132,21 @@ $scope.manageUsersActive = true; }; + $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.askDeleteOrganization = function(org) { bootbox.confirm('Are you sure you want to delete this organization? Its data will be deleted with it.', function(result) { @@ -185,5 +215,9 @@ // Load the initial status. $scope.checkStatus(); + $scope.$watch('options.predicate', sortOrgs); + $scope.$watch('options.reverse', sortOrgs); + $scope.$watch('options.filter', sortOrgs); + } }()); diff --git a/static/partials/super-user.html b/static/partials/super-user.html index 4e9eaa943..68605654c 100644 --- a/static/partials/super-user.html +++ b/static/partials/super-user.html @@ -111,17 +111,29 @@
-
+
+ + + + +
- +
- - + + + -
NameAdmin E-mail + Name + + Admin Email +