You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/views/settingsnotifications.html

265 lines
11 KiB

5 years ago
{% extends '_main.html' %}
{% block title %}Notifications - Bazarr{% endblock %}
{% block page_head %}
{% endblock page_head %}
{% block bcleft %}
<div id="buttons" class="">
<button class="btn btn-outline" id="save_button">
<div>
<span class="fa-stack">
<i class="fas fa-save fa-stack-2x align-top text-themecolor text-center font-20" aria-hidden="true"></i>
<i id="save_button_checkmark" class="fas fa-check fa-stack-2x" style="color:green;"></i>
</span>
</div>
<div class="align-bottom text-themecolor small text-center">Save</div>
</button>
5 years ago
</div>
5 years ago
{% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<div class="container-fluid" style="padding-top: 3em;">
<form class="form" name="settings_form" id="settings_form">
<div class="alert alert-secondary" role="alert">
<p>Thanks to caronc for his work on <a href="https://github.com/caronc/apprise" target="_blank">apprise</a>, the core of the Bazarr notification system.</p>
5 years ago
</div>
<div class="alert alert-secondary" role="alert">
<p>Please follow instructions on his <a href="https://github.com/caronc/apprise/wiki" target="_blank">Wiki</a> to configure your notification providers.</p>
</div><br>
<h4>Notifications</h4>
<hr/>
<div class="row">
<div class="col-sm-12">
<table class="table table-striped" id="notification_providers" style="width:100%;">
<thead>
<tr>
<th>Name</th>
<th>Enabled</th>
<th>URL</th>
</tr>
</thead>
</table>
5 years ago
</div>
5 years ago
</div>
<br>
<h4>Options</h4>
<hr/>
<div class="row">
<div class="col-sm-3 text-right">
<b>Do not notify for manual actions</b>
</div>
<div class="form-group col-sm-8">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-general-dont_notify_manual_actions"
name="settings-general-dont_notify_manual_actions">
<span class="custom-control-label" for="settings-general-dont_notify_manual_actions"></span>
</label>
<label>Suppress notifications when manually download/upload subtitles.</label>
</div>
</div>
5 years ago
</form>
</div>
<div id="editModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit Notification Provider</h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
5 years ago
</div>
5 years ago
<form class="form" name="edit_form" id="edit_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 text-right">
Name
</div>
<div class="col-sm-8">
<span id="notification_provider_name" value=""></span>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Enabled
</div>
<div class="form-group col-sm-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input provider" id="notification_provider_enabled">
<span class="custom-control-label"></span>
</label>
</div>
</div>
<div class="row">
<div class="col-sm-3 text-right">
URL
</div>
<div class="col-sm-8">
<textarea rows=4 class="form-control" id="notification_provider_url" value=""></textarea>
</div>
5 years ago
</div>
</div>
</div>
5 years ago
<div class="modal-footer">
5 years ago
<button type="button" id="test_button" class="btn btn-secondary">Test</button>
5 years ago
<button type="submit" id="edit_save_button" class="btn btn-info">Ok</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
5 years ago
</div>
5 years ago
</div>
5 years ago
</div>
5 years ago
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
// Show warning if there's unsaved changes in the settings_form
var form_changed = false;
$(window).on('beforeunload', function() {
if (form_changed) {
return "";
}
});
// Hide checkmark over save button
$('#save_button_checkmark').hide();
5 years ago
$('#save_button').prop('disabled', true).css('cursor', 'not-allowed');
5 years ago
// Set Checkbox input values
$('#settings-general-dont_notify_manual_actions').prop('checked', {{'true' if settings.general.getboolean('dont_notify_manual_actions') else 'false'}});
5 years ago
var table = $('#notification_providers').DataTable({
select: {
style: 'single'
},
language: {
zeroRecords: 'No Notification Providers'
},
searching: false,
ordering: false,
lengthChange: true,
5 years ago
responsive: true,
5 years ago
paging: false,
info: false,
processing: true,
serverSide: false,
ajax: {
url: "{{ url_for('api.notifications') }}",
type: 'GET'
},
columns: [
{ data: 'name' },
{ data: 'enabled',
render: function(data) {
if (data) {
return 'True';
} else {
return 'False';
}
}
},
{ data: 'url' }
5 years ago
],
"columnDefs": [
{
"targets": [ 2 ],
"visible": false,
"searchable": false
}
5 years ago
]
});
new $.fn.dataTable.Buttons(table, {
buttons: [
{
extend: 'selected',
text: '<div><span class="fa-stack"><i class="fas fa-edit align-top text-themecolor ' +
'text-center font-20" aria-hidden="true"></i></span></div><div class="align-bottom ' +
'text-themecolor small text-center">Edit</div>',
action: function () {
$('#notification_provider_name').text(table.row( { selected: true } ).data().name);
$('#notification_provider_enabled').prop('checked', table.row( { selected: true } ).data().enabled).trigger('change');
$('#notification_provider_url').val(table.row( { selected: true } ).data().url);
$('#editModal').modal('show');
}
}]
});
table.buttons().container().insertAfter('#save_button');
$('.dt-button').parent().addClass('btn btn-outline').removeClass('dt-buttons');
$('.dt-button').addClass('btn btn-outline').removeClass('dt-button');
$('#edit_save_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).data({name:$('#notification_provider_name').text(), enabled:$('#notification_provider_enabled').prop('checked'), url:$('#notification_provider_url').val()});
$('#settings_form').trigger('change');
$('#editModal').modal('hide');
});
$('#save_button').on('click', function() {
var formdata = new FormData(document.getElementById("settings_form"));
// Make sure all checkbox input are sent with true/false value
$('input[type=checkbox]').each(function () {
formdata.set($(this).prop('id'), $(this).prop('checked'));
});
5 years ago
formdata.append('notification_providers', JSON.stringify(table.rows().data().toArray()));
$.ajax({
url: "{{ url_for('api.notifications') }}",
data: formdata,
processData: false,
contentType: false,
type: 'POST',
complete: function () {
$('#save_button_checkmark').show();
form_changed = false;
5 years ago
$('#save_button').prop('disabled', true).css('cursor', 'not-allowed');
5 years ago
setTimeout(
function()
{
$('#save_button_checkmark').hide();
}, 2000);
}
});
});
5 years ago
$('#test_button').on('click', function() {
const url_field = $('#notification_provider_url').val();
const url_protocol = url_field.split(':')[0];
const url_string = url_field.split('://')[1];
$.ajax({
url: "{{ url_for('test_notification') }}/" + url_protocol + "/" + encodeURIComponent(url_string),
beforeSend: function () {
$('#loader').addClass('active');
},
complete: function () {
$('#loader').removeClass('active');
},
cache: false
});
});
5 years ago
// monitor changes to the settings_form
$('#settings_form').on('change', function() {
form_changed = true;
5 years ago
$('#save_button').prop('disabled', false).css('cursor', 'auto');
5 years ago
})
5 years ago
});
5 years ago
</script>
{% endblock tail %}