Add dropdown for Pushover sounds

This commit is contained in:
Jonathan Wong 2015-10-11 23:45:58 -07:00
parent c12862ffba
commit 7d3d2957c3
3 changed files with 41 additions and 11 deletions

View file

@ -90,9 +90,18 @@ from plexpy import helpers
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut();
})
var notificationConfig = $("#set_notification_config");
$('#save-notification-item').click(function() {
doAjaxCall('set_notification_config', $(this), 'tabs', true);
// Reload modal to update certain fields
$.ajax({
url: 'get_notification_agent_config',
data: { config_id: '${config_id}' },
cache: false,
async: true,
complete: function (xhr, status) {
$("#notification-config-modal").html(xhr.responseText);
}
});
return false;
});

View file

@ -905,11 +905,31 @@ class PUSHOVER(object):
self.notify('Main Screen Activate', 'Test Message')
def get_sounds(self):
http_handler = HTTPSConnection("api.pushover.net")
http_handler.request("GET", "/1/sounds.json?token=" + self.application_token)
response = http_handler.getresponse()
request_status = response.status
if request_status == 200:
data = json.loads(response.read())
sounds = data.get('sounds', {})
return sounds
elif request_status >= 400 and request_status < 500:
logger.info(u"Unable to retrieve Pushover notification sounds: %s" % response.reason)
return {}
else:
logger.info(u"Unable to retrieve Pushover notification sounds.")
return {}
def return_config_options(self):
config_option = [{'label': 'Pushover API Key',
sounds = self.get_sounds()
sounds[''] = ''
config_option = [{'label': 'Pushover User Key',
'value': self.keys,
'name': 'pushover_keys',
'description': 'Your Pushover API key.',
'description': 'Your Pushover user key.',
'input_type': 'text'
},
{'label': 'Priority',
@ -922,13 +942,14 @@ class PUSHOVER(object):
{'label': 'Sound',
'value': self.sound,
'name': 'pushover_sound',
'description': 'Set the notification sound (choose from <a href="https://pushover.net/api#sounds" target="_blank">this list</a> or leave blank for default)',
'input_type': 'text'
'description': 'Set the notification sound. Leave blank for the default sound.',
'input_type': 'select',
'select_options': sounds
},
{'label': 'Pushover API Token',
'value': plexpy.CONFIG.PUSHOVER_APITOKEN,
'name': 'pushover_apitoken',
'description': 'Your Pushover API toekn. Leave blank to use PlexPy default.',
'description': 'Your Pushover API token. Leave blank to use PlexPy default.',
'input_type': 'text'
}
]

View file

@ -1305,7 +1305,7 @@ class WebInterface(object):
checkboxes = {'email_tls': checked(plexpy.CONFIG.EMAIL_TLS)}
return serve_template(templatename="notification_config.html", title="Notification Configuration",
data=config, checkboxes=checkboxes)
config_id=config_id, data=config, checkboxes=checkboxes)
@cherrypy.expose
def get_notification_agent_triggers(self, config_id, **kwargs):