Merge pull request #71 from stack72/master
Allow users to be able to set how many reports they show
@@ -630,12 +630,6 @@ Screenshots
|
|||||||
:height: 700
|
:height: 700
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
.. image:: https://raw.github.com/nedap/puppetboard/master/screenshots/report_message.png
|
|
||||||
:alt: Report view with message
|
|
||||||
:width: 1024
|
|
||||||
:height: 700
|
|
||||||
:align: center
|
|
||||||
|
|
||||||
.. image:: https://raw.github.com/nedap/puppetboard/master/screenshots/facts.png
|
.. image:: https://raw.github.com/nedap/puppetboard/master/screenshots/facts.png
|
||||||
:alt: Facts view
|
:alt: Facts view
|
||||||
:width: 1024
|
:width: 1024
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from pypuppetdb import connect
|
|||||||
from puppetboard.forms import QueryForm
|
from puppetboard.forms import QueryForm
|
||||||
from puppetboard.utils import (
|
from puppetboard.utils import (
|
||||||
get_or_abort, yield_or_stop,
|
get_or_abort, yield_or_stop,
|
||||||
ten_reports, jsonprint
|
limit_reports, jsonprint
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -176,12 +176,13 @@ def node(node_name):
|
|||||||
"""
|
"""
|
||||||
node = get_or_abort(puppetdb.node, node_name)
|
node = get_or_abort(puppetdb.node, node_name)
|
||||||
facts = node.facts()
|
facts = node.facts()
|
||||||
reports = ten_reports(node.reports())
|
reports = limit_reports(node.reports(), app.config['REPORTS_COUNT'])
|
||||||
return render_template(
|
return render_template(
|
||||||
'node.html',
|
'node.html',
|
||||||
node=node,
|
node=node,
|
||||||
facts=yield_or_stop(facts),
|
facts=yield_or_stop(facts),
|
||||||
reports=yield_or_stop(reports))
|
reports=yield_or_stop(reports),
|
||||||
|
reports_count=app.config['REPORTS_COUNT'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/reports')
|
@app.route('/reports')
|
||||||
@@ -195,12 +196,13 @@ def reports():
|
|||||||
def reports_node(node):
|
def reports_node(node):
|
||||||
"""Fetches all reports for a node and processes them eventually rendering
|
"""Fetches all reports for a node and processes them eventually rendering
|
||||||
a table displaying those reports."""
|
a table displaying those reports."""
|
||||||
reports = ten_reports(yield_or_stop(
|
reports = limit_reports(yield_or_stop(
|
||||||
puppetdb.reports('["=", "certname", "{0}"]'.format(node))))
|
puppetdb.reports('["=", "certname", "{0}"]'.format(node))), app.config['REPORTS_COUNT'])
|
||||||
return render_template(
|
return render_template(
|
||||||
'reports_node.html',
|
'reports_node.html',
|
||||||
reports=reports,
|
reports=reports,
|
||||||
nodename=node)
|
nodename=node,
|
||||||
|
reports_count=app.config['REPORTS_COUNT'])
|
||||||
|
|
||||||
|
|
||||||
@app.route('/report/latest/<node_name>')
|
@app.route('/report/latest/<node_name>')
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ UNRESPONSIVE_HOURS = 2
|
|||||||
ENABLE_QUERY = True
|
ENABLE_QUERY = True
|
||||||
LOCALISE_TIMESTAMP = True
|
LOCALISE_TIMESTAMP = True
|
||||||
LOGLEVEL = 'info'
|
LOGLEVEL = 'info'
|
||||||
|
REPORTS_COUNT = 10
|
||||||
|
|||||||
@@ -95,9 +95,13 @@
|
|||||||
</script>
|
</script>
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{% macro reports_table(reports, nodename, condensed=False, hash_truncate=False, show_conf_col=True, show_agent_col=True, show_host_col=True) -%}
|
|
||||||
|
|
||||||
|
{% macro reports_table(reports, nodename, reports_count, condensed=False, hash_truncate=False, show_conf_col=True, show_agent_col=True, show_host_col=True) -%}
|
||||||
<div class="ui info message">
|
<div class="ui info message">
|
||||||
Only showing the last ten reports.
|
|
||||||
|
Only showing the last {{reports_count}} reports.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<table class='ui table basic {% if condensed %}compact{% endif %}'>
|
<table class='ui table basic {% if condensed %}compact{% endif %}'>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<h1>Reports</h1>
|
<h1>Reports</h1>
|
||||||
{{ macros.reports_table(reports, node.name, condensed=True, hash_truncate=True, show_conf_col=False, show_agent_col=False, show_host_col=False)}}
|
{{ macros.reports_table(reports, node.name, reports_count, condensed=True, hash_truncate=True, show_conf_col=False, show_agent_col=False, show_host_col=False)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='column'>
|
<div class='column'>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{% extends 'layout.html' %}
|
{% extends 'layout.html' %}
|
||||||
{% import '_macros.html' as macros %}
|
{% import '_macros.html' as macros %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ macros.reports_table(reports, nodename, condensed=False, hash_truncate=False, show_conf_col=True, show_agent_col=True, show_host_col=True)}}
|
{{ macros.reports_table(reports, nodename, reports_count, condensed=False, hash_truncate=False, show_conf_col=True, show_agent_col=True, show_host_col=True)}}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|||||||
@@ -28,17 +28,16 @@ def get_or_abort(func, *args, **kwargs):
|
|||||||
abort(204)
|
abort(204)
|
||||||
|
|
||||||
|
|
||||||
def ten_reports(reports):
|
def limit_reports(reports, limit):
|
||||||
"""Helper to yield the first then reports from the reports generator.
|
"""Helper to yield a number of from the reports generator.
|
||||||
|
|
||||||
This is an ugly solution at best...
|
This is an ugly solution at best...
|
||||||
"""
|
"""
|
||||||
for count, report in enumerate(reports):
|
for count, report in enumerate(reports):
|
||||||
if count == 10:
|
if count == limit:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
yield report
|
yield report
|
||||||
|
|
||||||
|
|
||||||
def yield_or_stop(generator):
|
def yield_or_stop(generator):
|
||||||
"""Similar in intent to get_or_abort this helper will iterate over our
|
"""Similar in intent to get_or_abort this helper will iterate over our
|
||||||
generators and handle certain errors.
|
generators and handle certain errors.
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 389 KiB After Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 179 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 367 KiB After Width: | Height: | Size: 318 KiB |
|
Before Width: | Height: | Size: 280 KiB After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 329 KiB |
|
Before Width: | Height: | Size: 244 KiB After Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 204 KiB |
|
Before Width: | Height: | Size: 170 KiB |