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

248 lines
11 KiB

{% extends '_main.html' %}
{% block title %}Series - Bazarr{% endblock %}
5 years ago
{% block bcleft %}
5 years ago
<div class="">
5 years ago
<button class="btn btn-outline" id="mass_edit"
onclick="window.location.href = '{{ url_for('serieseditor') }}';">
5 years ago
<div><i class="fas fa-list align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Mass Edit</div>
5 years ago
</button>
</div>
{% endblock bcleft %}
5 years ago
{% block bcright %}
5 years ago
5 years ago
{% endblock bcright %}
5 years ago
{% block body %}
5 years ago
<table id="series" class="table table-striped" style="width:100%">
<thead>
5 years ago
<tr>
<th>Name</th>
<th>Path Exist</th>
<th>Audio Profile Languages</th>
<th>Languages Profile</th>
5 years ago
<th>Subtitles</th>
<th></th>
</tr>
5 years ago
</thead>
</table>
5 years ago
<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">&times;</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 Profile Languages
5 years ago
</div>
<div class="form-group col-sm-8 pl-sm-0">
<span id="edit_audio_language_span"></span>
</div>
</div>
<br>
5 years ago
<div class="row">
<div class="col-sm-3 text-right">
Languages Profile
5 years ago
</div>
<div class="form-group col-sm-8 pl-sm-0">
<select class="selectpicker" id="edit_languages_select" name="languages"></select>
5 years ago
</div>
</div>
</div>
5 years ago
<input type="hidden" id="edit_sonarrSeriesId" name="sonarrSeriesId" value=""/>
5 years ago
</div>
<div class="modal-footer">
<button type="submit" id="edit_save_button" class="btn btn-info"><span id="edit_save_button_span">Save</span></button>
5 years ago
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
{% endblock body %}
5 years ago
{% block tail %}
5 years ago
<script>
$(document).ready(function () {
getLanguagesProfiles();
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' && 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) {
5 years ago
$('#series').DataTable().row(rowId).data(data.data[0]).draw('page');
5 years ago
$('[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});
}
}
});
5 years ago
var table = $('#series').DataTable({
5 years ago
dom:
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
processing: true,
serverSide: true,
5 years ago
language: {
zeroRecords: 'No Series Found',
processing: "Loading Series..."
},
5 years ago
searching: false,
ordering: false,
lengthChange: false,
responsive: true,
pageLength: {{ settings.general.page_size }},
ajax: "{{ url_for('api.series') }}",
columns: [
{
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
{
5 years ago
data: null,
className: "dt-center",
responsivePriority: 1,
render: function (data) {
5 years ago
if (data.exist === false) {
5 years ago
return '<i class="fas fa-exclamation-triangle" data-toggle="tooltip" data-placement="right" title="This path doesn\'t seem to be valid: ' + data.mapped_path + '"></i>';
5 years ago
} else if (data.exist === true) {
5 years ago
return '<i class="fas fa-check" data-toggle="tooltip" data-placement="right" title="This path seems to be valid: ' + data.mapped_path + '"></i>';
5 years ago
}
}
},
{
data: 'audio_language',
5 years ago
render: function (data) {
var audio_languages = '';
data.forEach(appendFunc);
return audio_languages;
5 years ago
5 years ago
function appendFunc(value) {
audio_languages = audio_languages + '<span class="badge badge-secondary">' + value.name + '</span> ';
5 years ago
}
}
},
5 years ago
{
data: "profileId.name",
5 years ago
className: "dt-center"
5 years ago
},
5 years ago
{
5 years ago
data: null,
responsivePriority: 2,
render: function (data) {
5 years ago
var total = data.episodeFileCount;
var completed = data.episodeFileCount - data.episodeMissingCount;
var completed_style = '';
var completed_text = '';
if (data.episodeFileCount && data.profileId.id !== null) {
5 years ago
completed_style = ' style="width: ' + completed / total * 100 + '%;"';
completed_text = completed + '/' + total;
}
return '<div class="progress"><div class="progress-bar" role="progressbar"' + completed_style + ' aria-valuenow="' + completed + '" aria-valuemin="0" aria-valuemax="' + total + '">' + completed_text + '</div></div>'
}
5 years ago
},
{
5 years ago
data: null,
render: function (data) {
return '<a href="" class="edit_button badge badge-secondary" data-sonarrSeriesId=' + data.sonarrSeriesId + ' data-audiolanguage=\'' + JSON.stringify(data.audio_language) + '\' data-title="' + data.title + '" data-languages_profile=' + data.profileId.id + ' data-hi="' + data.hearing_impaired + '" data-forced="' + data.forced + '"><i class="fas fa-wrench"></i></a>';
5 years ago
}
5 years ago
}
]
});
});
5 years ago
5 years ago
$('#series').on('click', '.edit_button', function (e) {
e.preventDefault();
$("#edit_series_title_span").html($(this).data('title'));
$("#edit_audio_language_span").empty();
$.each($(this).data('audiolanguage'), function (i, item) {
$("#edit_audio_language_span").append('<div class="badge badge-secondary">' + item['name'] + '</div> ');
})
5 years ago
$('#edit_sonarrSeriesId').val($(this).data('sonarrseriesid'));
5 years ago
5 years ago
$('#edit_languages_select').empty();
$('#edit_languages_select').append('<option value="None">None</option>');
$.each(languagesProfiles, function (i, item) {
$('#edit_languages_select').append('<option value="' + item.profileId + '">' + item.name + '</option>');
5 years ago
});
$("#edit_languages_select").selectpicker("refresh");
$('#edit_languages_select').selectpicker('val', (($(this).data('languages_profile')) ? $(this).data('languages_profile') : 'None'));
5 years ago
5 years ago
$('#editModal')
.modal({
focus: false
});
});
5 years ago
5 years ago
$('#edit_form').on('submit', function (e) {
e.preventDefault();
var formdata = new FormData(document.getElementById("edit_form"));
5 years ago
5 years ago
$.ajax({
url: "{{ url_for('api.series') }}?seriesid=" + $('#edit_sonarrSeriesId').val(),
data: formdata,
processData: false,
contentType: false,
type: 'POST',
beforeSend: function () {
$('#edit_save_button_span').html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
},
5 years ago
success: function () {
$('#editModal').modal('hide');
$('#edit_save_button_span').html('Save');
5 years ago
}
});
});
5 years ago
function getLanguagesProfiles() {
5 years ago
$.ajax({
url: "{{ url_for('api.languagesprofiles') }}",
5 years ago
success: function (data) {
languagesProfiles = data['data'];
5 years ago
}
});
}
5 years ago
</script>
{% endblock tail %}