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

193 lines
7.4 KiB

5 years ago
{% extends '_main.html' %}
5 years ago
{% block title %}Movies Editor - Bazarr{% endblock %}
5 years ago
{% block bcleft %}
<div id="buttons"></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>Audio Language</th>
<th>Languages Profile</th>
5 years ago
</tr>
</thead>
</table>
<nav id="edit_bar" class="navbar fixed-bottom navbar-dark bg-dark justify-content-end">
5 years ago
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="languages_select">Languages Profile: </label>
<select class="selectpicker" id="languages_select" name="languages"></select>
5 years ago
</div>
</div>
<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>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
$('#movies_nav').addClass("active");
getEnabledLanguages();
5 years ago
events.on('event', function (event) {
5 years ago
var event_json = JSON.parse(event);
if (event_json.type === 'movies_editor' && event_json.action === 'update') {
5 years ago
$.ajax({
url: "{{ url_for('api.movieseditor') }}",
5 years ago
success: function (data) {
if (data.data.length) {
4 years ago
$('#movies').DataTable().ajax.reload(null, false);
5 years ago
$('[data-toggle="tooltip"]').tooltip({html: true});
}
}
})
}
});
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'not-allowed');
var table = $('#movies').DataTable({
5 years ago
processing: true,
serverSide: true,
5 years ago
language: {
zeroRecords: 'No Movies Found',
processing: "Loading Movies..."
},
5 years ago
searching: false,
ordering: false,
lengthChange: true,
responsive: true,
paging: false,
ajax: "{{ url_for('api.movieseditor') }}",
5 years ago
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( 'movie', no='tempvalue' ) }}".replace("tempvalue", data.radarrId) + '">' + data.title + '</a>'
}
},
{
data: 'audio_language',
5 years ago
render: function (data) {
var audio_languages = '';
data.forEach(appendFunc);
return audio_languages;
5 years ago
function appendFunc(value) {
audio_languages = audio_languages + '<span class="badge badge-secondary">' + value.name + '</span> ';
5 years ago
}
}
},
{
data: "profileId.name",
5 years ago
className: "dt-center"
5 years ago
}
]
});
5 years ago
new $.fn.dataTable.Buttons(table, {
buttons: [
{
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>'
},
{
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
$('#save_button').on('click', function (e) {
5 years ago
e.preventDefault();
const values = {
5 years ago
radarrid: table.rows({selected: true}).ids().toArray(),
languages: $('#languages_select').val()
5 years ago
};
$.ajax({
url: "{{ url_for('api.movieseditsave') }}",
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', 'None');
5 years ago
}
});
});
});
function getEnabledLanguages() {
$.ajax({
url: "{{ url_for('api.languagesprofiles') }}",
5 years ago
success: function (data) {
5 years ago
$('#languages_select').append('<option value="None">None</option>');
$.each(data['data'], function (i, item) {
$('#languages_select').append('<option value="' + item.profileId + '">' + item.name + '</option>');
5 years ago
});
$("#languages_select").selectpicker("refresh");
}
});
}
</script>
{% endblock tail %}