bazarr/views/wantedmovies.html

115 lines
4.8 KiB
HTML
Raw Normal View History

2020-02-13 01:41:40 +08:00
{% extends '_main.html' %}
2018-05-02 18:25:42 +08:00
2020-02-13 01:41:40 +08:00
{% block title %}Wanted (Movies) - Bazarr{% endblock %}
2020-02-13 01:41:40 +08:00
{% block bcleft %}
2020-02-13 12:16:22 +08:00
<button class="btn btn-outline" id="search_button">
<div><i class="fas fa-search align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<div class="align-bottom text-themecolor small text-center">Search All</div>
</button>
2020-02-13 01:41:40 +08:00
{% endblock bcleft %}
2018-05-02 18:25:42 +08:00
2020-02-13 01:41:40 +08:00
{% block bcright %}
2018-05-02 18:25:42 +08:00
2020-02-13 01:41:40 +08:00
{% endblock bcright %}
2018-05-02 18:25:42 +08:00
2020-02-13 01:41:40 +08:00
{% block body %}
<table id="wanted_movies" class="table table-striped" style="width:100%">
<thead>
<tr>
<th>Movies</th>
<th>Missing Subtitle(s)</th>
</tr>
</thead>
</table>
{% endblock body %}
2018-05-02 18:25:42 +08:00
2020-02-13 01:41:40 +08:00
{% block tail %}
<script>
$(document).ready(function () {
var table = $('#wanted_movies').DataTable({
"processing": true,
"serverSide": true,
language: {
zeroRecords: 'No Missing Movies Subtitles',
processing: "Loading Missing Movies Subtitles..."
},
"searching": false,
"ordering": false,
"lengthChange": false,
"responsive": true,
"pageLength": {{ settings.general.page_size }},
"ajax": "{{ url_for('api.wantedmovies') }}",
"columns": [
{"data": null,
"render": function (data) {
return '<a href="' + "{{ url_for( 'movie', no='tempvalue' ) }}".replace("tempvalue", data.radarrId) + '">' + data.title + '</a>';
}
},
2020-02-13 08:38:52 +08:00
{"data": null,
"render": function (data) {
if (data.missing_subtitles !== 'None') {
var languages = '';
data.missing_subtitles.forEach(appendFunc);
return languages;
} else {
return null;
}
function appendFunc(value) {
languages = languages + '<a href="" class="get_subtitle badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + ((value.forced) ? ' forced':'') + '" data-moviepath="'+data.mapped_path+'" data-scenename="'+data.sceneName+'" data-movietitle="'+data.title+'" data-language="'+value.code3+'" data-hi="'+data.hearing_impaired+'" data-forced="'+value.forced+'" data-radarrid='+data.radarrId+'>' + value.code2 + ((value.forced) ? ':forced':'') + ' <i class="fas fa-search"></i></a> ';
}
}
}
2020-02-13 01:41:40 +08:00
]
});
2020-02-13 12:16:22 +08:00
$('#search_button').on('click', function(e){
e.preventDefault();
$.ajax({
url: "{{ url_for('api.searchwantedmovies') }}",
type: 'GET',
beforeSend: function() {
$('#search_button').find("i").addClass('fa-spin');
},
complete: function() {
$('#search_button').find("i").removeClass('fa-spin');
}
});
});
2020-02-13 08:38:52 +08:00
$('#wanted_movies').on('click', '.get_subtitle', function(e){
$(this).tooltip('dispose');
e.preventDefault();
const values = {
moviePath: $(this).attr("data-moviepath"),
sceneName: $(this).attr("data-scenename"),
language: $(this).attr("data-language"),
hi: $(this).attr("data-hi"),
forced: $(this).attr("data-forced"),
radarrId: $(this).attr("data-radarrid"),
title: $(this).attr("data-movietitle")
};
var cell = $(this).parent();
$.ajax({
url: "{{ url_for('api.moviesubtitlesdownload') }}",
type: "POST",
dataType: "json",
data: values,
beforeSend: function() {
cell.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
}
});
});
2020-02-13 01:41:40 +08:00
events.on('event', function(event) {
var event_json = JSON.parse(event);
if (event_json.type === 'movie') {
$('#wanted_movies').DataTable().ajax.reload(resetPaging=false);
$('[data-toggle="tooltip"]').tooltip({html: true});
}
});
});
</script>
{% endblock tail %}