mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
Inspect: show DataFrame JSON *before* transformation and field config are applied (#53867)
This commit is contained in:
parent
9be73e758d
commit
7755f4c4ba
@ -1,8 +1,17 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
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 { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Button, CodeEditor, Field, Select } from '@grafana/ui';
|
import { Button, CodeEditor, Field, Select } from '@grafana/ui';
|
||||||
import { appEvents } from 'app/core/core';
|
import { appEvents } from 'app/core/core';
|
||||||
@ -34,8 +43,11 @@ const options: Array<SelectableValue<ShowContent>> = [
|
|||||||
value: ShowContent.PanelData,
|
value: ShowContent.PanelData,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t({ id: 'dashboard.inspect-json.dataframe-label', message: 'DataFrame JSON' }),
|
label: t({ id: 'dashboard.inspect-json.dataframe-label', message: 'DataFrame JSON (from Query)' }),
|
||||||
description: t({ id: 'dashboard.inspect-json.dataframe-description', message: 'JSON formatted DataFrames' }),
|
description: t({
|
||||||
|
id: 'dashboard.inspect-json.dataframe-description',
|
||||||
|
message: 'Raw data without transformations and field config applied. ',
|
||||||
|
}),
|
||||||
value: ShowContent.DataFrames,
|
value: ShowContent.DataFrames,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@ -65,8 +77,8 @@ export class InspectJSONTab extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectChanged = (item: SelectableValue<ShowContent>) => {
|
onSelectChanged = async (item: SelectableValue<ShowContent>) => {
|
||||||
const show = this.getJSONObject(item.value!);
|
const show = await this.getJSONObject(item.value!);
|
||||||
const text = getPrettyJSON(show);
|
const text = getPrettyJSON(show);
|
||||||
this.setState({ text, show: item.value! });
|
this.setState({ text, show: item.value! });
|
||||||
};
|
};
|
||||||
@ -76,14 +88,25 @@ export class InspectJSONTab extends PureComponent<Props, State> {
|
|||||||
this.setState({ text });
|
this.setState({ text });
|
||||||
};
|
};
|
||||||
|
|
||||||
getJSONObject(show: ShowContent) {
|
async getJSONObject(show: ShowContent) {
|
||||||
const { data, panel } = this.props;
|
const { data, panel } = this.props;
|
||||||
if (show === ShowContent.PanelData) {
|
if (show === ShowContent.PanelData) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show === ShowContent.DataFrames) {
|
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) {
|
if (this.hasPanelJSON && show === ShowContent.PanelJSON) {
|
||||||
|
@ -109,11 +109,11 @@ msgstr "Apply panel transformations"
|
|||||||
|
|
||||||
#: public/app/features/inspector/InspectJSONTab.tsx
|
#: public/app/features/inspector/InspectJSONTab.tsx
|
||||||
msgid "dashboard.inspect-json.dataframe-description"
|
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
|
#: public/app/features/inspector/InspectJSONTab.tsx
|
||||||
msgid "dashboard.inspect-json.dataframe-label"
|
msgid "dashboard.inspect-json.dataframe-label"
|
||||||
msgstr "DataFrame JSON"
|
msgstr "DataFrame JSON (from Query)"
|
||||||
|
|
||||||
#: public/app/features/inspector/InspectJSONTab.tsx
|
#: public/app/features/inspector/InspectJSONTab.tsx
|
||||||
msgid "dashboard.inspect-json.panel-data-description"
|
msgid "dashboard.inspect-json.panel-data-description"
|
||||||
|
Loading…
Reference in New Issue
Block a user