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