add pagination

This commit is contained in:
Girish Ramakrishnan
2016-05-02 11:36:20 -07:00
parent 7fca9decc1
commit 6c1bd522e6
2 changed files with 27 additions and 3 deletions

View File

@@ -2,15 +2,20 @@
<br/>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="col-md-8 col-md-offset-1">
<h1>Activity Log</h1>
</div>
<div class="pagination col-md-offset-1">
<button class="btn btn-default btn-outline" ng-click="showPrevPage()" ng-disabled="busy || currentPage <= 1"><i class="fa fa-angle-double-left"></i> prev</button>
<button class="btn btn-default btn-outline" ng-click="showNextPage()" ng-disabled="busy || pageItems > eventLogs.length">next <i class="fa fa-angle-double-right"></i></button>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="col-md-10 col-md-offset-1">
<div class="card card-block" style="max-width: 100%">
<table class="table table-striped table-condensed table-hover">
<thead>

View File

@@ -5,8 +5,16 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca
$scope.eventLogs = [ ];
$scope.currentPage = 1;
$scope.pageItems = 20;
function fetchEventLogs() {
Client.getEventLogs(1, 20, function (error, eventLogs) {
$scope.busy = true;
Client.getEventLogs($scope.currentPage, $scope.pageItems, function (error, eventLogs) {
$scope.busy = false;
if (error) return console.error(error);
$scope.eventLogs = eventLogs;
@@ -17,4 +25,15 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca
fetchEventLogs();
});
$scope.showNextPage = function () {
$scope.currentPage++;
fetchEventLogs();
};
$scope.showPrevPage = function () {
if ($scope.currentPage > 1) $scope.currentPage--;
else $scope.currentPage = 1;
fetchEventLogs();
};
}]);