Browse Source

Can remove checks from "My Checks" page.

pull/7/head
Pēteris Caune 9 years ago
parent
commit
29e36fc14d
5 changed files with 75 additions and 8 deletions
  1. +1
    -0
      hc/front/urls.py
  2. +13
    -0
      hc/front/views.py
  3. +8
    -8
      static/css/style.css
  4. +9
    -0
      static/js/checks.js
  5. +44
    -0
      templates/front/my_checks.html

+ 1
- 0
hc/front/urls.py View File

@ -8,6 +8,7 @@ urlpatterns = [
url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"),
url(r'^checks/([\w-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"),
url(r'^checks/([\w-]+)/email/$', views.email_preview),
url(r'^checks/([\w-]+)/remove/$', views.remove, name="hc-remove-check"),
url(r'^pricing/$', views.pricing, name="hc-pricing"),
url(r'^docs/$', views.docs, name="hc-docs"),
url(r'^about/$', views.about, name="hc-about"),


+ 13
- 0
hc/front/views.py View File

@ -128,3 +128,16 @@ def email_preview(request, code):
}
return render(request, "emails/alert/body.html", ctx)
@login_required
def remove(request, code):
assert request.method == "POST"
check = Check.objects.get(code=code)
if check.user != request.user:
return HttpResponseForbidden()
check.delete()
return redirect("hc-index")

+ 8
- 8
static/css/style.css View File

@ -109,10 +109,6 @@ table.table tr > th.th-name {
padding-left: 21px;
}
.setup-link {
opacity: 0;
}
#checks-table .indicator-cell {
text-align: center;
}
@ -125,10 +121,6 @@ table.table tr > th.th-name {
vertical-align: middle;
}
.checks-row:hover .setup-link {
opacity: 1;
}
.name-edit.inactive .input-name {
border: 1px solid rgba(0, 0, 0, 0);
background: none;
@ -175,3 +167,11 @@ td.inactive .popover {
color: #337ab7;
border: 1px dotted #AAA;
}
.check-menu {
visibility: hidden;
}
tr:hover .check-menu {
visibility: visible;
}

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

@ -38,5 +38,14 @@ $(function () {
return false;
});
$(".check-menu-remove").click(function() {
var $this = $(this);
$("#remove-check-form").attr("action", $this.data("url"));
$(".remove-check-name").text($this.data("name"));
$('#remove-check-modal').modal("show");
return false;
});
});

+ 44
- 0
templates/front/my_checks.html View File

@ -16,6 +16,7 @@
<th>URL</th>
<th>Frequency</th>
<th>Last Ping</th>
<th></th>
</tr>
{% for check in checks %}
<tr class="checks-row">
@ -98,6 +99,23 @@
Never
{% endif %}
</td>
<td>
<div class="check-menu dropdown">
<button class="btn btn-sm btn-default dropdown-toggle" type="button" data-toggle="dropdown">
<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="#" class="check-menu-remove"
data-name="{{ check.name|default:check.code }}"
data-url="{% url 'hc-remove-check' check.code %}">
<span class="glyphicon glyphicon-trash"></span>
Remove
</a>
</li>
</ul>
</div>
</td>
</tr>
{% endfor %}
@ -117,6 +135,32 @@
</div>
<div id="remove-check-modal" class="modal fade">
<div class="modal-dialog">
<form id="remove-check-form" method="post">
{% csrf_token %}
<input type="hidden" name="code" class="remove-check-code" />
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</span></button>
<h4 class="remove-check-title">Remove Check <span class="remove-check-name"></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>
{% endblock %}


Loading…
Cancel
Save