Commit f51d74fa by carl bergquist

change the way options are added

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