changes implementation direction

moving average will now be based on another metric
instead of having moving average on itself
This commit is contained in:
carl bergquist
2015-12-09 09:04:48 +01:00
parent b4763290de
commit ad79df9b74
4 changed files with 27 additions and 19 deletions

View File

@@ -13,6 +13,7 @@ function (angular, _, queryDef) {
$scope.metricAggTypes = queryDef.metricAggTypes;
$scope.extendedStats = queryDef.extendedStats;
$scope.mavgSourceOptions = [];
$scope.init = function() {
$scope.agg = metricAggs[$scope.index];
@@ -22,6 +23,7 @@ function (angular, _, queryDef) {
$rootScope.onAppEvent('elastic-query-updated', function() {
$scope.index = _.indexOf(metricAggs, $scope.agg);
$scope.validateModel();
$scope.updateMovingAverageOptions();
}, $scope);
$scope.validateModel = function() {
@@ -36,7 +38,8 @@ function (angular, _, queryDef) {
switch($scope.agg.type) {
case 'moving_avg': {
$scope.agg.aggregation = $scope.agg.aggregation || 'sum';
$scope.agg.mavgSource = $scope.agg.mavgSource || '';
$scope.settingsLinkText = 'Moving average options';
break;
}
case 'percentiles': {
@@ -69,6 +72,11 @@ function (angular, _, queryDef) {
$scope.toggleOptions = function() {
$scope.showOptions = !$scope.showOptions;
$scope.updateMovingAverageOptions();
};
$scope.onChangeInternal = function() {
$scope.onChange();
};
$scope.onTypeChange = function() {
@@ -82,13 +90,6 @@ function (angular, _, queryDef) {
return $scope.getFields({$fieldType: 'number'});
};
$scope.getMetrics = function() {
var aggs = [{ text: 'Sum', type: 'sum'}, { text: 'Average', type: 'avg'}];
return $q.when(aggs)
.then(uiSegmentSrv.transformToSegments(false));
};
$scope.addMetricAgg = function() {
var addIndex = metricAggs.length;
@@ -100,6 +101,10 @@ function (angular, _, queryDef) {
$scope.onChange();
};
$scope.updateMovingAverageOptions = function() {
$scope.mvagSourceOptions = queryDef.getMovingAverageSourceOptions($scope.target);
};
$scope.removeMetricAgg = function() {
metricAggs.splice($scope.index, 1);
$scope.onChange();