@spalger/kibana
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
47 lines (39 loc) • 1.39 kB
JavaScript
var _ = require('lodash');
define(function (require) {
require('ui/modules')
.get('app/visualize')
.directive('visEditorAggGroup', function (Private) {
require('plugins/kibana/visualize/editor/agg');
require('plugins/kibana/visualize/editor/agg_add');
require('plugins/kibana/visualize/editor/nesting_indicator');
return {
restrict: 'E',
template: require('plugins/kibana/visualize/editor/agg_group.html'),
scope: true,
link: function ($scope, $el, attr) {
$scope.groupName = attr.groupName;
$scope.$bind('group', 'vis.aggs.bySchemaGroup["' + $scope.groupName + '"]');
$scope.$bind('schemas', 'vis.type.schemas["' + $scope.groupName + '"]');
$scope.$watchMulti([
'schemas',
'[]group'
], function () {
var stats = $scope.stats = {
min: 0,
max: 0,
count: $scope.group ? $scope.group.length : 0
};
if (!$scope.schemas) return;
$scope.schemas.forEach(function (schema) {
stats.min += schema.min;
stats.max += schema.max;
});
$scope.availableSchema = $scope.schemas.filter(function (schema) {
var count = _.where($scope.group, { schema }).length;
if (count < schema.max) return true;
});
});
}
};
});
});