Move pagination of transaction proposals to the backend

This commit is contained in:
Yemel Jardi 2014-05-20 14:34:55 -07:00
parent c51731dc69
commit 15fc035ba9
4 changed files with 16 additions and 11 deletions

View File

@ -388,7 +388,7 @@
<li> <button ng-click="show(true)" ng-disabled="loading || onlyPending" loading="Updating"> Pending </button> <li> <button ng-click="show(true)" ng-disabled="loading || onlyPending" loading="Updating"> Pending </button>
<li> <button ng-click="show()" ng-disabled="loading || !onlyPending" loading="Updating"> All </button> <li> <button ng-click="show()" ng-disabled="loading || !onlyPending" loading="Updating"> All </button>
</ul> </ul>
<div class="panel radius pending" ng-repeat="tx in txs | orderBy: 'createdTs':true | paged:txpCurrentPage:txpItemsPerPage:onlyPending"> <div class="panel radius pending" ng-repeat="tx in txs | paged">
<div class="txheader row m10"> <div class="txheader row m10">
<div class="large-8 medium-8 small-12 columns"> <div class="large-8 medium-8 small-12 columns">
<div class="row" ng-repeat="out in tx.outs"> <div class="row" ng-repeat="out in tx.outs">
@ -477,7 +477,7 @@
</div> </div>
</div> </div>
</div> </div>
<pagination ng-show="!onlyPending" total-items="txs.length" items-per-page="txpItemsPerPage" page="txpCurrentPage" class="pagination-small"></pagination> <pagination ng-show="!onlyPending" total-items="txs.length" items-per-page="txpItemsPerPage" page="txpCurrentPage" on-select-page="show()" class="pagination-small"></pagination>
</div> </div>
<div class="large-12 columns"> <div class="large-12 columns">
<h4>Last transactions</h4> <h4>Last transactions</h4>

View File

@ -13,7 +13,12 @@ angular.module('copay.transactions').controller('TransactionsController',
$scope.update = function () { $scope.update = function () {
$scope.loading = false; $scope.loading = false;
controllerUtils.updateTxs({onlyPending:$scope.onlyPending}); var from = ($scope.txpCurrentPage-1) * $scope.txpItemsPerPage;
var opts = {
onlyPending: $scope.onlyPending,
skip: !$scope.onlyPending ? [from, from + $scope.txpItemsPerPage] : null
};
controllerUtils.updateTxs(opts);
$rootScope.$digest(); $rootScope.$digest();
}; };

View File

@ -21,11 +21,7 @@ angular.module('copay.filters', [])
}; };
}) })
.filter('paged', function() { .filter('paged', function() {
return function(elements, page, pageSize, disable) { return function(elements) {
if (disable) return elements; return elements.filter(Boolean);
var from = (page - 1) * pageSize;
var to = from + pageSize;
return elements.slice(from, to);;
}; };
}); });

View File

@ -132,11 +132,15 @@ angular.module('copay.controllerUtils')
console.log('## updating tx proposals', opts); //TODO console.log('## updating tx proposals', opts); //TODO
var myCopayerId = w.getMyCopayerId(); var myCopayerId = w.getMyCopayerId();
var pendingForUs = 0; var pendingForUs = 0;
var inT = w.getTxProposals(); var inT = w.getTxProposals().sort(function(t1, t2) { return t1.createdTs < t2.createdTs });
var txs = []; var txs = [];
console.log('[START LOOP]'); //TODO console.log('[START LOOP]'); //TODO
inT.forEach(function(i){ inT.forEach(function(i, index){
if (opts.skip && (index < opts.skip[0] || index >= opts.skip[1])) {
return txs.push(null);
}
if (myCopayerId != i.creator && !i.finallyRejected && !i.sentTs && !i.rejectedByUs && !i.signedByUs) { if (myCopayerId != i.creator && !i.finallyRejected && !i.sentTs && !i.rejectedByUs && !i.signedByUs) {
pendingForUs++; pendingForUs++;
} }