mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import React, { PureComponent } from 'react';
|
|
import {
|
|
PanelEditorProps,
|
|
ThresholdsEditor,
|
|
Threshold,
|
|
PanelOptionsGrid,
|
|
ValueMappingsEditor,
|
|
ValueMapping,
|
|
} from '@grafana/ui';
|
|
|
|
import { SingleStatValueEditor } from 'app/plugins/panel/gauge/SingleStatValueEditor';
|
|
import { GaugeOptionsBox } from './GaugeOptionsBox';
|
|
import { GaugeOptions, SingleStatValueOptions } from './types';
|
|
|
|
export class GaugePanelEditor extends PureComponent<PanelEditorProps<GaugeOptions>> {
|
|
onThresholdsChanged = (thresholds: Threshold[]) =>
|
|
this.props.onChange({
|
|
...this.props.options,
|
|
thresholds,
|
|
});
|
|
|
|
onValueMappingsChanged = (valueMappings: ValueMapping[]) =>
|
|
this.props.onChange({
|
|
...this.props.options,
|
|
valueMappings,
|
|
});
|
|
|
|
onValueOptionsChanged = (valueOptions: SingleStatValueOptions) =>
|
|
this.props.onChange({
|
|
...this.props.options,
|
|
valueOptions,
|
|
});
|
|
|
|
render() {
|
|
const { onChange, options } = this.props;
|
|
|
|
return (
|
|
<>
|
|
<PanelOptionsGrid>
|
|
<SingleStatValueEditor onChange={this.onValueOptionsChanged} options={options.valueOptions} />
|
|
<GaugeOptionsBox onChange={onChange} options={options} />
|
|
<ThresholdsEditor onChange={this.onThresholdsChanged} thresholds={options.thresholds} />
|
|
</PanelOptionsGrid>
|
|
|
|
<ValueMappingsEditor onChange={this.onValueMappingsChanged} valueMappings={options.valueMappings} />
|
|
</>
|
|
);
|
|
}
|
|
}
|