1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-25 01:02:19 +00:00
This commit is contained in:
Louis Vézina 2020-03-11 06:58:45 -04:00
parent 362691220c
commit d3aa8d4c80
9 changed files with 612 additions and 482 deletions

View file

@ -9,9 +9,10 @@ from operator import itemgetter
import platform
import io
from calendar import day_name
import importlib
from get_args import args
from config import settings, base_url
from config import settings, base_url, save_settings
from init import *
import logging
@ -64,6 +65,13 @@ class Languages(Resource):
return jsonify(result)
class SaveSettings(Resource):
def post(self):
save_settings(request.form.items())
return '', 200
class SystemTasks(Resource):
def get(self):
taskid = request.args.get('taskid')
@ -1128,6 +1136,8 @@ class SearchWantedMovies(Resource):
api.add_resource(Badges, '/badges')
api.add_resource(Languages, '/languages')
api.add_resource(SaveSettings, '/savesettings')
api.add_resource(SystemTasks, '/systemtasks')
api.add_resource(SystemLogs, '/systemlogs')
api.add_resource(SystemProviders, '/systemproviders')

View file

@ -148,6 +148,23 @@ settings.read(os.path.join(args.config_dir, 'config', 'config.ini'))
base_url = settings.general.base_url
def save_settings(settings_items):
for key, value in settings_items:
settings_keys = key.split('-')
if value == 'true':
value = 'True'
elif value == 'false':
value = 'False'
if settings_keys[0] == 'settings':
settings[settings_keys[1]][settings_keys[2]] = str(value)
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
def url_sonarr():
if settings.sonarr.getboolean('ssl'):
protocol_sonarr = "https"

View file

@ -42,8 +42,16 @@
{% endblock head_css %}
{% block head %}
<style>
.table td, .table th {
padding: .4rem !important;
}
</style>
{% endblock head %}
{% block page_head %}
{% endblock page_head %}
{% block head_tail %}
{% endblock head_tail %}

View file

@ -2,7 +2,7 @@
{% block title %}Series - Bazarr{% endblock %}
{% block head %}
{% block page_head %}
<style>
#seriesFanart {
background-repeat: no-repeat;
@ -42,7 +42,7 @@
vertical-align: middle;
}
</style>
{% endblock head %}
{% endblock page_head %}
{% block bcleft %}
<div class="">

View file

@ -2,7 +2,7 @@
{% block title %}Movie - Bazarr{% endblock %}
{% block head %}
{% block page_head %}
<style>
#movieFanart {
background-repeat: no-repeat;
@ -42,7 +42,7 @@
vertical-align: middle;
}
</style>
{% endblock head %}
{% endblock page_head %}
{% block bcleft %}
<div class="">

View file

@ -2,10 +2,23 @@
{% block title %}General - Bazarr{% endblock %}
{% block page_head %}
<style>
.restart {
color: orange;
}
</style>
{% endblock page_head %}
{% block bcleft %}
<div class="">
<button class="btn btn-outline" id="save_button">
<div><i class="fas fa-save align-top text-themecolor text-center font-20" aria-hidden="true"></i></div>
<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>
@ -17,32 +30,38 @@
{% block body %}
<div class="container-fluid" style="padding-top: 3em;">
<form class="form" name="settings_form" id="settings_form">
<h4>Host</h4>
<hr/>
<div class="row">
<div class="col-sm-2 text-right">
<b>Listening IP Address</b>
<b>Bind Address</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-general-ip" name="settings-general-ip" value="{{settings.general.ip}}">
<label for="settings-general-ip">Valid IP4 address or '0.0.0.0' for all interfaces</label><br>
<label class="restart">Requires restart to take effect</label>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-2 text-right">
<b>Listening Port</b>
<b>Port Number</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-general-port" name="settings-general-port" value="{{settings.general.port}}">
<input type="text" class="form-control" id="settings-general-port" name="settings-general-port" value="{{settings.general.port}}"><br>
<label class="restart">Requires restart to take effect</label>
</div>
</div>
<br>
<div class="row">
<div class="col-sm-2 text-right">
<b>Base URL</b>
<b>URL Base</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-general-base_url" name="settings-general-base_url" value="{{settings.general.base_url}}">
<label for="settings-general-base_url">For reverse proxy support, default is '/'</label><br>
<label class="restart">Requires restart to take effect</label>
</div>
</div>
<br>
@ -59,6 +78,8 @@
<option value="Basic">Basic</option>
<option value="Form">Form</option>
</select>
<label for="settings-auth-type">Require Username and Password to access Bazarr</label><br>
<label class="restart">Requires restart to take effect</label>
</div>
</div>
<div id="authentication_div">
@ -85,8 +106,11 @@
<div class="col-sm-2 text-right">
<b>API Key</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-auth-apikey" name="settings-auth-apikey" value="{{settings.auth.apikey}}">
<div class="input-group col-sm-4">
<input type="text" class="form-control" id="settings-auth-apikey" name="settings-auth-apikey" readonly value="{{settings.auth.apikey}}">
<div class="input-group-append">
<button class="btn btn-danger" type="button" onclick="generate_apikey()"><i class="fas fa-sync"></i></button>
</div>
</div>
</div>
<br>
@ -103,7 +127,8 @@
<option value="http">HTTP(S)</option>
<option value="socks4">Socks4</option>
<option value="socks5">Socks5</option>
</select>
</select><br>
<label class="restart">Requires restart to take effect</label>
</div>
</div>
<div id="proxy_div">
@ -204,6 +229,7 @@
</div>
<br>
<div id="update_div">
<h4>Updates</h4>
<hr/>
<div class="row">
@ -240,12 +266,84 @@
</div>
</div>
</div>
</form>
</div>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
// Hide checkmark over save button
$('#save_button_checkmark').hide();
})
// Hide update_div if args.no-update
{% if args.no_update %}
$('#update_div').hide()
{% endif %}
// Hide *_div on Select input changed to None
$('#settings-auth-type').on('change', function() {
if ($(this).val() === 'None') {
$('#authentication_div').hide();
} else {
$('#authentication_div').show();
}
});
$('#settings-proxy-type').on('change', function() {
if ($(this).val() === 'None') {
$('#proxy_div').hide();
} else {
$('#proxy_div').show();
}
});
// Set Select input values
$('#settings-auth-type').val('{{settings.auth.type}}').trigger('change');
$('#settings-proxy-type').val('{{settings.proxy.type}}').trigger('change');
$('#settings-general-page_size').val('{{settings.general.page_size}}');
$('#settings-general-branch').val('{{settings.general.branch}}');
// Set Checkbox input values
$('#settings-general-debug').prop('checked', {{'true' if settings.general.getboolean('debug')}});
$('#settings-analytics-enabled').prop('checked', {{'true' if settings.analytics.getboolean('enabled')}});
$('#settings-general-auto_update').prop('checked', {{'true' if settings.general.getboolean('auto_update')}});
$('#settings-general-update_restart').prop('checked', {{'true' if settings.general.getboolean('update_restart')}});
$('#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 generate_apikey() {
var result = '';
var characters = 'abcdef0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < 32; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
$( "#settings-auth-apikey" ).val( result );
}
</script>
{% endblock tail %}

View file

@ -2,7 +2,7 @@
{% block title %}Logs - Bazarr{% endblock %}
{% block head %}
{% block page_head %}
<style>
.dropdown-item-checked::before {
position: absolute;
@ -11,7 +11,7 @@
font-weight: 900;
}
</style>
{% endblock head %}
{% endblock page_head %}
{% block bcleft %}
<div class="">

View file

@ -2,10 +2,6 @@
{% block title %}Logs - Bazarr{% endblock %}
{% block head %}
{% endblock head %}
{% block bcleft %}
{% endblock bcleft %}

View file

@ -19,6 +19,7 @@
<title>Settings - Bazarr</title>
{{ super() }}
<style>
body {
background-color: #272727;