Skip to content

Commit

Permalink
Merge pull request midgetspy#886 from thezoggy/dev--pushover_update
Browse files Browse the repository at this point in the history
Pushover notifier update
  • Loading branch information
midgetspy committed Oct 16, 2014
2 parents e7581c3 + e1c14b2 commit 90a7622
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 59 deletions.
90 changes: 77 additions & 13 deletions data/interfaces/default/config_notifications.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,11 @@
<label class="nocheck clearfix">
<span class="component-title">Prowl Priority:</span>
<select id="prowl_priority" name="prowl_priority">
<option value="-2" #if $sickbeard.PROWL_PRIORITY == "-2" then 'selected="selected"' else ""#>Very Low</option>
<option value="-1" #if $sickbeard.PROWL_PRIORITY == "-1" then 'selected="selected"' else ""#>Moderate</option>
<option value="0" #if $sickbeard.PROWL_PRIORITY == "0" then 'selected="selected"' else ""#>Normal</option>
<option value="1" #if $sickbeard.PROWL_PRIORITY == "1" then 'selected="selected"' else ""#>High</option>
<option value="2" #if $sickbeard.PROWL_PRIORITY == "2" then 'selected="selected"' else ""#>Emergency</option>
<option value="-2" #if $sickbeard.PROWL_PRIORITY == -2 then 'selected="selected"' else ""#>Very Low</option>
<option value="-1" #if $sickbeard.PROWL_PRIORITY == -1 then 'selected="selected"' else ""#>Moderate</option>
<option value="0" #if $sickbeard.PROWL_PRIORITY == 0 then 'selected="selected"' else ""#>Normal</option>
<option value="1" #if $sickbeard.PROWL_PRIORITY == 1 then 'selected="selected"' else ""#>High</option>
<option value="2" #if $sickbeard.PROWL_PRIORITY == 2 then 'selected="selected"' else ""#>Emergency</option>
</select>
</label>
<label class="nocheck clearfix">
Expand Down Expand Up @@ -687,7 +687,72 @@
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">User key of your Pushover account</span>
<span class="component-desc">User/Group key of your Pushover account</span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">Pushover Priority:</span>
<select id="pushover_priority" name="pushover_priority">
<option value="-2" #if $sickbeard.PUSHOVER_PRIORITY == -2 then 'selected="selected"' else ""#>Lowest</option>
<option value="-1" #if $sickbeard.PUSHOVER_PRIORITY == -1 then 'selected="selected"' else ""#>Low</option>
<option value="0" #if $sickbeard.PUSHOVER_PRIORITY == 0 then 'selected="selected"' else ""#>Normal</option>
<option value="1" #if $sickbeard.PUSHOVER_PRIORITY == 1 then 'selected="selected"' else ""#>High</option>
</select>
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Priority of Pushover messages from Sick-Beard.</span>
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Overview: <a href="https://pushover.net/api#priority" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;">https://pushover.net/api#priority</a></span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">Pushover Device</span>
<input type="hidden" name="pushover_device" id="pushover_device" value="$sickbeard.PUSHOVER_DEVICE" size="35" />
<select id="pushover_device_list" name="pushover_device_list" class="float-left" style="margin-right: 5px;">
</select>
<input type="button" class="btn" value="Refresh Devices" id="getPushoverDevices" />
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Which device do you want to push to?</span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">Pushover Sound</span>
<select id="pushover_sound" name="pushover_sound">
<option value="pushover" #if $sickbeard.PUSHOVER_SOUND == "pushover" then 'selected="selected"' else ""#>Pushover (default)</option>
<option value="bike" #if $sickbeard.PUSHOVER_SOUND == "bike" then 'selected="selected"' else ""#>Bike</option>
<option value="bugle" #if $sickbeard.PUSHOVER_SOUND == "bugle" then 'selected="selected"' else ""#>Bugle</option>
<option value="cashregister" #if $sickbeard.PUSHOVER_SOUND == "cashregister" then 'selected="selected"' else ""#>Cash Register</option>
<option value="classical" #if $sickbeard.PUSHOVER_SOUND == "classical" then 'selected="selected"' else ""#>Classical</option>
<option value="cosmic" #if $sickbeard.PUSHOVER_SOUND == "cosmic" then 'selected="selected"' else ""#>Cosmic</option>
<option value="falling" #if $sickbeard.PUSHOVER_SOUND == "falling" then 'selected="selected"' else ""#>Falling</option>
<option value="gamelan" #if $sickbeard.PUSHOVER_SOUND == "gamelan" then 'selected="selected"' else ""#>Gamelan</option>
<option value="incoming" #if $sickbeard.PUSHOVER_SOUND == "incoming" then 'selected="selected"' else ""#>Incoming</option>
<option value="intermission" #if $sickbeard.PUSHOVER_SOUND == "intermission" then 'selected="selected"' else ""#>Intermission</option>
<option value="magic" #if $sickbeard.PUSHOVER_SOUND == "magic" then 'selected="selected"' else ""#>Magic</option>
<option value="mechanical" #if $sickbeard.PUSHOVER_SOUND == "mechanical" then 'selected="selected"' else ""#>Mechanical</option>
<option value="pianobar" #if $sickbeard.PUSHOVER_SOUND == "pianobar" then 'selected="selected"' else ""#>Piano Bar</option>
<option value="siren" #if $sickbeard.PUSHOVER_SOUND == "siren" then 'selected="selected"' else ""#>Siren</option>
<option value="spacealarm" #if $sickbeard.PUSHOVER_SOUND == "spacealarm" then 'selected="selected"' else ""#>Space Alarm</option>
<option value="tugboat" #if $sickbeard.PUSHOVER_SOUND == "tugboat" then 'selected="selected"' else ""#>Tug Boat</option>
<option value="alien" #if $sickbeard.PUSHOVER_SOUND == "alien" then 'selected="selected"' else ""#>Alien Alarm (long)</option>
<option value="climb" #if $sickbeard.PUSHOVER_SOUND == "climb" then 'selected="selected"' else ""#>Climb (long)</option>
<option value="persistent" #if $sickbeard.PUSHOVER_SOUND == "persistent" then 'selected="selected"' else ""#>Persistent (long)</option>
<option value="echo" #if $sickbeard.PUSHOVER_SOUND == "echo" then 'selected="selected"' else ""#>Pushover Echo (long)</option>
<option value="updown" #if $sickbeard.PUSHOVER_SOUND == "updown" then 'selected="selected"' else ""#>Up Down (long)</option>
<option value="none" #if $sickbeard.PUSHOVER_SOUND == "none" then 'selected="selected"' else ""#>None (silent)</option>
</select>
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Select one of the predefined sounds for your notifications</span>
</label>
</div>
<div class="testNotification" id="testPushover-result">Click below to test.</div>
Expand Down Expand Up @@ -824,18 +889,18 @@
</label>
<label class="nocheck clearfix">
<span class="component-title">&nbsp;</span>
<span class="component-desc">Multiple keys (maxium of 5) must be seperated by commas</span>
<span class="component-desc">Multiple keys (maxium of 5) must be separated by commas</span>
</label>
</div>
<div class="field-pair">
<label class="nocheck clearfix">
<span class="component-title">NMA priority:</span>
<select id="nma_priority" name="nma_priority">
<option value="-2" #if $sickbeard.NMA_PRIORITY == "-2" then 'selected="selected"' else ""#>Very Low</option>
<option value="-1" #if $sickbeard.NMA_PRIORITY == "-1" then 'selected="selected"' else ""#>Moderate</option>
<option value="0" #if $sickbeard.NMA_PRIORITY == "0" then 'selected="selected"' else ""#>Normal</option>
<option value="1" #if $sickbeard.NMA_PRIORITY == "1" then 'selected="selected"' else ""#>High</option>
<option value="2" #if $sickbeard.NMA_PRIORITY == "2" then 'selected="selected"' else ""#>Emergency</option>
<option value="-2" #if $sickbeard.NMA_PRIORITY == -2 then 'selected="selected"' else ""#>Very Low</option>
<option value="-1" #if $sickbeard.NMA_PRIORITY == -1 then 'selected="selected"' else ""#>Moderate</option>
<option value="0" #if $sickbeard.NMA_PRIORITY == 0 then 'selected="selected"' else ""#>Normal</option>
<option value="1" #if $sickbeard.NMA_PRIORITY == 1 then 'selected="selected"' else ""#>High</option>
<option value="2" #if $sickbeard.NMA_PRIORITY == 2 then 'selected="selected"' else ""#>Emergency</option>
</select>
</label>
<label class="nocheck clearfix">
Expand Down Expand Up @@ -967,7 +1032,6 @@
<span class="component-desc">Which device do you want to push to?</span>
</label>
</div>

<div class="testNotification" id="testPushbullet-result">Click below to test.</div>
<input type="button" class="btn" value="Test Pushbullet" id="testPushbullet" />
<input type="submit" class="btn config_submitter" value="Save Changes" />
Expand Down
76 changes: 64 additions & 12 deletions data/js/configNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,69 @@ $(document).ready(function () {

$("#testPushover").click(function () {
var pushover_userkey = $.trim($("#pushover_userkey").val());
var pushover_priority = $("#pushover_priority").val();
var pushover_device = $("#pushover_device").val();
var pushover_sound = $("#pushover_sound").val();
if (!pushover_userkey) {
$("#testPushover-result").html("Please fill out the necessary fields above.");
return;
}
$(this).prop("disabled", true);
$("#testPushover-result").html(loading);
$.get(sbRoot + "/home/testPushover", {'userKey': pushover_userkey})
$.get(sbRoot + "/home/testPushover", {'userKey': pushover_userkey, 'priority': pushover_priority, 'device': pushover_device, 'sound': pushover_sound})
.done(function (data) {
$("#testPushover-result").html(data);
$("#testPushover").prop("disabled", false);
});
});

function get_pushover_devices (msg) {
var pushover_userkey = $.trim($("#pushover_userkey").val());
if (!pushover_userkey) {
$("#testPushover-result").html("Please fill out the necessary fields above.");
return;
}
$(this).prop("disabled", true);
if (msg) {
$("#testPushover-result").html(loading);
}
var current_pushover_device = $("#pushover_device").val();
$.get(sbRoot + "/home/getPushoverDevices", {'userKey': pushover_userkey})
.done(function (data) {
var devices = jQuery.parseJSON(data || '{}').devices;
$("#pushover_device_list").html('');
// add default option to send to all devices
$("#pushover_device_list").append('<option value="all" selected="selected">-- All Devices --</option>');
if (devices) {
for (var i = 0; i < devices.length; i++) {
// if a device in the list matches our current iden, select it
if (current_pushover_device == devices[i]) {
$("#pushover_device_list").append('<option value="' + devices[i] + '" selected="selected">' + devices[i] + '</option>');
} else {
$("#pushover_device_list").append('<option value="' + devices[i] + '">' + devices[i] + '</option>');
}
}
}
$("#getPushoverDevices").prop("disabled", false);
if (msg) {
$('#testPushover-result').html(msg);
}
});

$("#pushover_device_list").change(function () {
$("#pushover_device").val($("#pushover_device_list").val());
$('#testPushover-result').html("Don't forget to save your new Pushover settings.");
});
}

$("#getPushoverDevices").click(function () {
get_pushover_devices("Device list updated. Select specific device to use.");
});

if ($("#use_pushover").prop('checked')) {
get_pushover_devices();
}

$("#testLibnotify").click(function () {
$("#testLibnotify-result").html(loading);
$.get(sbRoot + "/home/testLibnotify",
Expand Down Expand Up @@ -315,18 +365,20 @@ $(document).ready(function () {
var current_pushbullet_device = $("#pushbullet_device_iden").val();
$.get(sbRoot + "/home/getPushbulletDevices", {'accessToken': pushbullet_access_token})
.done(function (data) {
var devices = jQuery.parseJSON(data).devices;
var devices = jQuery.parseJSON(data || '{}').devices;
$("#pushbullet_device_list").html('');
// add default option to send to all devices
$("#pushbullet_device_list").append('<option value="" selected="selected">-- All Devices --</option>');
for (var i = 0; i < devices.length; i++) {
// only list active device targets
if (devices[i].active == true) {
// if a device in the list matches our current iden, select it
if (current_pushbullet_device == devices[i].iden) {
$("#pushbullet_device_list").append('<option value="' + devices[i].iden + '" selected="selected">' + devices[i].manufacturer + ' ' + devices[i].nickname + '</option>');
} else {
$("#pushbullet_device_list").append('<option value="' + devices[i].iden + '">' + devices[i].manufacturer + ' ' + devices[i].nickname + '</option>');
if (devices) {
for (var i = 0; i < devices.length; i++) {
// only list active device targets
if (devices[i].active == true) {
// if a device in the list matches our current iden, select it
if (current_pushbullet_device == devices[i].iden) {
$("#pushbullet_device_list").append('<option value="' + devices[i].iden + '" selected="selected">' + devices[i].manufacturer + ' ' + devices[i].nickname + '</option>');
} else {
$("#pushbullet_device_list").append('<option value="' + devices[i].iden + '">' + devices[i].manufacturer + ' ' + devices[i].nickname + '</option>');
}
}
}
}
Expand All @@ -338,12 +390,12 @@ $(document).ready(function () {

$("#pushbullet_device_list").change(function () {
$("#pushbullet_device_iden").val($("#pushbullet_device_list").val());
$('#testPushbullet-result').html("Don't forget to save your new pushbullet settings.");
$('#testPushbullet-result').html("Don't forget to save your new Pushbullet settings.");
});
}

$("#getPushbulletDevices").click(function () {
get_pushbullet_devices("Device list updated. Select device target to use.");
get_pushbullet_devices("Device list updated. Select specific device to use.");
});

if ($("#use_pushbullet").prop('checked')) {
Expand Down
Loading

0 comments on commit 90a7622

Please sign in to comment.