Commit f51d74fa by carl bergquist

change the way options are added

parent 78c6ce84
...@@ -76,8 +76,12 @@ function (_, queryDef) { ...@@ -76,8 +76,12 @@ function (_, queryDef) {
newSeries = { datapoints: [], metric: metric.type, field: metric.field, props: props}; newSeries = { datapoints: [], metric: metric.type, field: metric.field, props: props};
for (i = 0; i < esAgg.buckets.length; i++) { for (i = 0; i < esAgg.buckets.length; i++) {
bucket = esAgg.buckets[i]; bucket = esAgg.buckets[i];
value = bucket[metric.id].value;
newSeries.datapoints.push([value, bucket.key]); value = bucket[metric.id];
if (value !== undefined) {
newSeries.datapoints.push([value.value, bucket.key]);
}
} }
seriesList.push(newSeries); seriesList.push(newSeries);
break; break;
......
...@@ -13,7 +13,6 @@ function (angular, _, queryDef) { ...@@ -13,7 +13,6 @@ function (angular, _, queryDef) {
$scope.metricAggTypes = queryDef.metricAggTypes; $scope.metricAggTypes = queryDef.metricAggTypes;
$scope.extendedStats = queryDef.extendedStats; $scope.extendedStats = queryDef.extendedStats;
$scope.mavgSourceOptions = [];
$scope.init = function() { $scope.init = function() {
$scope.agg = metricAggs[$scope.index]; $scope.agg = metricAggs[$scope.index];
...@@ -23,7 +22,6 @@ function (angular, _, queryDef) { ...@@ -23,7 +22,6 @@ function (angular, _, queryDef) {
$rootScope.onAppEvent('elastic-query-updated', function() { $rootScope.onAppEvent('elastic-query-updated', function() {
$scope.index = _.indexOf(metricAggs, $scope.agg); $scope.index = _.indexOf(metricAggs, $scope.agg);
$scope.validateModel(); $scope.validateModel();
$scope.updateMovingAverageOptions();
}, $scope); }, $scope);
$scope.validateModel = function() { $scope.validateModel = function() {
...@@ -38,7 +36,7 @@ function (angular, _, queryDef) { ...@@ -38,7 +36,7 @@ function (angular, _, queryDef) {
switch($scope.agg.type) { switch($scope.agg.type) {
case 'moving_avg': { case 'moving_avg': {
$scope.agg.mavgSource = $scope.agg.mavgSource || ''; $scope.agg.mavgSource = $scope.agg.mavgSource || 'Basec on metric';
$scope.settingsLinkText = 'Moving average options'; $scope.settingsLinkText = 'Moving average options';
break; break;
} }
...@@ -90,6 +88,11 @@ function (angular, _, queryDef) { ...@@ -90,6 +88,11 @@ function (angular, _, queryDef) {
return $scope.getFields({$fieldType: 'number'}); return $scope.getFields({$fieldType: 'number'});
}; };
$scope.mavgSourceOptions = function() {
return $q.when(queryDef.getMovingAverageSourceOptions($scope.target))
.then(uiSegmentSrv.transformToSegments(false));
};
$scope.addMetricAgg = function() { $scope.addMetricAgg = function() {
var addIndex = metricAggs.length; var addIndex = metricAggs.length;
...@@ -101,10 +104,6 @@ function (angular, _, queryDef) { ...@@ -101,10 +104,6 @@ function (angular, _, queryDef) {
$scope.onChange(); $scope.onChange();
}; };
$scope.updateMovingAverageOptions = function() {
$scope.mvagSourceOptions = queryDef.getMovingAverageSourceOptions($scope.target);
};
$scope.removeMetricAgg = function() { $scope.removeMetricAgg = function() {
metricAggs.splice($scope.index, 1); metricAggs.splice($scope.index, 1);
$scope.onChange(); $scope.onChange();
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
Based on Based on
</li> </li>
<li> <li>
<metric-segment-model property="agg.mavgSource" options="mavgSourceOptions" on-change="onChangeInternal()" css-class="last"></metric-segment-model> <metric-segment-model property="agg.mavgSource" get-options="mavgSourceOptions()" on-change="onChangeInternal()" css-class="last"></metric-segment-model>
</li> </li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
......
...@@ -13,7 +13,7 @@ function (_) { ...@@ -13,7 +13,7 @@ function (_) {
{text: "Min", value: 'min', requiresField: true}, {text: "Min", value: 'min', requiresField: true},
{text: "Extended Stats", value: 'extended_stats', requiresField: true}, {text: "Extended Stats", value: 'extended_stats', requiresField: true},
{text: "Percentiles", value: 'percentiles', requiresField: true}, {text: "Percentiles", value: 'percentiles', requiresField: true},
{text: "Moving Avg", value: 'moving_avg', requiresField: false }, {text: "Moving Average", value: 'moving_avg', requiresField: false },
{text: "Unique Count", value: "cardinality", requiresField: true}, {text: "Unique Count", value: "cardinality", requiresField: true},
{text: "Raw Document", value: "raw_document", requiresField: false} {text: "Raw Document", value: "raw_document", requiresField: false}
], ],
......
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