diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index dd8be871829..70606c79aef 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -126,14 +126,16 @@ export class QueryEditorRow extends PureComponent { const { data, query } = this.props; if (data !== prevProps.data) { - this.setState({ data: filterPanelDataToQuery(data, query.refId) }); + const dataFilteredByRefId = filterPanelDataToQuery(data, query.refId); + + this.setState({ data: dataFilteredByRefId }); if (this.angularScope) { this.angularScope.range = getTimeSrv().timeRange(); } - if (this.angularQueryEditor) { - notifyAngularQueryEditorsOfData(this.angularScope!, data, this.angularQueryEditor); + if (this.angularQueryEditor && dataFilteredByRefId) { + notifyAngularQueryEditorsOfData(this.angularScope!, dataFilteredByRefId, this.angularQueryEditor); } } @@ -353,17 +355,7 @@ export class QueryEditorRow extends PureComponent { } } -// To avoid sending duplicate events for each row we have this global cached object here -// So we can check if we already emitted this legacy data event -let globalLastPanelDataCache: PanelData | null = null; - function notifyAngularQueryEditorsOfData(scope: AngularQueryComponentScope, data: PanelData, editor: AngularComponent) { - if (data === globalLastPanelDataCache) { - return; - } - - globalLastPanelDataCache = data; - if (data.state === LoadingState.Done) { const legacy = data.series.map((v) => toLegacyResponseData(v)); scope.events.emit(PanelEvents.dataReceived, legacy); diff --git a/public/app/plugins/datasource/mssql/partials/query.editor.html b/public/app/plugins/datasource/mssql/partials/query.editor.html index 4036d7ea756..a1c71e0ccc8 100644 --- a/public/app/plugins/datasource/mssql/partials/query.editor.html +++ b/public/app/plugins/datasource/mssql/partials/query.editor.html @@ -20,12 +20,13 @@ -
-
@@ -78,6 +79,10 @@ Or build your own conditionals using these macros which just return the values: +
+
{{ctrl.lastQueryMeta.executedQueryString}}
+
+
{{ctrl.lastQueryError}}
diff --git a/public/app/plugins/datasource/mssql/query_ctrl.ts b/public/app/plugins/datasource/mssql/query_ctrl.ts index 2b17ed45053..f826d63c692 100644 --- a/public/app/plugins/datasource/mssql/query_ctrl.ts +++ b/public/app/plugins/datasource/mssql/query_ctrl.ts @@ -1,8 +1,7 @@ import _ from 'lodash'; import { QueryCtrl } from 'app/plugins/sdk'; import { auto } from 'angular'; -import { PanelEvents } from '@grafana/data'; -import { getLocationSrv } from '@grafana/runtime'; +import { PanelEvents, QueryResultMeta } from '@grafana/data'; export interface MssqlQuery { refId: string; @@ -11,10 +10,6 @@ export interface MssqlQuery { rawSql: string; } -export interface QueryMeta { - sql: string; -} - const defaultQuery = `SELECT $__timeEpoch(), as value, @@ -31,7 +26,8 @@ export class MssqlQueryCtrl extends QueryCtrl { formats: any[]; target: MssqlQuery; - lastQueryError: string | null; + lastQueryMeta?: QueryResultMeta; + lastQueryError?: string; showHelp: boolean; /** @ngInject */ @@ -59,15 +55,9 @@ export class MssqlQueryCtrl extends QueryCtrl { this.panelCtrl.events.on(PanelEvents.dataError, this.onDataError.bind(this), $scope); } - showQueryInspector() { - getLocationSrv().update({ - query: { inspect: this.panel.id, inspectTab: 'query' }, - partial: true, - }); - } - onDataReceived(dataList: any) { - this.lastQueryError = null; + this.lastQueryError = undefined; + this.lastQueryMeta = dataList[0]?.meta; } onDataError(err: any) { diff --git a/public/app/plugins/datasource/mysql/partials/query.editor.html b/public/app/plugins/datasource/mysql/partials/query.editor.html index 22896f9636f..a04ea7891c2 100644 --- a/public/app/plugins/datasource/mysql/partials/query.editor.html +++ b/public/app/plugins/datasource/mysql/partials/query.editor.html @@ -120,10 +120,11 @@ -
-
-
-