mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(elasticsearch): improve pipeline aggs structure
This commit is contained in:
@@ -13,15 +13,12 @@ function (angular, _, queryDef) {
|
|||||||
|
|
||||||
$scope.metricAggTypes = queryDef.metricAggTypes;
|
$scope.metricAggTypes = queryDef.metricAggTypes;
|
||||||
$scope.extendedStats = queryDef.extendedStats;
|
$scope.extendedStats = queryDef.extendedStats;
|
||||||
$scope.pipelineSettings = [];
|
|
||||||
|
|
||||||
$scope.pipelineAggOptions = [];
|
$scope.pipelineAggOptions = [];
|
||||||
|
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.agg = metricAggs[$scope.index];
|
$scope.agg = metricAggs[$scope.index];
|
||||||
$scope.validateModel();
|
$scope.validateModel();
|
||||||
$scope.updatePipelineAggOptions();
|
$scope.updatePipelineAggOptions();
|
||||||
$scope.pipelineSettings = queryDef.getPipelineSettings($scope.agg);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.updatePipelineAggOptions = function() {
|
$scope.updatePipelineAggOptions = function() {
|
||||||
@@ -44,7 +41,11 @@ function (angular, _, queryDef) {
|
|||||||
$scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric';
|
$scope.agg.pipelineAgg = $scope.agg.pipelineAgg || 'select metric';
|
||||||
$scope.agg.field = $scope.agg.pipelineAgg;
|
$scope.agg.field = $scope.agg.pipelineAgg;
|
||||||
$scope.settingsLinkText = 'Options';
|
$scope.settingsLinkText = 'Options';
|
||||||
delete $scope.agg.field;
|
|
||||||
|
_.each(queryDef.getPipelineOptions($scope.agg), function(opt) {
|
||||||
|
$scope.agg.settings[opt.text] = $scope.agg.settings[opt.text] || opt.default;
|
||||||
|
});
|
||||||
|
|
||||||
} else if (!$scope.agg.field) {
|
} else if (!$scope.agg.field) {
|
||||||
$scope.agg.field = 'select field';
|
$scope.agg.field = 'select field';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,9 +34,9 @@
|
|||||||
|
|
||||||
<div class="tight-form" ng-if="showOptions">
|
<div class="tight-form" ng-if="showOptions">
|
||||||
<div class="tight-form-inner-box">
|
<div class="tight-form-inner-box">
|
||||||
<div class="tight-form last" ng-if="agg.pipelineAgg !== undefined">
|
<div class="tight-form first" ng-if="agg.pipelineAgg !== undefined">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item">
|
<li class="tight-form-item" style="width: 75px;">
|
||||||
Based on
|
Based on
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@@ -45,19 +45,17 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="agg.pipelineAgg !== undefined">
|
<div class="tight-form last" ng-if="agg.settings.window !== undefined">
|
||||||
<div class="tight-form" ng-repeat="setting in agg.pipelineSettings">
|
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item" style="width: 100px">
|
<li class="tight-form-item" style="width: 75px;">
|
||||||
{{stat.text}}
|
Window
|
||||||
</li>
|
</li>
|
||||||
<li class="tight-form-item last">
|
<li>
|
||||||
<editor-checkbox text="" model="agg.meta.{{stat.value}}" change="onChange()"></editor-checkbox>
|
<input type="number" class="input-medium tight-form-input" ng-change="onChangeInternal()" ng-model="agg.settings.window" blur="onChange()" spellcheck='false'>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="tight-form last" ng-if="agg.type === 'percentiles'">
|
<div class="tight-form last" ng-if="agg.type === 'percentiles'">
|
||||||
<ul class="tight-form-list">
|
<ul class="tight-form-list">
|
||||||
<li class="tight-form-item">
|
<li class="tight-form-item">
|
||||||
|
|||||||
@@ -68,24 +68,25 @@ function (_) {
|
|||||||
{text: '1d', value: '1d'},
|
{text: '1d', value: '1d'},
|
||||||
],
|
],
|
||||||
|
|
||||||
pipelineAggs: ['moving_avg', 'derivative'],
|
pipelineOptions: {
|
||||||
|
'moving_avg' : [
|
||||||
pipelineSettings: {
|
{text: 'window', default: 5}
|
||||||
'moving_avg' : ['model', 'gap_policy', 'window', 'minimize'],
|
],
|
||||||
'derivative': []
|
'derivative': []
|
||||||
},
|
},
|
||||||
|
|
||||||
getPipelineSettings: function(metric) {
|
getPipelineOptions: function(metric) {
|
||||||
if (this.isPipelineAgg(metric) === false) {
|
if (!this.isPipelineAgg(metric)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.pipelineSettings[metric.type];
|
return this.pipelineOptions[metric.type];
|
||||||
},
|
},
|
||||||
|
|
||||||
isPipelineAgg: function(metric) {
|
isPipelineAgg: function(metric) {
|
||||||
if (metric.type) {
|
if (metric.type) {
|
||||||
return this.pipelineAggs.indexOf(metric.type) > -1;
|
var po = this.pipelineOptions[metric.type];
|
||||||
|
return po !== null && po !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user