diff --git a/src/kibana/apps/visualize/editor/agg.html b/src/kibana/apps/visualize/editor/agg.html index 911a1229551c1..80d0da93534cc 100644 --- a/src/kibana/apps/visualize/editor/agg.html +++ b/src/kibana/apps/visualize/editor/agg.html @@ -66,18 +66,18 @@
- - -
- - - +
+

+ "{{ agg.schema.title }}" aggs must run before all other buckets! +

+
+ +
\ No newline at end of file diff --git a/src/kibana/apps/visualize/editor/agg.js b/src/kibana/apps/visualize/editor/agg.js index f39493c4f5375..9bcb4d046cbde 100644 --- a/src/kibana/apps/visualize/editor/agg.js +++ b/src/kibana/apps/visualize/editor/agg.js @@ -5,6 +5,7 @@ define(function (require) { var _ = require('lodash'); var $ = require('jquery'); var aggTypes = Private(require('components/agg_types/index')); + var aggSelectHtml = require('text!apps/visualize/editor/agg_select.html'); require('apps/visualize/editor/agg_param'); @@ -35,24 +36,36 @@ define(function (require) { var i = $scope.$index; $scope.$first = i === 0; $scope.$last = i === $scope.group.length - 1; + $scope.aggIsTooLow = calcAggIsTooLow(); }); (function setupControlManagement() { var $editorContainer = $el.find('.vis-editor-agg-editor'); + // this will contain the controls for the schema (rows or columns?), which are unrelated to + // controls for the agg, which is why they are first + var $schemaEditor = $('
').addClass('schemaEditors').appendTo($editorContainer); if ($scope.agg.schema.editor) { - var $schemaEditor = $('
').prependTo($editorContainer); $schemaEditor.append($scope.agg.schema.editor); $compile($schemaEditor)(editorScope()); } + // allow selection of an aggregation + var $aggSelect = $(aggSelectHtml).appendTo($editorContainer); + $compile($aggSelect)($scope); + + // params for the selected agg, these are rebuilt every time the agg changes var $aggParamEditors; var $aggParamEditorsScope; $scope.$watch('agg.type', function updateAggParamEditor(newType, oldType) { if ($aggParamEditors) { $aggParamEditors.remove(); + $aggParamEditors = null; + } + + if ($aggParamEditorsScope) { $aggParamEditorsScope.$destroy(); - $aggParamEditors = $aggParamEditorsScope = null; + $aggParamEditorsScope = null; } var agg = $scope.agg; @@ -166,6 +179,22 @@ define(function (require) { aggs.splice(index, 1); }; + + function calcAggIsTooLow() { + if (!$scope.agg.schema.mustBeFirst) { + return false; + } + + var firstDifferentSchema = _.findIndex($scope.group, function (agg) { + return agg.schema !== $scope.agg.schema; + }); + + if (firstDifferentSchema === -1) { + return false; + } + + return $scope.$index > firstDifferentSchema; + } } }; }); diff --git a/src/kibana/apps/visualize/editor/agg_select.html b/src/kibana/apps/visualize/editor/agg_select.html new file mode 100644 index 0000000000000..9fc7e281be686 --- /dev/null +++ b/src/kibana/apps/visualize/editor/agg_select.html @@ -0,0 +1,11 @@ +
+ + + +
\ No newline at end of file diff --git a/src/kibana/apps/visualize/editor/editor.less b/src/kibana/apps/visualize/editor/styles/editor.less similarity index 95% rename from src/kibana/apps/visualize/editor/editor.less rename to src/kibana/apps/visualize/editor/styles/editor.less index df0b78485f9c9..d88c896ea28e1 100644 --- a/src/kibana/apps/visualize/editor/editor.less +++ b/src/kibana/apps/visualize/editor/styles/editor.less @@ -138,6 +138,14 @@ } } + &-error { + margin: @vis-editor-agg-editor-spacing 0; + padding: @vis-editor-agg-editor-spacing; + text-align: center; + background: @btn-danger-bg; + color: @btn-danger-color; + } + &-editor { margin-top: @vis-editor-agg-editor-spacing; diff --git a/src/kibana/apps/visualize/styles/main.less b/src/kibana/apps/visualize/styles/main.less index 67207d1583dd2..6a8ec51f85735 100644 --- a/src/kibana/apps/visualize/styles/main.less +++ b/src/kibana/apps/visualize/styles/main.less @@ -19,4 +19,4 @@ font-size: 1.2em; } -@import "../editor/editor.less"; +@import "../editor/styles/editor.less"; diff --git a/src/kibana/components/vis_types/pie.js b/src/kibana/components/vis_types/pie.js index 8079d26c266ce..cfdc4b622d538 100644 --- a/src/kibana/components/vis_types/pie.js +++ b/src/kibana/components/vis_types/pie.js @@ -39,6 +39,7 @@ define(function (require) { name: 'split', icon: 'fa fa-th', title: 'Split Chart', + mustBeFirst: true, min: 0, max: 1 }