Browse Source

Add Check

pull/7/head
Pēteris Caune 10 years ago
parent
commit
d85ef38cc0
8 changed files with 72 additions and 6 deletions
  1. +1
    -1
      hc/api/views.py
  2. +3
    -2
      hc/front/urls.py
  3. +10
    -1
      hc/front/views.py
  4. +7
    -0
      static/js/bootstrap.min.js
  5. +3
    -0
      static/js/checks.js
  6. +4
    -0
      static/js/jquery-2.1.4.min.js
  7. +4
    -0
      templates/base.html
  8. +40
    -2
      templates/front/index.html

+ 1
- 1
hc/api/views.py View File

@ -16,4 +16,4 @@ def ping(request, code):
check.save()
return HttpResponse()
return HttpResponse("OK")

+ 3
- 2
hc/front/urls.py View File

@ -3,6 +3,7 @@ from django.conf.urls import url
from hc.front import views
urlpatterns = [
url(r'^$', views.index, name="hc-index"),
url(r'^checks/$', views.checks, name="hc-checks"),
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"),
]

+ 10
- 1
hc/front/views.py View File

@ -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
- 0
static/js/bootstrap.min.js
File diff suppressed because it is too large
View File


+ 3
- 0
static/js/checks.js View File

@ -0,0 +1,3 @@
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});

+ 4
- 0
static/js/jquery-2.1.4.min.js
File diff suppressed because it is too large
View File


+ 4
- 0
templates/base.html View File

@ -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>

+ 40
- 2
templates/front/index.html View File

@ -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">&nbsp;</span>
{% endif %}
{% if check.status == "down" %}
<span
data-toggle="tooltip"
data-placement="right"
title="This check is DOWN"
class="label label-danger">&nbsp;</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">&nbsp;</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…
Cancel
Save