bazarr/views/movies.html

257 lines
12 KiB
HTML

{% extends '_main.html' %}
{% block title %}Movies - Bazarr{% endblock %}
{% block bcleft %}
<div class="">
<button class="btn btn-outline" id="mass_edit"
onclick="window.location.href = '{{ url_for('movieseditor') }}';">
<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>
</button>
</div>
{% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<table id="movies" class="table table-striped" style="width:100%">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Path Exist</th>
<th>Audio Language</th>
<th>Languages Profile</th>
<th>Missing Subtitles</th>
<th></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_movies_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 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">
Languages Profile
</div>
<div class="form-group col-sm-8 pl-sm-0">
<select class="selectpicker" id="edit_languages_select" name="languages"></select>
</div>
</div>
</div>
<input type="hidden" id="edit_radarrId" name="radarrId" value=""/>
</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>
<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 () {
getLanguagesProfiles();
events.on('event', function (event) {
var event_json = JSON.parse(event);
if (event_json.type === 'movie' && event_json.action === 'insert') {
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + event_json.movie,
success: function (data) {
if (data.data.length) {
$('#movies').DataTable().rows.add(data.data);
$('#movies').DataTable().columns.adjust().draw(false);
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
})
} else if (event_json.type === 'movie' && event_json.action === 'update') {
var rowId = $('#movies').DataTable().row('#row_' + event_json.movie);
if (rowId.length) {
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + event_json.movie,
success: function (data) {
if (data.data.length) {
$('#movies').DataTable().row(rowId).data(data.data[0]).draw('page');
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
})
}
} else if (event_json.type === 'movie' && event_json.action === 'delete') {
var rowId = $('#movies').DataTable().row('#row_' + event_json.movie);
if (rowId.length) {
$('#movies').DataTable().row(rowId).remove();
$('#movies').DataTable().columns.adjust().draw(false);
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
});
var table = $('#movies').DataTable({
dom:
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
processing: false,
serverSide: true,
searching: false,
ordering: false,
lengthChange: true,
responsive: true,
pageLength: {{ settings.general.page_size }},
ajax: "{{ url_for('api.movies') }}",
columns: [
{
data: "monitored",
render: function (data, type, row) {
if (data === 'False') {
return '<i class="far fa-bookmark" data-toggle="tooltip" data-placement="right" title="Movie unmonitored in Radarr"></i>';
} else if (data === 'True') {
return '<i class="fas fa-bookmark" data-toggle="tooltip" data-placement="right" title="Movie monitored in Radarr"></i>';
}
}
},
{
data: null,
render: function (data) {
if (data.sceneName) {
return '<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="right" title="' + data.sceneName + '"></i> ' + '<a href="' + "{{ url_for( 'movie', no='tempvalue' ) }}".replace("tempvalue", data.radarrId) + '">' + data.title + '</a>';
} else {
return '<a href="' + "{{ url_for( 'movie', no='tempvalue' ) }}".replace("tempvalue", data.radarrId) + '">' + data.title + '</a>';
}
}
},
{
data: null,
className: "dt-center",
render: function (data) {
if (data.exist === false) {
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>';
} else if (data.exist === true) {
return '<i class="fas fa-check" data-toggle="tooltip" data-placement="right" title="This path seems to be valid: ' + data.mapped_path + '"></i>';
}
}
},
{
data: 'audio_language',
render: function (data) {
var audio_languages = '';
data.forEach(appendFunc);
return audio_languages;
function appendFunc(value) {
audio_languages = audio_languages + '<span class="badge badge-secondary">' + value.name + '</span> ';
}
}
},
{
data: "profileId.name",
className: "dt-center"
},
{
data: "missing_subtitles",
render: function (data) {
if (data && 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: null,
render: function (data) {
return '<a href="" class="edit_button badge badge-secondary" data-radarrId=' + data.radarrId + ' 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>';
}
}
]
});
});
$('#movies').on('click', '.edit_button', function (e) {
e.preventDefault();
$("#edit_movies_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> ');
})
$('#edit_radarrId').val($(this).data('radarrid'));
$('#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>');
});
$("#edit_languages_select").selectpicker("refresh");
$('#edit_languages_select').selectpicker('val', (($(this).data('languages_profile')) ? $(this).data('languages_profile') : 'None'));
$('#editModal')
.modal({
focus: false
});
});
$('#edit_form').on('submit', function (e) {
e.preventDefault();
var formdata = new FormData(document.getElementById("edit_form"));
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + $('#edit_radarrId').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>');
},
success: function () {
$('#editModal').modal('hide');
$('#edit_save_button_span').html('Save');
}
});
});
function getLanguagesProfiles() {
$.ajax({
url: "{{ url_for('api.languagesprofiles') }}",
success: function (data) {
languagesProfiles = data['data'];
}
});
}
</script>
{% endblock tail %}