From df8d304b244bfc88bc20416ec0a186f65cf6908e Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Wed, 4 Nov 2015 11:28:37 -0500 Subject: [PATCH] Additional fields for singlestat panel We are adding support for the following fields: decimals postfix postfixFontSize prefix prefixFontSize valueFontSize Change-Id: I45c8d953ae6847a078a7d2c916d1ddc189bcfb1a Signed-off-by: Paul Belanger --- grafana_dashboards/schema/panel.py | 15 +++++++++++++++ tests/schema/fixtures/dashboard-0006.json | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/grafana_dashboards/schema/panel.py b/grafana_dashboards/schema/panel.py index ee87208..c66c310 100644 --- a/grafana_dashboards/schema/panel.py +++ b/grafana_dashboards/schema/panel.py @@ -75,11 +75,26 @@ class Panel(object): v.Required('colorBackground', default=False): v.All(bool), v.Required('colorValue', default=False): v.All(bool), v.Required('maxDataPoints', default=100): v.All(int), + v.Required('postfix', default=''): v.All(str), + # Support 0% to 200% by 10 + v.Required( + 'postfixFontSize', default='50%'): v.All( + v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')), + v.Required('prefix', default=''): v.All(str), + # Support 0% to 200% by 10 + v.Required( + 'prefixFontSize', default='50%'): v.All( + v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')), v.Required('sparkline', default=sparkline_defaults): sparkline, v.Required('targets', default=[]): v.All(list), v.Required('thresholds', default=''): v.All(str), + # Support 0% to 200% by 10 + v.Required( + 'valueFontSize', default='80%'): v.All( + v.Match(r'^[1-9]?[0]{1}%$|^1[0-9]?[0]{1}%$|^200%$')), v.Required('valueName', default='avg'): v.All( 'avg', 'current', 'max', 'min', 'total'), + v.Optional('decimals'): v.All(int, v.Range(min=0, max=12)), } self.singlestat.update(self.base) diff --git a/tests/schema/fixtures/dashboard-0006.json b/tests/schema/fixtures/dashboard-0006.json index 6b66f3e..a073347 100644 --- a/tests/schema/fixtures/dashboard-0006.json +++ b/tests/schema/fixtures/dashboard-0006.json @@ -13,6 +13,10 @@ "editable": true, "error": false, "maxDataPoints": 100, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", "span": 12, "sparkline": { "fillColor": "rgba(31, 118, 189, 0.18)", @@ -24,6 +28,7 @@ "thresholds": "", "title": "no title (click here)", "type": "singlestat", + "valueFontSize": "80%", "valueName": "avg" } ],