1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-24 00:33:27 +00:00
bazarr/views/movieseditor.html

193 lines
7.4 KiB
HTML
Raw Normal View History

2020-02-05 03:50:35 +00:00
{% extends '_main.html' %}
2020-02-13 18:25:35 +00:00
{% block title %}Movies Editor - Bazarr{% endblock %}
2020-02-05 03:50:35 +00:00
{% 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>
2020-02-05 03:50:35 +00:00
</tr>
</thead>
</table>
<nav id="edit_bar" class="navbar fixed-bottom navbar-dark bg-dark justify-content-end">
2020-02-05 03:50:35 +00:00
<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>
2020-02-05 03:50:35 +00:00
</div>
</div>
<div class="form-check form-check-inline">
2020-02-12 21:51:31 +00:00
<button type="submit" class="btn btn-info" id="save_button">Save</button>
2020-02-05 03:50:35 +00:00
</div>
</nav>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
$('#movies_nav').addClass("active");
getEnabledLanguages();
2020-02-13 09:12:23 +00:00
events.on('event', function (event) {
2020-02-05 03:50:35 +00:00
var event_json = JSON.parse(event);
if (event_json.type === 'movies_editor' && event_json.action === 'update') {
2020-02-05 03:50:35 +00:00
$.ajax({
url: "{{ url_for('api.movieseditor') }}",
2020-02-05 03:50:35 +00:00
success: function (data) {
if (data.data.length) {
2020-12-22 05:10:32 +00:00
$('#movies').DataTable().ajax.reload(null, false);
2020-02-05 03:50:35 +00:00
$('[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({
2020-02-13 09:12:23 +00:00
processing: true,
serverSide: true,
2020-02-12 17:41:40 +00:00
language: {
zeroRecords: 'No Movies Found',
processing: "Loading Movies..."
},
2020-02-13 09:12:23 +00:00
searching: false,
ordering: false,
lengthChange: true,
responsive: true,
paging: false,
ajax: "{{ url_for('api.movieseditor') }}",
2020-02-13 09:12:23 +00:00
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'multi',
selector: 'td:first-child'
2020-02-05 03:50:35 +00:00
},
2020-02-13 09:12:23 +00:00
columns: [
{defaultContent: ""},
{
data: null,
render: function (data) {
2020-02-05 03:50:35 +00:00
return '<a href="' + "{{ url_for( 'movie', no='tempvalue' ) }}".replace("tempvalue", data.radarrId) + '">' + data.title + '</a>'
}
},
{
data: 'audio_language',
2020-02-13 09:12:23 +00:00
render: function (data) {
var audio_languages = '';
data.forEach(appendFunc);
return audio_languages;
2020-02-05 03:50:35 +00:00
function appendFunc(value) {
audio_languages = audio_languages + '<span class="badge badge-secondary">' + value.name + '</span> ';
2020-02-05 03:50:35 +00:00
}
}
},
{
data: "profileId.name",
2020-02-13 09:12:23 +00:00
className: "dt-center"
2020-02-05 03:50:35 +00:00
}
]
});
2020-02-13 09:12:23 +00:00
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>'
}]
});
2020-02-05 03:50:35 +00:00
table.buttons().container().appendTo('#buttons');
2020-02-13 09:12:23 +00:00
var btns = $('.dt-button');
btns.addClass('btn btn-outline');
btns.removeClass('dt-button');
table.on('select', function () {
2020-02-05 03:50:35 +00:00
$('.selectpicker').prop('disabled', false);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', false);
$('#save_button').removeClass('disabled');
$('#save_button').css('cursor', 'auto');
2020-02-13 09:12:23 +00:00
});
2020-02-05 03:50:35 +00:00
2020-02-13 09:12:23 +00:00
table.on('deselect', function () {
if (table.rows('.selected').count() === 0) {
2020-02-05 03:50:35 +00:00
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'not-allowed');
}
2020-02-13 09:12:23 +00:00
});
2020-02-05 03:50:35 +00:00
2020-02-13 09:12:23 +00:00
$('#save_button').on('click', function (e) {
2020-02-05 03:50:35 +00:00
e.preventDefault();
const values = {
2020-02-13 09:12:23 +00:00
radarrid: table.rows({selected: true}).ids().toArray(),
languages: $('#languages_select').val()
2020-02-05 03:50:35 +00:00
};
$.ajax({
url: "{{ url_for('api.movieseditsave') }}",
method: "POST",
2020-04-15 04:02:44 +00:00
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');
},
2020-02-13 09:12:23 +00:00
success: function () {
2020-02-05 03:50:35 +00:00
table.rows().deselect();
$('#languages_select').selectpicker('val', 'None');
2020-02-05 03:50:35 +00:00
}
});
});
});
function getEnabledLanguages() {
$.ajax({
url: "{{ url_for('api.languagesprofiles') }}",
2020-02-13 09:12:23 +00:00
success: function (data) {
2020-02-05 03:50:35 +00:00
$('#languages_select').append('<option value="None">None</option>');
$.each(data['data'], function (i, item) {
$('#languages_select').append('<option value="' + item.profileId + '">' + item.name + '</option>');
2020-02-05 03:50:35 +00:00
});
$("#languages_select").selectpicker("refresh");
}
});
}
</script>
{% endblock tail %}