Commit d55cc4e2 by Dhia MOAKHAR

[elasticsearch] Fix add metric that was not working properly

 when selecting Raw Documet metric type, the $scope.target.metrics was replaced by [$scope.agg],
 however the pointer to this variables is shared with metricAggs.
 Instead we free the array and add $scope.agg
parent 966c2912
...@@ -67,7 +67,6 @@ function (angular, _, queryDef) { ...@@ -67,7 +67,6 @@ function (angular, _, queryDef) {
} else if (!$scope.agg.field) { } else if (!$scope.agg.field) {
$scope.agg.field = 'select field'; $scope.agg.field = 'select field';
} }
switch($scope.agg.type) { switch($scope.agg.type) {
case 'cardinality': { case 'cardinality': {
var precision_threshold = $scope.agg.settings.precision_threshold || ''; var precision_threshold = $scope.agg.settings.precision_threshold || '';
...@@ -105,12 +104,12 @@ function (angular, _, queryDef) { ...@@ -105,12 +104,12 @@ function (angular, _, queryDef) {
case 'raw_document': { case 'raw_document': {
$scope.agg.settings.size = $scope.agg.settings.size || 500; $scope.agg.settings.size = $scope.agg.settings.size || 500;
$scope.settingsLinkText = 'Size: ' + $scope.agg.settings.size ; $scope.settingsLinkText = 'Size: ' + $scope.agg.settings.size ;
$scope.target.metrics = [$scope.agg]; $scope.target.metrics.splice(0,$scope.target.metrics.length, $scope.agg);
$scope.target.bucketAggs = []; $scope.target.bucketAggs = [];
break; break;
} }
} }
if ($scope.aggDef.supportsInlineScript) { if ($scope.aggDef.supportsInlineScript) {
// I know this stores the inline script twice // I know this stores the inline script twice
// but having it like this simplifes the query_builder // but having it like this simplifes the query_builder
......
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