|
|
|
@ -1,13 +1,30 @@ |
|
|
|
|
import React, { PureComponent } from 'react'; |
|
|
|
|
import Gauge from 'app/viz/Gauge'; |
|
|
|
|
import { NullValueMode, PanelProps } from 'app/types'; |
|
|
|
|
import { NullValueMode, PanelOptionsProps, PanelProps } from 'app/types'; |
|
|
|
|
import { getTimeSeriesVMs } from 'app/viz/state/timeSeries'; |
|
|
|
|
import { GaugeOptions } from './GaugeOptions'; |
|
|
|
|
import { Label } from '../../../core/components/Label/Label'; |
|
|
|
|
import SimplePicker from '../../../core/components/Picker/SimplePicker'; |
|
|
|
|
|
|
|
|
|
export interface Options {} |
|
|
|
|
export interface Options { |
|
|
|
|
stat: { value: string; text: string }; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface Props extends PanelProps<Options> {} |
|
|
|
|
|
|
|
|
|
const statOptions = [ |
|
|
|
|
{ value: 'min', text: 'Min' }, |
|
|
|
|
{ value: 'max', text: 'Max' }, |
|
|
|
|
{ value: 'avg', text: 'Average' }, |
|
|
|
|
{ value: 'current', text: 'Current' }, |
|
|
|
|
{ value: 'total', text: 'Total' }, |
|
|
|
|
{ value: 'name', text: 'Name' }, |
|
|
|
|
{ value: 'first', text: 'First' }, |
|
|
|
|
{ value: 'delta', text: 'Delta' }, |
|
|
|
|
{ value: 'diff', text: 'Difference' }, |
|
|
|
|
{ value: 'range', text: 'Range' }, |
|
|
|
|
{ value: 'last_time', text: 'Time of last point' }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
export class GaugePanel extends PureComponent<Props> { |
|
|
|
|
render() { |
|
|
|
|
const { timeSeries, width, height } = this.props; |
|
|
|
@ -17,8 +34,36 @@ export class GaugePanel extends PureComponent<Props> { |
|
|
|
|
nullValueMode: NullValueMode.Ignore, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return <Gauge timeSeries={vmSeries} {...this.props.options} width={width} height={height} />; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class GaugeOptions extends PureComponent<PanelOptionsProps<Options>> { |
|
|
|
|
onStatChange = value => { |
|
|
|
|
this.props.onChange({ ...this.props.options, stat: value }); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
|
const { stat } = this.props.options; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<Gauge maxValue={100} minValue={0} timeSeries={vmSeries} thresholds={[0, 100]} height={height} width={width} /> |
|
|
|
|
<div> |
|
|
|
|
<div className="section gf-form-group"> |
|
|
|
|
<h5 className="page-heading">Value</h5> |
|
|
|
|
<div className="gf-form-inline"> |
|
|
|
|
<Label width={5}>Stat</Label> |
|
|
|
|
<SimplePicker |
|
|
|
|
defaultValue={statOptions.find(option => option.value === stat.value)} |
|
|
|
|
width={11} |
|
|
|
|
options={statOptions} |
|
|
|
|
getOptionLabel={i => i.text} |
|
|
|
|
getOptionValue={i => i.value} |
|
|
|
|
onSelected={this.onStatChange} |
|
|
|
|
value={stat} |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|