From 08b4520efb773250024a68220bdd54801d73455f Mon Sep 17 00:00:00 2001 From: Eldad Marciano Date: Wed, 7 Mar 2018 15:44:59 +0200 Subject: [PATCH] Add gauge caps for singlestat panel. Change-Id: Ic87e610cff0f2389464f8d744d7853a369939dc6 --- grafana_dashboards/schema/panel/singlestat.py | 9 +++++++++ tests/schema/fixtures/dashboard-0017.json | 7 +++++++ tests/schema/fixtures/dashboard-0017.yaml | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/grafana_dashboards/schema/panel/singlestat.py b/grafana_dashboards/schema/panel/singlestat.py index f8b48e4..7c81fb7 100644 --- a/grafana_dashboards/schema/panel/singlestat.py +++ b/grafana_dashboards/schema/panel/singlestat.py @@ -39,6 +39,14 @@ class Singlestat(Base): v.Required('show', default=False): v.All(bool), } + gauge = { + v.Required('maxValue'): v.All(int), + v.Required('minValue'): v.Any(int), + v.Required('show', default=False): v.All(bool), + v.Required('thresholdLabels', default=False): v.All(bool), + v.Required('thresholdMarkers', default=False): v.All(bool), + } + singlestat = { v.Required('colorBackground', default=False): v.All(bool), v.Required('colorValue', default=False): v.All(bool), @@ -64,6 +72,7 @@ class Singlestat(Base): 'avg', 'current', 'max', 'min', 'total'), v.Optional('datasource'): v.All(str), v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)), + v.Optional('gauge'): gauge, v.Optional('hideTimeOverride'): v.All(bool), v.Optional('timeFrom'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')), v.Optional('timeShift'): v.All(v.Match(r'[1-9]+[0-9]*[smhdw]')), diff --git a/tests/schema/fixtures/dashboard-0017.json b/tests/schema/fixtures/dashboard-0017.json index 6c3bca2..1bace55 100644 --- a/tests/schema/fixtures/dashboard-0017.json +++ b/tests/schema/fixtures/dashboard-0017.json @@ -12,6 +12,13 @@ "colorValue": false, "editable": true, "error": false, + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": true, + "thresholdLabels": false, + "thresholdMarkers": true + }, "hideTimeOverride": true, "maxDataPoints": 100, "postfix": "", diff --git a/tests/schema/fixtures/dashboard-0017.yaml b/tests/schema/fixtures/dashboard-0017.yaml index 34e18d7..04fb383 100644 --- a/tests/schema/fixtures/dashboard-0017.yaml +++ b/tests/schema/fixtures/dashboard-0017.yaml @@ -9,3 +9,9 @@ dashboard: timeFrom: 10d timeShift: 1h hideTimeOverride: true + gauge: + maxValue: 100 + minValue: 0 + show: true + thresholdLabels: false + thresholdMarkers: true