Commit c72053a0 by Rashid Khan

Added pagination to table module

parent 4904c7fc
......@@ -6,7 +6,7 @@ angular.module('kibana.pie', [])
// Set and populate defaults
var _d = {
query : { field:"_all", query:"*", goal: 1},
size : 100,
size : 10,
exclude : [],
donut : false,
tilt : false,
......
<kibana-panel ng-controller='table'>
<div style="height:{{row.height}};overflow-y:auto;overflow-x:auto">
<div style="height:{{row.height}};overflow-y:auto;overflow-x:auto">
<div class="row-fluid">
<div class="span1 offset3" style="text-align:right">
<i ng-click="panel.offset = 0;get_data();" ng-show="panel.offset > 0" class='icon-circle-arrow-left pointer'></i>
<i ng-click="panel.offset = (panel.offset - panel.size);get_data();" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i>
</div>
<div class="span4" style="text-align:center">
<strong>{{panel.offset}}</strong> to <strong>{{panel.offset + data.length}}</strong>
<small> of &#8805 {{hits}} hits</small>
</div>
<div class="span1" style="text-align:left">
<i ng-click="panel.offset = (panel.offset + panel.size);get_data();" ng-show="hits > (panel.offset + data.length)" class='icon-arrow-right pointer'></i>
</div>
</div>
<table class="table table-condensed table-striped" ng-style="panel.style">
<thead>
<th style="white-space:nowrap" ng-repeat="field in panel.fields">
......@@ -13,5 +26,18 @@
<td ng-repeat="field in panel.fields">{{row['_source'][field]}}</td>
</tr>
</table>
<div class="row-fluid">
<div class="span1 offset3" style="text-align:right">
<i ng-click="panel.offset = 0;get_data();" ng-show="panel.offset > 0" class='icon-circle-arrow-left pointer'></i>
<i ng-click="panel.offset = (panel.offset - panel.size);get_data();" ng-show="panel.offset > 0" class='icon-arrow-left pointer'></i>
</div>
<div class="span4" style="text-align:center">
<strong>{{panel.offset}}</strong> to <strong>{{panel.offset + data.length}}</strong>
<small> of &#8805 {{hits}} hits</small>
</div>
<div class="span1" style="text-align:left">
<i ng-click="panel.offset = (panel.offset + panel.size);get_data();" ng-show="hits > (panel.offset + data.length)" class='icon-arrow-right pointer'></i>
</div>
</div>
</div>
</kibana-panel>
\ No newline at end of file
......@@ -7,6 +7,7 @@ angular.module('kibana.table', [])
var _d = {
query : "*",
size : 100,
offset : 0,
sort : ['@timestamp','desc'],
group : "default",
style : {},
......@@ -54,6 +55,11 @@ angular.module('kibana.table', [])
broadcast_fields();
}
$scope.page = function(page) {
$scope.panel.offset = page*$scope.panel.size
$scope.get_data();
}
$scope.get_data = function() {
// Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
......@@ -70,6 +76,7 @@ angular.module('kibana.table', [])
)
)
.size($scope.panel.size)
.from($scope.panel.offset)
.sort($scope.panel.sort[0],$scope.panel.sort[1])
.doSearch();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment