Add scripts

This commit is contained in:
Hellowlol 2015-12-12 01:32:18 +01:00
commit 9328b7e586
6 changed files with 293 additions and 145 deletions

View file

@ -48,7 +48,7 @@ from plexpy import helpers
<div class="form-group">
<label for="${item['name']}">${item['label']}</label>
<div class="row">
<div class="col-md-5">
<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']:
@ -79,6 +79,41 @@ from plexpy import helpers
<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">Script path</label>
<select class="form-control" id="test_script" name="test_script" >
% for key, value in sorted(data[1]['select_options'].iteritems()):
<option value="${key}">${value}</option>
% endfor
</select>
<p class="help-block">Pick your script</p>
</div>
<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="buffer">Buffer warning</option>
<option value="watched">Watched</option>
<option value="play">Playback start</option>
<option value="pause">Playback stopp</option>
<option value="resume">Playback resume</option>
<option value="stop">Playback stop</option>
<option value="extdown">Plex Server Remote Down</option>
<option value="extup">Plex Server Remote Up</option>
<option value="intdown">Plex Server Down</option>
<option value="intup">Plex Server Up</option>
<option value="created">Recently added</option>
</select>
<p class="help-block">Pick your 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 a custom script args: -zomg --x.</p>
</div>
% endif
<div class="form-group">
<div class="row">
<div class="col-md-8">
@ -148,7 +183,10 @@ from plexpy import helpers
url: 'test_notifier',
data: { config_id: '${agent["id"]}',
subject: $('#test_subject').val(),
body: $('#test_body').val() },
body: $('#test_body').val(),
notify_action: $('#test_script_action').val(),
script: $('#test_script').val(),
script_args: $('#test_script_args').val() },
cache: false,
async: true,
complete: function (xhr, status) {
@ -164,6 +202,12 @@ from plexpy import helpers
return false;
});
$('#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');

View file

@ -758,7 +758,7 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<li>
<div class="form-group">
<label for="notify_scripts_args_text">Script arguments</label>
<input class="form-control" type="text" id="notify_scripts_args_text" name="notify_scripts_args_text" value="${config['notify_scripts_args_text']}" data-parsley-trigger="change" required>
<input class="form-control" type="text" id="notify_scripts_args_text" name="notify_scripts_args_text" value="${config['notify_scripts_args_text']}" data-parsley-trigger="change">
<p class="help-block">Set arguments passed to the script</p>
</div>
@ -767,7 +767,6 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
</li>
</ul>
<p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p>
</div>
<div role="tabpanel" class="tab-pane" id="tabs-10">
@ -1127,6 +1126,14 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
<td><strong>{transcode_audio_channels}</strong></td>
<td>The audio channels of the transcoded media.</td>
</tr>
<tr>
<td><strong>{streams}</strong></td>
<td>The number of concurrent streams.</td>
</tr>
<tr>
<td><strong>{action}</strong></td>
<td>The action that trigged the notification.</td>
</tr>
</tbody>
</table>
<table class="notification-params">