Fixed interpanel communication

This commit is contained in:
Rashid Khan
2013-02-05 14:30:08 -07:00
parent 834e63a123
commit 1095373aa7
12 changed files with 278 additions and 212 deletions
+13 -10
View File
@@ -1,25 +1,28 @@
angular.module('kibana.sort', [])
.controller('sort', function($scope, $rootScope) {
var _id = _.uniqueId();
// Set and populate defaults
var _d = {
label : "Sort",
query : "*",
size : 100,
sort : [config.timefield,'desc'],
group : "default"
}
_.defaults($scope.panel,_d);
$scope.init = function() {
$scope.fields = [];
$scope.$on($scope.panel.group+"-fields", function(event, fields) {
$scope.panel.sort = fields.sort;
$scope.fields = _.union(fields.all,$scope.fields);
});
}
_.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);
});
$scope.init();
})