diff --git a/puppetboard/app.py b/puppetboard/app.py index 20571ea..c7301dc 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -534,21 +534,20 @@ def reports_ajax(env, node_name): report_event_counts = {} # Create a map from the metrics data to what the templates # use to express the data. - report_map = { - 'success': 'successes', - 'failure': 'failures', - 'skipped': 'skips', - 'noops': 'noop' - } + events_metrics = ['success', 'failure', 'noop'] + resources_metrics = ['total', 'skipped'] for report in reports_events: if total is None: total = puppetdb.total - report_counts = {'successes': 0, 'failures': 0, 'skips': 0} - for metrics in report.metrics: - if 'name' in metrics and metrics['name'] in report_map: - key_name = report_map[metrics['name']] - report_counts[key_name] = metrics['value'] + report_counts = {} + for metric in report.metrics: + if ('category' in metric and metric['category'] == 'events' and + 'name' in metric and metric['name'] in events_metrics): + report_counts[metric['name']] = metric['value'] + if ('category' in metric and metric['category'] == 'resources' and + 'name' in metric and metric['name'] in resources_metrics): + report_counts[metric['name']] = metric['value'] report_event_counts[report.hash_] = report_counts diff --git a/puppetboard/static/css/puppetboard.css b/puppetboard/static/css/puppetboard.css index 19506f5..71b6856 100644 --- a/puppetboard/static/css/puppetboard.css +++ b/puppetboard/static/css/puppetboard.css @@ -72,6 +72,14 @@ h1.ui.header.no-margin-bottom { background-color: #DB843D; } +.ui.header.total { + color: #989898; +} + +.ui.label.total { + background-color: #989898; +} + .ui.label.unchanged { background-color: #89A54E; } diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index fe28cc5..7a07f15 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -57,6 +57,19 @@ {% endif %} {%- endmacro %} +{% macro report_status(caller, status, node_name, events, current_env, unreported_time=False, report_hash=False) -%} + {{ status|upper }} + {% if status == 'unreported' %} + {{ unreported_time|upper }} + {% else %} + {{events['total']}}{% else %}">0{% endif%} + {{events['failure']}}{% else %}">0{% endif%} + {{events['success']}}{% else %}">0{% endif%} + {{events['skipped']}}{% else %}">0{% endif%} + {{events['noop']}}{% else %}">0{% endif%} + {% endif %} +{%- endmacro %} + {% macro datatable_init(table_html_id, ajax_url, default_length, length_selector, extra_options=None) -%} // Init datatable $.fn.dataTable.ext.errMode = 'throw'; diff --git a/puppetboard/templates/reports.json.tpl b/puppetboard/templates/reports.json.tpl index 2c24659..9f74e31 100644 --- a/puppetboard/templates/reports.json.tpl +++ b/puppetboard/templates/reports.json.tpl @@ -15,7 +15,7 @@ "{{ report[column.attr] }}" {%- elif column.type == 'status' -%} {% filter jsonprint -%} - {{ macros.status_counts(status=report.status, node_name=report.node, events=report_event_counts[report.hash_], report_hash=report.hash_, current_env=current_env) }} + {{ macros.report_status(status=report.status, node_name=report.node, events=report_event_counts[report.hash_], report_hash=report.hash_, current_env=current_env) }} {%- endfilter %} {%- elif column.type == 'node' -%} {% filter jsonprint %}{{ report.node }}{% endfilter %}