Skip to content

Commit

Permalink
[feature #141392693] New dashboard tab for failed jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
wanjikum committed Apr 12, 2017
1 parent d1c5d77 commit d57e938
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 126 deletions.
28 changes: 6 additions & 22 deletions hc/front/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,21 @@ def docs(request):


def reports(request):
check = _welcome_check(request)
q = Check.objects.filter(user=request.team.user).order_by("created")
checks = list(q)

counter = Counter()
down_tags, grace_tags = set(), set()
checks = Check.objects.filter(user=request.team.user).order_by("created")
failed_checks = []
for check in checks:
status = check.get_status()
for tag in check.tags_list():
if tag == "":
continue

counter[tag] += 1

if status == "down":
down_tags.add(tag)
elif check.in_grace_period():
grace_tags.add(tag)
if check.get_status() == "down" and check.n_pings:
failed_checks.append(check)
ctx = {
"page": "reports",
"check": check,
"checks": failed_checks,
"now": timezone.now(),
"tags": counter.most_common(),
"down_tags": down_tags,
"grace_tags": grace_tags,
"ping_endpoint": settings.PING_ENDPOINT
}


return render(request, "front/reports.html", ctx)


def docs_api(request):
ctx = {
"page": "docs",
Expand Down
120 changes: 16 additions & 104 deletions templates/front/reports.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@


<div class="row">
<h2>This is a header in reports</h2>
<div class="col-sm-12">
<h1>
{% if request.team == request.user.profile %}
My Checks
Failed Jobs
{% else %}
{{ request.team.team_name }}
{% endif %}
Expand All @@ -37,113 +36,26 @@ <h1>


{% if checks %}
{% include "front/my_checks_mobile.html" %}
{% include "front/my_checks_desktop.html" %}
<table id="failed-checks-table" class="table hidden-xs">
<tr>
<th class="th-name">Name</th>
<th>Last Ping</th>
</tr>
{% for check in checks %}
<tr>
<td class="th-name">{{check.name}}</td>
<td>
{{ check.last_ping }}
</td>
</tr>
{% endfor %}
</table>
{% else %}
<div class="alert alert-info">You don't have any checks yet.</div>
<div class="alert alert-info"> You don't have failed checks yet.</div>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-sm-12">
<form method="post" action="{% url 'hc-add-check' %}" class="text-center">
{% csrf_token %}
<input type="submit" class="btn btn-primary btn-lg" value="Add Check">
</form>
</div>
</div>

<div id="update-name-modal" class="modal">
<div class="modal-dialog">
<form id="update-name-form" class="form-horizontal" method="post">
{% csrf_token %}
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="update-timeout-title">Name and Tags</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="update-name-input" class="col-sm-2 control-label">
Name
</label>
<div class="col-sm-9">
<input
id="update-name-input"
name="name"
type="text"
value="---"
placeholder="unnamed"
class="input-name form-control" />

<span class="help-block">
Give this check a human-friendly name,
so you can easily recognize it later.
</span>
</div>
</div>

<div class="form-group">
<label for="update-tags-input" class="col-sm-2 control-label">
Tags
</label>
<div class="col-sm-9">
<input
id="update-tags-input"
name="tags"
type="text"
value=""
placeholder="production www"
class="form-control" />

<span class="help-block">
Optionally, assign tags for easy filtering.
Separate multiple tags with spaces.
</span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
</form>
</div>
</div>



<div id="remove-check-modal" class="modal">
<div class="modal-dialog">
<form id="remove-check-form" method="post">
{% csrf_token %}
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="remove-check-title">Remove Check <span class="remove-check-name"></span></h4>
</div>
<div class="modal-body">
<p>You are about to remove check
<strong class="remove-check-name">---</strong>.
</p>
<p>Once it's gone there is no "undo" and you cannot get
the old ping URL back.</p>
<p>Are you sure?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-danger">Remove</button>
</div>
</div>
</form>
</div>
</div>


<form id="pause-form" method="post">
{% csrf_token %}
</form>

{% endblock %}

Expand Down

0 comments on commit d57e938

Please sign in to comment.