From ada9ac1be1d72fccdf9a694d031de52388b1a568 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 11 Mar 2019 19:37:10 -0700 Subject: [PATCH] use new settings --- public/app/plugins/panel/gauge/GaugePanel.tsx | 11 +++--- .../plugins/panel/gauge/GaugePanelEditor.tsx | 35 ++++++++----------- public/app/plugins/panel/gauge/types.ts | 4 +-- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/public/app/plugins/panel/gauge/GaugePanel.tsx b/public/app/plugins/panel/gauge/GaugePanel.tsx index 425ccb00356..b3af5c7ef75 100644 --- a/public/app/plugins/panel/gauge/GaugePanel.tsx +++ b/public/app/plugins/panel/gauge/GaugePanel.tsx @@ -38,13 +38,13 @@ export class GaugePanel extends Component { findDisplayValue(props: Props): DisplayValue { const { replaceVariables, options } = this.props; - const { displayOptions } = options; + const { display } = options; - const prefix = replaceVariables(displayOptions.prefix); - const suffix = replaceVariables(displayOptions.suffix); + const prefix = replaceVariables(display.prefix); + const suffix = replaceVariables(display.suffix); return getValueProcessor({ color: BasicGaugeColor.Red, // The default color - ...displayOptions, + ...display, prefix, suffix, // ??? theme:getTheme(GrafanaThemeType.Dark), !! how do I get it here??? @@ -72,6 +72,7 @@ export class GaugePanel extends Component { render() { const { width, height, options } = this.props; const { value } = this.state; + const { display } = options; return ( @@ -80,7 +81,7 @@ export class GaugePanel extends Component { value={value} width={width} height={height} - thresholds={options.thresholds} + thresholds={display.thresholds} showThresholdLabels={options.showThresholdLabels} showThresholdMarkers={options.showThresholdMarkers} minValue={options.minValue} diff --git a/public/app/plugins/panel/gauge/GaugePanelEditor.tsx b/public/app/plugins/panel/gauge/GaugePanelEditor.tsx index 55a0377848d..db64c00f241 100644 --- a/public/app/plugins/panel/gauge/GaugePanelEditor.tsx +++ b/public/app/plugins/panel/gauge/GaugePanelEditor.tsx @@ -10,37 +10,32 @@ import { import { SingleStatValueEditor } from 'app/plugins/panel/gauge/SingleStatValueEditor'; import { GaugeOptionsBox } from './GaugeOptionsBox'; -import { GaugeOptions, SingleStatValueOptions } from './types'; +import { GaugeOptions } from './types'; import { DisplayValueEditor } from './DisplayValueEditor'; import { DisplayValueOptions } from '@grafana/ui/src/utils/valueProcessor'; export class GaugePanelEditor extends PureComponent> { - onThresholdsChanged = (thresholds: Threshold[]) => + onDisplayOptionsChanged = (displayOptions: DisplayValueOptions) => this.props.onOptionsChange({ ...this.props.options, + display: displayOptions, + }); + + onThresholdsChanged = (thresholds: Threshold[]) => + this.onDisplayOptionsChanged({ + ...this.props.options.display, thresholds, }); onValueMappingsChanged = (valueMappings: ValueMapping[]) => - this.props.onOptionsChange({ - ...this.props.options, - valueMappings, - }); - - onValueOptionsChanged = (valueOptions: SingleStatValueOptions) => - this.props.onOptionsChange({ - ...this.props.options, - valueOptions, - }); - - onDisplayOptionsChanged = (displayOptions: DisplayValueOptions) => - this.props.onOptionsChange({ - ...this.props.options, - displayOptions, + this.onDisplayOptionsChanged({ + ...this.props.options.display, + mappings: valueMappings, }); render() { const { onOptionsChange, options } = this.props; + const { display } = options; return ( <> @@ -48,12 +43,12 @@ export class GaugePanelEditor extends PureComponent - + - + - + ); } diff --git a/public/app/plugins/panel/gauge/types.ts b/public/app/plugins/panel/gauge/types.ts index b6c191b730c..c90b254cdc4 100644 --- a/public/app/plugins/panel/gauge/types.ts +++ b/public/app/plugins/panel/gauge/types.ts @@ -8,7 +8,7 @@ export interface GaugeOptions { showThresholdMarkers: boolean; stat: string; - displayOptions: DisplayValueOptions; + display: DisplayValueOptions; // TODO: migrate to DisplayValueOptions thresholds?: Threshold[]; @@ -32,7 +32,7 @@ export const defaults: GaugeOptions = { showThresholdLabels: false, stat: 'avg', - displayOptions: { + display: { prefix: '', suffix: '', decimals: null,