From 95ef0417cf9737ec58a9a2e735347a77374c55b7 Mon Sep 17 00:00:00 2001 From: Jake Utley <5660346+jutley@users.noreply.github.com> Date: Sun, 26 Jul 2020 07:52:42 -0700 Subject: [PATCH] TablePanel: Add support for basic gauge as a cell display mode (#26595) --- packages/grafana-ui/src/components/Table/BarGaugeCell.tsx | 2 ++ packages/grafana-ui/src/components/Table/types.ts | 1 + packages/grafana-ui/src/components/Table/utils.ts | 1 + public/app/plugins/panel/table/module.tsx | 1 + 4 files changed, 5 insertions(+) diff --git a/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx b/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx index c2c614538da..abb33d98a60 100644 --- a/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx +++ b/packages/grafana-ui/src/components/Table/BarGaugeCell.tsx @@ -37,6 +37,8 @@ export const BarGaugeCell: FC = props => { if (field.config.custom && field.config.custom.displayMode === TableCellDisplayMode.LcdGauge) { barGaugeMode = BarGaugeDisplayMode.Lcd; + } else if (field.config.custom && field.config.custom.displayMode === TableCellDisplayMode.BasicGauge) { + barGaugeMode = BarGaugeDisplayMode.Basic; } let width; diff --git a/packages/grafana-ui/src/components/Table/types.ts b/packages/grafana-ui/src/components/Table/types.ts index 687c9e60295..0a60c52b4f2 100644 --- a/packages/grafana-ui/src/components/Table/types.ts +++ b/packages/grafana-ui/src/components/Table/types.ts @@ -17,6 +17,7 @@ export enum TableCellDisplayMode { GradientGauge = 'gradient-gauge', LcdGauge = 'lcd-gauge', JSONView = 'json-view', + BasicGauge = 'basic', } export type FieldTextAlignment = 'auto' | 'left' | 'right' | 'center'; diff --git a/packages/grafana-ui/src/components/Table/utils.ts b/packages/grafana-ui/src/components/Table/utils.ts index ce37b5c99fd..580bad1666a 100644 --- a/packages/grafana-ui/src/components/Table/utils.ts +++ b/packages/grafana-ui/src/components/Table/utils.ts @@ -91,6 +91,7 @@ function getCellComponent(displayMode: TableCellDisplayMode, field: Field) { case TableCellDisplayMode.ColorBackground: return withTableStyles(DefaultCell, getBackgroundColorStyle); case TableCellDisplayMode.LcdGauge: + case TableCellDisplayMode.BasicGauge: case TableCellDisplayMode.GradientGauge: return BarGaugeCell; case TableCellDisplayMode.JSONView: diff --git a/public/app/plugins/panel/table/module.tsx b/public/app/plugins/panel/table/module.tsx index a5fb9d86044..44e11f1529f 100644 --- a/public/app/plugins/panel/table/module.tsx +++ b/public/app/plugins/panel/table/module.tsx @@ -45,6 +45,7 @@ export const plugin = new PanelPlugin(TablePanel) { value: TableCellDisplayMode.ColorBackground, label: 'Color background' }, { value: TableCellDisplayMode.GradientGauge, label: 'Gradient gauge' }, { value: TableCellDisplayMode.LcdGauge, label: 'LCD gauge' }, + { value: TableCellDisplayMode.BasicGauge, label: 'Basic gauge' }, { value: TableCellDisplayMode.JSONView, label: 'JSON View' }, ], },