forked from GithubBackups/healthchecks
Add Check
This commit is contained in:
parent
aad4bd2ffb
commit
d85ef38cc0
@ -16,4 +16,4 @@ def ping(request, code):
|
||||
|
||||
check.save()
|
||||
|
||||
return HttpResponse()
|
||||
return HttpResponse("OK")
|
||||
|
@ -5,4 +5,5 @@ from hc.front import views
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name="hc-index"),
|
||||
url(r'^checks/$', views.checks, name="hc-checks"),
|
||||
url(r'^checks/add/$', views.add_check, name="hc-add-check"),
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from hc.api.models import Check
|
||||
|
||||
@ -18,3 +18,12 @@ def checks(request):
|
||||
}
|
||||
|
||||
return render(request, "front/index.html", ctx)
|
||||
|
||||
|
||||
@login_required
|
||||
def add_check(request):
|
||||
assert request.method == "POST"
|
||||
|
||||
check = Check(user=request.user)
|
||||
check.save()
|
||||
return redirect("hc-checks")
|
||||
|
7
static/js/bootstrap.min.js
vendored
Normal file
7
static/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
static/js/checks.js
Normal file
3
static/js/checks.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
});
|
4
static/js/jquery-2.1.4.min.js
vendored
Normal file
4
static/js/jquery-2.1.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -12,5 +12,9 @@
|
||||
<div class="container">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
|
||||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
<script src="{% static 'js/checks.js' %}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -6,18 +6,56 @@
|
||||
<h1>Hello {{ request.user.email }}</h1>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Name</th>
|
||||
<th>Code</th>
|
||||
<th>Frequency</th>
|
||||
<th>Last Ping</th>
|
||||
</tr>
|
||||
{% for check in checks %}
|
||||
<tr>
|
||||
<td>{{ check.code }}</td>
|
||||
<td>
|
||||
{% if check.status == "up" %}
|
||||
<span
|
||||
data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="This check is UP"
|
||||
class="label label-success"> </span>
|
||||
{% endif %}
|
||||
|
||||
{% if check.status == "down" %}
|
||||
<span
|
||||
data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="This check is DOWN"
|
||||
class="label label-danger"> </span>
|
||||
{% endif %}
|
||||
|
||||
{% if check.status == "new" %}
|
||||
<span
|
||||
data-toggle="tooltip"
|
||||
data-placement="right"
|
||||
title="This check has not yet been triggered"
|
||||
class="label label-warning"> </span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td></td>
|
||||
<td><code>{{ check.code }}</code></td>
|
||||
<td>{{ check.timeout }}</td>
|
||||
<td>{{ check.last_ping }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-4 center-block"></div>
|
||||
<form method="post" action="{% url 'hc-add-check' %}">
|
||||
{% csrf_token %}
|
||||
<input type="submit" class="btn btn-primary btn-lg" value="Add Check">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user