diff --git a/public/app/plugins/datasource/influxdb-ifql/README.md b/public/app/plugins/datasource/influxdb-ifql/README.md index 91f82b2a89d..515709f70fa 100644 --- a/public/app/plugins/datasource/influxdb-ifql/README.md +++ b/public/app/plugins/datasource/influxdb-ifql/README.md @@ -16,11 +16,9 @@ Read more about InfluxDB here: ## Roadmap -- Sync Grafana time ranges with `range()` -- Template variable expansion +- metricFindQuery - Syntax highlighting - Tab completion (functions, values) -- Result helpers (result counts, table previews) - Annotations support - Alerting integration - Explore UI integration diff --git a/public/app/plugins/datasource/influxdb-ifql/datasource.ts b/public/app/plugins/datasource/influxdb-ifql/datasource.ts index 41bdbe81c43..2175b36bc36 100644 --- a/public/app/plugins/datasource/influxdb-ifql/datasource.ts +++ b/public/app/plugins/datasource/influxdb-ifql/datasource.ts @@ -81,13 +81,9 @@ export default class InfluxDatasource { const { query, resultFormat } = target; if (resultFormat === 'table') { - return ( - this._seriesQuery(query, options) - .then(response => parseResults(response.data)) - // Keep only first result from each request - .then(results => results[0]) - .then(getTableModelFromResult) - ); + return this._seriesQuery(query, options) + .then(response => parseResults(response.data)) + .then(results => results.map(getTableModelFromResult)); } else { return this._seriesQuery(query, options) .then(response => parseResults(response.data)) diff --git a/public/app/plugins/datasource/influxdb-ifql/partials/query.editor.html b/public/app/plugins/datasource/influxdb-ifql/partials/query.editor.html index 31f5923cdb2..cf694aafc9d 100644 --- a/public/app/plugins/datasource/influxdb-ifql/partials/query.editor.html +++ b/public/app/plugins/datasource/influxdb-ifql/partials/query.editor.html @@ -1,8 +1,10 @@
- + +
@@ -12,9 +14,15 @@ ng-change="ctrl.refresh()">
-
- - +
+ +
+
+ + + +
diff --git a/public/app/plugins/datasource/influxdb-ifql/query_ctrl.ts b/public/app/plugins/datasource/influxdb-ifql/query_ctrl.ts index edd00b37db8..6bccfa0aba9 100644 --- a/public/app/plugins/datasource/influxdb-ifql/query_ctrl.ts +++ b/public/app/plugins/datasource/influxdb-ifql/query_ctrl.ts @@ -1,3 +1,4 @@ +import appEvents from 'app/core/app_events'; import { QueryCtrl } from 'app/plugins/sdk'; function makeDefaultQuery(database) { @@ -9,18 +10,46 @@ function makeDefaultQuery(database) { export class InfluxIfqlQueryCtrl extends QueryCtrl { static templateUrl = 'partials/query.editor.html'; + dataPreview: string; + resultRecordCount: string; + resultTableCount: string; resultFormats: any[]; /** @ngInject **/ constructor($scope, $injector) { super($scope, $injector); + this.resultRecordCount = ''; + this.resultTableCount = ''; + if (this.target.query === undefined) { this.target.query = makeDefaultQuery(this.datasource.database); } this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }]; + + appEvents.on('ds-request-response', this.onResponseReceived, $scope); + this.panelCtrl.events.on('refresh', this.onRefresh, $scope); + this.panelCtrl.events.on('data-received', this.onDataReceived, $scope); } + onDataReceived = dataList => { + this.resultRecordCount = dataList.reduce((count, model) => { + const records = model.type === 'table' ? model.rows.length : model.datapoints.length; + return count + records; + }, 0); + this.resultTableCount = dataList.length; + }; + + onResponseReceived = response => { + this.dataPreview = response.data; + }; + + onRefresh = () => { + this.dataPreview = ''; + this.resultRecordCount = ''; + this.resultTableCount = ''; + }; + getCollapsedText() { return this.target.query; }