forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/elastic#1903
- Loading branch information
Showing
23 changed files
with
621 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,13 @@ | ||
<paginate | ||
<paginated-table | ||
ng-if="formattedRows.length" | ||
|
||
list="formattedRows" | ||
per-page-prop="perPage" | ||
|
||
class="agg-table"> | ||
<div class="agg-table-paginated"> | ||
<table class="table table-condensed"> | ||
<thead> | ||
<tr bindonce> | ||
<th | ||
ng-repeat="col in table.columns" | ||
ng-click="aggTable.cycleSort(col)" | ||
ng-class="aggTable.getColumnClass(col, $first, $last)"> | ||
<span bo-text="col.title"></span> | ||
<i | ||
class="fa" | ||
ng-class="{ | ||
'fa-sort-asc': aggTable.sort.col === col && aggTable.sort.asc, | ||
'fa-sort-desc': aggTable.sort.col === col && !aggTable.sort.asc, | ||
'fa-sort': !aggTable.sort || aggTable.sort.col !== col | ||
}"> | ||
</i> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody kbn-rows="page" kbn-rows-min="perPage"></tbody> | ||
</table> | ||
</div> | ||
rows="formattedRows" | ||
columns="formattedColumns" | ||
per-page="perPage"> | ||
|
||
<div class="agg-table-controls"> | ||
<a class="small" ng-click="aggTable.exportAsCsv()"> | ||
Export <i class="fa fa-download"></i> | ||
</a> | ||
<paginate-controls></paginate-controls> | ||
</div> | ||
</paginate> | ||
</paginated-table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/kibana/components/paginated_table/paginated_table.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<paginate | ||
ng-if="sortedRows.length" | ||
list="sortedRows" | ||
per-page-prop="perPage" | ||
class="agg-table"> | ||
<div class="agg-table-paginated"> | ||
<table class="table table-condensed"> | ||
<thead> | ||
<tr bindonce> | ||
<th | ||
ng-repeat="col in columns" | ||
ng-click="paginatedTable.sortColumn(col)" | ||
class="{{ col.class }}"> | ||
<span bo-text="col.title"></span> | ||
<kbn-info ng-if="col.info" info="{{ col.info }}" placement="top"></kbn-info> | ||
<i | ||
class="fa" | ||
ng-class="{ | ||
'fa-sort-asc': paginatedTable.sort.columnName === col.title && paginatedTable.sort.direction === 'asc', | ||
'fa-sort-desc': paginatedTable.sort.columnName === col.title && paginatedTable.sort.direction === 'desc', | ||
'fa-sort': paginatedTable.sort.direction === null || paginatedTable.sort.columnName !== col.title | ||
}"> | ||
</i> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody kbn-rows="page" kbn-rows-min="perPage"></tbody> | ||
</table> | ||
</div> | ||
|
||
<!-- auto-inserted by the paginate directive... --> | ||
<!-- <paginate-controls></paginate-controls> --> | ||
<div class="pagination-container" ng-transclude></div> | ||
|
||
</paginate> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
define(function (require) { | ||
require('modules') | ||
.get('kibana') | ||
.directive('paginatedTable', function ($filter, config, Private) { | ||
var _ = require('lodash'); | ||
var orderBy = $filter('orderBy'); | ||
|
||
return { | ||
restrict: 'E', | ||
template: require('text!components/paginated_table/paginated_table.html'), | ||
transclude: true, | ||
scope: { | ||
rows: '=', | ||
columns: '=', | ||
perPage: '=?', | ||
sortHandler: '=?', | ||
showSelector: '=?' | ||
}, | ||
controllerAs: 'paginatedTable', | ||
controller: function ($scope) { | ||
var self = this; | ||
self.sort = { | ||
columnName: null, | ||
direction: null | ||
}; | ||
|
||
self.sortColumn = function (col) { | ||
var sortDirection; | ||
var cols = _.pluck($scope.columns, 'title'); | ||
var index = cols.indexOf(col.title); | ||
|
||
if (index === -1) return; | ||
|
||
if (self.sort.columnName !== col.title) { | ||
sortDirection = 'asc'; | ||
} else { | ||
var directions = { | ||
null: 'asc', | ||
'asc': 'desc', | ||
'desc': null | ||
}; | ||
sortDirection = directions[self.sort.direction]; | ||
} | ||
|
||
self.sort.columnName = col.title; | ||
self.sort.direction = sortDirection; | ||
self._setSortGetter(index); | ||
}; | ||
|
||
self._setSortGetter = function (index) { | ||
if (_.isFunction($scope.sortHandler)) { | ||
// use custom sort handler | ||
self.sort.getter = $scope.sortHandler(index); | ||
} else { | ||
// use generic sort handler | ||
self.sort.getter = function (row) { | ||
var value = row[index]; | ||
if (value.value) return value.value; | ||
return value; | ||
}; | ||
} | ||
}; | ||
|
||
// update the sordedRows result | ||
$scope.$watchMulti([ | ||
'paginatedTable.sort.direction', | ||
'rows' | ||
], function () { | ||
if (self.sort.direction == null) { | ||
$scope.sortedRows = $scope.rows.slice(0); | ||
return; | ||
} | ||
|
||
$scope.sortedRows = orderBy($scope.rows, self.sort.getter, self.sort.direction === 'desc'); | ||
}); | ||
} | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.