瀏覽代碼

[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

Dhia MOAKHAR 8 年之前
父節點
當前提交
d55cc4e2a3
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. 2 3
      public/app/plugins/datasource/elasticsearch/metric_agg.js

+ 2 - 3
public/app/plugins/datasource/elasticsearch/metric_agg.js

@@ -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