diff --git a/puppetboard/app.py b/puppetboard/app.py index b1efd51..7dab122 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -250,6 +250,12 @@ def fact(fact): name=fact, facts=localfacts))) +@app.route('/fact//') +def fact_value(fact, value): + """On asking for fact/value get all nodes with that fact.""" + facts = get_or_abort(puppetdb.facts, fact, value) + localfacts = [f for f in yield_or_stop(facts)] + return render_template('fact.html', name=fact, value=value, facts=localfacts) @app.route('/query', methods=('GET', 'POST')) def query(): diff --git a/puppetboard/templates/_macros.html b/puppetboard/templates/_macros.html index 86b4f53..814881c 100644 --- a/puppetboard/templates/_macros.html +++ b/puppetboard/templates/_macros.html @@ -1,4 +1,4 @@ -{% macro facts_table(facts, autofocus=False, condensed=False, show_node=False, margin_top=20, margin_bottom=20) -%} +{% macro facts_table(facts, autofocus=False, condensed=False, show_node=False, show_value=True, link_facts=False, margin_top=20, margin_bottom=20) -%}
@@ -10,7 +10,9 @@ {% else %} Fact {% endif %} + {% if show_value %} Value + {% endif %} @@ -21,7 +23,15 @@ {% else %} {{fact.name}} {% endif %} - {{fact.value}} + {% if show_value %} + + {% if link_facts %} + {{fact.value}} + {% else %} + {{fact.value}} + {% endif %} + + {% endif %} {% endfor %} diff --git a/puppetboard/templates/fact.html b/puppetboard/templates/fact.html index e2d3ded..0617065 100644 --- a/puppetboard/templates/fact.html +++ b/puppetboard/templates/fact.html @@ -1,8 +1,12 @@ {% extends 'layout.html' %} {% import '_macros.html' as macros %} {% block content %} -

{{name}}

+

{{name}}{% if value %}/{{value}}{% endif %}

{{macros.facts_graph(facts, autofocus=True, show_node=True, margin_bottom=10)}} {{macros.facts_graph_value(facts, autofocus=True, show_node=True, margin_bottom=10)}} -{{macros.facts_table(facts, autofocus=True, show_node=True, margin_bottom=10)}} +{% if value %} +{{macros.facts_table(facts, autofocus=True, show_node=True, show_value=False, margin_bottom=10)}} +{% else %} +{{macros.facts_table(facts, autofocus=True, show_node=True, link_facts=True, margin_bottom=10)}} +{% endif %} {% endblock content %} diff --git a/puppetboard/templates/node.html b/puppetboard/templates/node.html index 6b817af..ac93247 100644 --- a/puppetboard/templates/node.html +++ b/puppetboard/templates/node.html @@ -27,7 +27,7 @@

Facts

- {{macros.facts_table(facts, condensed=True, margin_top=10)}} + {{macros.facts_table(facts, link_facts=True, condensed=True, margin_top=10)}}

Reports