// Libraries import React, { PureComponent } from 'react'; import { PanelOptionsGrid, FieldDisplayEditor, PanelOptionsGroup, FormLabel, Select, FieldPropertiesEditor, ThresholdsEditor, LegacyValueMappingsEditor, DataLinksEditor, } from '@grafana/ui'; import { PanelEditorProps, FieldDisplayOptions, FieldConfig, ValueMapping, ThresholdsConfig, DataLink, } from '@grafana/data'; import { StatPanelOptions, colorModes, graphModes, justifyModes } from './types'; import { orientationOptions } from '../gauge/types'; import { getCalculationValueDataLinksVariableSuggestions, getDataLinksVariableSuggestions, } from '../../../features/panel/panellinks/link_srv'; export class StatPanelEditor extends PureComponent> { onThresholdsChanged = (thresholds: ThresholdsConfig) => { const current = this.props.fieldConfig; this.props.onFieldConfigChange({ ...current, defaults: { ...current.defaults, thresholds, }, }); }; onValueMappingsChanged = (mappings: ValueMapping[]) => { const current = this.props.fieldConfig; this.props.onFieldConfigChange({ ...current, defaults: { ...current.defaults, mappings, }, }); }; onDisplayOptionsChanged = (fieldOptions: FieldDisplayOptions) => this.props.onOptionsChange({ ...this.props.options, fieldOptions, }); onColorModeChanged = ({ value }: any) => this.props.onOptionsChange({ ...this.props.options, colorMode: value }); onGraphModeChanged = ({ value }: any) => this.props.onOptionsChange({ ...this.props.options, graphMode: value }); onJustifyModeChanged = ({ value }: any) => this.props.onOptionsChange({ ...this.props.options, justifyMode: value }); onOrientationChange = ({ value }: any) => this.props.onOptionsChange({ ...this.props.options, orientation: value }); onDefaultsChange = (field: FieldConfig) => { this.props.onFieldConfigChange({ ...this.props.fieldConfig, defaults: field, }); }; onDataLinksChanged = (links: DataLink[]) => { const current = this.props.fieldConfig; this.props.onFieldConfigChange({ ...current, defaults: { ...current.defaults, links, }, }); }; render() { const { options, fieldConfig } = this.props; const { fieldOptions } = options; const { defaults } = fieldConfig; const suggestions = fieldOptions.values ? getDataLinksVariableSuggestions(this.props.data.series) : getCalculationValueDataLinksVariableSuggestions(this.props.data.series); return ( <>
Orientation item.value === options.colorMode)} />
Graph item.value === options.justifyMode)} />
); } }