From 42ed123fe37d1e234f80624609ebec9269e733cd Mon Sep 17 00:00:00 2001 From: redref Date: Thu, 2 Feb 2017 18:23:09 +0100 Subject: [PATCH] Fix number formating in counters --- puppetboard/templates/_macros.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index b39fadb..e4cb163 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -65,7 +65,17 @@ {% for metric in config.DISPLAYED_METRICS %} {% set path = metric.split('.') %} {% set title = ' '.join(path) %} - {{ "%.2g"|format(metrics[path[0]][path[1]]) }}{% else %}">0{% endif%} + {% if metrics[path[0]] and metrics[path[0]][path[1]] %} + {% set value = metrics[path[0]][path[1]] %} + {% if value != 0 and value|int != value %} + {% set format_str = '%.2f' %} + {% else %} + {% set format_str = '%s' %} + {% endif %} + {{ format_str|format(value) }} + {% else %} + 0 + {% endif%} {% endfor %} {% endif %} {%- endmacro %}