forked from GithubBackups/healthchecks
Can remove channels
This commit is contained in:
parent
ab58e76ca2
commit
058101b941
@ -8,7 +8,7 @@ urlpatterns = [
|
|||||||
url(r'^checks/([\w-]+)/name/$', views.update_name, name="hc-update-name"),
|
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-]+)/timeout/$', views.update_timeout, name="hc-update-timeout"),
|
||||||
url(r'^checks/([\w-]+)/email/$', views.email_preview),
|
url(r'^checks/([\w-]+)/email/$', views.email_preview),
|
||||||
url(r'^checks/([\w-]+)/remove/$', views.remove, name="hc-remove-check"),
|
url(r'^checks/([\w-]+)/remove/$', views.remove_check, name="hc-remove-check"),
|
||||||
url(r'^checks/([\w-]+)/log/$', views.log, name="hc-log"),
|
url(r'^checks/([\w-]+)/log/$', views.log, name="hc-log"),
|
||||||
url(r'^pricing/$', views.pricing, name="hc-pricing"),
|
url(r'^pricing/$', views.pricing, name="hc-pricing"),
|
||||||
url(r'^docs/$', views.docs, name="hc-docs"),
|
url(r'^docs/$', views.docs, name="hc-docs"),
|
||||||
@ -16,6 +16,7 @@ urlpatterns = [
|
|||||||
url(r'^channels/$', views.channels, name="hc-channels"),
|
url(r'^channels/$', views.channels, name="hc-channels"),
|
||||||
url(r'^channels/add/$', views.add_channel, name="hc-add-channel"),
|
url(r'^channels/add/$', views.add_channel, name="hc-add-channel"),
|
||||||
url(r'^channels/([\w-]+)/checks/$', views.channel_checks, name="hc-channel-checks"),
|
url(r'^channels/([\w-]+)/checks/$', views.channel_checks, name="hc-channel-checks"),
|
||||||
|
url(r'^channels/([\w-]+)/remove/$', views.remove_channel, name="hc-remove-channel"),
|
||||||
url(r'^channels/([\w-]+)/verify/([\w-]+)/$',
|
url(r'^channels/([\w-]+)/verify/([\w-]+)/$',
|
||||||
views.verify_email, name="hc-verify-email"),
|
views.verify_email, name="hc-verify-email"),
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ def email_preview(request, code):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@uuid_or_400
|
@uuid_or_400
|
||||||
def remove(request, code):
|
def remove_check(request, code):
|
||||||
assert request.method == "POST"
|
assert request.method == "POST"
|
||||||
|
|
||||||
check = Check.objects.get(code=code)
|
check = Check.objects.get(code=code)
|
||||||
@ -251,3 +251,17 @@ def verify_email(request, code, token):
|
|||||||
return render(request, "front/verify_email_success.html")
|
return render(request, "front/verify_email_success.html")
|
||||||
|
|
||||||
return render(request, "bad_link.html")
|
return render(request, "bad_link.html")
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@uuid_or_400
|
||||||
|
def remove_channel(request, code):
|
||||||
|
assert request.method == "POST"
|
||||||
|
|
||||||
|
channel = Channel.objects.get(code=code)
|
||||||
|
if channel.user != request.user:
|
||||||
|
return HttpResponseForbidden()
|
||||||
|
|
||||||
|
channel.delete()
|
||||||
|
|
||||||
|
return redirect("hc-channels")
|
||||||
|
@ -67,3 +67,11 @@ table.channels-table > tbody > tr > th {
|
|||||||
.channel-row:hover .edit-checks {
|
.channel-row:hover .edit-checks {
|
||||||
border: 1px dotted #AAA;
|
border: 1px dotted #AAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-remove {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.channel-row:hover .channel-remove {
|
||||||
|
visibility: visible;
|
||||||
|
}
|
@ -26,7 +26,6 @@ $(function() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var $cm = $("#checks-modal");
|
var $cm = $("#checks-modal");
|
||||||
$cm.on("click", "#toggle-all", function() {
|
$cm.on("click", "#toggle-all", function() {
|
||||||
var value = $(this).prop("checked");
|
var value = $(this).prop("checked");
|
||||||
@ -35,4 +34,15 @@ $(function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".channel-remove").click(function() {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
$("#remove-channel-form").attr("action", $this.data("url"));
|
||||||
|
$(".remove-channel-name").text($this.data("name"));
|
||||||
|
$('#remove-channel-modal').modal("show");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
@ -9,6 +9,7 @@
|
|||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<h1>Notification Channels</h1>
|
<h1>Notification Channels</h1>
|
||||||
<table class="table channels-table">
|
<table class="table channels-table">
|
||||||
|
{% if channels %}
|
||||||
<tr>
|
<tr>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Value</th>
|
<th>Value</th>
|
||||||
@ -41,11 +42,21 @@
|
|||||||
{{ ch.checks.count }} of {{ num_checks }}
|
{{ ch.checks.count }} of {{ num_checks }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<button
|
||||||
|
data-name="{{ ch.value }}"
|
||||||
|
data-url="{% url 'hc-remove-channel' ch.code %}"
|
||||||
|
class="btn btn-sm btn-default channel-remove"
|
||||||
|
type="button">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" class="channels-add-title">
|
<th colspan="2" class="channels-add-title">
|
||||||
Add Notification Channel
|
Add Notification Channel
|
||||||
@ -71,7 +82,6 @@
|
|||||||
<button type="submit" class="btn btn-success">Add</button>
|
<button type="submit" class="btn btn-success">Add</button>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</form>
|
</form>
|
||||||
</tr>
|
</tr>
|
||||||
@ -109,6 +119,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="remove-channel-modal" class="modal">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<form id="remove-channel-form" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</span></button>
|
||||||
|
<h4 class="remove-check-title">Remove Channel <span class="remove-channel-name"></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>You are about to remove channel
|
||||||
|
<strong class="remove-channel-name">---</strong>.
|
||||||
|
</p>
|
||||||
|
<p>Once it's gone it's gone. But, if you change your
|
||||||
|
mind later, you can create a similar channel again.</p>
|
||||||
|
<p>Do you want to continue?</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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
<li role="separator" class="divider"></li>
|
<li role="separator" class="divider"></li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="check-menu-remove"
|
<a href="#" class="check-menu-remove"
|
||||||
data-name="{{ check.name|default:check.code }}"
|
data-name="{{ check.name_then_code }}"
|
||||||
data-url="{% url 'hc-remove-check' check.code %}">
|
data-url="{% url 'hc-remove-check' check.code %}">
|
||||||
<span class="glyphicon glyphicon-trash"></span>
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
Remove
|
Remove
|
||||||
|
Loading…
x
Reference in New Issue
Block a user