forked from GithubBackups/healthchecks
Style tweaks for PushOver integration
This commit is contained in:
parent
404744f235
commit
3ba47b1a67
@ -26,6 +26,14 @@ CHANNEL_KINDS = (("email", "Email"), ("webhook", "Webhook"),
|
||||
("hipchat", "HipChat"),
|
||||
("slack", "Slack"), ("pd", "PagerDuty"), ("po", "Pushover"))
|
||||
|
||||
PO_PRIORITIES = {
|
||||
-2: "lowest",
|
||||
-1: "low",
|
||||
0: "normal",
|
||||
1: "high",
|
||||
2: "emergency"
|
||||
}
|
||||
|
||||
|
||||
class Check(models.Model):
|
||||
|
||||
@ -195,7 +203,7 @@ class Channel(models.Model):
|
||||
else:
|
||||
title = "%s is now UP" % check.name_then_code()
|
||||
|
||||
user_key, priority = self.po_value
|
||||
user_key, priority, _ = self.po_value
|
||||
payload = {
|
||||
"token": settings.PUSHOVER_API_TOKEN,
|
||||
"user": user_key,
|
||||
@ -219,7 +227,7 @@ class Channel(models.Model):
|
||||
assert self.kind == "po"
|
||||
user_key, prio = self.value.split("|")
|
||||
prio = int(prio)
|
||||
return user_key, prio
|
||||
return user_key, prio, PO_PRIORITIES[prio]
|
||||
|
||||
|
||||
class Notification(models.Model):
|
||||
|
@ -358,11 +358,8 @@ def add_pushover(request):
|
||||
|
||||
if request.GET.get("pushover_unsubscribed", "0") == "1":
|
||||
# Unsubscription: delete all Pushover channels for this user
|
||||
for channel in Channel.objects.filter(user=request.user, kind="po"):
|
||||
channel.delete()
|
||||
|
||||
Channel.objects.filter(user=request.user, kind="po").delete()
|
||||
return redirect("hc-channels")
|
||||
|
||||
else:
|
||||
# Subscription
|
||||
user_key = request.GET["pushover_user_key"]
|
||||
@ -373,10 +370,10 @@ def add_pushover(request):
|
||||
"value": "%s|%d" % (user_key, priority),
|
||||
})
|
||||
|
||||
else:
|
||||
ctx = {
|
||||
"page": "channels",
|
||||
"po_retry_delay": td(seconds=settings.PUSHOVER_EMERGENCY_RETRY_DELAY),
|
||||
"po_expiration": td(seconds=settings.PUSHOVER_EMERGENCY_EXPIRATION),
|
||||
}
|
||||
return render(request, "integrations/add_pushover.html", ctx)
|
||||
# Integration Settings form
|
||||
ctx = {
|
||||
"page": "channels",
|
||||
"po_retry_delay": td(seconds=settings.PUSHOVER_EMERGENCY_RETRY_DELAY),
|
||||
"po_expiration": td(seconds=settings.PUSHOVER_EMERGENCY_EXPIRATION),
|
||||
}
|
||||
return render(request, "integrations/add_pushover.html", ctx)
|
||||
|
8
static/css/add_pushover.css
Normal file
8
static/css/add_pushover.css
Normal file
@ -0,0 +1,8 @@
|
||||
#add-pushover .radio {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
#add-pushover .help {
|
||||
display: block;
|
||||
color: #888;
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
<link rel="stylesheet" href="{% static 'css/channels.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/channel_checks.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/log.css' %}" type="text/css">
|
||||
<link rel="stylesheet" href="{% static 'css/add_pushover.css' %}" type="text/css">
|
||||
{% endcompress %}
|
||||
</head>
|
||||
<body class="page-{{ page }}">
|
||||
|
@ -29,11 +29,12 @@
|
||||
<span class="preposition">
|
||||
{% if ch.kind == "email" %} to {% endif %}
|
||||
{% if ch.kind == "pd" %} API key {% endif %}
|
||||
{% if ch.kind == "po" %} User key / priority {% endif %}
|
||||
{% if ch.kind == "po" %} user key {% endif %}
|
||||
</span>
|
||||
|
||||
{% if ch.kind == "po" %}
|
||||
{{ ch.po_value|join:" / " }}
|
||||
{{ ch.po_value|first }}
|
||||
({{ ch.po_value|last }} priority)
|
||||
{% else %}
|
||||
{{ ch.value }}
|
||||
{% endif %}
|
||||
|
@ -16,25 +16,61 @@
|
||||
|
||||
<h2>Integration Settings</h2>
|
||||
|
||||
<form method="post" class="form-horizontal" action="{% url 'hc-add-pushover' %}">
|
||||
<form method="post" id="add-pushover" class="form-horizontal" action="{% url 'hc-add-pushover' %}">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label for="po_priority" class="col-sm-2 control-label">Notification priority</label>
|
||||
<div class="col-sm-3">
|
||||
<select class="form-control" id="po_priority" name="po_priority">
|
||||
<option value="-2">Lowest</option>
|
||||
<option value="-1">Low</option>
|
||||
<option value="0" selected>Normal</option>
|
||||
<option value="1">High</option>
|
||||
<option value="2"
|
||||
data-toggle="tooltip" data-placement="right"
|
||||
title="Emergency notifications will be repeated every
|
||||
{{po_retry_delay|hc_duration }} for at most
|
||||
{{ po_expiration|hc_duration }} until you
|
||||
acknowledge them.">
|
||||
Emergency
|
||||
</option>
|
||||
</select>
|
||||
<div class="col-sm-6">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="po_priority" value="-2">
|
||||
Lowest Priority.
|
||||
<span class="help">
|
||||
Generates no notification/alert on your device.
|
||||
On iOS, the application badge number will be increased.
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="po_priority" value="-1">
|
||||
Low Priority.
|
||||
<span class="help">
|
||||
Sends a quiet notification.
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="po_priority" value="0" checked>
|
||||
Normal Priority.
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="po_priority" value="1">
|
||||
<span class="text-warning">High Priority.</span>
|
||||
<span class="help">
|
||||
Bypasses user's quiet hours.
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="po_priority" value="-2">
|
||||
<span class="text-danger">Emergency Priority.</span>
|
||||
<span class="help">
|
||||
The notification is repeated every
|
||||
{{po_retry_delay|hc_duration }} for at most
|
||||
{{ po_expiration|hc_duration }} until you
|
||||
acknowledge them.
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -55,7 +91,4 @@
|
||||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
{% endcompress %}
|
||||
<script>$(function() {
|
||||
$('[data-toggle="tooltip"]').tooltip({container: 'body'});
|
||||
})</script>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user