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/serieseditor.html

227 lines
9.2 KiB

5 years ago
{% extends '_main.html' %}
5 years ago
{% block title %}Series Editor - Bazarr{% endblock %}
5 years ago
{% block bcleft %}
5 years ago
<div id="buttons"></div>
5 years ago
{% 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>
5 years ago
<nav id="edit_bar" class="navbar fixed-bottom navbar-dark bg-dark">
5 years ago
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="languages_select">Language(s): </label>
5 years ago
<select class="selectpicker" id="languages_select" name="languages" title="No change" multiple></select>
5 years ago
</div>
</div>
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="hi_select">Hearing-Impaired: </label>
5 years ago
<select class="selectpicker show-tick" id="hi_select" name="hi" title="No change" multiple>
5 years ago
<option value="False">False</option>
<option value="True">True</option>
</select>
</div>
</div>
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="forced_select">Forced: </label>
5 years ago
<select class="selectpicker show-tick" id="forced_select" name="forced" title="No change" multiple>
5 years ago
<option value="False">False</option>
<option value="True">True</option>
<option value="Both">Both</option>
</select>
5 years ago
</div>
</div>
5 years ago
<div class="form-check form-check-inline">
5 years ago
<button type="submit" class="btn btn-info" id="save_button">Save</button>
5 years ago
</div>
</nav>
5 years ago
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
5 years ago
$('#series_nav').addClass("active");
5 years ago
getEnabledLanguages();
5 years ago
5 years ago
events.on('event', function (event) {
5 years ago
var event_json = JSON.parse(event);
if (event_json.type === 'series_editor' && event_json.action === 'update') {
5 years ago
$.ajax({
url: "{{ url_for('api.series') }}",
5 years ago
success: function (data) {
if (data.data.length) {
$('#series').DataTable().ajax.reload(resetPaging = false);
5 years ago
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
})
}
});
5 years ago
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'not-allowed');
5 years ago
var table = $('#series').DataTable({
5 years ago
processing: true,
serverSide: true,
5 years ago
language: {
zeroRecords: 'No Series Found',
processing: "Loading Series..."
},
5 years ago
searching: false,
ordering: false,
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'
5 years ago
},
5 years ago
columns: [
{defaultContent: ""},
{
data: null,
render: function (data) {
5 years ago
return '<a href="' + "{{ url_for( 'episodes', no='tempvalue' ) }}".replace("tempvalue", data.sonarrSeriesId) + '">' + data.title + '</a>'
5 years ago
}
},
5 years ago
{data: "audio_language.name"},
5 years ago
{
5 years ago
data: "languages",
render: function (data) {
5 years ago
if (data && data !== 'None') {
5 years ago
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> ';
}
}
},
5 years ago
{data: "hearing_impaired", className: "dt-center"},
{data: "forced", className: "dt-center"}
]
});
new $.fn.dataTable.Buttons(table, {
buttons: [
5 years ago
{
5 years ago
extend: 'selectAll',
text: '<div><i class="far fa-check-square align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>\n' +
' <div class="align-bottom text-themecolor small text-center">Select ALL</div>'
5 years ago
},
{
5 years ago
extend: 'selectNone',
text: '<div><i class="far fa-square align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>\n' +
' <div class="align-bottom text-themecolor small text-center nowrap">Deselect ALL</div>'
}]
5 years ago
});
table.buttons().container().appendTo('#buttons');
5 years ago
var btns = $('.dt-button');
btns.addClass('btn btn-outline');
btns.removeClass('dt-button');
table.on('select', function () {
5 years ago
$('.selectpicker').prop('disabled', false);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', false);
$('#save_button').removeClass('disabled');
$('#save_button').css('cursor', 'auto');
5 years ago
});
5 years ago
5 years ago
table.on('deselect', function () {
if (table.rows('.selected').count() === 0) {
5 years ago
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'not-allowed');
}
5 years ago
});
5 years ago
5 years ago
if ('{{settings.general.single_language}}' === 'True') {
$('#languages_select').selectpicker({maxOptions: 1});
}
$('#hi_select').selectpicker({maxOptions: 1});
$('#forced_select').selectpicker({maxOptions: 1});
5 years ago
$('#save_button').on('click', function (e) {
5 years ago
e.preventDefault();
const values = {
5 years ago
seriesid: table.rows({selected: true}).ids().toArray(),
5 years ago
languages: $('#languages_select').val(),
hi: $('#hi_select').val(),
forced: $('#forced_select').val()
};
$.ajax({
url: "{{ url_for('api.serieseditsave') }}",
method: "POST",
5 years ago
data: values,
beforeSend: function () {
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'wait');
},
5 years ago
success: function () {
5 years ago
table.rows().deselect();
$('#languages_select').selectpicker('val', '');
$('#hi_select').selectpicker('val', '');
$('#forced_select').selectpicker('val', '');
}
});
5 years ago
});
5 years ago
});
5 years ago
function getEnabledLanguages() {
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=true",
5 years ago
success: function (data) {
5 years ago
$('#languages_select').append('<option value="None">None</option>');
5 years ago
$.each(data, function (i, item) {
5 years ago
$('#languages_select').append('<option value="' + item.code2 + '">' + item.name + '</option>');
5 years ago
});
$("#languages_select").selectpicker("refresh");
5 years ago
}
});
}
</script>
{% endblock tail %}