[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
This commit is contained in:
Dhia MOAKHAR 2017-06-03 02:50:10 +00:00
parent 966c2912fc
commit d55cc4e2a3

View File

@ -67,7 +67,6 @@ function (angular, _, queryDef) {
} else if (!$scope.agg.field) {
$scope.agg.field = 'select field';
}
switch($scope.agg.type) {
case 'cardinality': {
var precision_threshold = $scope.agg.settings.precision_threshold || '';
@ -105,12 +104,12 @@ function (angular, _, queryDef) {
case 'raw_document': {
$scope.agg.settings.size = $scope.agg.settings.size || 500;
$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 = [];
break;
}
}
if ($scope.aggDef.supportsInlineScript) {
// I know this stores the inline script twice
// but having it like this simplifes the query_builder