add pagination
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
}]);
|
||||
|
||||
Reference in New Issue
Block a user