-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support single row layout, feedback for no data, unsupported data
- Loading branch information
Showing
5 changed files
with
194 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,52 @@ | ||
import { FieldConfigProperty, PanelPlugin, ThresholdsMode } from '@grafana/data'; | ||
import { PanelPlugin } from '@grafana/data'; | ||
import { SortOptions, TrafficLightOptions } from './types'; | ||
import { TrafficLightPanel } from './components/TrafficLightPanel'; | ||
|
||
export const plugin = new PanelPlugin<TrafficLightOptions>(TrafficLightPanel) | ||
.useFieldConfig({ | ||
standardOptions: { | ||
[FieldConfigProperty.Thresholds]: { | ||
defaultValue: { | ||
mode: ThresholdsMode.Percentage, | ||
steps: [ | ||
{ color: 'red', value: -Infinity }, | ||
{ color: 'red', value: 0 }, | ||
{ color: '#EAB839', value: 50 }, | ||
{ color: '#73BF69', value: 80 }, | ||
], | ||
}, | ||
}, | ||
}, | ||
}) | ||
.useFieldConfig() | ||
.setPanelOptions((builder) => { | ||
return builder | ||
.addNumberInput({ | ||
path: 'minLightWidth', | ||
name: 'Minimum light width', | ||
description: 'Set the minimum traffic light width', | ||
defaultValue: 75, | ||
}) | ||
.addRadio({ | ||
path: 'sortLights', | ||
name: 'Sort lights', | ||
description: 'Sort lights based on values', | ||
defaultValue: SortOptions.None, | ||
settings: { | ||
options: [ | ||
{ value: SortOptions.None, label: 'None' }, | ||
{ value: SortOptions.Asc, label: 'Ascending' }, | ||
{ value: SortOptions.Desc, label: 'Descending' }, | ||
], | ||
}, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'showValue', | ||
name: 'Show value', | ||
description: 'Show or hide the value', | ||
defaultValue: true, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'showTrend', | ||
name: 'Show trend', | ||
description: 'Show or hide the trend color', | ||
defaultValue: true, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'horizontal', | ||
name: 'Horizontal traffic lights', | ||
description: 'Change the orientation of the traffic lights', | ||
defaultValue: false, | ||
}); | ||
}); | ||
return builder | ||
.addNumberInput({ | ||
path: 'minLightWidth', | ||
name: 'Minimum light width', | ||
description: 'Set the minimum traffic light width', | ||
defaultValue: 100, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'singleRow', | ||
name: 'Single row', | ||
description: 'Place all lights in a single row', | ||
defaultValue: false, | ||
}) | ||
.addRadio({ | ||
path: 'sortLights', | ||
name: 'Sort lights', | ||
description: 'Sort lights based on values', | ||
defaultValue: SortOptions.None, | ||
settings: { | ||
options: [ | ||
{ value: SortOptions.None, label: 'None' }, | ||
{ value: SortOptions.Asc, label: 'Ascending' }, | ||
{ value: SortOptions.Desc, label: 'Descending' }, | ||
], | ||
}, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'showValue', | ||
name: 'Show value', | ||
description: 'Show or hide the value', | ||
defaultValue: true, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'showTrend', | ||
name: 'Show trend', | ||
description: 'Show or hide the trend color', | ||
defaultValue: true, | ||
}) | ||
.addBooleanSwitch({ | ||
path: 'horizontal', | ||
name: 'Horizontal traffic lights', | ||
description: 'Change the orientation of the traffic lights', | ||
defaultValue: false, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters