Commit 150fd869 by Torkel Ödegaard

Finalized work on influxdb field and func selection, #2311

parent 50795adc
......@@ -124,7 +124,7 @@ function (angular, _, $) {
function addElementsAndCompile() {
$funcLink.appendTo(elem);
var $paramLink = $('<a ng-click="" class="graphite-func-param-link">value</a>');
var $paramLink = $('<a ng-click="" class="graphite-func-param-link">' + $scope.field.name + '</a>');
var $input = $(paramTemplate);
$paramLink.appendTo(elem);
......
......@@ -66,9 +66,12 @@
SELECT
</li>
<li class="dropdown" ng-repeat="field in target.fields">
<span influxdb-func-editor field="field" get-fields="getFields()" on-change="get_data()" class="tight-form-item">
<span influxdb-func-editor field="field" get-fields="getFields()" on-change="fieldChanged(field)" class="tight-form-item">
</span>
</li>
<li>
<metric-segment segment="addFieldSegment" get-alt-segments="getFieldSegments()" on-value-changed="addField()"></metric-segment>
</li>
</ul>
<div class="clearfix"></div>
......
......@@ -27,6 +27,8 @@ function (angular, _, InfluxQueryBuilder) {
$scope.measurementSegment = new MetricSegment(target.measurement);
}
$scope.addFieldSegment = MetricSegment.newPlusButton();
$scope.tagSegments = [];
_.each(target.tags, function(tag) {
if (tag.condition) {
......@@ -92,7 +94,11 @@ function (angular, _, InfluxQueryBuilder) {
var fieldsQuery = $scope.queryBuilder.buildExploreQuery('FIELDS');
return $scope.datasource.metricFindQuery(fieldsQuery)
.then(function(results) {
return _.pluck(results, 'text');
var values = _.pluck(results, 'text');
if ($scope.target.fields.length > 1) {
values.splice(0, 0, "-- remove from select --");
}
return values;
});
};
......@@ -161,6 +167,25 @@ function (angular, _, InfluxQueryBuilder) {
.then(null, $scope.handleQueryError);
};
$scope.getFieldSegments = function() {
var fieldsQuery = $scope.queryBuilder.buildExploreQuery('FIELDS');
return $scope.datasource.metricFindQuery(fieldsQuery)
.then($scope.transformToSegments)
.then(null, $scope.handleQueryError);
};
$scope.addField = function() {
$scope.target.fields.push({name: $scope.addFieldSegment.value, func: 'mean'});
_.extend($scope.addFieldSegment, MetricSegment.newPlusButton());
};
$scope.fieldChanged = function(field) {
if (field.name === '-- remove from select --') {
$scope.target.fields = _.without($scope.target.fields, field);
}
$scope.get_data();
};
$scope.getGroupByTagSegments = function(segment) {
var query = $scope.queryBuilder.buildExploreQuery('TAG_KEYS');
......
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