bazarr/views/wantedseries.html

130 lines
5.3 KiB
HTML
Raw Normal View History

2020-02-12 17:41:40 +00:00
{% extends '_main.html' %}
2018-05-02 10:25:42 +00:00
2020-02-12 17:41:40 +00:00
{% block title %}Wanted (Series) - Bazarr{% endblock %}
2020-02-12 17:41:40 +00:00
{% block bcleft %}
2020-02-13 04:16:22 +00:00
<button class="btn btn-outline" id="search_button">
2020-02-13 09:12:23 +00:00
<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-12 17:41:40 +00:00
{% endblock bcleft %}
2018-05-02 10:25:42 +00:00
2020-02-12 17:41:40 +00:00
{% block bcright %}
2018-05-02 10:25:42 +00:00
2020-02-12 17:41:40 +00:00
{% endblock bcright %}
2018-05-02 10:25:42 +00:00
2020-02-12 17:41:40 +00:00
{% block body %}
<table id="wanted_series" class="table table-striped" style="width:100%">
<thead>
2020-02-13 09:12:23 +00:00
<tr>
<th>Series</th>
<th>Episode</th>
<th>Episode Title</th>
<th>Missing Subtitle(s)</th>
</tr>
2020-02-12 17:41:40 +00:00
</thead>
</table>
{% endblock body %}
2018-05-02 10:25:42 +00:00
2020-02-12 17:41:40 +00:00
{% block tail %}
<script>
$(document).ready(function () {
var table = $('#wanted_series').DataTable({
2020-02-13 09:12:23 +00:00
processing: true,
serverSide: true,
2020-02-12 17:41:40 +00:00
language: {
zeroRecords: 'No Missing Series Subtitles',
processing: "Loading Missing Series Subtitles..."
},
2020-02-13 09:12:23 +00:00
searching: false,
ordering: false,
lengthChange: false,
responsive: true,
pageLength: {{ settings.general.page_size }},
ajax: "{{ url_for('api.wantedseries') }}",
columns: [
{
data: null,
render: function (data) {
2020-02-12 17:41:40 +00:00
return '<a href="' + "{{ url_for( 'episodes', no='tempvalue' ) }}".replace("tempvalue", data.sonarrSeriesId) + '">' + data.seriesTitle + '</a>';
}
},
2020-02-13 09:12:23 +00:00
{data: "episode_number"},
{data: "episodeTitle"},
{
data: null,
render: function (data) {
2020-02-13 00:38:52 +00:00
if (data.missing_subtitles !== 'None') {
var languages = '';
data.missing_subtitles.forEach(appendFunc);
return languages;
} else {
return null;
}
function appendFunc(value) {
2020-09-10 18:26:37 +00:00
if (value.forced) {
var advtag = ':forced';
} else if (value.hi) {
var advtag = ':HI';
} else {
var advtag = '';
}
languages = languages + '<a href="" class="get_subtitle badge badge-secondary" data-toggle="tooltip" data-placement="right" title="' + value.name + advtag + '" data-episodepath="' + data.mapped_path + '" data-scenename="' + data.scene_name + '" data-seriestitle="' + data.seriesTitle + '" data-language="' + value.code3 + '" data-hi="' + data.hearing_impaired + '" data-forced="' + value.forced + '" data-sonarrseriesid=' + data.sonarrSeriesId + ' data-sonarrepisodeid=' + data.sonarrEpisodeId + '>' + value.code2 + advtag + ' <i class="fas fa-search"></i></a> ';
2020-02-13 00:38:52 +00:00
}
}
}
2020-02-12 17:41:40 +00:00
]
});
2020-02-13 09:12:23 +00:00
$('#search_button').on('click', function (e) {
2020-02-13 04:16:22 +00:00
e.preventDefault();
$.ajax({
url: "{{ url_for('api.searchwantedseries') }}",
type: 'GET',
2020-02-13 09:12:23 +00:00
beforeSend: function () {
2020-02-13 04:16:22 +00:00
$('#search_button').find("i").addClass('fa-spin');
},
2020-02-13 09:12:23 +00:00
complete: function () {
2020-02-13 04:16:22 +00:00
$('#search_button').find("i").removeClass('fa-spin');
}
});
});
2020-02-13 09:12:23 +00:00
$('#wanted_series').on('click', '.get_subtitle', function (e) {
2020-02-13 00:38:52 +00:00
$(this).tooltip('dispose');
e.preventDefault();
const values = {
episodePath: $(this).attr("data-episodepath"),
sceneName: $(this).attr("data-scenename"),
language: $(this).attr("data-language"),
hi: $(this).attr("data-hi"),
forced: $(this).attr("data-forced"),
sonarrSeriesId: $(this).attr("data-sonarrseriesid"),
sonarrEpisodeId: $(this).attr('data-sonarrepisodeid'),
title: $(this).attr("data-seriestitle")
};
var cell = $(this).parent();
$.ajax({
url: "{{ url_for('api.episodessubtitlesdownload') }}",
type: "POST",
dataType: "json",
data: values,
2020-02-13 09:12:23 +00:00
beforeSend: function () {
2020-02-13 00:38:52 +00:00
cell.html('<div class="spinner-border spinner-border-sm" role="status"><span class="sr-only">Loading...</span></div>');
}
});
});
2020-02-13 09:12:23 +00:00
events.on('event', function (event) {
2020-02-12 17:41:40 +00:00
var event_json = JSON.parse(event);
2020-02-13 00:38:52 +00:00
if (event_json.type === 'episode') {
2020-12-22 05:10:32 +00:00
$('#wanted_series').DataTable().ajax.reload(null, false);
2020-02-12 17:41:40 +00:00
$('[data-toggle="tooltip"]').tooltip({html: true});
}
});
2020-02-13 09:12:23 +00:00
});
2020-02-12 17:41:40 +00:00
</script>
{% endblock tail %}