bazarr/views/movies.html

289 lines
13 KiB
HTML
Raw Normal View History

2019-12-28 05:52:00 +00:00
{% extends '_main.html' %}
{% block title %}Movies - Bazarr{% endblock %}
2020-01-01 22:15:50 +00:00
{% block bcleft %}
2020-02-05 03:50:35 +00:00
<div class="">
2020-02-13 09:12:23 +00:00
<button class="btn btn-outline" id="mass_edit"
onclick="window.location.href = '{{ url_for('movieseditor') }}';">
2020-02-05 03:50:35 +00:00
<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>
2020-01-01 22:15:50 +00:00
</button>
</div>
{% endblock bcleft %}
2019-12-28 05:52:00 +00:00
2020-01-01 22:15:50 +00:00
{% block bcright %}
2020-02-05 03:50:35 +00:00
2020-01-01 22:15:50 +00:00
{% endblock bcright %}
2019-12-28 05:52:00 +00:00
{% block body %}
2020-01-01 22:15:50 +00:00
<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>Subtitles Languages</th>
<th>Hearing-Impaired</th>
<th>Forced</th>
2020-02-04 17:57:37 +00:00
<th></th>
2020-01-01 22:15:50 +00:00
</tr>
</thead>
</table>
2020-02-04 17:57:37 +00:00
<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">
Subtitles Language(s)
</div>
<div class="form-group col-sm-8 pl-sm-0">
2020-02-13 09:12:23 +00:00
<select class="selectpicker" id="edit_languages_select" name="languages" multiple
data-live-search="true"></select>
2020-02-04 17:57:37 +00:00
</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>
2020-02-13 09:12:23 +00:00
<input type="hidden" id="edit_radarrId" name="radarrId" value=""/>
2020-02-04 17:57:37 +00:00
</div>
<div class="modal-footer">
2020-02-12 21:51:31 +00:00
<button type="submit" id="edit_save_button" class="btn btn-info">Save</button>
2020-02-04 17:57:37 +00:00
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
2019-12-28 05:52:00 +00:00
{% endblock body %}
{% block tail %}
2019-12-29 10:56:34 +00:00
<script>
$(document).ready(function () {
2020-02-04 17:57:37 +00:00
getLanguages();
2020-02-13 09:12:23 +00:00
getEnabledLanguages();
2020-02-04 17:57:37 +00:00
2020-02-13 09:12:23 +00:00
events.on('event', function (event) {
2020-02-04 17:57:37 +00:00
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) {
2020-02-12 17:41:40 +00:00
$('#movies').DataTable().row(rowId).data(data.data[0]).draw('page');
2020-02-04 17:57:37 +00:00
$('[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});
}
}
});
2019-12-29 10:56:34 +00:00
var table = $('#movies').DataTable({
2020-02-13 09:12:23 +00:00
dom:
2020-01-01 22:15:50 +00:00
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
2020-02-13 09:12:23 +00:00
processing: false,
serverSide: true,
searching: false,
ordering: false,
lengthChange: true,
responsive: true,
pageLength: {{ settings.general.page_size }},
ajax: "{{ url_for('api.movies') }}",
columns: [
2019-12-29 10:56:34 +00:00
{
2020-02-13 09:12:23 +00:00
data: "monitored",
render: function (data, type, row) {
2019-12-29 10:56:34 +00:00
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>';
}
}
},
{
2020-02-13 09:12:23 +00:00
data: null,
render: function (data) {
2019-12-29 10:56:34 +00:00
if (data.sceneName) {
2020-02-05 03:50:35 +00:00
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>';
2019-12-29 10:56:34 +00:00
} else {
2020-02-05 03:50:35 +00:00
return '<a href="' + "{{ url_for( 'movie', no='tempvalue' ) }}".replace("tempvalue", data.radarrId) + '">' + data.title + '</a>';
2019-12-29 10:56:34 +00:00
}
}
},
{
2020-02-13 09:12:23 +00:00
data: null,
className: "dt-center",
render: function (data) {
2019-12-29 16:29:07 +00:00
if (data.exist === false) {
2020-01-01 22:15:50 +00:00
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>';
2019-12-29 16:29:07 +00:00
} else if (data.exist === true) {
2020-01-01 22:15:50 +00:00
return '<i class="fas fa-check" data-toggle="tooltip" data-placement="right" title="This path seems to be valid: ' + data.mapped_path + '"></i>';
2019-12-29 10:56:34 +00:00
}
}
},
2020-02-13 09:12:23 +00:00
{data: "audio_language.name"},
2019-12-29 10:56:34 +00:00
{
2020-02-13 09:12:23 +00:00
data: "languages",
render: function (data) {
2020-03-24 18:29:16 +00:00
if (data && data !== 'None') {
2019-12-29 10:56:34 +00:00
var languages = '';
data.forEach(appendFunc);
return languages;
} else {
return null
}
2019-12-29 04:39:13 +00:00
2019-12-29 10:56:34 +00:00
function appendFunc(value) {
languages = languages + '<span class="badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + '">' + value.code2 + '</span> ';
}
}
},
2020-01-01 22:15:50 +00:00
{
2020-02-13 09:12:23 +00:00
data: "hearing_impaired",
className: "dt-center"
2019-12-29 16:29:07 +00:00
},
2020-01-01 22:15:50 +00:00
{
2020-02-13 09:12:23 +00:00
data: "forced",
className: "dt-center"
2020-02-04 17:57:37 +00:00
},
{
2020-02-13 09:12:23 +00:00
data: null,
render: function (data) {
return '<a href="" class="edit_button badge badge-secondary" data-radarrId=' + data.radarrId + ' data-audiolanguage="' + data.audio_language.name + '" data-title="' + data.title + '" data-languages=' + JSON.stringify(data.languages) + ' data-hi="' + data.hearing_impaired + '" data-forced="' + data.forced + '"><i class="fas fa-wrench"></i></a>';
2019-12-29 16:29:07 +00:00
}
}
2019-12-29 10:56:34 +00:00
]
});
});
2020-02-04 17:57:37 +00:00
2020-02-13 09:12:23 +00:00
$('#movies').on('click', '.edit_button', function (e) {
e.preventDefault();
$("#edit_movies_title_span").html($(this).data('title'));
$("#edit_audio_language_span").html($(this).data('audiolanguage'));
$('#edit_radarrId').val($(this).data('radarrid'));
2020-02-04 17:57:37 +00:00
2020-02-13 09:12:23 +00:00
$('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
}
if ('{{settings.general.single_language}}' === 'True') {
2020-02-04 17:57:37 +00:00
$('#edit_languages_select').append('<option value="None">None</option>');
}
$.each(enabledLanguages, function (i, item) {
2020-02-13 09:12:23 +00:00
$('#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();
2020-02-04 17:57:37 +00:00
2020-02-13 09:12:23 +00:00
$('#editModal')
.modal({
focus: false
});
});
2020-02-04 17:57:37 +00:00
2020-02-13 09:12:23 +00:00
$('#edit_form').on('submit', function (e) {
e.preventDefault();
var formdata = new FormData(document.getElementById("edit_form"));
2020-02-04 17:57:37 +00:00
2020-02-13 09:12:23 +00:00
$.ajax({
url: "{{ url_for('api.movies') }}?radarrid=" + $('#edit_radarrId').val(),
data: formdata,
processData: false,
contentType: false,
type: 'POST',
success: function () {
$('#editModal').modal('hide');
}
});
});
2020-02-04 17:57:37 +00:00
function getLanguages() {
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=false",
2020-02-13 09:12:23 +00:00
success: function (data) {
2020-02-04 17:57:37 +00:00
availableLanguages = data;
}
});
}
function getEnabledLanguages() {
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=true",
2020-02-13 09:12:23 +00:00
success: function (data) {
2020-02-04 17:57:37 +00:00
enabledLanguages = data;
}
});
}
2019-12-29 10:56:34 +00:00
</script>
2019-12-28 05:52:00 +00:00
{% endblock tail %}