mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-30 10:51:52 +00:00
WIP
This commit is contained in:
parent
898bdf95e4
commit
67d5e2a9c2
5 changed files with 202 additions and 3 deletions
|
@ -92,9 +92,9 @@ class Languages(Resource):
|
|||
def get(self):
|
||||
enabled = request.args.get('enabled')
|
||||
if enabled.lower() in ['true', '1']:
|
||||
result = database.execute("SELECT * FROM table_settings_languages WHERE enabled=1")
|
||||
result = database.execute("SELECT * FROM table_settings_languages WHERE enabled=1 ORDER BY name")
|
||||
else:
|
||||
result = database.execute("SELECT * FROM table_settings_languages")
|
||||
result = database.execute("SELECT * FROM table_settings_languages ORDER BY name")
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
|
|
|
@ -152,6 +152,10 @@ base_url = settings.general.base_url
|
|||
|
||||
def save_settings(settings_items):
|
||||
for key, value in settings_items:
|
||||
if key == 'enabled_languages':
|
||||
print(key)
|
||||
continue
|
||||
|
||||
settings_keys = key.split('-')
|
||||
|
||||
if value == 'true':
|
||||
|
|
|
@ -343,6 +343,12 @@ def settingssubtitles():
|
|||
return render_template('settingssubtitles.html')
|
||||
|
||||
|
||||
@app.route('/settings/languages/')
|
||||
@login_required
|
||||
def settingslanguages():
|
||||
return render_template('settingslanguages.html')
|
||||
|
||||
|
||||
@app.route('/check_update')
|
||||
@login_required
|
||||
def check_update():
|
||||
|
|
|
@ -204,7 +204,7 @@
|
|||
<li><a href="{{ url_for('settingssonarr') }}"> Sonarr</a></li>
|
||||
<li><a href="{{ url_for('settingsradarr') }}"> Radarr</a></li>
|
||||
<li><a href="{{ url_for('settingssubtitles') }}"> Subtitles</a></li>
|
||||
<li><a href="/"> Languages</a></li>
|
||||
<li><a href="{{ url_for('settingslanguages') }}"> Languages</a></li>
|
||||
<li><a href="/"> Providers</a></li>
|
||||
<li><a href="/"> Notifications</a></li>
|
||||
<li><a href="/"> Scheduler</a></li>
|
||||
|
|
189
views/settingslanguages.html
Normal file
189
views/settingslanguages.html
Normal file
|
@ -0,0 +1,189 @@
|
|||
{% extends '_main.html' %}
|
||||
|
||||
{% block title %}Languages - Bazarr{% endblock %}
|
||||
|
||||
{% block page_head %}
|
||||
|
||||
{% endblock page_head %}
|
||||
|
||||
{% block bcleft %}
|
||||
<div class="">
|
||||
<button class="btn btn-outline" id="save_button">
|
||||
<div>
|
||||
<span class="fa-stack">
|
||||
<i class="fas fa-save fa-stack-2x align-top text-themecolor text-center font-20" aria-hidden="true"></i>
|
||||
<i id="save_button_checkmark" class="fas fa-check fa-stack-2x" style="color:green;"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="align-bottom text-themecolor small text-center">Save</div>
|
||||
</button>
|
||||
</div>
|
||||
{% endblock bcleft %}
|
||||
|
||||
{% block bcright %}
|
||||
|
||||
{% endblock bcright %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container-fluid" style="padding-top: 3em;">
|
||||
<form class="form" name="settings_form" id="settings_form">
|
||||
<h4>Subtitles languages</h4>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Single Language</b>
|
||||
</div>
|
||||
<div class="form-group col-sm-1">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="settings-general-single_language" name="settings-general-single_language">
|
||||
<span class="custom-control-label" for="settings-general-single_language"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Enabled Languages</b>
|
||||
</div>
|
||||
<div class="form-group col-sm-8 pl-sm-0">
|
||||
<select class="selectpicker" id="enabled_languages" name="enabled_languages" data-live-search="true" multiple></select>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<h4>Default Settings</h4>
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Series Default Settings</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div id="series_default_div">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Languages</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Hearing-Impaired</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Forced</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Movies Default Settings</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div id="movies_default_div">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Languages</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Hearing-Impaired</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="col-sm-3 text-right">
|
||||
<b>Forced</b>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock body %}
|
||||
|
||||
{% block tail %}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
getLanguages();
|
||||
|
||||
// Hide checkmark over save button
|
||||
$('#save_button_checkmark').hide();
|
||||
|
||||
// Hide *_div on Select input changed to None
|
||||
|
||||
|
||||
// Set Select input values
|
||||
$('#settings-general-subfolder').val('{{settings.general.subfolder}}').trigger('change');
|
||||
$('#settings-general-anti_captcha_provider').val('{{settings.general.anti_captcha_provider}}').trigger('change');
|
||||
$('.selectpicker').selectpicker('refresh')
|
||||
|
||||
// Set Checkbox input values
|
||||
$('#settings-general-single_language').prop('checked', {{'true' if settings.general.getboolean('single_language') else 'false'}}).trigger('change');
|
||||
|
||||
$('#save_button').on('click', function() {
|
||||
var formdata = new FormData(document.getElementById("settings_form"));
|
||||
|
||||
// Make sure all checkbox input are sent with true/false value
|
||||
$('input[type=checkbox]').each(function () {
|
||||
formdata.set($(this).prop('id'), $(this).prop('checked'));
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url_for('api.savesettings') }}",
|
||||
data: formdata,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
complete: function () {
|
||||
$('#save_button_checkmark').show();
|
||||
setTimeout(
|
||||
function()
|
||||
{
|
||||
$('#save_button_checkmark').hide();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getLanguages() {
|
||||
$.ajax({
|
||||
url: "{{ url_for('api.languages') }}?enabled=false",
|
||||
success: function (data) {
|
||||
$('#enabled_languages').empty();
|
||||
$.each(data, function (i, item) {
|
||||
$('#enabled_languages').append('<option value="' + item.code2 + '">' + item.name + '</option>');
|
||||
});
|
||||
getEnabledLanguages();
|
||||
$("#enabled_languages").selectpicker("refresh");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getEnabledLanguages() {
|
||||
$.ajax({
|
||||
url: "{{ url_for('api.languages') }}?enabled=true",
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
$('#enabled_languages').selectpicker('val', data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock tail %}
|
Loading…
Reference in a new issue