Commit 896a6f7c by Rashid Khan

added sorting

parent 06b8dc38
<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>
\ No newline at end of file
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);
});
})
\ No newline at end of file
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