diff --git a/hc/front/urls.py b/hc/front/urls.py index eeca64ff..56c4c030 100644 --- a/hc/front/urls.py +++ b/hc/front/urls.py @@ -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"), diff --git a/hc/front/views.py b/hc/front/views.py index 1e7b0916..7563e2c7 100644 --- a/hc/front/views.py +++ b/hc/front/views.py @@ -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") diff --git a/static/css/style.css b/static/css/style.css index 4485af95..1f1bc7f2 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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; +} \ No newline at end of file diff --git a/static/js/checks.js b/static/js/checks.js index eca84fe1..32181dd7 100644 --- a/static/js/checks.js +++ b/static/js/checks.js @@ -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; + }); }); \ No newline at end of file diff --git a/templates/front/my_checks.html b/templates/front/my_checks.html index 19c54272..15aafa2c 100644 --- a/templates/front/my_checks.html +++ b/templates/front/my_checks.html @@ -16,6 +16,7 @@