mirror of
https://github.com/grafana/grafana.git
synced 2025-01-25 15:56:56 -06:00
added sorting
This commit is contained in:
parent
06b8dc3809
commit
896a6f7c10
5
panels/sort/module.html
Normal file
5
panels/sort/module.html
Normal file
@ -0,0 +1,5 @@
|
||||
<div ng-controller='sort'>
|
||||
<h4 ng-hide="_.isUndefined(panel.title)">{{panel.title}}</h4>
|
||||
<select ng-model="panel.sort[0]" ng-options="f for f in fields"></select>
|
||||
<i ng-click="toggle_sort()" ng-class="{'icon-chevron-up': panel.sort[1] == 'asc','icon-chevron-down': panel.sort[1] == 'desc'}"></i>
|
||||
</div>
|
24
panels/sort/module.js
Normal file
24
panels/sort/module.js
Normal file
@ -0,0 +1,24 @@
|
||||
angular.module('kibana.sort', [])
|
||||
.controller('sort', function($scope, $rootScope) {
|
||||
|
||||
// Set and populate defaults
|
||||
var _d = {
|
||||
query : "*",
|
||||
size : 100,
|
||||
sort : [config.timefield,'desc'],
|
||||
}
|
||||
_.each(_d, function(v, k) {
|
||||
$scope.panel[k] = _.isUndefined($scope.panel[k])
|
||||
? _d[k] : $scope.panel[k];
|
||||
});
|
||||
|
||||
$scope.toggle_sort = function() {
|
||||
$scope.panel.sort[1] = $scope.panel.sort[1] == 'asc' ? 'desc' : 'asc';
|
||||
}
|
||||
|
||||
$scope.fields = [];
|
||||
$scope.$on($scope.panel.group+"-fields", function(event, fields) {
|
||||
$scope.panel.sort = fields.sort;
|
||||
$scope.fields = _.union(fields.all,$scope.fields);
|
||||
});
|
||||
})
|
Loading…
Reference in New Issue
Block a user