Inspect: include annotation data in DataFrameJSON debugger (#49204)

This commit is contained in:
Ryan McKinley 2022-05-18 17:31:03 -07:00 committed by GitHub
parent d0d4d8af7f
commit 3b017e0fb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import AutoSizer from 'react-virtualized-auto-sizer';
import { AppEvents, dataFrameToJSON, PanelData, SelectableValue } from '@grafana/data';
import { AppEvents, DataFrameJSON, dataFrameToJSON, DataTopic, PanelData, SelectableValue } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { Button, CodeEditor, Field, Select } from '@grafana/ui';
import { appEvents } from 'app/core/core';
@ -76,11 +76,7 @@ export class InspectJSONTab extends PureComponent<Props, State> {
}
if (show === ShowContent.DataFrames) {
const series = data?.series;
if (!series) {
return { note: 'Missing Response Data' };
}
return data.series.map((frame) => dataFrameToJSON(frame));
return getPanelDataFrames(data);
}
if (this.hasPanelJSON && show === ShowContent.PanelJSON) {
@ -159,6 +155,26 @@ export class InspectJSONTab extends PureComponent<Props, State> {
}
}
function getPanelDataFrames(data?: PanelData): DataFrameJSON[] {
const frames: DataFrameJSON[] = [];
if (data?.series) {
for (const f of data.series) {
frames.push(dataFrameToJSON(f));
}
}
if (data?.annotations) {
for (const f of data.annotations) {
const json = dataFrameToJSON(f);
if (!json.schema?.meta) {
json.schema!.meta = {};
}
json.schema!.meta.dataTopic = DataTopic.Annotations;
frames.push(json);
}
}
return frames;
}
function getPrettyJSON(obj: any): string {
return JSON.stringify(obj, null, 2);
}