From 1ab374008f178b3997910703c5255f462c4b1961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 9 Sep 2015 14:17:55 +0200 Subject: [PATCH] feat(influxdb): completed work on new influxdb query editor, now supports #2708, #2647, #2599 --- CHANGELOG.md | 3 +++ .../datasource/influxdb/partials/query.editor2.html | 3 ++- public/app/plugins/datasource/influxdb/queryBuilder.js | 9 ++++++++- public/app/plugins/datasource/influxdb/queryCtrl.js | 6 +----- public/test/specs/influx09-querybuilder-specs.js | 3 ++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce7e0956314..8110aed4bc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ it allows you to add queries of differnet data source types & instances to the s - [Issue #2457](https://github.com/grafana/grafana/issues/2457). Admin: admin page for all grafana organizations (list / edit view) - [Issue #1186](https://github.com/grafana/grafana/issues/1186). Time Picker: New option `today`, will set time range from midnight to now - [Issue #1186](https://github.com/grafana/grafana/issues/1186). Time Picker: New option `today`, will set time range from midnight to now +- [Issue #2647](https://github.com/grafana/grafana/issues/2647). InfluxDB: You can now set group by time interval on each query +- [Issue #2599](https://github.com/grafana/grafana/issues/2599). InfluxDB: Improved alias support, you can now use the `AS` clause for each select statement +- [Issue #2708](https://github.com/grafana/grafana/issues/2708). InfluxDB: You can now set math expression for select clauses. **Fixes** - [Issue #2413](https://github.com/grafana/grafana/issues/2413). InfluxDB 0.9: Fix for handling empty series object in response from influxdb diff --git a/public/app/plugins/datasource/influxdb/partials/query.editor2.html b/public/app/plugins/datasource/influxdb/partials/query.editor2.html index 5aca5d6bb82..259cebb0c41 100644 --- a/public/app/plugins/datasource/influxdb/partials/query.editor2.html +++ b/public/app/plugins/datasource/influxdb/partials/query.editor2.html @@ -109,7 +109,8 @@
  • time - + +
  • diff --git a/public/app/plugins/datasource/influxdb/queryBuilder.js b/public/app/plugins/datasource/influxdb/queryBuilder.js index a46c380e1d4..9ab0953b576 100644 --- a/public/app/plugins/datasource/influxdb/queryBuilder.js +++ b/public/app/plugins/datasource/influxdb/queryBuilder.js @@ -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'; diff --git a/public/app/plugins/datasource/influxdb/queryCtrl.js b/public/app/plugins/datasource/influxdb/queryCtrl.js index 14483fa4dd7..9d006c384f1 100644 --- a/public/app/plugins/datasource/influxdb/queryCtrl.js +++ b/public/app/plugins/datasource/influxdb/queryCtrl.js @@ -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 --'}); }; diff --git a/public/test/specs/influx09-querybuilder-specs.js b/public/test/specs/influx09-querybuilder-specs.js index cfbb7ddffe1..9bb861282bc 100644 --- a/public/test/specs/influx09-querybuilder-specs.js +++ b/public/test/specs/influx09-querybuilder-specs.js @@ -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)'); }); });