Stage one of notification rewrite. Page cache refresh required.

Each notification has it's own modal config now, PlexWeb-style.
Few minor text changes.
This commit is contained in:
Tim 2015-07-22 01:40:20 +02:00
parent bb3139727e
commit e309d6ba92
6 changed files with 503 additions and 516 deletions

View file

@ -8367,6 +8367,7 @@ ol.test >li {
width: 100%;
max-width: 320px;
min-width: 200px;
border-top: 1px solid #2d2d2d;
}
.nav-settings > li > a {
@ -8387,3 +8388,43 @@ ol.test >li {
color: #eb8600;
background-color: #2f2f2f;
}
.stacked-configs,
.stacked-configs ul {
margin: 0px 0px 20px 0px;
}
.stacked-configs > li {
list-style: none;
background-color: #282828;
width: 100%;
min-width: 320px;
max-width: 768px;
}
.stacked-configs > li > span {
display: block;
padding: 8px 20px 8px 15px;
color: #eee;
border-left: 2px solid #444;
border-top: 1px solid #2d2d2d;
}
.stacked-configs > li > span:hover,
.stacked-configs > li > span:focus {
color: #eee;
background-color: #2f2f2f;
}
.stacked-configs > li > span > a {
float: right;
color: #999;
}
.stacked-configs > li > span > a:hover {
color: #eee;
}
.stacked-configs > li > span > input[type='checkbox'] {
}

View file

@ -0,0 +1,53 @@
% if data:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i
class="fa fa-remove"></i></button>
<h3 id="notification-config-modal-header">Set Config</h3>
</div>
<div class="modal-body" id="">
<div class="container-fluid">
<div class="row-fluid">
<form action="set_notification_config" method="post" class="form" id="set_notification_config" data-parsley-validate>
<div class="span6">
% for item in data:
% if item['input_type'] != 'checkbox':
<div class="form-group">
<label for="${item['name']}">${item['label']}</label>
<input type="${item['input_type']}" id="${item['name']}" name="${item['name']}" value="${item['value']}" size="30">
% if item['name'] == 'osx_notify_app':
<input type="button" class="btn btn-link" value="Register" id="osxnotifyregister">
% endif
<p class="help-block">${item['description']}</p>
</div>
% elif item['input_type'] == 'checkbox':
<div class="checkbox">
<input type="checkbox" id="${item['name']}" name="${item['name']}" value="1" ${item['value']}> ${item['label']}
<p class="help-block">${item['description']}</p>
</div>
% endif
% endfor
</div>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<div class="">
<input type="button" id="save-notification-item" class="rounded rounded-primary" value="Save">
</div>
</div>
% endif
<script>
$('#osxnotifyregister').click(function () {
var osx_notify_app = $("#osx_notify_app").val();
$.get("/osxnotifyregister", {'app': osx_notify_app}, function (data) { $('#ajaxMsg').html("<div class='msg'><span class='ui-icon ui-icon-check'></span>"+data+"</div>"); });
$('#ajaxMsg').addClass('success').fadeIn().delay(3000).fadeOut()
})
var notificationConfig = $("#set_notification_config");
$('#save-notification-item').click(function() {
doAjaxCall('set_notification_config',$(this),'tabs',true);
return false;
});
</script>

View file

@ -1,6 +1,9 @@
<%inherit file="base.html"/>
<%!
import plexpy
from plexpy import notifiers
available_notification_agents = notifiers.available_notification_agents()
%>
<%def name="headerIncludes()">
@ -31,9 +34,9 @@
<li role="presentation" class="active"><a href="#tabs-1" aria-controls="tabs-1" role="tab" data-toggle="tab">General</a></li>
<li role="presentation"><a href="#tabs-2" aria-controls="tabs-2" role="tab" data-toggle="tab">Web Interface</a></li>
<li role="presentation"><a href="#tabs-3" aria-controls="tabs-3" role="tab" data-toggle="tab">Access Control</a></li>
<li role="presentation"><a href="#tabs-4" aria-controls="tabs-4" role="tab" data-toggle="tab">Plex Server Settings</a></li>
<li role="presentation"><a href="#tabs-4" aria-controls="tabs-4" role="tab" data-toggle="tab">Plex Media Server</a></li>
<li role="presentation"><a href="#tabs-5" aria-controls="tabs-5" role="tab" data-toggle="tab">Plex.tv Account</a></li>
<li role="presentation"><a href="#tabs-6" aria-controls="tabs-6" role="tab" data-toggle="tab">Extra Setting</a></li>
<li role="presentation"><a href="#tabs-6" aria-controls="tabs-6" role="tab" data-toggle="tab">Extra Settings</a></li>
<li role="presentation"><a href="#tabs-7" aria-controls="tabs-7" role="tab" data-toggle="tab">Monitoring</a></li>
<li role="presentation"><a href="#tabs-8" aria-controls="tabs-8" role="tab" data-toggle="tab">Notifications</a></li>
<li role="presentation"><a href="#tabs-9" aria-controls="tabs-9" role="tab" data-toggle="tab">Notification Agents</a></li>
@ -187,8 +190,8 @@
</div>
<div class="form-group">
<label for="refresh_users_interval">User list Refresh Interval</label>
<input type="text" data-parsley-type="integer" id="refresh_users_interval" name="refresh_users_interval" value="${config['refresh_users_interval']}" size="5" data-parsley-min="0" data-parsley-trigger="change" required>
<p class="help-block">The interval (in hours) PlexPy will request an updated friends list from Plex.tv. 0 to disable.</p>
<input type="text" data-parsley-type="integer" id="refresh_users_interval" name="refresh_users_interval" value="${config['refresh_users_interval']}" size="5" data-parsley-range="[1,24]" data-parsley-trigger="change" required>
<p class="help-block">The interval (in hours) PlexPy will request an updated friends list from Plex.tv. 1 minimum, 24 maximum.</p>
</div>
<div class="checkbox">
<input type="checkbox" id="refresh_users_on_startup" name="refresh_users_on_startup" value="1" ${config['refresh_users_on_startup']}> Refresh user list on startup
@ -338,276 +341,24 @@
<div role="tabpanel" class="tab-pane" id="tabs-9">
<fieldset>
<div class="wellheader">
<h3>Growl</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="growl_enabled" id="growl" value="1" ${config['growl_enabled']}> Enable Growl Notifications
</div>
<div id="growloptions">
<div class="form-group">
<label for="growl_host">Growl Host:Port</label>
<input type="text" id="growl_host" name="growl_host" value="${config['growl_host']}" size="30">
</div>
<div class="form-group">
<label for="growl_password">Growl Password</label>
<input type="password" id="growl_password" name="growl_password" value="${config['growl_password']}" size="30">
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Prowl</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="prowl_enabled" id="prowl" value="1" ${config['prowl_enabled']}> Enable Prowl Notifications
</div>
<div id="prowloptions">
<div class="form-group">
<label for="prowl_keys">API Key</label>
<input type="text" id="prowl_keys" name="prowl_keys" value="${config['prowl_keys']}" size="50">
</div>
<div class="form-group">
<label for="prowl_priority">Priority (-2,-1,0,1 or 2)</label>
<input type="text" id="prowl_priority" name="prowl_priority" value="${config['prowl_priority']}" size="2">
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>XBMC</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="xbmc_enabled" id="xbmc" value="1" ${config['xbmc_enabled']}> Enable XBMC Notifications
</div>
<div id="xbmcoptions">
<div class="form-group">
<label for="xbmc_host">XBMC Host:Port</label>
<input type="text" id="xbmc_host" name="xbmc_host" value="${config['xbmc_host']}" size="30">
<p class="help-block">e.g. http://localhost:8080. Separate hosts with commas.</p>
</div>
<div class="form-group">
<label for="xbmc_username">XBMC Username</label>
<input type="text" id="xbmc_username" name="xbmc_username" value="${config['xbmc_username']}" size="30">
</div>
<div class="form-group">
<label for="xbmc_password">XBMC Password</label>
<input type="password" id="xbmc_password" name="xbmc_password" value="${config['xbmc_password']}" size="30">
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Plex Home Theatre</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="plex_enabled" id="plex" value="1" ${config['plex_enabled']}> Enable Plex Notifications
</div>
<div id="plexoptions">
<div class="form-group">
<label for="plex_client_host">Plex Client Host:Port</label>
<input type="text" id="plex_client_host" name="plex_client_host" value="${config['plex_client_host']}" size="30">
<p class="help-block">Host running Plex Client (eg. http://192.168.1.100:3000).</p>
</div>
<div class="form-group">
<label for="plex_username">Plex Username</label>
<input type="text" id="plex_username"name="plex_username" value="${config['plex_username']}" size="30">
<p class="help-block">Username of your Plex client API (blank for none).</p>
</div>
<div class="form-group">
<label for="plex_password">Plex Password</label>
<input type="password" id="plex_password" name="plex_password" value="${config['plex_password']}" size="30">
<p class="help-block">Password of your Plex client API (blank for none).</p>
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>NotifyMyAndroid</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="nma_enabled" id="nma" value="1" ${config['nma_enabled']}> Enable NotifyMyAndroid
</div>
<div id="nmaoptions">
<div class="form-group">
<label for="nma_apikey">NotifyMyAndroid API Key</label>
<input type="text" id="nma_apikey" name="nma_apikey" value="${config['nma_apikey']}" size="30">
<p class="help-block">Separate multiple api keys with commas.</p>
</div>
<div class="form-group">
<label for="nma_priority">Priority</label>
<select id="nma_priority" name="nma_priority">
%for x in [-2,-1,0,1,2]:
<%
if config['nma_priority'] == x:
nma_priority_selected = 'selected'
else:
nma_priority_selected = ''
if x == -2:
nma_priority_value = 'Very Low'
elif x == -1:
nma_priority_value = 'Moderate'
elif x == 0:
nma_priority_value = 'Normal'
elif x == 1:
nma_priority_value = 'High'
else:
nma_priority_value = 'Emergency'
%>
<option value=${x} ${nma_priority_selected}>${nma_priority_value}</option>
%endfor
</select>
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Pushalot</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="pushalot_enabled" id="pushalot" value="1" ${config['pushalot_enabled']}> Enable Pushalot
</div>
<div id="pushalotoptions">
<div class="form-group">
<label for="pushalot_apikey">Pushalot API Key</label>
<input type="text" id="pushalot_apikey" name="pushalot_apikey" value="${config['pushalot_apikey']}" size="30">
<p class="help-block">Separate multiple api keys with commas.</p>
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Email</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="email_enabled" id="email" value="1" ${config['email_enabled']}> Enable Email Notifications
</div>
<div id="email_options">
<div class="form-group">
<label for="email_from">From</label>
<input type="text" id="email_from" name="email_from" value="${config['email_from']}" size="254">
</div>
<div class="form-group">
<label for="email_to">To</label>
<input type="text" id="email_to" name="email_to" value="${config['email_to']}" size="254">
</div>
<div class="form-group">
<label for="email_smtp_server">SMTP Server</label>
<input type="text" id="email_smtp_server" name="email_smtp_server" value="${config['email_smtp_server']}" size="254">
</div>
<div class="form-group">
<label for="email_smtp_user">SMTP User</label>
<input type="text" id="email_smtp_user" name="email_smtp_user" value="${config['email_smtp_user']}" size="254">
</div>
<div class="form-group">
<label for="email_smtp_password">SMTP Password</label>
<input type="password" id="email_smtp_password" name="email_smtp_password" value="${config['email_smtp_password']}" size="50">
</div>
<div class="form-group">
<label for="email_smtp_port">SMTP Port</label>
<input type="text" id="email_smtp_port" name="email_smtp_port" value="${config['email_smtp_port']}" size="4">
</div>
<div class="checkbox">
<input type="checkbox" name="email_tls" value="1" ${config['email_tls']}> TLS
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Pushover</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="pushover_enabled" id="pushover" value="1" ${config['pushover_enabled']}> Enable Pushover Notifications
</div>
<div id="pushoveroptions">
<div class="form-group">
<label for="pushover_keys">User key</label>
<input type="text" id="pushover_keys" name="pushover_keys" value="${config['pushover_keys']}" size="50">
</div>
<div class="form-group">
<label for="pushover_priority">Priority (-1,0, or 1)</label>
<input type="text" id="pushover_priority" name="pushover_priority" value="${config['pushover_priority']}" size="2">
</div>
<div class="form-group">
<label for="pushover_apitoken">API Token (leave blank to use PlexPy default)</label>
<input type="text" id="pushover_apitoken" name="pushover_apitoken" value="${config['pushover_apitoken']}" size="50">
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Pushbullet</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="pushbullet_enabled" id="pushbullet" value="1" ${config['pushbullet_enabled']}> Enable PushBullet Notifications
</div>
<div id="pushbulletoptions">
<div class="form-group">
<label for="pushbullet_apikey">API Key</label>
<input type="text" id="pushbullet_apikey" name="pushbullet_apikey" value="${config['pushbullet_apikey']}" size="50">
</div>
<div class="form-group">
<label for="pushbullet_deviceid">Device ID</label>
<input type="text" id="pushbullet_deviceid" name="pushbullet_deviceid" value="${config['pushbullet_deviceid']}" size="50">
</div>
</div>
</fieldset>
<!-- We need to test Twitter first
<fieldset>
<div class="wellheader">
<h3>Twitter</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="twitter_enabled" id="twitter" value="1" ${config['twitter_enabled']}> Enable Twitter Notifications
</div>
<div id="twitteroptions">
<div class="form-group">
<input type="button" class="btn btn-small" value="Request Authorization" id="twitterStep1" />
</div>
<div class="form-group">
<input type="text" id="twitter_key" value="" size="35" placeholder="Input Authorization Key" />
<input type="button" class="btn btn-link" value="Verify Key" id="twitterStep2" />
</div>
<div class="form-group">
<input type="button" class="btn btn-small" value="Test Twitter" id="testTwitter" />
</div>
</div>
</fieldset>
-->
<fieldset>
<div class="wellheader">
<h3>OS X</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="osx_notify_enabled" id="osx_notify" value="1" ${config['osx_notify_enabled']}> Enable OS X Notifications
</div>
<div id="osx_notify_options">
<div class="form-group">
<label for="osx_notify_reg">Register Notify App</label>
<input type="text" id="osx_notify_reg" name="osx_notify_app" value="${config['osx_notify_app']}" size="50">
<input type="button" class="btn btn-link" value="Register" id="osxnotifyregister">
<p class="help-block">Enter the path/application name to be registered with the Notification Center, default is /Applications/PlexPy.</p>
</div>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Boxcar2</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="boxcar_enabled" id="boxcar" value="1" ${config['boxcar_enabled']}> Enable Boxcar2 Notifications
</div>
<div id="boxcar_options">
<div class="form-group">
<label for="boxcar_token">Access Token</label>
<input type="text" id="boxcar_token" name="boxcar_token" value="${config['boxcar_token']}" size="35">
</div>
</div>
<h3>Notification Agents</h3>
</div>
<p class="help-block">
Check the desired notification option and configure it by selecting the settings icon to the right.
</p>
<br/>
<ul class="stacked-configs">
% for agent in available_notification_agents:
<li>
<span>
<input type="checkbox" name="${agent['config_name']}" id="${agent['config_name']}" value="1" ${agent['state']}> ${agent['name']}
% if agent['has_config']:
<a href="#notification-config-modal" data-id="${agent['id']}" class="toggle-notification-config-modal" data-toggle="modal"><i class="fa fa-lg fa-cog"></i></a>
% endif
</span>
</li>
% endfor
</ul>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
@ -777,6 +528,9 @@
<div id="plexwatch-import-modal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="plexwatch-import-modal" aria-hidden="true">
</div>
<div id="notification-config-modal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="notification-setting-modal" aria-hidden="true">
</div>
</div>
</div>
</div>
@ -939,245 +693,18 @@
});
});
// Legacy stuff we need to remove
if ($("#growl").is(":checked"))
{
$("#growloptions").show();
}
else
{
$("#growloptions").hide();
}
$("#growl").click(function(){
if ($("#growl").is(":checked"))
{
$("#growloptions").slideDown();
}
else
{
$("#growloptions").slideUp();
// Load PlexWatch import modal
$(".toggle-notification-config-modal").click(function() {
var configId = $(this).data('id');
$.ajax({
url: 'get_notification_agent_config',
data: { config_id: configId },
cache: false,
async: true,
complete: function(xhr, status) {
$("#notification-config-modal").html(xhr.responseText);
}
});
if ($("#prowl").is(":checked"))
{
$("#prowloptions").show();
}
else
{
$("#prowloptions").hide();
}
$("#prowl").click(function(){
if ($("#prowl").is(":checked"))
{
$("#prowloptions").slideDown();
}
else
{
$("#prowloptions").slideUp();
}
});
if ($("#xbmc").is(":checked"))
{
$("#xbmcoptions").show();
}
else
{
$("#xbmcoptions").hide();
}
$("#xbmc").click(function(){
if ($("#xbmc").is(":checked"))
{
$("#xbmcoptions").slideDown();
}
else
{
$("#xbmcoptions").slideUp();
}
});
if ($("#plex").is(":checked"))
{
$("#plexoptions").show();
}
else
{
$("#plexoptions").hide();
}
$("#plex").click(function(){
if ($("#plex").is(":checked"))
{
$("#plexoptions").slideDown();
}
else
{
$("#plexoptions").slideUp();
}
});
if ($("#nma").is(":checked"))
{
$("#nmaoptions").show();
}
else
{
$("#nmaoptions").hide();
}
$("#nma").click(function(){
if ($("#nma").is(":checked"))
{
$("#nmaoptions").slideDown();
}
else
{
$("#nmaoptions").slideUp();
}
});
if ($("#pushalot").is(":checked"))
{
$("#pushalotoptions").show();
}
else
{
$("#pushalotoptions").hide();
}
$("#pushalot").click(function(){
if ($("#pushalot").is(":checked"))
{
$("#pushalotoptions").slideDown();
}
else
{
$("#pushalotoptions").slideUp();
}
});
if ($("#pushover").is(":checked"))
{
$("#pushoveroptions").show();
}
else
{
$("#pushoveroptions").hide();
}
$("#pushover").click(function(){
if ($("#pushover").is(":checked"))
{
$("#pushoveroptions").slideDown();
}
else
{
$("#pushoveroptions").slideUp();
}
});
if ($("#pushbullet").is(":checked"))
{
$("#pushbulletoptions").show();
}
else
{
$("#pushbulletoptions").hide();
}
$("#pushbullet").click(function(){
if ($("#pushbullet").is(":checked"))
{
$("#pushbulletoptions").slideDown();
}
else
{
$("#pushbulletoptions").slideUp();
}
});
if ($("#twitter").is(":checked"))
{
$("#twitteroptions").show();
}
else
{
$("#twitteroptions").hide();
}
$("#twitter").click(function(){
if ($("#twitter").is(":checked"))
{
$("#twitteroptions").slideDown();
}
else
{
$("#twitteroptions").slideUp();
}
});
if ($("#osx_notify").is(":checked"))
{
$("#osx_notify_options").show();
}
else
{
$("#osx_notify_options").hide();
}
$("#osx_notify").click(function(){
if ($("#osx_notify").is(":checked"))
{
$("#osx_notify_options").slideDown();
}
else
{
$("#osx_notify_options").slideUp();
}
});
if ($("#boxcar").is(":checked"))
{
$("#boxcar_options").show();
}
else
{
$("#boxcar_options").hide();
}
$("#boxcar").click(function(){
if ($("#boxcar").is(":checked"))
{
$("#boxcar_options").slideDown();
}
else
{
$("#boxcar_options").slideUp();
}
});
if ($("#email").is(":checked"))
{
$("#email_options").show();
}
else
{
$("#email_options").hide();
}
$("#email").click(function(){
if ($("#email").is(":checked"))
{
$("#email_options").slideDown();
}
else
{
$("#email_options").slideUp();
}
});
if ($("#tv_notify_enable").is(":checked"))

View file

@ -134,7 +134,7 @@ from plexpy import version
<h3>PlexWatch Import</h3>
<p class="help-block">If you have an existing PlexWatch database, you can import the data into PlexPy.</p>
<p class="help-block">
When you complete this wizard navigate to the settings menu and to the Monitoring tab. You will find an import tool there
When you complete this wizard navigate to the settings menu and to the Extra Settings tab. You will find an import tool there
which will convert your plexWatch database into a format that PlexPy can read.
</p>
<!-- Figure out best way to get friends list refreshed before adding this back

View file

@ -14,6 +14,7 @@
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
from plexpy import logger, helpers, common, request
from plexpy.helpers import checked, radio
from xml.dom import minidom
from httplib import HTTPSConnection
@ -38,6 +39,131 @@ from email.mime.text import MIMEText
import smtplib
import email.utils
AGENT_IDS = {"Growl": 0,
"Prowl": 1,
"XBMC": 2,
"Plex": 3,
"NMA": 4,
"PushAlot": 5,
"PushBullet": 6,
"PushOver": 7,
"OSX Notify": 8,
"Boxcar2": 9,
"Email": 10}
def available_notification_agents():
agents = [{'name': 'Growl',
'id': AGENT_IDS['Growl'],
'config_name': 'growl_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.GROWL_ENABLED)
},
{'name': 'Prowl',
'id': AGENT_IDS['Prowl'],
'config_name': 'prowl_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.PROWL_ENABLED)
},
{'name': 'XBMC',
'id': AGENT_IDS['XBMC'],
'config_name': 'xbmc_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.XBMC_ENABLED)
},
{'name': 'Plex',
'id': AGENT_IDS['Plex'],
'config_name': 'plex_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.PLEX_ENABLED)
},
{'name': 'NotifyMyAndroid',
'id': AGENT_IDS['NMA'],
'config_name': 'nma_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.NMA_ENABLED)
},
{'name': 'PushAlot',
'id': AGENT_IDS['PushAlot'],
'config_name': 'pushalot_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.PUSHALOT_ENABLED)
},
{'name': 'PushBullet',
'id': AGENT_IDS['PushBullet'],
'config_name': 'pushbullet_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.PUSHBULLET_ENABLED)
},
{'name': 'PushOver',
'id': AGENT_IDS['PushOver'],
'config_name': 'pushover_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.PUSHOVER_ENABLED)
},
{'name': 'OSX Notify',
'id': AGENT_IDS['OSX Notify'],
'config_name': 'osx_notify_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.OSX_NOTIFY_ENABLED)
},
{'name': 'Boxcar2',
'id': AGENT_IDS['Boxcar2'],
'config_name': 'boxcar_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.BOXCAR_ENABLED)
},
{'name': 'E-mail',
'id': AGENT_IDS['Email'],
'config_name': 'email_enabled',
'has_config': True,
'state': checked(plexpy.CONFIG.EMAIL_ENABLED)
}
]
return agents
def get_notification_agent_config(config_id):
if config_id:
config_id = int(config_id)
if config_id == 0:
growl = GROWL()
return growl.return_config_options()
elif config_id == 1:
prowl = PROWL()
return prowl.return_config_options()
elif config_id == 2:
xbmc = XBMC()
return xbmc.return_config_options()
elif config_id == 3:
plex = Plex()
return plex.return_config_options()
elif config_id == 4:
nma = NMA()
return nma.return_config_options()
elif config_id == 5:
pushalot = PUSHALOT()
return pushalot.return_config_options()
elif config_id == 6:
pushbullet = PUSHBULLET()
return pushbullet.return_config_options()
elif config_id == 7:
pushover = PUSHOVER()
return pushover.return_config_options()
elif config_id == 8:
osx_notify = OSX_NOTIFY()
return osx_notify.return_config_options()
elif config_id == 9:
boxcar = BOXCAR()
return boxcar.return_config_options()
elif config_id == 10:
email = Email()
return email.return_config_options()
else:
return []
else:
return []
class GROWL(object):
"""
@ -124,6 +250,22 @@ class GROWL(object):
self.notify('ZOMG Lazors Pewpewpew!', 'Test Message')
def return_config_options(self):
config_option = [{'label': 'Host',
'value': self.host,
'name': 'growl_host',
'description': 'Set the hostname.',
'input_type': 'text'
},
{'label': 'Password',
'value': self.password,
'name': 'growl_password',
'description': 'Set the password.',
'input_type': 'password'
}
]
return config_option
class PROWL(object):
"""
@ -178,6 +320,23 @@ class PROWL(object):
self.notify('ZOMG Lazors Pewpewpew!', 'Test Message')
def return_config_options(self):
config_option = [{'label': 'API Key',
'value': self.keys,
'name': 'prowl_keys',
'description': 'Set the API key.',
'input_type': 'text'
},
{'label': 'Priority (-2,-1,0,1 or 2)',
'value': self.priority,
'name': 'prowl_priority',
'description': 'Set the priority.',
'input_type': 'number'
}
]
return config_option
class XBMC(object):
"""
XBMC notifications
@ -239,11 +398,32 @@ class XBMC(object):
except Exception:
logger.error('Error sending notification request to XBMC')
def return_config_options(self):
config_option = [{'label': 'XBMC Host:Port',
'value': self.hosts,
'name': 'xbmc_host',
'description': 'e.g. http://localhost:8080. Separate hosts with commas.',
'input_type': 'text'
},
{'label': 'Username',
'value': self.username,
'name': 'xbmc_username',
'description': 'Set the Username.',
'input_type': 'text'
},
{'label': 'Password',
'value': self.password,
'name': 'xbmc_password',
'description': 'Set the Password.',
'input_type': 'password'
}
]
return config_option
class Plex(object):
def __init__(self):
self.server_hosts = plexpy.CONFIG.PLEX_SERVER_HOST
self.client_hosts = plexpy.CONFIG.PLEX_CLIENT_HOST
self.username = plexpy.CONFIG.PLEX_USERNAME
self.password = plexpy.CONFIG.PLEX_PASSWORD
@ -296,6 +476,28 @@ class Plex(object):
except:
logger.warn('Error sending notification request to Plex Media Server')
def return_config_options(self):
config_option = [{'label': 'Plex Client Host:Port',
'value': self.client_hosts,
'name': 'plex_client_host',
'description': 'Host running Plex Client (eg. http://192.168.1.100:3000).',
'input_type': 'text'
},
{'label': 'Plex Username',
'value': self.username,
'name': 'plex_username',
'description': 'Username of your Plex client API (blank for none).',
'input_type': 'text'
},
{'label': 'Plex Password',
'value': self.password,
'name': 'plex_password',
'description': 'Password of your Plex client API (blank for none).',
'input_type': 'password'
}
]
return config_option
class NMA(object):
def notify(self, subject=None, message=None):
@ -329,6 +531,22 @@ class NMA(object):
else:
return True
def return_config_options(self):
config_option = [{'label': 'NotifyMyAndroid API Key',
'value': plexpy.CONFIG.NMA_APIKEY,
'name': 'nma_apikey',
'description': 'Separate multiple api keys with commas.',
'input_type': 'text'
},
{'label': 'Priority',
'value': plexpy.CONFIG.NMA_PRIORITY,
'name': 'nma_priority',
'description': 'Priority (-2,-1,0,1 or 2).',
'input_type': 'number'
}
]
return config_option
class PUSHBULLET(object):
@ -378,6 +596,22 @@ class PUSHBULLET(object):
self.notify('Main Screen Activate', 'Test Message')
def return_config_options(self):
config_option = [{'label': 'API Key',
'value': self.apikey,
'name': 'pushbullet_apikey',
'description': 'Your Pushbullet API key.',
'input_type': 'text'
},
{'label': 'Device ID',
'value': self.deviceid,
'name': 'pushbullet_deviceid',
'description': 'A device ID (optional).',
'input_type': 'text'
}
]
return config_option
class PUSHALOT(object):
@ -418,6 +652,16 @@ class PUSHALOT(object):
logger.info(u"Pushalot notification failed.")
return False
def return_config_options(self):
config_option = [{'label': 'API Key',
'value': plexpy.CONFIG.PUSHALOT_APIKEY,
'name': 'pushalot_apikey',
'description': 'Your Pushalot API key.',
'input_type': 'text'
}
]
return config_option
class PUSHOVER(object):
@ -477,6 +721,28 @@ class PUSHOVER(object):
self.notify('Main Screen Activate', 'Test Message')
def return_config_options(self):
config_option = [{'label': 'API Key',
'value': self.keys,
'name': 'pushover_keys',
'description': 'Your Pushover API key.',
'input_type': 'text'
},
{'label': 'Priority',
'value': self.priority,
'name': 'pushover_priority',
'description': 'Priority (-1,0, or 1).',
'input_type': 'number'
},
{'label': 'API Token',
'value': self.priority,
'name': 'pushover_apitoken',
'description': 'Leave blank to use PlexPy default.',
'input_type': 'text'
}
]
return config_option
class TwitterNotifier(object):
@ -579,7 +845,6 @@ class TwitterNotifier(object):
return self._send_tweet(prefix + ": " + message)
class OSX_NOTIFY(object):
def __init__(self):
@ -641,6 +906,17 @@ class OSX_NOTIFY(object):
def swizzled_bundleIdentifier(self, original, swizzled):
return 'ade.plexpy.osxnotify'
def return_config_options(self):
config_option = [{'label': 'Register Notify App',
'value': plexpy.CONFIG.OSX_NOTIFY_APP,
'name': 'osx_notify_app',
'description': 'Enter the path/application name to be registered with the '
'Notification Center, default is /Applications/PlexPy.',
'input_type': 'text'
}
]
return config_option
class BOXCAR(object):
@ -668,6 +944,16 @@ class BOXCAR(object):
logger.warn('Error sending Boxcar2 Notification: %s' % e)
return False
def return_config_options(self):
config_option = [{'label': 'Access Token',
'value': plexpy.CONFIG.BOXCAR_TOKEN,
'name': 'boxcar_token',
'description': 'Your Boxcar access token.',
'input_type': 'text'
}
]
return config_option
class Email(object):
@ -696,3 +982,50 @@ class Email(object):
except Exception, e:
logger.warn('Error sending Email: %s' % e)
return False
def return_config_options(self):
config_option = [{'label': 'From',
'value': plexpy.CONFIG.EMAIL_FROM,
'name': 'email_from',
'description': 'Who should the sender be.',
'input_type': 'text'
},
{'label': 'To',
'value': plexpy.CONFIG.EMAIL_TO,
'name': 'email_to',
'description': 'Who should the recipeint be.',
'input_type': 'text'
},
{'label': 'SMTP Server',
'value': plexpy.CONFIG.EMAIL_SMTP_SERVER,
'name': 'email_smtp_server',
'description': 'Host for the SMTP server.',
'input_type': 'text'
},
{'label': 'SMTP Port',
'value': plexpy.CONFIG.EMAIL_SMTP_PORT,
'name': 'email_smtp_port',
'description': 'Port for the SMTP server.',
'input_type': 'number'
},
{'label': 'SMTP User',
'value': plexpy.CONFIG.EMAIL_SMTP_USER,
'name': 'email_smtp_user',
'description': 'User for the SMTP server.',
'input_type': 'text'
},
{'label': 'SMTP Password',
'value': plexpy.CONFIG.EMAIL_SMTP_PASSWORD,
'name': 'email_smtp_password',
'description': 'Password for the SMTP server.',
'input_type': 'password'
},
{'label': 'TLS',
'value': checked(plexpy.CONFIG.EMAIL_TLS),
'name': 'email_tls',
'description': 'Does the server use encryption.',
'input_type': 'checkbox'
}
]
return config_option

View file

@ -563,6 +563,30 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("config")
@cherrypy.expose
def set_notification_config(self, **kwargs):
# Handle the variable config options. Note - keys with False values aren't getting passed
checked_configs = [
"email_tls"
]
for checked_config in checked_configs:
if checked_config not in kwargs:
# checked items should be zero or one. if they were not sent then the item was not checked
kwargs[checked_config] = 0
for plain_config, use_config in [(x[4:], x) for x in kwargs if x.startswith('use_')]:
# the use prefix is fairly nice in the html, but does not match the actual config
kwargs[plain_config] = kwargs[use_config]
del kwargs[use_config]
plexpy.CONFIG.process_kwargs(kwargs)
# Write the config
plexpy.CONFIG.write()
raise cherrypy.HTTPRedirect("settings")
@cherrypy.expose
def do_state_change(self, signal, title, timer):
message = title
@ -1155,3 +1179,12 @@ class WebInterface(object):
random_number = randint(0, len(quote_list) - 1)
return quote_list[int(random_number)]
@cherrypy.expose
def get_notification_agent_config(self, config_id, **kwargs):
config = notifiers.get_notification_agent_config(config_id=config_id)
checkboxes = {'email_tls': checked(plexpy.CONFIG.EMAIL_TLS)}
return serve_template(templatename="notification_config.html", title="Notification Configuration",
data=config, checkboxes=checkboxes)