diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index 485c94c1d76..4b73b748ae4 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -2081,6 +2081,8 @@ module.controller('RealmImportCtrl', function($scope, realm, $route, $scope.ifResourceExists='FAIL'; $scope.isMultiRealm = false; $scope.results = {}; + $scope.currentPage = 0; + var pageSize = 15; var oldCopy = angular.copy($scope.fileContent); @@ -2115,10 +2117,52 @@ module.controller('RealmImportCtrl', function($scope, realm, $route, $scope.hasResults = function() { return (Object.keys($scope.results).length > 0) && - ($scope.results.results !== 'undefined') && + ($scope.results.results !== undefined) && ($scope.results.results.length > 0); } + $scope.resultsPage = function() { + if (!$scope.hasResults()) return {}; + return $scope.results.results.slice(startIndex(), endIndex()); + } + + function startIndex() { + return pageSize * $scope.currentPage; + } + + function endIndex() { + var length = $scope.results.results.length; + var endIndex = startIndex() + pageSize; + if (endIndex > length) endIndex = length; + return endIndex; + } + + $scope.setFirstPage = function() { + $scope.currentPage = 0; + } + + $scope.setNextPage = function() { + $scope.currentPage++; + } + + $scope.setPreviousPage = function() { + $scope.currentPage--; + } + + $scope.hasNext = function() { + if (!$scope.hasResults()) return false; + var length = $scope.results.results.length; + //console.log('length=' + length); + var endIndex = startIndex() + pageSize; + //console.log('endIndex=' + endIndex); + return length > endIndex; + } + + $scope.hasPrevious = function() { + if (!$scope.hasResults()) return false; + return $scope.currentPage > 0; + } + $scope.viewImportDetails = function() { $modal.open({ templateUrl: resourceUrl + '/partials/modal/view-object.html', diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/partial-import.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/partial-import.html index 4a82f41767e..26301c37b9b 100644 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/partial-import.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/partial-import.html @@ -95,8 +95,19 @@