Reports counts - add total and noop

This commit is contained in:
redref
2017-01-31 23:33:03 +01:00
parent 2f347fd665
commit 1758f972f1
4 changed files with 32 additions and 12 deletions

View File

@@ -534,21 +534,20 @@ def reports_ajax(env, node_name):
report_event_counts = {} report_event_counts = {}
# Create a map from the metrics data to what the templates # Create a map from the metrics data to what the templates
# use to express the data. # use to express the data.
report_map = { events_metrics = ['success', 'failure', 'noop']
'success': 'successes', resources_metrics = ['total', 'skipped']
'failure': 'failures',
'skipped': 'skips',
'noops': 'noop'
}
for report in reports_events: for report in reports_events:
if total is None: if total is None:
total = puppetdb.total total = puppetdb.total
report_counts = {'successes': 0, 'failures': 0, 'skips': 0} report_counts = {}
for metrics in report.metrics: for metric in report.metrics:
if 'name' in metrics and metrics['name'] in report_map: if ('category' in metric and metric['category'] == 'events' and
key_name = report_map[metrics['name']] 'name' in metric and metric['name'] in events_metrics):
report_counts[key_name] = metrics['value'] 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 report_event_counts[report.hash_] = report_counts

View File

@@ -72,6 +72,14 @@ h1.ui.header.no-margin-bottom {
background-color: #DB843D; background-color: #DB843D;
} }
.ui.header.total {
color: #989898;
}
.ui.label.total {
background-color: #989898;
}
.ui.label.unchanged { .ui.label.unchanged {
background-color: #89A54E; background-color: #89A54E;
} }

View File

@@ -57,6 +57,19 @@
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{% macro report_status(caller, status, node_name, events, current_env, unreported_time=False, report_hash=False) -%}
<a class="ui {{status}} label status" href="{{url_for('report', env=current_env, node_name=node_name, report_id=report_hash)}}">{{ status|upper }}</a>
{% if status == 'unreported' %}
<span class="ui label status"> {{ unreported_time|upper }} </span>
{% else %}
<span title="Total resources" class="ui small count label{% if events['total'] %} total">{{events['total']}}{% else %}">0{% endif%}</span>
<span title="Failure events" class="ui small count label{% if events['failure'] %} failed">{{events['failure']}}{% else %}">0{% endif%}</span>
<span title="Success events" class="ui small count label{% if events['success'] %} changed">{{events['success']}}{% else %}">0{% endif%}</span>
<span title="Skip events" class="ui small count label{% if events['skipped'] %} skipped">{{events['skipped']}}{% else %}">0{% endif%}</span>
<span title="Noop resources" class="ui small count label{% if events['noop'] %} noop">{{events['noop']}}{% else %}">0{% endif%}</span>
{% endif %}
{%- endmacro %}
{% macro datatable_init(table_html_id, ajax_url, default_length, length_selector, extra_options=None) -%} {% macro datatable_init(table_html_id, ajax_url, default_length, length_selector, extra_options=None) -%}
// Init datatable // Init datatable
$.fn.dataTable.ext.errMode = 'throw'; $.fn.dataTable.ext.errMode = 'throw';

View File

@@ -15,7 +15,7 @@
"<span rel=\"utctimestamp\">{{ report[column.attr] }}</span>" "<span rel=\"utctimestamp\">{{ report[column.attr] }}</span>"
{%- elif column.type == 'status' -%} {%- elif column.type == 'status' -%}
{% filter jsonprint -%} {% 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 %} {%- endfilter %}
{%- elif column.type == 'node' -%} {%- elif column.type == 'node' -%}
{% filter jsonprint %}<a href="{{url_for('node', env=current_env, node_name=report.node)}}">{{ report.node }}</a>{% endfilter %} {% filter jsonprint %}<a href="{{url_for('node', env=current_env, node_name=report.node)}}">{{ report.node }}</a>{% endfilter %}