diff --git a/public/app/features/inspector/InspectJSONTab.tsx b/public/app/features/inspector/InspectJSONTab.tsx index e5dd4e0c3a9..c1985f4c974 100644 --- a/public/app/features/inspector/InspectJSONTab.tsx +++ b/public/app/features/inspector/InspectJSONTab.tsx @@ -1,8 +1,17 @@ import { t } from '@lingui/macro'; import React, { PureComponent } from 'react'; import AutoSizer from 'react-virtualized-auto-sizer'; +import { firstValueFrom } from 'rxjs'; -import { AppEvents, DataFrameJSON, dataFrameToJSON, DataTopic, PanelData, SelectableValue } from '@grafana/data'; +import { + AppEvents, + DataFrameJSON, + dataFrameToJSON, + DataTopic, + PanelData, + SelectableValue, + LoadingState, +} from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { Button, CodeEditor, Field, Select } from '@grafana/ui'; import { appEvents } from 'app/core/core'; @@ -34,8 +43,11 @@ const options: Array> = [ value: ShowContent.PanelData, }, { - label: t({ id: 'dashboard.inspect-json.dataframe-label', message: 'DataFrame JSON' }), - description: t({ id: 'dashboard.inspect-json.dataframe-description', message: 'JSON formatted DataFrames' }), + label: t({ id: 'dashboard.inspect-json.dataframe-label', message: 'DataFrame JSON (from Query)' }), + description: t({ + id: 'dashboard.inspect-json.dataframe-description', + message: 'Raw data without transformations and field config applied. ', + }), value: ShowContent.DataFrames, }, ]; @@ -65,8 +77,8 @@ export class InspectJSONTab extends PureComponent { }; } - onSelectChanged = (item: SelectableValue) => { - const show = this.getJSONObject(item.value!); + onSelectChanged = async (item: SelectableValue) => { + const show = await this.getJSONObject(item.value!); const text = getPrettyJSON(show); this.setState({ text, show: item.value! }); }; @@ -76,14 +88,25 @@ export class InspectJSONTab extends PureComponent { this.setState({ text }); }; - getJSONObject(show: ShowContent) { + async getJSONObject(show: ShowContent) { const { data, panel } = this.props; if (show === ShowContent.PanelData) { return data; } if (show === ShowContent.DataFrames) { - return getPanelDataFrames(data); + let d = data; + + // do not include transforms and + if (panel && data?.state === LoadingState.Done) { + d = await firstValueFrom( + panel.getQueryRunner().getData({ + withFieldConfig: false, + withTransforms: false, + }) + ); + } + return getPanelDataFrames(d); } if (this.hasPanelJSON && show === ShowContent.PanelJSON) { diff --git a/public/locales/en-US/messages.po b/public/locales/en-US/messages.po index 05f5fd5f008..eb901ba3d4e 100644 --- a/public/locales/en-US/messages.po +++ b/public/locales/en-US/messages.po @@ -109,11 +109,11 @@ msgstr "Apply panel transformations" #: public/app/features/inspector/InspectJSONTab.tsx msgid "dashboard.inspect-json.dataframe-description" -msgstr "JSON formatted DataFrames" +msgstr "Raw data without transformations and field config applied." #: public/app/features/inspector/InspectJSONTab.tsx msgid "dashboard.inspect-json.dataframe-label" -msgstr "DataFrame JSON" +msgstr "DataFrame JSON (from Query)" #: public/app/features/inspector/InspectJSONTab.tsx msgid "dashboard.inspect-json.panel-data-description"