|
|
|
|
@ -21,6 +21,7 @@ import { TimeRange } from '@grafana/ui'; |
|
|
|
|
|
|
|
|
|
import variables from 'sass/_variables.scss'; |
|
|
|
|
import templateSrv from 'app/features/templating/template_srv'; |
|
|
|
|
import { DataQueryResponse } from '@grafana/ui/src'; |
|
|
|
|
|
|
|
|
|
export interface Props { |
|
|
|
|
panel: PanelModel; |
|
|
|
|
@ -83,16 +84,42 @@ export class PanelChrome extends PureComponent<Props, State> { |
|
|
|
|
return templateSrv.replace(value, this.props.panel.scopedVars, format); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
onDataResponse = (dataQueryResponse: DataQueryResponse) => { |
|
|
|
|
if (this.props.dashboard.isSnapshot()) { |
|
|
|
|
this.props.panel.snapshotData = dataQueryResponse; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
get isVisible() { |
|
|
|
|
return !this.props.dashboard.otherPanelInFullscreen(this.props.panel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderPanel(loading, timeSeries, width, height): JSX.Element { |
|
|
|
|
const { panel, plugin } = this.props; |
|
|
|
|
const { timeRange, renderCounter } = this.state; |
|
|
|
|
const PanelComponent = plugin.exports.Panel; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="panel-content"> |
|
|
|
|
<PanelComponent |
|
|
|
|
loading={loading} |
|
|
|
|
timeSeries={timeSeries} |
|
|
|
|
timeRange={timeRange} |
|
|
|
|
options={panel.getOptions(plugin.exports.PanelDefaults)} |
|
|
|
|
width={width - 2 * variables.panelHorizontalPadding} |
|
|
|
|
height={height - PANEL_HEADER_HEIGHT - variables.panelVerticalPadding} |
|
|
|
|
renderCounter={renderCounter} |
|
|
|
|
onInterpolate={this.onInterpolate} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { panel, dashboard, plugin } = this.props; |
|
|
|
|
const { refreshCounter, timeRange, timeInfo, renderCounter } = this.state; |
|
|
|
|
const { panel, dashboard } = this.props; |
|
|
|
|
const { refreshCounter, timeRange, timeInfo } = this.state; |
|
|
|
|
|
|
|
|
|
const { datasource, targets, transparent } = panel; |
|
|
|
|
const PanelComponent = plugin.exports.Panel; |
|
|
|
|
const containerClassNames = `panel-container panel-container--absolute ${transparent ? 'panel-transparent' : ''}`; |
|
|
|
|
return ( |
|
|
|
|
<AutoSizer> |
|
|
|
|
@ -113,31 +140,23 @@ export class PanelChrome extends PureComponent<Props, State> { |
|
|
|
|
links={panel.links} |
|
|
|
|
/> |
|
|
|
|
|
|
|
|
|
<DataPanel |
|
|
|
|
datasource={datasource} |
|
|
|
|
queries={targets} |
|
|
|
|
timeRange={timeRange} |
|
|
|
|
isVisible={this.isVisible} |
|
|
|
|
widthPixels={width} |
|
|
|
|
refreshCounter={refreshCounter} |
|
|
|
|
> |
|
|
|
|
{({ loading, timeSeries }) => { |
|
|
|
|
return ( |
|
|
|
|
<div className="panel-content"> |
|
|
|
|
<PanelComponent |
|
|
|
|
loading={loading} |
|
|
|
|
timeSeries={timeSeries} |
|
|
|
|
timeRange={timeRange} |
|
|
|
|
options={panel.getOptions(plugin.exports.PanelDefaults)} |
|
|
|
|
width={width - 2 * variables.panelHorizontalPadding} |
|
|
|
|
height={height - PANEL_HEADER_HEIGHT - variables.panelVerticalPadding} |
|
|
|
|
renderCounter={renderCounter} |
|
|
|
|
onInterpolate={this.onInterpolate} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}} |
|
|
|
|
</DataPanel> |
|
|
|
|
{panel.snapshotData ? ( |
|
|
|
|
this.renderPanel(false, panel.snapshotData, width, height) |
|
|
|
|
) : ( |
|
|
|
|
<DataPanel |
|
|
|
|
datasource={datasource} |
|
|
|
|
queries={targets} |
|
|
|
|
timeRange={timeRange} |
|
|
|
|
isVisible={this.isVisible} |
|
|
|
|
widthPixels={width} |
|
|
|
|
refreshCounter={refreshCounter} |
|
|
|
|
onDataResponse={this.onDataResponse} |
|
|
|
|
> |
|
|
|
|
{({ loading, timeSeries }) => { |
|
|
|
|
return this.renderPanel(loading, timeSeries, width, height); |
|
|
|
|
}} |
|
|
|
|
</DataPanel> |
|
|
|
|
)} |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}} |
|
|
|
|
|