mirror of https://github.com/grafana/grafana
Merge pull request #14608 from marefr/es_bucket_script
Fix support bucket script pipeline aggregationspull/14872/head
commit
130e4aa666
@ -0,0 +1,20 @@ |
||||
<div ng-repeat="var in variables"> |
||||
<div class="gf-form offset-width-7" ng-if="$index === 0"> |
||||
<label class="gf-form-label width-10">Variables</label> |
||||
<input type="text" class="gf-form-input max-width-12" ng-model="var.name" placeholder="Variable name" ng-blur="onChangeInternal()" spellcheck='false'> |
||||
<metric-segment-model property="var.pipelineAgg" options="options" on-change="onChangeInternal()" custom="false" css-class="width-12"></metric-segment-model> |
||||
<label class="gf-form-label"> |
||||
<a class="pointer" ng-click="remove($index)"><i class="fa fa-minus"></i></a> |
||||
</label> |
||||
<label class="gf-form-label"> |
||||
<a class="pointer" ng-click="add()"><i class="fa fa-plus"></i></a> |
||||
</label> |
||||
</div> |
||||
<div class="gf-form offset-width-17" ng-if="$index !== 0"> |
||||
<input type="text" class="gf-form-input max-width-12" ng-model="var.name" placeholder="Variable name" ng-blur="onChangeInternal()" spellcheck='false'> |
||||
<metric-segment-model property="var.pipelineAgg" options="options" on-change="onChangeInternal()" custom="false" css-class="width-12"></metric-segment-model> |
||||
<label class="gf-form-label"> |
||||
<a class="pointer" ng-click="remove($index)"><i class="fa fa-minus"></i></a> |
||||
</label> |
||||
</div> |
||||
</div> |
@ -0,0 +1,45 @@ |
||||
import coreModule from 'app/core/core_module'; |
||||
import _ from 'lodash'; |
||||
|
||||
export function elasticPipelineVariables() { |
||||
return { |
||||
templateUrl: 'public/app/plugins/datasource/elasticsearch/partials/pipeline_variables.html', |
||||
controller: 'ElasticPipelineVariablesCtrl', |
||||
restrict: 'E', |
||||
scope: { |
||||
onChange: '&', |
||||
variables: '=', |
||||
options: '=', |
||||
}, |
||||
}; |
||||
} |
||||
|
||||
const newVariable = index => { |
||||
return { |
||||
name: 'var' + index, |
||||
pipelineAgg: 'select metric', |
||||
}; |
||||
}; |
||||
|
||||
export class ElasticPipelineVariablesCtrl { |
||||
constructor($scope) { |
||||
$scope.variables = $scope.variables || [newVariable(1)]; |
||||
|
||||
$scope.onChangeInternal = () => { |
||||
$scope.onChange(); |
||||
}; |
||||
|
||||
$scope.add = () => { |
||||
$scope.variables.push(newVariable($scope.variables.length + 1)); |
||||
$scope.onChange(); |
||||
}; |
||||
|
||||
$scope.remove = index => { |
||||
$scope.variables.splice(index, 1); |
||||
$scope.onChange(); |
||||
}; |
||||
} |
||||
} |
||||
|
||||
coreModule.directive('elasticPipelineVariables', elasticPipelineVariables); |
||||
coreModule.controller('ElasticPipelineVariablesCtrl', ElasticPipelineVariablesCtrl); |
Loading…
Reference in new issue