|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import appEvents from 'app/core/app_events';
|
|
|
import { QueryCtrl } from 'app/plugins/sdk';
|
|
import { QueryCtrl } from 'app/plugins/sdk';
|
|
|
|
|
|
|
|
function makeDefaultQuery(database) {
|
|
function makeDefaultQuery(database) {
|
|
@@ -9,18 +10,46 @@ function makeDefaultQuery(database) {
|
|
|
export class InfluxIfqlQueryCtrl extends QueryCtrl {
|
|
export class InfluxIfqlQueryCtrl extends QueryCtrl {
|
|
|
static templateUrl = 'partials/query.editor.html';
|
|
static templateUrl = 'partials/query.editor.html';
|
|
|
|
|
|
|
|
|
|
+ dataPreview: string;
|
|
|
|
|
+ resultRecordCount: string;
|
|
|
|
|
+ resultTableCount: string;
|
|
|
resultFormats: any[];
|
|
resultFormats: any[];
|
|
|
|
|
|
|
|
/** @ngInject **/
|
|
/** @ngInject **/
|
|
|
constructor($scope, $injector) {
|
|
constructor($scope, $injector) {
|
|
|
super($scope, $injector);
|
|
super($scope, $injector);
|
|
|
|
|
|
|
|
|
|
+ this.resultRecordCount = '';
|
|
|
|
|
+ this.resultTableCount = '';
|
|
|
|
|
+
|
|
|
if (this.target.query === undefined) {
|
|
if (this.target.query === undefined) {
|
|
|
this.target.query = makeDefaultQuery(this.datasource.database);
|
|
this.target.query = makeDefaultQuery(this.datasource.database);
|
|
|
}
|
|
}
|
|
|
this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }];
|
|
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() {
|
|
getCollapsedText() {
|
|
|
return this.target.query;
|
|
return this.target.query;
|
|
|
}
|
|
}
|