mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-25 16:42:34 +00:00
Bare bones pagination for partial import results.
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -95,8 +95,19 @@
|
||||
<th>Id</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="table-nav">
|
||||
<button data-ng-click="setFirstPage()" class="first" ng-disabled="">First page</button>
|
||||
<button data-ng-click="setPreviousPage()" class="prev" ng-disabled="!hasPrevious()">Previous page</button>
|
||||
<button data-ng-click="setNextPage()" class="next" ng-disabled="!hasNext()">Next page</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<tr ng-repeat="result in results.results" >
|
||||
<tr ng-repeat="result in resultsPage()" >
|
||||
<td>{{result.action}}</td>
|
||||
<td>{{result.resourceType}}</td>
|
||||
<td>{{result.resourceName}}</td>
|
||||
|
||||
Reference in New Issue
Block a user