Merge pull request #344 from redref/reports_noops_display
Add total and noop boxes on reports page.
This commit is contained in:
@@ -531,26 +531,17 @@ def reports_ajax(env, node_name):
|
|||||||
reports_events = []
|
reports_events = []
|
||||||
total = 0
|
total = 0
|
||||||
|
|
||||||
report_event_counts = {}
|
# Convert metrics to relational dict
|
||||||
# Create a map from the metrics data to what the templates
|
metrics = {}
|
||||||
# use to express the data.
|
|
||||||
report_map = {
|
|
||||||
'success': 'successes',
|
|
||||||
'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}
|
metrics[report.hash_] = {}
|
||||||
for metrics in report.metrics:
|
for m in report.metrics:
|
||||||
if 'name' in metrics and metrics['name'] in report_map:
|
if m['category'] not in metrics[report.hash_]:
|
||||||
key_name = report_map[metrics['name']]
|
metrics[report.hash_][m['category']] = {}
|
||||||
report_counts[key_name] = metrics['value']
|
metrics[report.hash_][m['category']][m['name']] = m['value']
|
||||||
|
|
||||||
report_event_counts[report.hash_] = report_counts
|
|
||||||
|
|
||||||
if total is None:
|
if total is None:
|
||||||
total = 0
|
total = 0
|
||||||
@@ -561,7 +552,7 @@ def reports_ajax(env, node_name):
|
|||||||
total=total,
|
total=total,
|
||||||
total_filtered=total,
|
total_filtered=total,
|
||||||
reports=reports,
|
reports=reports,
|
||||||
report_event_counts=report_event_counts,
|
metrics=metrics,
|
||||||
envs=envs,
|
envs=envs,
|
||||||
current_env=env,
|
current_env=env,
|
||||||
columns=REPORTS_COLUMNS[:max_col])
|
columns=REPORTS_COLUMNS[:max_col])
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ LOGLEVEL = 'info'
|
|||||||
NORMAL_TABLE_COUNT = 100
|
NORMAL_TABLE_COUNT = 100
|
||||||
LITTLE_TABLE_COUNT = 10
|
LITTLE_TABLE_COUNT = 10
|
||||||
TABLE_COUNT_SELECTOR = [10, 20, 50, 100, 500]
|
TABLE_COUNT_SELECTOR = [10, 20, 50, 100, 500]
|
||||||
|
DISPLAYED_METRICS = ['resources.total',
|
||||||
|
'events.failure',
|
||||||
|
'events.success',
|
||||||
|
'resources.skipped',
|
||||||
|
'events.noop']
|
||||||
OFFLINE_MODE = False
|
OFFLINE_MODE = False
|
||||||
ENABLE_CATALOG = False
|
ENABLE_CATALOG = False
|
||||||
OVERVIEW_FILTER = None
|
OVERVIEW_FILTER = None
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ TABLE_COUNT_DEF = "10,20,50,100,500"
|
|||||||
TABLE_COUNT_SELECTOR = [int(x) for x in os.getenv('TABLE_COUNT_SELECTOR',
|
TABLE_COUNT_SELECTOR = [int(x) for x in os.getenv('TABLE_COUNT_SELECTOR',
|
||||||
TABLE_COUNT_DEF).split(',')]
|
TABLE_COUNT_DEF).split(',')]
|
||||||
|
|
||||||
|
DISP_METR_DEF = ','.join(['resources.total', 'events.failure',
|
||||||
|
'events.success', 'resources.skipped',
|
||||||
|
'events.noop'])
|
||||||
|
|
||||||
|
DISPLAYED_METRICS = [x.strip() for x in os.getenv('DISPLAYED_METRICS',
|
||||||
|
DISP_METR_DEF).split(',')]
|
||||||
|
|
||||||
OFFLINE_MODE = bool(os.getenv('OFFLINE_MODE', 'False').upper() == 'TRUE')
|
OFFLINE_MODE = bool(os.getenv('OFFLINE_MODE', 'False').upper() == 'TRUE')
|
||||||
ENABLE_CATALOG = bool(os.getenv('ENABLE_CATALOG', 'False').upper() == 'TRUE')
|
ENABLE_CATALOG = bool(os.getenv('ENABLE_CATALOG', 'False').upper() == 'TRUE')
|
||||||
OVERVIEW_FILTER = os.getenv('OVERVIEW_FILTER', None)
|
OVERVIEW_FILTER = os.getenv('OVERVIEW_FILTER', None)
|
||||||
@@ -46,7 +53,6 @@ GRAPH_FACTS_DEFAULT = ','.join(['architecture', 'clientversion', 'domain',
|
|||||||
GRAPH_FACTS = [x.strip() for x in os.getenv('GRAPH_FACTS',
|
GRAPH_FACTS = [x.strip() for x in os.getenv('GRAPH_FACTS',
|
||||||
GRAPH_FACTS_DEFAULT).split(',')]
|
GRAPH_FACTS_DEFAULT).split(',')]
|
||||||
|
|
||||||
|
|
||||||
GRAPH_TYPE = os.getenv('GRAPH_TYPE', 'pie')
|
GRAPH_TYPE = os.getenv('GRAPH_TYPE', 'pie')
|
||||||
|
|
||||||
# Tuples are hard to express as an environment variable, so here
|
# Tuples are hard to express as an environment variable, so here
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ h1.ui.header.no-margin-bottom {
|
|||||||
color: #AA4643;
|
color: #AA4643;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui.label.failed {
|
.ui.label.failed, .ui.label.events.failure {
|
||||||
background-color: #AA4643;
|
background-color: #AA4643;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ h1.ui.header.no-margin-bottom {
|
|||||||
color: #4572A7;
|
color: #4572A7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui.label.changed {
|
.ui.label.changed, .ui.label.events.success {
|
||||||
background-color: #4572A7;
|
background-color: #4572A7;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,10 +68,14 @@ h1.ui.header.no-margin-bottom {
|
|||||||
color: #DB843D;
|
color: #DB843D;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui.label.noop {
|
.ui.label.noop, .ui.label.events.noop {
|
||||||
background-color: #DB843D;
|
background-color: #DB843D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui.label.resources.total {
|
||||||
|
background-color: #989898;
|
||||||
|
}
|
||||||
|
|
||||||
.ui.label.unchanged {
|
.ui.label.unchanged {
|
||||||
background-color: #89A54E;
|
background-color: #89A54E;
|
||||||
}
|
}
|
||||||
@@ -80,7 +84,7 @@ h1.ui.header.no-margin-bottom {
|
|||||||
color: orange;
|
color: orange;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui.label.skipped {
|
.ui.label.skipped, .ui.label.resources.skipped {
|
||||||
background-color: orange;
|
background-color: orange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,29 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
{% macro report_status(caller, status, node_name, metrics, 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 %}
|
||||||
|
{% for metric in config.DISPLAYED_METRICS %}
|
||||||
|
{% set path = metric.split('.') %}
|
||||||
|
{% set title = ' '.join(path) %}
|
||||||
|
{% 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 %}
|
||||||
|
<span title="{{ title }}" class="ui small count label {{ title }}">{{ format_str|format(value) }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span title="{{ title }}" class="ui small count label">0</span>
|
||||||
|
{% endif%}
|
||||||
|
{% endfor %}
|
||||||
|
{% 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';
|
||||||
|
|||||||
@@ -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, metrics=metrics[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 %}
|
||||||
|
|||||||
@@ -116,3 +116,11 @@ def test_env_table_selector(cleanUpEnv):
|
|||||||
os.environ['TABLE_COUNT_SELECTOR'] = '5,15,25'
|
os.environ['TABLE_COUNT_SELECTOR'] = '5,15,25'
|
||||||
reload(docker_settings)
|
reload(docker_settings)
|
||||||
assert [5, 15, 25] == docker_settings.TABLE_COUNT_SELECTOR
|
assert [5, 15, 25] == docker_settings.TABLE_COUNT_SELECTOR
|
||||||
|
|
||||||
|
|
||||||
|
def test_env_column_options(cleanUpEnv):
|
||||||
|
os.environ['DISPLAYED_METRICS'] = 'resources.total, events.failure'
|
||||||
|
|
||||||
|
reload(docker_settings)
|
||||||
|
assert ['resources.total',
|
||||||
|
'events.failure'] == docker_settings.DISPLAYED_METRICS
|
||||||
|
|||||||
Reference in New Issue
Block a user