diff --git a/themes/src/main/resources/theme/base/admin/resources/js/app.js b/themes/src/main/resources/theme/base/admin/resources/js/app.js index eeae412e9f..adb0c5ea41 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/app.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/app.js @@ -2680,20 +2680,38 @@ module.directive('kcOnReadFile', function ($parse) { }); module.controller('PagingCtrl', function ($scope) { - $scope.isLastPage = function() - { - if ($scope.currentPage === $scope.numberOfPages) { - return true; - } - return false; + $scope.currentPageInput = 1; + + $scope.firstPage = function() { + if (!$scope.hasPrevious()) return; + $scope.currentPage = 1; + $scope.currentPageInput = 1; }; - - $scope.isFirstPage = function() - { - if ($scope.currentPage === 1) { - return true; - } - return false; + + $scope.lastPage = function() { + if (!$scope.hasNext()) return; + $scope.currentPage = $scope.numberOfPages; + $scope.currentPageInput = $scope.numberOfPages; + }; + + $scope.previousPage = function() { + if (!$scope.hasPrevious()) return; + $scope.currentPage--; + $scope.currentPageInput = $scope.currentPage; + }; + + $scope.nextPage = function() { + if (!$scope.hasNext()) return; + $scope.currentPage++; + $scope.currentPageInput = $scope.currentPage; + }; + + $scope.hasNext = function() { + return $scope.currentPage < $scope.numberOfPages; + }; + + $scope.hasPrevious = function() { + return $scope.currentPage > 1; }; }); @@ -2701,15 +2719,34 @@ module.directive('kcPaging', function () { return { scope: { currentPage: '=', + currentPageInput: '=', numberOfPages: '=' }, - restrict: 'A', + restrict: 'E', replace: true, controller: 'PagingCtrl', templateUrl: resourceUrl + '/templates/kc-paging.html' } }); +// Tests the page number input from currentPageInput to see +// if it represents a valid page. If so, the current page is changed. +module.directive('kcValidPage', function() { + return { + require: 'ngModel', + link: function(scope, element, attrs, ctrl) { + ctrl.$validators.inRange = function(modelValue, viewValue) { + if (viewValue >= 1 && viewValue <= scope.numberOfPages) { + scope.currentPage = viewValue; + } + + return true; + } + } + } +}); + +// filter used for paged tables module.filter('startFrom', function () { return function (input, start) { if (input) { diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js index d81882d797..7d8de51ead 100755 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/clients.js @@ -735,6 +735,7 @@ module.controller('ClientListCtrl', function($scope, realm, clients, Client, ser $scope.realm = realm; $scope.clients = clients; $scope.currentPage = 1; + $scope.currentPageInput = 1; $scope.pageSize = 20; $scope.numberOfPages = Math.ceil($scope.clients.length/$scope.pageSize); @@ -743,6 +744,7 @@ module.controller('ClientListCtrl', function($scope, realm, clients, Client, ser $scope.totalItems = $scope.filtered.length; $scope.numberOfPages = Math.ceil($scope.totalItems/$scope.pageSize); $scope.currentPage = 1; + $scope.currentPageInput = 1; }, true); $scope.removeClient = function(client) { diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index a42ef3c5e4..d7909ac509 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -1227,14 +1227,16 @@ module.controller('RoleListCtrl', function($scope, $route, Dialog, Notifications $scope.realm = realm; $scope.roles = roles; $scope.currentPage = 1; + $scope.currentPageInput = 1; $scope.pageSize = 20; $scope.numberOfPages = Math.ceil($scope.roles.length/$scope.pageSize); $scope.$watch('searchQuery', function (newVal, oldVal) { - $scope.filtered = filterFilter($scope.roles, newVal); + $scope.filtered = filterFilter($scope.roles, {name: newVal}); $scope.totalItems = $scope.filtered.length; $scope.numberOfPages = Math.ceil($scope.totalItems/$scope.pageSize); $scope.currentPage = 1; + $scope.currentPageInput = 1; }, true); $scope.removeRole = function (role) { diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/client-list.html b/themes/src/main/resources/theme/base/admin/resources/partials/client-list.html index 50c71dcb57..51aaa2009b 100755 --- a/themes/src/main/resources/theme/base/admin/resources/partials/client-list.html +++ b/themes/src/main/resources/theme/base/admin/resources/partials/client-list.html @@ -4,59 +4,53 @@ {{:: 'clients.tooltip' | translate}} - +
- - + - - - - - - - - - - - + - + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/role-list.html b/themes/src/main/resources/theme/base/admin/resources/partials/role-list.html index ca27439622..5c0d47304e 100755 --- a/themes/src/main/resources/theme/base/admin/resources/partials/role-list.html +++ b/themes/src/main/resources/theme/base/admin/resources/partials/role-list.html @@ -6,54 +6,48 @@
  • {{:: 'default-roles' | translate}}
  • - +
    - - + - - - - - - - - - - - + - + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/themes/src/main/resources/theme/base/admin/resources/templates/kc-paging.html b/themes/src/main/resources/theme/base/admin/resources/templates/kc-paging.html index d875c72d1c..653e4a58c9 100644 --- a/themes/src/main/resources/theme/base/admin/resources/templates/kc-paging.html +++ b/themes/src/main/resources/theme/base/admin/resources/templates/kc-paging.html @@ -1,19 +1,25 @@ -
    -
    \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak/admin/resources/css/styles.css b/themes/src/main/resources/theme/keycloak/admin/resources/css/styles.css index daa55f5187..9253c8c839 100755 --- a/themes/src/main/resources/theme/keycloak/admin/resources/css/styles.css +++ b/themes/src/main/resources/theme/keycloak/admin/resources/css/styles.css @@ -379,14 +379,4 @@ h1 i { .ace_editor { height: 600px; width: 100%; -} - -.kc-pagination { - border: 1px solid #d1d1d1; - font-size: 12px; - height: 23px; - margin-right: 10px; - padding-right: 10px; - text-align: right; - width: 30px; } \ No newline at end of file