plexpy/data/interfaces/default/settings.html
Tim b394ebc1a3 Stage three of notification rewrite. Page cache refresh required.
Watched notifications added with configurable cutoff percent.
Styling fixes.
Add information back to settings page for required restart on web interface changes.
Use user_id on user link in activity pane.
Added channels option to Pushbullet.
Possible fix for text encoding issues in Plexwatch importer.
Thread the notifications.
Move most of the notification logic to the notification handler.
2015-07-24 00:53:31 +02:00

775 lines
No EOL
44 KiB
HTML

<%inherit file="base.html"/>
<%!
import plexpy
from plexpy import notifiers
available_notification_agents = notifiers.available_notification_agents()
%>
<%def name="headerIncludes()">
</%def>
<%def name="body()">
<div class="container-fluid">
<div class='row-fluid'>
<div class='span12'>
<div class='table-card-back'>
<div class="header-bar">
<h2><i class="fa fa-cog"></i> Settings</h2>
</div>
<div class="button-bar">
% if config['check_github']:
<button id="menu_link_update_check" class="rounded"><i class="fa fa-arrow-circle-up"></i> Check for Updates</button>
% endif
<button id="menu_link_restart" class="rounded"><i class="fa fa-refresh"></i> Restart</button>
<button id="menu_link_shutdown" class="rounded"><i class="fa fa-power-off"></i> Shut Down</button>
</div>
</div>
<div class="settings-pane">
<div role="tabpanel" class="row-fluid">
<!-- Nav tabs -->
<div class="settings-pane-options-list">
<ul class="nav-settings" role="tablist">
<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 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 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>
</ul>
</div>
<div class="settings-pane-content">
<form action="configUpdate" method="post" class="form" id="configUpdate" data-parsley-validate>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tabs-1">
<fieldset>
<div class="wellheader">
<h3>Software Updates</h3>
</div>
<div class="checkbox">
<input type="checkbox" id="check_github" name="check_github" value="1" ${config['check_github']}> Enable Updates
<p class="help-block">If you have Git installed, allow periodic checks for updates.</p>
</div>
% if plexpy.CURRENT_VERSION:
<p class="help-block">Current version: ${plexpy.CURRENT_VERSION}</p>
% endif
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Display Settings</h3>
</div>
<div class="form-group">
<label for="date_format">Date Format</label>
<input type="text" id="date_format" name="date_format" value="${config['date_format']}" size="30" data-parsley-trigger="change" required>
<p class="help-block">Set your preferred date format. <a href="#dateTimeOptionsModal" data-toggle="modal">Click here</a> to see the parameter list.</p>
</div>
<div class="form-group">
<label for="date_format">Time Format</label>
<input type="text" id="time_format" name="time_format" value="${config['time_format']}" size="30" data-parsley-trigger="change" required>
<p class="help-block">Set your preferred time format. <a href="#dateTimeOptionsModal" data-toggle="modal">Click here</a> to see the parameter list.</p>
</div>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-2">
<fieldset>
<div class="wellheader">
<h3>Web Interface</h3>
</div>
<p class="help-block">Web interface changes require a restart.</p>
<div class="form-group">
<label for="http_host">HTTP Host</label>
<input type="text" id="http_host" name="http_host" value="${config['http_host']}" size="30" data-parsley-trigger="change" required>
<p class="help-block">e.g. localhost or an IP, such as 0.0.0.0</p>
</div>
<div class="form-group">
<label for="http_port">HTTP Port</label>
<input type="text" data-parsley-type="integer" id="http_port" name="http_port" value="${config['http_port']}" size="10" data-parsley-trigger="change" required>
<p class="help-block">Port to bind web server to. Note that ports below 1024 may require root.</p>
</div>
<div class="checkbox">
<input type="checkbox" name="launch_browser" value="1" ${config['launch_browser']}> Launch Browser on Startup
<p class="help-block">Launch browser pointed to PlexPy, on startup.</p>
</div>
<div class="checkbox">
<input type="checkbox" name="enable_https" id="enable_https" value="1" ${config['enable_https']} /> Enable HTTPS
<p class="help-block">Enable HTTPS for web server for encrypted communication.</p>
</div>
<div id="https_options">
<div class="form-group">
<label for="https_cert">HTTPS Cert</label>
<input type="text" id="https_cert" name="https_cert" value="${config['https_cert']}" size="30">
</div>
<div class="form-group">
<label for="https_key">HTTPS Key</label>
<input type="text" id="https_key" name="https_key" value="${config['https_key']}" size="30">
</div>
</div>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-3">
<fieldset>
<div class="wellheader">
<h3>Authentication</h3>
</div>
<p class="help-block">Authentication changes require a restart.</p>
<div class="form-group">
<label for="http_username">HTTP Username</label>
<input type="text" id="http_username" name="http_username" value="${config['http_username']}" size="30">
<p class="help-block">Username for web server authentication. Leave empty to disable.</p>
</div>
<div class="form-group">
<label for="http_password">HTTP Password</label>
<input type="password" id="http_password" name="http_password" value="${config['http_password']}" size="30">
<p class="help-block">Password for web server authentication. Leave empty to disable.</p>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>API</h3>
</div>
<div class="checkbox">
<input type="checkbox" id="api_enabled" name="api_enabled" value="1" ${config['api_enabled']}> Enable API
<p class="help-block">Allow remote applications to interface with PlexPy.</p>
</div>
<div id="apioptions" class="form-group">
<label for="api_key">API key</label>
<input type="text" name="api_key" id="api_key" value="${config['api_key']}" size="20">
<input type="button" class="btn btn-link" value="Generate" id="generate_api">
<p class="help-block">Current API key: <strong><br/>${config['api_key']}</strong></p>
</div>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-4">
<fieldset>
<div class="wellheader">
<h3>Plex Media Server</h3>
</div>
<div class="form-group">
<label for="pms_ip">Plex IP or Hostname</label>
<input type="text" class="pms-settings" id="pms_ip" name="pms_ip" value="${config['pms_ip']}" size="30" data-parsley-trigger="change" required>
<span style="margin-left: 10px; display: none;" id="pms-verify-status"></span>
<p class="help-block">IP Address or hostname for Plex Media Server.</p>
</div>
<div class="form-group">
<label for="pms_port">Plex Port</label>
<input data-parsley-type="integer" class="pms-settings" type="text" id="pms_port" name="pms_port" value="${config['pms_port']}" size="30" data-parsley-trigger="change" required>
<p class="help-block">Port that Plex Media Server is listening on.</p>
</div>
<div class="checkbox">
<input type="checkbox" id="pms_is_remote" name="pms_is_remote" value="1" ${config['pms_is_remote']}> Remote Server
<p class="help-block">Check this is your Plex Server is not on the same local network as PlexPy.</p>
</div>
<div class="checkbox">
<input type="checkbox" id="pms_ssl" name="pms_ssl" value="1" ${config['pms_ssl']}> Force SSL
<p class="help-block">Force PlexPy to connect to your Plex Server via SSL. Your server needs to have remote access enabled.</p>
</div>
<input type="hidden" id="pms_identifier" name="pms_identifier" value="${config['pms_identifier']}">
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-5">
<fieldset>
<div class="wellheader">
<h3>Plex.tv Authentication</h3>
</div>
<div class="form-group">
<label for="pms_token">PMS Token</label>
<input type="text" id="pms_token" name="pms_token" value="${config['pms_token']}" size="30" data-parsley-trigger="change" required>
<a href="#pms-auth-modal" data-toggle="modal">&nbspFetch Token</a>
<p class="help-block">Token for Plex.tv authentication.</p>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>Friends List</h3>
</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-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
<p class="help-block">Refresh the user list when PlexPy starts.</p>
</div>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-6">
<div class="wellheader">
<h3>Extra Settings</h3>
</div>
<fieldset>
<div class="checkbox">
<input type="checkbox" id="pms_use_bif" name="pms_use_bif" value="1" ${config['pms_use_bif']}> Use BIF thumbs
<p class="help-block">If you have media indexing enabled on your server, use these on the activity pane.</p>
</div>
</fieldset>
<div class="wellheader">
<h3>Plex Logs</h3>
</div>
<fieldset>
<div class="form-group">
<label for="pms_logs_folder">Logs Folder</label>
<input type="text" id="pms_logs_folder" name="pms_logs_folder" value="${config['pms_logs_folder']}" size="30" data-parsley-trigger="change">
<p class="help-block">Set the folder where your Plex Server logs are. This is required if you enable IP logging.<br/><a href="https://support.plex.tv/hc/en-us/articles/200250417-Plex-Media-Server-Log-Files" target="_blank">Click here</a> for help.</p>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>PlexWatch Import Tool</h3>
</div>
<p class="help-block"><a href="#plexwatch-import-modal" id="toggle-plexwatch-import-modal" data-toggle="modal">Click here to Import an existing Plexwatch database.</a></p>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-7">
<fieldset>
<div class="wellheader">
<h3>Monitoring Settings</h3>
</div>
<div class="form-group">
<label for="monitoring_interval">Monitoring Interval</label>
<input type="text" data-parsley-type="integer" id="monitoring_interval" name="monitoring_interval" value="${config['monitoring_interval']}" size="5" data-parsley-min="30" data-parsley-trigger="change" required>
<p class="help-block">The interval (in seconds) PlexPy will ping your Plex Server. Min 30 seconds, Recommended 60 seconds.</p>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>History Logging</h3>
</div>
<div class="checkbox">
<input type="checkbox" id="video_logging_enable" name="video_logging_enable" value="1" ${config['video_logging_enable']}> Log Movies and TV
<p class="help-block">Keep records of all video items played from your Plex Media Server.</p>
</div>
<div class="form-group">
<label for="monitoring_interval">Ignore Interval</label>
<input type="text" data-parsley-type="integer" id="logging_ignore_interval" name="logging_ignore_interval" value="${config['logging_ignore_interval']}" size="5" data-parsley-min="0" data-parsley-trigger="change" required>
<p class="help-block">The interval (in seconds) PlexPy will wait for a video item to be active before logging it. 0 to disable.</p>
</div>
<div class="checkbox">
<input type="checkbox" id="music_logging_enable" name="music_logging_enable" value="1" ${config['music_logging_enable']}> Log Music
<p class="help-block">Keep records of all audio items played from your Plex Media Server. VERY experimental.</p>
</div>
</fieldset>
<fieldset>
<div class="wellheader">
<h3>IP Logging</h3>
</div>
<div class="checkbox">
<input type="checkbox" id="ip_logging_enable" name="ip_logging_enable" value="1" ${config['ip_logging_enable']}> Enable IP Logging
<p class="help-block">
Enable this to attempt to log the IP address of the user. Debug logging must be enabled and your log folder must be set in the PlexPy settings.
</p>
</div>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-8">
<fieldset>
<div class="wellheader">
<h3>Global Notification Toggles</h3>
</div>
<div class="checkbox">
<input type="checkbox" name="movie_notify_enable" id="movie_notify_enable" value="1" ${config['movie_notify_enable']}> Enable Movie and TV Notifications
</div>
<div class="checkbox">
<input type="checkbox" name="music_notify_enable" id="music_notify_enable" value="1" ${config['music_notify_enable']}> Enable Music Notifications
</div>
</fieldset>
<div class="wellheader">
<h3>Notification Tuning</h3>
</div>
<fieldset>
<div class="form-group">
<label for="notify_watched_percent">Watched Percent</label>
<input type="text" data-parsley-type="integer" id="notify_watched_percent" name="notify_watched_percent" value="${config['notify_watched_percent']}" size="5" data-parsley-range="[50,95]" data-parsley-trigger="change" required>
<p class="help-block">Set the progress percentage of when a watched notification should be triggered. Minimum 50, Maximum 95.</p>
</div>
</fieldset>
<input type="button" class="rounded rounded-primary save-button" value="Save" data-success="Changes saved successfully">
</div>
<div role="tabpanel" class="tab-pane" id="tabs-9">
<fieldset>
<div class="wellheader">
<h3>Notification Agents</h3>
</div>
<p class="help-block">
Toggle the desired notification option and configure it by selecting the settings icon to the right.
Watched notifications are only applicable for video items.
</p>
<br/>
<ul class="stacked-configs">
% for agent in available_notification_agents:
<li>
<span>
<!--<input type="checkbox" name="${agent['config_prefix']}_enabled" id="${agent['config_prefix']}" value="1" ${agent['state']}> ${agent['name']}-->
<a class="toggle-left notify-toggle-icon" href="javascript:void(0)" data-toggle="tooltip" data-placement="top" title data-title="Notify on playback start" data-id="${agent['id']}" data-config-name="${agent['config_prefix']}_on_play" data-config-value="${agent['on_play']}"><i class="fa fa-play"></i></a>
<a class="toggle-left notify-toggle-icon" href="javascript:void(0)" data-toggle="tooltip" data-placement="top" title data-title="Notify on stop" data-id="${agent['id']}" data-config-name="${agent['config_prefix']}_on_stop" data-config-value="${agent['on_stop']}"><i class="fa fa-stop"></i></a>
<a class="toggle-left notify-toggle-icon" href="javascript:void(0)" data-toggle="tooltip" data-placement="top" title data-title="Notify on watched" data-id="${agent['id']}" data-config-name="${agent['config_prefix']}_on_watched" data-config-value="${agent['on_watched']}"><i class="fa fa-eye"></i></a>
${agent['name']}
% if agent['has_config']:
<a href="#notification-config-modal" rel="tooltip" data-placement="top" title data-title="Open configuration" data-id="${agent['id']}" class="toggle-notification-config-modal toggle-right" data-toggle="modal"><i class="fa fa-lg fa-cog"></i></a>
% endif
</span>
</li>
% endfor
</ul>
</fieldset>
</div>
</div>
</form>
</div>
</div>
</div>
<div id="dateTimeOptionsModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="dateTimeOptionsModal" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="fa fa-remove"></i>
</button>
<h3 id="myModalLabel">Date &amp; Time Format Options</h3>
</div>
<div class="modal-body">
<div class="card-back">
<table>
<tbody>
<tr>
<td colspan="3"><h5>Day</h5></td>
</tr>
<tr>
<td align="center"><strong>DD</strong></td>
<td width="300">Numeric, with leading zeros</td>
<td>01 to 31</td>
</tr>
<tr>
<td align="center"><strong>D</strong></td>
<td>Numeric, without leading zeros</td>
<td>1 to 31</td>
</tr>
<tr>
<td align="center"><strong>Do</strong></td>
<td>The English suffix for the day of the month</td>
<td>st, nd or th in the 1st, 2nd or 15th.</td>
</tr>
<tr>
<td colspan="3"><h5>Month</h5></td>
</tr>
<tr>
<td align="center"><strong>MM</strong></td>
<td>Numeric, with leading zeros</td>
<td>01 to 31</td>
</tr>
<tr>
<td align="center"><strong>M</strong></td>
<td>Numeric, without leading zeros</td>
<td>1 to 31</td>
</tr>
<tr>
<td align="center"><strong>MMMM</strong></td>
<td>Textual full</td>
<td>January to December</td>
</tr>
<tr>
<td align="center"><strong>MMM</strong></td>
<td>Textual three letters</td>
<td>Jan to Dec</td>
</tr>
<tr>
<td colspan="3"><h5>Year</h5></td>
</tr>
<tr>
<td align="center"><strong>YYYY</strong></td>
<td>Numeric, 4 digits</td>
<td>Eg., 1999, 2003</td>
</tr>
<tr>
<td align="center"><strong>YY</strong></td>
<td>Numeric, 2 digits</td>
<td>Eg., 99, 03</td>
</tr>
<tr>
<td colspan="3"><h5>Time</h5></td>
</tr>
<tr>
<td align="center"><strong>a</strong></td>
<td width="300">am/pm Lowercase</td>
<td>am, pm</td>
</tr>
<tr>
<td align="center"><strong>A</strong></td>
<td>AM/PM Uppercase</td>
<td>AM, PM</td>
</tr>
<tr>
<td align="center"><strong>h</strong></td>
<td>Hour, 12-hour, without leading zeros</td>
<td>1-12</td>
</tr>
<tr>
<td align="center"><strong>hh</strong></td>
<td>Hour, 12-hour, with leading zeros</td>
<td>01-12</td>
</tr>
<tr>
<td align="center"><strong>H</strong></td>
<td>Hour, 24-hour, without leading zeros</td>
<td>0-23</td>
</tr>
<tr>
<td align="center"><strong>HH</strong></td>
<td>Hour, 24-hour, with leading zeros</td>
<td>00-23</td>
</tr>
<tr>
<td align="center"><strong>mm</strong></td>
<td>Minutes, with leading zeros</td>
<td>00-59</td>
</tr>
<tr>
<td align="center"><strong>ss</strong></td>
<td>Seconds, with leading zeros</td>
<td>00-59</td>
</tr>
<tr>
<td align="center"><strong>zz</strong></td>
<td>Timezone abbreviation</td>
<td>Eg., EST, MDT ...</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="modal-footer"></div>
</div>
<div id="pms-auth-modal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="ip-info-modal" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i
class="fa fa-remove"></i></button>
<h3 id="PMSAuthModal">Fetch Plex.tv Token</h3>
</div>
<div class="modal-body" id="modal-text">
<div>
<div class="card-back">
<span>
This will attempt to fetch your token for you. This will not work on Internet Explorer 9 or lower.
PlexPy does not store your username and password.
</span>
<br/><br/>
<div class="form-group">
<label for="pms_username">PMS Username</label>
<input type="text" id="pms_username" name="pms_username" size="30">
<p class="help-block">Username for Plex.tv authentication.</p>
</div>
<div class="form-group">
<label for="pms_password">PMS Password</label>
<input type="password" id="pms_password" name="pms_password" size="30">
<p class="help-block">Password for Plex.tv authentication.</p>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="">
<input type="button" id="get-pms-auth-token" class="rounded rounded-primary" value="Fetch Token">
<span id="pms-token-status"></span>
</div>
</div>
</div>
<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>
</%def>
<%def name="javascriptIncludes()">
<script src="interfaces/default/js/parsley.min.js"></script>
<script>
$(document).ready(function() {
var configForm = $("#configUpdate");
$('.save-button').click(function() {
if ($("#pms_identifier").val() == "") {
showMsg('<i class="fa fa-exclamation-circle"></i>&nbspPlease verify your server.',false,true,2000,true)
} else {
if (configForm.parsley().validate()) {
doAjaxCall('configUpdate',$(this),'tabs',true);
return false;
} else {
showMsg('<i class="fa fa-exclamation-circle"></i>&nbspPlease verify your settings.',false,true,2000,true)
}
}
});
$("#menu_link_shutdown").click(function() {
var r = confirm("Are you sure you want to shutdown PlexPy?");
if (r == true) {
window.location.href = "shutdown";
}
});
$("#menu_link_restart").click(function() {
window.location.href = "restart";
});
$("#menu_link_update_check").click(function() {
window.location.href = "checkGithub";
});
if ($("#api_enabled").is(":checked")) {
$("#apioptions").show();
} else {
$("#apioptions").hide();
}
$("#api_enabled").click(function(){
if ($("#api_enabled").is(":checked")) {
$("#apioptions").slideDown();
} else {
$("#apioptions").slideUp();
}
});
$('#api_key').click(function(){ $('#api_key').select() });
$("#generate_api").click(function() {
$.get('generateAPI',
function(data){
if (data.error != undefined) {
alert(data.error);
return;
}
$('#api_key').val(data);
});
});
if ($("#enable_https").is(":checked")) {
$("#https_options").show();
} else {
$("#https_options").hide();
}
$("#enable_https").click(function(){
if ($("#enable_https").is(":checked")) {
$("#https_options").slideDown();
} else {
$("#https_options").slideUp();
}
});
$( ".pms-settings" ).change(function() {
$("#pms_identifier").val("");
$("#pms-verify-status").html("");
verifyServer();
});
function verifyServer() {
var pms_ip = $("#pms_ip").val()
var pms_port = $("#pms_port").val()
if (($("#pms_ip").val() !== '') || ($("#pms_port").val() !== '')) {
$("#pms-verify-status").html('<i class="fa fa-refresh fa-spin"></i> Verifying server...');
$('#pms-verify-status').fadeIn('fast');
$.ajax({
url: 'get_server_id',
data : { hostname: pms_ip, port: pms_port },
cache: true,
async: true,
timeout: 5000,
error: function(jqXHR, textStatus, errorThrown) {
$("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i> This is not a Plex Server!');
$('#pms-verify-status').fadeIn('fast');
},
success: function (xml) {
if ($(xml).find('MediaContainer').attr('machineIdentifier')) {
$("#pms_identifier").val($(xml).find('MediaContainer').attr('machineIdentifier'));
$("#pms-verify-status").html('<i class="fa fa-check"></i> Server verified!');
$('#pms-verify-status').fadeIn('fast');
} else {
$("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i> This is not a Plex Server!');
$('#pms-verify-status').fadeIn('fast');
}
}
});
} else {
$("#pms-verify-status").html('<i class="fa fa-exclamation-circle"></i> Please enter IP and port number.');
$('#pms-verify-status').fadeIn('fast');
}
}
// Plex.tv auth token fetch
$("#get-pms-auth-token").click(function() {
$("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i> Fetching token...');
if (($("#pms_username").val() !== '') || ($("#pms_password").val() !== '')) {
$.ajax({
type: "post",
url: "https://plex.tv/users/sign_in.xml",
dataType: 'xml',
async: true,
headers: {'Content-Type': 'application/xml; charset=utf-8',
'X-Plex-Device-Name': 'PlexPy',
'X-Plex-Product': 'PlexPy',
'X-Plex-Version': 'v0.1 dev',
'X-Plex-Client-Identifier': '${config['pms_uuid']}',
'Authorization': 'Basic ' + btoa($("#pms_username").val() + ':' + $("#pms_password").val())
},
error: function(jqXHR, textStatus, errorThrown) {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> Authentation failed!');
},
success: function (xml) {
var authToken = $(xml).find('user').attr('authenticationToken');
$("#pms-token-status").html('<i class="fa fa-check"></i> Authentation successful!');
$("#pms_token").val(authToken);
$('#pms-auth-modal').modal('hide');
}
});
} else {
$("#pms-token-status").html("You must enter both fields.");
}
});
// Load PlexWatch import modal
$("#toggle-plexwatch-import-modal").click(function() {
$.ajax({
url: 'plexwatch_import',
cache: false,
async: true,
complete: function(xhr, status) {
$("#plexwatch-import-modal").html(xhr.responseText);
}
});
});
// 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);
}
});
});
$('.notify-toggle-icon').tooltip();
$('.notify-toggle-icon').each(function() {
if ($(this).data('config-value') == 1) {
$(this).addClass("active");
}
});
$('.notify-toggle-icon').click(function() {
var configToggle = $(this).data('id');
var toggle = $(this);
if ($(this).hasClass("active")) {
var data = {};
data[$(this).data('config-name')] = 0;
$.ajax({
url: 'set_notification_config',
data: data,
async: true,
success: function(data) {
toggle.removeClass("active");
}
});
} else {
var data = {};
data[$(this).data('config-name')] = 1;
$.ajax({
url: 'set_notification_config',
data: data,
async: true,
success: function(data) {
toggle.addClass("active");
}
});
}
});
if ($("#tv_notify_enable").is(":checked"))
{
$("#tv_notify_options").show();
}
else
{
$("#tv_notify_options").hide();
}
$("#tv_notify_enable").click(function(){
if ($("#tv_notify_enable").is(":checked"))
{
$("#tv_notify_options").slideDown();
}
else
{
$("#tv_notify_options").slideUp();
}
});
if ($("#movie_notify_enable").is(":checked"))
{
$("#movie_notify_options").show();
}
else
{
$("#movie_notify_options").hide();
}
$("#movie_notify_enable").click(function(){
if ($("#movie_notify_enable").is(":checked"))
{
$("#movie_notify_options").slideDown();
}
else
{
$("#movie_notify_options").slideUp();
}
});
if ($("#music_notify_enable").is(":checked"))
{
$("#music_notify_options").show();
}
else
{
$("#music_notify_options").hide();
}
$("#music_notify_enable").click(function(){
if ($("#music_notify_enable").is(":checked"))
{
$("#music_notify_options").slideDown();
}
else
{
$("#music_notify_options").slideUp();
}
});
$('#osxnotifyregister').click(function () {
var osx_notify_app = $("#osx_notify_reg").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()
})
});
</script>
</%def>