From d3aa8d4c801424d83a9ceca32c6cf9516048f08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 11 Mar 2020 06:58:45 -0400 Subject: [PATCH] WIP --- bazarr/api.py | 12 +- bazarr/config.py | 17 ++ views/_main.html | 556 +++++++++++++++++++------------------ views/episodes.html | 4 +- views/movie.html | 4 +- views/settingsgeneral.html | 492 +++++++++++++++++++------------- views/systemlogs.html | 4 +- views/systemproviders.html | 4 - views/wizard.html | 1 + 9 files changed, 612 insertions(+), 482 deletions(-) diff --git a/bazarr/api.py b/bazarr/api.py index e03e1d2ea..1ce582e61 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -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') diff --git a/bazarr/config.py b/bazarr/config.py index 8991569bf..3aef9614b 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -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" diff --git a/views/_main.html b/views/_main.html index 847edb5b3..a28bca58e 100644 --- a/views/_main.html +++ b/views/_main.html @@ -1,9 +1,9 @@ - - {% block title %}Bazarr{% endblock %} + + {% block title %}Bazarr{% endblock %} - {% block head_meta %} + {% block head_meta %} @@ -17,9 +17,9 @@ - {% endblock head_meta %} + {% endblock head_meta %} - {% block head_css %} + {% block head_css %} @@ -39,296 +39,304 @@ href="{{ url_for('static',filename='plugins/datatables.net-bs4/css/dataTables.bootstrap4.min.css') }}"> - {% endblock head_css %} + {% endblock head_css %} - {% block head %} - {% endblock head %} + {% block head %} + + {% endblock head %} - {% block head_tail %} - {% endblock head_tail %} + {% block page_head %} + {% endblock page_head %} - - - - - -
- - - -
-{% block page_body %} - - - -
+ {% block head_tail %} + {% endblock head_tail %} + + + - + -
- -
- - - - - - - - - - -
-
- {% block breadcrumb %} - - - -
-
- {% block bcleft %} - {% endblock bcleft %} -
-
- {% block bcright %} - {% endblock bcright %} -
+ - {% endblock breadcrumb %} - {% block body %} + + + + + + + + + + + + + + + + +
+
+ {% block breadcrumb %} + + + +
+
+ {% block bcleft %} + {% endblock bcleft %} +
+
+ {% block bcright %} + {% endblock bcright %} +
+
+ {% endblock breadcrumb %} + {% block body %} + + {% endblock body %} +
+
+ + + +
+ + + + +
+
+

Connection to Backend Lost.

+
+ {% endblock page_body %} + + + {% block tail_js %} + - + -
- - - + + + + + + + + -
-
-

Connection to Backend Lost.

- -
-
-{% endblock page_body %} + + + + + + + + + + + + + + - - - - - - - + events = io.connect({ + path: '{{ settings.general.base_url.rstrip('/') }}/socket.io', + upgrade: false, + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 3000, + reconnectionAttempts: 3 + }); - - - - - - - - - - - - - + events.on('reconnect_failed', (reason) => { + $('#reconnect_overlay').show(); + }); - -{% endblock tail_js %} -{% block tail %} -{% endblock tail %} - + $(window).on('beforeunload', function() { + events.close(); + }); + + {% endblock tail_js %} + {% block tail %} + {% endblock tail %} + \ No newline at end of file diff --git a/views/episodes.html b/views/episodes.html index f7e7fb25a..3693d6300 100644 --- a/views/episodes.html +++ b/views/episodes.html @@ -2,7 +2,7 @@ {% block title %}Series - Bazarr{% endblock %} -{% block head %} +{% block page_head %} -{% endblock head %} +{% endblock page_head %} {% block bcleft %}
diff --git a/views/movie.html b/views/movie.html index 20487903b..4568fd44c 100644 --- a/views/movie.html +++ b/views/movie.html @@ -2,7 +2,7 @@ {% block title %}Movie - Bazarr{% endblock %} -{% block head %} +{% block page_head %} -{% endblock head %} +{% endblock page_head %} {% block bcleft %}
diff --git a/views/settingsgeneral.html b/views/settingsgeneral.html index 28294336b..30c5d9ccd 100644 --- a/views/settingsgeneral.html +++ b/views/settingsgeneral.html @@ -2,10 +2,23 @@ {% block title %}General - Bazarr{% endblock %} +{% block page_head %} + +{% endblock page_head %} + {% block bcleft %}
@@ -17,235 +30,320 @@ {% block body %}
-

Host

-
-
-
- Listening IP Address +
+

Host

+
+
+
+ Bind Address +
+
+ +
+ +
-
- +
+
+
+ Port Number +
+
+
+ +
-
-
-
-
- Listening Port +
+
+
+ URL Base +
+
+ +
+ +
-
- -
-
-
-
-
- Base URL -
-
- -
-
-
+
-

Security

-
-
-
- Authentication -
-
- -
-
-
+

Security

+
- Username + Authentication
-
- +
+ +
+ +
+
+
+
+
+ Username +
+
+ +
+
+
+
+
+ Password +
+
+ +
+
+
+
+
+
+ API Key +
+
+ +
+ +

-
-
- Password -
-
- -
-
-
-
-
-
- API Key -
-
- -
-
-
-

Proxy

-
-
-
- Type -
-
- -
-
-
+

Proxy

+
- Hostname + Type
-
- +
+
+
-
-
-
- Port +
+
+
+ Hostname +
+
+ +
-
- +
+
+
+ Port +
+
+ +
+
+
+
+ Username +
+
+ +
+
+
+
+
+ Password +
+
+ +
+
+
+
+
+ Ignored Addresses +
+
+ +
+
+
-
-
-
- Username -
-
- -
-
-
-
-
- Password -
-
- -
-
-
-
-
- Ignored Addresses -
-
- -
-
-
-
-

UI

-
-
-
- Page Size +

UI

+
+
+
+ Page Size +
+
+ +
-
- -
-
-
+
-

Logging

-
-
-
- Debug +

Logging

+
+
+
+ Debug +
+
+ +
-
- -
-
-
+
-

Analytics

-
-
-
- Enabled +

Analytics

+
+
+
+ Enabled +
+
+ +
-
- -
-
-
+
-

Updates

-
-
-
- Branch +
+

Updates

+
+
+
+ Branch +
+
+ +
+
+
+
+ Automatic +
+
+ +
+
+
+
+ Restart After Update +
+
+ +
+
-
- -
-
-
-
- Automatic -
-
- -
-
-
-
- Restart After Update -
-
- -
-
+
{% endblock body %} {% block tail %} {% endblock tail %} diff --git a/views/systemlogs.html b/views/systemlogs.html index 7b59ceeec..7433b6e35 100644 --- a/views/systemlogs.html +++ b/views/systemlogs.html @@ -2,7 +2,7 @@ {% block title %}Logs - Bazarr{% endblock %} -{% block head %} +{% block page_head %} -{% endblock head %} +{% endblock page_head %} {% block bcleft %}
diff --git a/views/systemproviders.html b/views/systemproviders.html index 3043b7e5e..7ba0c0fae 100644 --- a/views/systemproviders.html +++ b/views/systemproviders.html @@ -2,10 +2,6 @@ {% block title %}Logs - Bazarr{% endblock %} -{% block head %} - -{% endblock head %} - {% block bcleft %} {% endblock bcleft %} diff --git a/views/wizard.html b/views/wizard.html index 1818383c2..bd95cc09d 100644 --- a/views/wizard.html +++ b/views/wizard.html @@ -19,6 +19,7 @@ Settings - Bazarr + {{ super() }}