|
|
|
import { PanelOptions, Pod } from './types';
|
|
|
|
import { Panel } from './components/Panel';
|
|
|
|
|
|
|
|
import { PanelPlugin } from '@grafana/data';
|
|
|
|
import { IconsEditor } from 'components/editors/IconsEditor';
|
|
|
|
|
|
|
|
|
|
|
|
export const plugin = new PanelPlugin<PanelOptions>(Panel).setPanelOptions((builder) => {
|
|
|
|
return builder
|
|
|
|
.addRadio({
|
|
|
|
path: 'visualizationType',
|
|
|
|
name: 'Pod',
|
|
|
|
category: ['Visualization'],
|
|
|
|
defaultValue: Pod.GAUGE,
|
|
|
|
settings: {
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
label: 'Gauge',
|
|
|
|
value: Pod.GAUGE,
|
|
|
|
description: 'Enable gauge pod',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Line',
|
|
|
|
value: Pod.LINE,
|
|
|
|
description: 'Enable line pod',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Bar',
|
|
|
|
value: Pod.BAR,
|
|
|
|
description: 'Enable bar pod',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
.addFieldNamePicker({
|
|
|
|
name: 'Value',
|
|
|
|
path: 'gauge.value.metricName',
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE
|
|
|
|
})
|
|
|
|
|
|
|
|
.addNumberInput({
|
|
|
|
path: 'gauge.min.value',
|
|
|
|
name: 'Min',
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.min.useMetric,
|
|
|
|
})
|
|
|
|
.addFieldNamePicker({
|
|
|
|
name: 'Min',
|
|
|
|
path: 'gauge.min.metricName',
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.min.useMetric,
|
|
|
|
})
|
|
|
|
.addBooleanSwitch({
|
|
|
|
path: 'gauge.min.useMetric',
|
|
|
|
name: 'Use metric',
|
|
|
|
defaultValue: false,
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE,
|
|
|
|
})
|
|
|
|
|
|
|
|
.addNumberInput({
|
|
|
|
path: 'gauge.max.value',
|
|
|
|
name: 'Max',
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE && !config.gauge.max.useMetric,
|
|
|
|
})
|
|
|
|
.addFieldNamePicker({
|
|
|
|
name: 'Max',
|
|
|
|
path: 'gauge.max.metricName',
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE && config.gauge.max.useMetric,
|
|
|
|
})
|
|
|
|
.addBooleanSwitch({
|
|
|
|
path: 'gauge.max.useMetric',
|
|
|
|
name: 'Use metric',
|
|
|
|
defaultValue: false,
|
|
|
|
category: ['Extremum'],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE,
|
|
|
|
})
|
|
|
|
|
|
|
|
.addCustomEditor({
|
|
|
|
id: 'icons',
|
|
|
|
path: 'gauge.icons',
|
|
|
|
name: 'Icons',
|
|
|
|
category: ['Icons'],
|
|
|
|
defaultValue: [],
|
|
|
|
showIf: (config) => config.visualizationType === Pod.GAUGE,
|
|
|
|
editor: IconsEditor as any,
|
|
|
|
})
|
|
|
|
});
|