Skip to content

Commit

Permalink
Merge 7af74a4 into 5f0d5ad
Browse files Browse the repository at this point in the history
  • Loading branch information
murageden committed May 3, 2018
2 parents 5f0d5ad + 7af74a4 commit 89f20f4
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 0 deletions.
1 change: 1 addition & 0 deletions hc/front/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
urlpatterns = [
url(r'^$', views.index, name="hc-index"),
url(r'^checks/$', views.my_checks, name="hc-checks"),
url(r'^checks/unresolved$', views.my_unresolved_checks, name="hc-unresolved"),
url(r'^checks/add/$', views.add_check, name="hc-add-check"),
url(r'^checks/([\w-]+)/', include(check_urls)),
url(r'^integrations/', include(channel_urls)),
Expand Down
27 changes: 27 additions & 0 deletions hc/front/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ def my_checks(request):

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

@login_required
def my_unresolved_checks(request):
q = Check.objects.filter(user=request.team.user).order_by("created")
all_checks = list(q)

counter = Counter()
down_tags = set()
checks = [ch for ch in all_checks if ch.get_status() == "down"]

for check in checks:
for tag in check.tags_list():
if tag == "":
continue
counter[tag] += 1
down_tags.add(tag)

ctx = {
"page": "checks/unresolved",
"checks": checks,
"now": timezone.now(),
"tags": counter.most_common(),
"down_tags": down_tags,
"ping_endpoint": settings.PING_ENDPOINT
}

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


def _welcome_check(request):
check = None
Expand Down
4 changes: 4 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
<a href="{% url 'hc-checks' %}">Checks</a>
</li>

<li {% if page == 'checks/unresolved' %} class="active" {% endif %}>
<a href="{% url 'hc-unresolved' %}">Unresolved Checks</a>
</li>

<li {% if page == 'channels' %} class="active" {% endif %}>
<a href="{% url 'hc-channels' %}">Integrations</a>
</li>
Expand Down
283 changes: 283 additions & 0 deletions templates/front/my_unresolved_checks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
{% extends "base.html" %}
{% load compress staticfiles %}

{% block title %}My Unresolved Checks - healthchecks.io{% endblock %}


{% block content %}
<div class="row">
<div class="col-sm-12">
<h1>
{% if request.team == request.user.profile %}
Unresolved Checks
{% else %}
{{ request.team.team_name }}
{% endif %}
</h1>
</div>
{% if tags %}
<div id="my-checks-tags" class="col-sm-12">
{% for tag, count in tags %}
{% if tag in down_tags %}
<button class="btn btn-danger btn-xs" data-toggle="button">{{ tag }}</button>
{% elif tag in grace_tags %}
<button class="btn btn-warning btn-xs" data-toggle="button">{{ tag }}</button>
{% else %}
<button class="btn btn-default btn-xs" data-toggle="button">{{ tag }}</button>
{% endif %}
{% endfor %}
</div>
{% endif %}

</div>
<div class="row">
<div class="col-sm-12">


{% if checks %}
{% include "front/my_checks_mobile.html" %}
{% include "front/my_checks_desktop.html" %}
{% else %}
<div class="alert alert-info">You don't have any unresolved checks yet.</div>
{% endif %}
</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="update-timeout-modal" class="modal">
<div class="modal-dialog">
<form id="update-timeout-form" method="post">
{% csrf_token %}
<input type="hidden" name="timeout" id="update-timeout-timeout" />
<input type="hidden" name="grace" id="update-timeout-grace" />
<div class="modal-content">
<div class="modal-body">
<div class="update-timeout-info text-center">
<span
class="update-timeout-label"
data-toggle="tooltip"
title="Expected time between pings.">
Period
</span>
<span
id="period-slider-value"
class="update-timeout-value">
1 day
</span>
</div>
<div id="period-slider"></div>

<div class="update-timeout-info text-center">
<span
class="update-timeout-label"
data-toggle="tooltip"
title="When check is late, how much time to wait until alert is sent">
Grace Time
</span>
<span
id="grace-slider-value"
class="update-timeout-value">
1 day
</span>
</div>

<div id="grace-slider"></div>

<div class="update-timeout-terms">
<p>
<span>Period</span>
Expected time between pings.
</p>
<p>
<span>Grace Time</span>
When a check is late, how much time to wait until alert is sent.
</p>
</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>

<div id="show-usage-modal" class="modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<ul class="nav nav-pills" role="tablist">
<li class="active">
<a href="#crontab" data-toggle="tab">Crontab</a>
</li>
<li>
<a href="#bash" data-toggle="tab">Bash</a>
</li>
<li>
<a href="#python" data-toggle="tab">Python</a>
</li>
<li class="hidden-xs">
<a href="#node" data-toggle="tab">Node.js</a>
</li>
<li class="hidden-xs">
<a href="#php" data-toggle="tab">PHP</a>
</li>
<li class="hidden-xs">
<a href="#browser" data-toggle="tab">Browser</a>
</li>
<li class="hidden-xs">
<a href="#powershell" data-toggle="tab">PowerShell</a>
</li>
<li class="hidden-xs">
<a href="#email" data-toggle="tab">Email</a>
</li>
</ul>

</div>
<div class="modal-body">


<div class="tab-content">
{% with ping_url="<span class='ex'></span>" %}
<div role="tabpanel" class="tab-pane active" id="crontab">
{% include "front/snippets/crontab.html" %}
</div>
<div role="tabpanel" class="tab-pane" id="bash">
{% include "front/snippets/bash.html" %}
</div>
<div role="tabpanel" class="tab-pane" id="python">
{% include "front/snippets/python.html" %}
</div>
<div role="tabpanel" class="tab-pane" id="node">
{% include "front/snippets/node.html" %}
</div>
<div role="tabpanel" class="tab-pane" id="php">
{% include "front/snippets/php.html" %}
</div>
<div class="tab-pane" id="browser">
{% include "front/snippets/browser.html" %}
</div>
<div class="tab-pane" id="powershell">
{% include "front/snippets/powershell.html" %}
</div>
<div class="tab-pane" id="email">
As an alternative to HTTP/HTTPS requests,
you can "ping" this check by sending an
email message to
<div class="email-address">
<code class="em"></code>
</div>
</div>
{% endwith %}
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Got It!</button>
</div>
</div>
</div>
</div>

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

{% endblock %}

{% block scripts %}
{% compress js %}
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/nouislider.min.js' %}"></script>
<script src="{% static 'js/clipboard.min.js' %}"></script>
<script src="{% static 'js/checks.js' %}"></script>
{% endcompress %}
{% endblock %}

0 comments on commit 89f20f4

Please sign in to comment.