mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
231 lines
12 KiB
HTML
231 lines
12 KiB
HTML
<%!
|
|
from plexpy import helpers
|
|
%>
|
|
% if data:
|
|
<div class="modal-dialog" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-remove"></i></button>
|
|
<h4 class="modal-title" id="notification-config-modal-header">${agent['name']} Settings</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<form action="set_notification_config" method="post" class="form" id="set_notification_config" data-parsley-validate>
|
|
<div class="col-md-12">
|
|
% for item in data:
|
|
% if item['input_type'] == 'help':
|
|
<div class="form-group">
|
|
<label>${item['label']}</label>
|
|
<p class="help-block">${item['description'] | n}</p>
|
|
</div>
|
|
% elif item['input_type'] == 'text' or item['input_type'] == 'number' or item['input_type'] == 'password':
|
|
<div class="form-group">
|
|
<label for="${item['name']}">${item['label']}</label>
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<input type="${item['input_type']}" class="form-control" id="${item['name']}" name="${item['name']}" value="${item['value']}" size="30">
|
|
% if item['name'] == 'osx_notify_app':
|
|
<a href="javascript:void(0)" id="osxnotifyregister">Register</a>
|
|
% endif
|
|
</div>
|
|
</div>
|
|
<p class="help-block">${item['description'] | n}</p>
|
|
</div>
|
|
% elif item['input_type'] == 'button':
|
|
<div class="form-group">
|
|
<label for="${item['name']}">${item['label']}</label>
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<input type="${item['input_type']}" class="btn btn-bright" id="${item['name']}" name="${item['name']}" value="${item['value']}">
|
|
</div>
|
|
</div>
|
|
<p class="help-block">${item['description'] | n}</p>
|
|
</div>
|
|
% elif item['input_type'] == 'checkbox':
|
|
<div class="checkbox">
|
|
<label>
|
|
<input type="checkbox" data-id="${item['name']}" class="checkboxes" value="1" ${helpers.checked(item['value'])}> ${item['label']}
|
|
</label>
|
|
<p class="help-block">${item['description'] | n}</p>
|
|
<input type="hidden" id="${item['name']}" name="${item['name']}" value="${item['value']}">
|
|
</div>
|
|
% elif item['input_type'] == 'select':
|
|
<div class="form-group">
|
|
<label for="${item['name']}">${item['label']}</label>
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<select class="form-control" id="${item['name']}" name="${item['name']}" >
|
|
% for key, value in sorted(item['select_options'].iteritems()):
|
|
% if key == item['value']:
|
|
<option value="${key}" selected>${value}</option>
|
|
% else:
|
|
<option value="${key}">${value}</option>
|
|
% endif
|
|
% endfor
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<p class="help-block">${item['description'] | n}</p>
|
|
</div>
|
|
% endif
|
|
% endfor
|
|
</div>
|
|
</form>
|
|
<div class="col-md-12" style="margin-top: 10px; padding-top: 10px; border-top: 1px solid #444;">
|
|
<h4>Test ${agent['name']}</h4>
|
|
<p class="help-block">Test if ${agent['name']} notifications are working. See <a href="/logs">logs</a> for troubleshooting.</p>
|
|
<div class="form-group">
|
|
<label for="test_subject">Subject Line</label>
|
|
<input class="form-control" type="text" id="test_subject" name="test_subject" value="PlexPy">
|
|
<p class="help-block">Set a custom subject line.</p>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="test_body">Message Body</label>
|
|
<input class="form-control" type="text" id="test_body" name="test_body" value="Test notification">
|
|
<p class="help-block">Set a custom body.</p>
|
|
</div>
|
|
%if agent['name'] == 'Scripts':
|
|
<div class="form-group">
|
|
<label for="test_script_action">Script action</label>
|
|
<select class="form-control" id="test_script_action" name="test_script_action">
|
|
<option value=""></option>
|
|
<option value="play">Playback start</option>
|
|
<option value="stop">Playback stop</option>
|
|
<option value="pause">Playback pause</option>
|
|
<option value="resume">Playback resume</option>
|
|
<option value="watched">Watched</option>
|
|
<option value="buffer">Buffer warnings</option>
|
|
<option value="created">Recently added</option>
|
|
<option value="extdown">Plex remote access down</option>
|
|
<option value="intdown">Plex server down</option>
|
|
<option value="extup">Plex remote access back up</option>
|
|
<option value="intup">Plex server back up</option>
|
|
</select>
|
|
<p class="help-block">Choose a notification action.</p>
|
|
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="test_script_args">Script args</label>
|
|
<input class="form-control" type="text" id="test_script_args" name="test_script_args" value="">
|
|
<p class="help-block">Set custom script arguments: -zomg --x.</p>
|
|
</div>
|
|
% endif
|
|
<div class="form-group">
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<input type="button" class="btn btn-bright" id="test_notifier" name="test_notifier" value="Test ${agent['name']}">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<%
|
|
nosave = any(d['input_type'] == 'nosave' for d in data)
|
|
%>
|
|
% if not nosave:
|
|
<input type="button" id="save-notification-item" class="btn btn-bright" value="Save">
|
|
% else:
|
|
<input type="button" class="btn btn-bright" data-dismiss="modal" value="Close">
|
|
% endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
% endif
|
|
|
|
<script>
|
|
|
|
function reloadModal() {
|
|
$.ajax({
|
|
url: 'get_notification_agent_config',
|
|
data: { config_id: '${agent["id"]}' },
|
|
cache: false,
|
|
async: true,
|
|
complete: function (xhr, status) {
|
|
$("#notification-config-modal").html(xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#osxnotifyregister').click(function () {
|
|
var osx_notify_app = $("#osx_notify_app").val();
|
|
$.get("/osxnotifyregister", { 'app': osx_notify_app }, function (data) { showMsg("<i class='fa fa-check'></i> " + data, false, true, 3000); });
|
|
})
|
|
|
|
$('#save-notification-item').click(function () {
|
|
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
|
// Reload modal to update certain fields
|
|
reloadModal();
|
|
return false;
|
|
});
|
|
|
|
function disableTwitterVerify() {
|
|
if ($('#twitter_key').val() != '') { $('#twitterStep2').prop('disabled', false); }
|
|
else { $('#twitterStep2').prop('disabled', true); }
|
|
}
|
|
disableTwitterVerify();
|
|
$('#twitter_key').on('change', function () {
|
|
disableTwitterVerify()
|
|
});
|
|
|
|
$('#twitterStep1').click(function () {
|
|
$.get("/twitterStep1", function (data) {window.open(data); })
|
|
.done(function () { showMsg("<i class='fa fa-check'></i> Confirm Authorization. Check pop-up blocker if no response.", false, true, 3000); });
|
|
});
|
|
$('#twitterStep2').click(function () {
|
|
var twitter_key = $("#twitter_key").val();
|
|
$.get("/twitterStep2", { 'key': twitter_key }, function (data) { showMsg("<i class='fa fa-check'></i> " + data, false, true, 3000); });
|
|
});
|
|
|
|
function disableFacebookRequest() {
|
|
if ($('#facebook_app_id').val() != '' && $('#facebook_app_secret').val() != '') { $('#facebookStep1').prop('disabled', false); }
|
|
else { $('#facebookStep1').prop('disabled', true); }
|
|
}
|
|
disableFacebookRequest();
|
|
$('#facebook_app_id, #facebook_app_secret').on('change', function () {
|
|
disableFacebookRequest()
|
|
});
|
|
|
|
$('#facebookStep1').click(function () {
|
|
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
|
$.get("/facebookStep1", function (data) {window.open(data); })
|
|
.done(function () { showMsg("<i class='fa fa-check'></i> Confirm Authorization. Check pop-up blocker if no response.", false, true, 3000); });
|
|
});
|
|
|
|
$('#test_notifier').click(function () {
|
|
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
|
$.ajax({
|
|
url: 'test_notifier',
|
|
data: { config_id: '${agent["id"]}',
|
|
subject: $('#test_subject').val(),
|
|
body: $('#test_body').val(),
|
|
notify_action: $('#test_script_action').val(),
|
|
script_args: $('#test_script_args').val() },
|
|
cache: false,
|
|
async: true,
|
|
complete: function (xhr, status) {
|
|
msg = '<i class="fa fa-check"></i> ' + xhr.responseText;
|
|
showMsg(msg, false, true, 2000);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#pushbullet_apikey, #pushover_apitoken, #scripts_folder').on('change', function () {
|
|
doAjaxCall('set_notification_config', $(this), 'tabs', true);
|
|
reloadModal();
|
|
return false;
|
|
});
|
|
|
|
// Never send checkbox values directly, always substitute value in hidden input.
|
|
$('.checkboxes').click(function () {
|
|
var configToggle = $(this).data('id');
|
|
if ($(this).is(":checked")) {
|
|
$("#"+configToggle).val(1);
|
|
} else {
|
|
$("#"+configToggle).val(0);
|
|
}
|
|
});
|
|
</script>
|