updates for paginator and pagination in logs.

This commit is contained in:
kunw 2016-08-06 15:11:20 +08:00
parent f44e6f5991
commit d4035e0ec3
3 changed files with 19 additions and 30 deletions

View File

@ -47,8 +47,8 @@
</tr>
</tbody>
</table>
<paginator class="pull-right" total-count="//vm.totalCount//" page-size="1" page="vm.page" display-count="3" retrieve="vm.search({op: vm.op, username: vm.username})"></paginator>
</div>
<paginator class="pull-right" total-count="//vm.totalCount//" page-size="//vm.pageSize//" page="vm.page" display-count="3"></paginator>
</div>
</div>
</div>

View File

@ -53,7 +53,7 @@
};
vm.page = 1;
vm.pageSize = 1;
vm.pageSize = 2;
$scope.$watch('vm.totalCount', function(current) {
if(current) {

View File

@ -22,8 +22,7 @@
'totalCount': '@',
'pageSize': '@',
'page': '=',
'displayCount': '@',
'retrieve': '&'
'displayCount': '@'
},
'link': link,
'controller': PaginatorController,
@ -57,6 +56,7 @@
++this.time;
++ctrl.page;
}
scope.$apply();
}
TimeCounter.prototype.canIncrement = function() {
@ -71,6 +71,7 @@
--this.time;
--ctrl.page;
}
scope.$apply();
}
TimeCounter.prototype.canDecrement = function() {
@ -94,10 +95,7 @@
}
element.find('ul li:first a').on('click', previous);
ctrl.showPrevious = false;
element.find('ul li:last a').on('click', next);
ctrl.showNext = (buttonCount > displayCount);
var drawButtons = function(time) {
element.find('li[tag="pagination-button"]').remove();
@ -114,12 +112,12 @@
}
drawButtons(tc.getTime());
togglePrevious(false);
toggleNext((buttonCount > displayCount));
togglePrevious(tc.canDecrement());
toggleNext(tc.canIncrement());
togglePageButton();
function togglePrevious(status) {
if(status){
element.find('ul li:first').removeClass('disabled');
@ -139,24 +137,14 @@
function buttonClickHandler(e) {
ctrl.page = $(e.target).attr('page');
togglePageButton();
ctrl.retrieve();
if(tc.canIncrement()) {
toggleNext(true);
}else {
toggleNext(false);
}
if(tc.canDecrement()) {
togglePrevious(true);
}else{
togglePrevious(false);
}
togglePrevious(tc.canDecrement());
toggleNext(tc.canIncrement());
scope.$apply();
}
function togglePageButton() {
element.find('li[tag="pagination-button"]').removeClass('active');
element.find('li[tag="pagination-button"] a[page="' + ctrl.page + '"]').parent().addClass('active');
element.find('li[tag="pagination-button"]').removeClass('active');
element.find('li[tag="pagination-button"] a[page="' + ctrl.page + '"]').parent().addClass('active');
}
function previous() {
@ -165,6 +153,7 @@
drawButtons(tc.getTime());
element.find('li[tag="pagination-button"] a[page="' + ctrl.page + '"]').trigger('click');
}
scope.$apply();
}
function next() {
@ -172,8 +161,8 @@
tc.increment();
drawButtons(tc.getTime());
element.find('li[tag="pagination-button"] a[page="' + ctrl.page + '"]').trigger('click');
}
scope.$apply();
}
}
});