2020-01-27 05:07:35 +00:00
|
|
|
{% extends '_main.html' %}
|
|
|
|
|
|
|
|
{% block title %}Series - Bazarr{% endblock %}
|
|
|
|
|
|
|
|
{% block bcleft %}
|
|
|
|
<div id="buttons"></div>
|
|
|
|
{% endblock bcleft %}
|
|
|
|
|
|
|
|
{% block bcright %}
|
|
|
|
|
|
|
|
{% endblock bcright %}
|
|
|
|
|
|
|
|
{% block body %}
|
|
|
|
<table id="series" class="table table-striped" style="width:100%">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th></th>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Audio Language</th>
|
|
|
|
<th>Subtitles Languages</th>
|
|
|
|
<th>Hearing-Impaired</th>
|
|
|
|
<th>Forced</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<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"><span id="edit_series_title_span"></span></h5><br>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<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">
|
|
|
|
Audio Language
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-sm-8 pl-sm-0">
|
|
|
|
<span id="edit_audio_language_span"></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-3 text-right">
|
|
|
|
Subtitles Language(s)
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-sm-8 pl-sm-0">
|
|
|
|
<select class="selectpicker" id="edit_languages_select" name="languages" multiple data-live-search="true"></select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-3 text-right">
|
|
|
|
Hearing-Impaired
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-sm-1 pl-sm-0">
|
|
|
|
<label class="custom-control custom-checkbox">
|
|
|
|
<input type="checkbox" class="custom-control-input" id="hi_checkbox" name="hi">
|
|
|
|
<span class="custom-control-label" for="hi_checkbox"></span>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-sm-3 text-right">
|
|
|
|
Forced
|
|
|
|
</div>
|
|
|
|
<div class="form-group col-sm-8 pl-sm-0">
|
|
|
|
<select class="selectpicker" id="edit_forced_select" name="forced">
|
|
|
|
<option value="False">False</option>
|
|
|
|
<option value="True">True</option>
|
|
|
|
<option value="Both">Both</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<input type="hidden" id="edit_sonarrSeriesId" name="sonarrSeriesId" value="" />
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="submit" id="edit_save_button" class="btn btn-primary">Save</button>
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{% endblock body %}
|
|
|
|
|
|
|
|
{% block tail %}
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
getLanguages();
|
|
|
|
getEnabledLanguages();
|
|
|
|
|
|
|
|
events.on('event', function(event) {
|
|
|
|
var event_json = JSON.parse(event);
|
|
|
|
if (event_json.type === 'series' && event_json.action === 'insert') {
|
|
|
|
$.ajax({
|
|
|
|
url: "{{ url_for('api.series') }}?seriesid=" + event_json.series,
|
|
|
|
success: function (data) {
|
|
|
|
if (data.data.length) {
|
|
|
|
$('#series').DataTable().rows.add(data.data);
|
|
|
|
$('#series').DataTable().columns.adjust().draw(false);
|
|
|
|
$('[data-toggle="tooltip"]').tooltip({html: true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else if (event_json.type === 'series' && event_json.action === 'update') {
|
|
|
|
var rowId = $('#series').DataTable().row('#row_' + event_json.series);
|
|
|
|
if (rowId.length) {
|
|
|
|
$.ajax({
|
|
|
|
url: "{{ url_for('api.series') }}?seriesid=" + event_json.series,
|
|
|
|
success: function (data) {
|
|
|
|
if (data.data.length) {
|
|
|
|
$('#series').DataTable().row(rowId).data(data.data[0]);
|
|
|
|
$('[data-toggle="tooltip"]').tooltip({html: true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
} else if (event_json.type === 'series' && event_json.action === 'delete') {
|
|
|
|
var rowId = $('#series').DataTable().row('#row_' + event_json.series);
|
|
|
|
if (rowId.length) {
|
|
|
|
$('#series').DataTable().row(rowId).remove();
|
|
|
|
$('#series').DataTable().columns.adjust().draw(false);
|
|
|
|
$('[data-toggle="tooltip"]').tooltip({html: true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var table = $('#series').DataTable({
|
|
|
|
"processing": true,
|
|
|
|
"serverSide": true,
|
|
|
|
"searching": false,
|
2020-01-27 17:52:05 +00:00
|
|
|
"ordering": false,
|
2020-01-27 05:07:35 +00:00
|
|
|
"lengthChange": true,
|
|
|
|
"responsive": true,
|
|
|
|
"paging": false,
|
|
|
|
"ajax": "{{ url_for('api.series') }}",
|
|
|
|
"columnDefs": [ {
|
|
|
|
"orderable": false,
|
|
|
|
"className": 'select-checkbox',
|
|
|
|
"targets": 0
|
|
|
|
} ],
|
|
|
|
"select": {
|
|
|
|
"style": 'multi',
|
|
|
|
"selector": 'td:first-child'
|
|
|
|
},
|
|
|
|
"columns": [
|
|
|
|
{"defaultContent": ""},
|
|
|
|
{"data": null,
|
|
|
|
"render": function (data) {
|
|
|
|
return '<a href="{{ url_for( 'episodes' ) }}' + data.sonarrSeriesId + '">' + data.title + '</a>'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{"data": "audio_language.name"},
|
|
|
|
{
|
|
|
|
"data": "languages",
|
|
|
|
"render": function (data) {
|
|
|
|
if (data !== 'None') {
|
|
|
|
var languages = '';
|
|
|
|
data.forEach(appendFunc);
|
|
|
|
return languages;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function appendFunc(value) {
|
|
|
|
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "hearing_impaired",
|
|
|
|
"className": "dt-center"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": "forced",
|
|
|
|
"className": "dt-center"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new $.fn.dataTable.Buttons( table, {
|
|
|
|
"buttons": [
|
|
|
|
'selectAll',
|
|
|
|
'selectNone'
|
|
|
|
]
|
|
|
|
} );
|
|
|
|
|
|
|
|
table.buttons().container().appendTo('#buttons');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#series').on('click', '.edit_button', function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
$("#edit_series_title_span").html($(this).data('title'));
|
|
|
|
$("#edit_audio_language_span").html($(this).data('audiolanguage'));
|
|
|
|
$('#edit_sonarrSeriesId').val($(this).data('sonarrseriesid'));
|
|
|
|
|
|
|
|
|
|
|
|
$('#edit_languages_select').empty();
|
|
|
|
if ('{{settings.general.single_language}}' === 'True') {
|
|
|
|
$('#edit_languages_select').selectpicker({maxOptions: 1});
|
2018-01-07 21:49:50 +00:00
|
|
|
}
|
2020-01-27 05:07:35 +00:00
|
|
|
$.each(enabledLanguages, function (i, item) {
|
|
|
|
$('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
|
|
|
|
});
|
|
|
|
$("#edit_languages_select").selectpicker("refresh");
|
|
|
|
var selected_languages = Array();
|
|
|
|
$.each(Array.from($(this).data('languages')), function (i, item) {
|
|
|
|
selected_languages.push(item.code2);
|
|
|
|
});
|
|
|
|
$('#edit_languages_select').selectpicker('val', selected_languages);
|
|
|
|
$('#hi_checkbox').prop('checked', ($(this).data('hi') === 'True'));
|
|
|
|
$('#edit_forced_select').val($(this).data('forced')).change();
|
|
|
|
|
|
|
|
$('#editModal')
|
|
|
|
.modal({
|
|
|
|
focus: false
|
|
|
|
});
|
2018-12-09 20:23:51 +00:00
|
|
|
});
|
2018-01-07 17:29:11 +00:00
|
|
|
|
2020-01-27 05:07:35 +00:00
|
|
|
$('#edit_form').on('submit', function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
var formdata = new FormData(document.getElementById("edit_form"));
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: "{{ url_for('api.series') }}?seriesid=" + $('#edit_sonarrSeriesId').val(),
|
|
|
|
data: formdata,
|
|
|
|
processData: false,
|
|
|
|
contentType: false,
|
|
|
|
type: 'POST',
|
|
|
|
success: function(){
|
|
|
|
//seriesDetailsRefresh();
|
|
|
|
$('#editModal').modal('hide');
|
|
|
|
}
|
|
|
|
});
|
2018-01-07 17:29:11 +00:00
|
|
|
});
|
2020-01-27 05:07:35 +00:00
|
|
|
|
|
|
|
function getLanguages() {
|
|
|
|
$.ajax({
|
|
|
|
url: "{{ url_for('api.languages') }}?enabled=false",
|
|
|
|
success:function(data) {
|
|
|
|
availableLanguages = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEnabledLanguages() {
|
|
|
|
$.ajax({
|
|
|
|
url: "{{ url_for('api.languages') }}?enabled=true",
|
|
|
|
success:function(data) {
|
|
|
|
enabledLanguages = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{% endblock tail %}
|