Merge pull request #26 from lsjostro/list-nodes-with-failure
make failed/success event counts clickable
This commit is contained in:
@@ -10,6 +10,7 @@ from datetime import datetime, timedelta
|
|||||||
from flask import (
|
from flask import (
|
||||||
Flask, render_template, abort, url_for,
|
Flask, render_template, abort, url_for,
|
||||||
Response, stream_with_context, redirect,
|
Response, stream_with_context, redirect,
|
||||||
|
request
|
||||||
)
|
)
|
||||||
|
|
||||||
from pypuppetdb import connect
|
from pypuppetdb import connect
|
||||||
@@ -147,6 +148,7 @@ def nodes():
|
|||||||
works. Once pagination is in place we can change this but we'll need to
|
works. Once pagination is in place we can change this but we'll need to
|
||||||
provide a search feature instead.
|
provide a search feature instead.
|
||||||
"""
|
"""
|
||||||
|
status_arg = request.args.get('status', '')
|
||||||
latest_events = puppetdb._query(
|
latest_events = puppetdb._query(
|
||||||
'event-counts',
|
'event-counts',
|
||||||
query='["=", "latest-report?", true]',
|
query='["=", "latest-report?", true]',
|
||||||
@@ -161,7 +163,11 @@ def nodes():
|
|||||||
if status:
|
if status:
|
||||||
node.status = status[0]
|
node.status = status[0]
|
||||||
else:
|
else:
|
||||||
node.status = None
|
node.status = {}
|
||||||
|
if status_arg:
|
||||||
|
if node.status.has_key(status_arg) and node.status[status_arg]:
|
||||||
|
nodes.append(node)
|
||||||
|
else:
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
|
|
||||||
return Response(stream_with_context(
|
return Response(stream_with_context(
|
||||||
|
|||||||
@@ -4,11 +4,15 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="span4 stat">
|
<div class="span4 stat">
|
||||||
|
<a href="nodes?status=failures">
|
||||||
<h1 class="error">{{latest_event_count['failures']}} <small>node(s)</small></h1>
|
<h1 class="error">{{latest_event_count['failures']}} <small>node(s)</small></h1>
|
||||||
|
</a>
|
||||||
<span>with failures in latest reports</span>
|
<span>with failures in latest reports</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4 stat">
|
<div class="span4 stat">
|
||||||
|
<a href="nodes?status=successes">
|
||||||
<h1 class="success">{{latest_event_count['successes']}} <small>node(s)</small></h1>
|
<h1 class="success">{{latest_event_count['successes']}} <small>node(s)</small></h1>
|
||||||
|
</a>
|
||||||
<span>with successes in latest reports</span>
|
<span>with successes in latest reports</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4 stat">
|
<div class="span4 stat">
|
||||||
|
|||||||
Reference in New Issue
Block a user