feat(influxdb): completed work on new influxdb query editor, now supports #2708, #2647, #2599

This commit is contained in:
Torkel Ödegaard
2015-09-09 14:17:55 +02:00
parent 8c9d551826
commit 1ab374008f
5 changed files with 16 additions and 8 deletions
@@ -109,7 +109,8 @@
</li>
<li ng-if="groupBy.type === 'time'">
<span class="tight-form-item">time</span>
<metric-segment-model property="groupBy.interval" get-options="getGroupByTimeIntervals()" on-change="get_data()"></metric-segment>
<metric-segment-model property="groupBy.interval" get-options="getGroupByTimeIntervals()" on-change="get_data()">
</metric-segment>
</li>
<li ng-if="groupBy.type === 'tag'">
<metric-segment-model property="groupBy.key" get-options="getTagOptions()" on-change="get_data()"></metric-segment>
@@ -6,6 +6,14 @@ function (_) {
function InfluxQueryBuilder(target) {
this.target = target;
if (target.groupByTags) {
target.groupBy = [{type: 'time', interval: 'auto'}];
for (var i in target.groupByTags) {
target.groupBy.push({type: 'tag', key: target.groupByTags[i]});
}
delete target.groupByTags;
}
}
function renderTagCondition (tag, index) {
@@ -84,7 +92,6 @@ function (_) {
return query;
};
p._getGroupByTimeInterval = function(interval) {
if (interval === 'auto') {
return '$interval';
@@ -16,10 +16,7 @@ function (angular, _, InfluxQueryBuilder) {
var target = $scope.target;
target.tags = target.tags || [];
target.groupBy = target.groupBy || [{type: 'time', interval: 'auto'}];
target.fields = target.fields || [{
name: 'value',
func: target.function || 'mean'
}];
target.fields = target.fields || [{name: 'value', func: target.function || 'mean'}];
$scope.queryBuilder = new InfluxQueryBuilder(target);
@@ -49,7 +46,6 @@ function (angular, _, InfluxQueryBuilder) {
});
$scope.fixTagSegments();
$scope.removeTagFilterSegment = uiSegmentSrv.newSegment({fake: true, value: '-- remove tag filter --'});
};
@@ -68,7 +68,8 @@ define([
});
var query = builder.build();
expect(query).to.be('SELECT sum("tx_in") AS "tx_in", mean("tx_out") AS "tx_out" FROM "cpu" WHERE $timeFilter GROUP BY time($interval)');
expect(query).to.be('SELECT sum("tx_in") AS "tx_in", mean("tx_out") AS "tx_out" ' +
'FROM "cpu" WHERE $timeFilter GROUP BY time($interval)');
});
});