The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/dashboard/components/Inspector/PanelInspector.tsx

49 lines
1.2 KiB

// Libraries
import React, { PureComponent } from 'react';
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
import { JSONFormatter, Modal } from '@grafana/ui';
import { css } from 'emotion';
import { getLocationSrv } from '@grafana/runtime';
interface Props {
dashboard: DashboardModel;
panel: PanelModel;
}
interface State {}
export class PanelInspector extends PureComponent<Props, State> {
constructor(props: Props) {
super(props);
}
onDismiss = () => {
getLocationSrv().update({
query: { inspect: null },
partial: true,
});
};
render() {
const { panel } = this.props;
if (!panel) {
this.onDismiss(); // Try to close the component
return null;
}
const bodyStyle = css`
max-height: 70vh;
overflow-y: scroll;
`;
// TODO? should we get the result with an observable once?
const data = (panel.getQueryRunner() as any).lastResult;
return (
<Modal title={panel.title} icon="fa fa-info-circle" onDismiss={this.onDismiss} isOpen={true}>
<div className={bodyStyle}>
<JSONFormatter json={data} open={2} />
</div>
</Modal>
);
}
}