From 83abf21687b519502684f6350dfb2ac41e3bcac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 17 Feb 2020 21:45:12 -0500 Subject: [PATCH] WIP --- bazarr/logger.py | 1 + bazarr/main.py | 14 +++++++------- bazarr/utils.py | 2 -- views/systemlogs.html | 33 +++++++++++++++++++++++++++------ 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/bazarr/logger.py b/bazarr/logger.py index 385bbef6d..b52e0a3af 100644 --- a/bazarr/logger.py +++ b/bazarr/logger.py @@ -182,3 +182,4 @@ class PublicIPFilter(ArgsFilteringFilter): def empty_log(): fh.doRollover() + logging.info('BAZARR Log file emptied') diff --git a/bazarr/main.py b/bazarr/main.py index b73912f26..26cbcd584 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -444,19 +444,19 @@ def save_wizard(): @app.route('/emptylog') @login_required def emptylog(): - ref = request.environ['HTTP_REFERER'] - empty_log() - logging.info('BAZARR Log file emptied') - - redirect(ref) + return '', 200 @app.route('/bazarr.log') @login_required def download_log(): - return send_file(os.path.join(args.config_dir, 'log/'), - attachment_filename='bazarr.log') + r = Response() + r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" + r.headers["Pragma"] = "no-cache" + r.headers["Expires"] = "0" + r.headers['Cache-Control'] = 'public, max-age=0' + return send_file(os.path.join(args.config_dir, 'log', 'bazarr.log'), cache_timeout=0) @app.route('/image_proxy/', methods=['GET']) diff --git a/bazarr/utils.py b/bazarr/utils.py index a820ac2ca..1e3ca4a46 100644 --- a/bazarr/utils.py +++ b/bazarr/utils.py @@ -15,12 +15,10 @@ from websocket_handler import event_stream from subliminal import region as subliminal_cache_region import datetime import glob -from threading import Event def history_log(action, sonarr_series_id, sonarr_episode_id, description, video_path=None, language=None, provider=None, score=None): - thread = Event() database.execute("INSERT INTO table_history (action, sonarrSeriesId, sonarrEpisodeId, timestamp, description," "video_path, language, provider, score) VALUES (?,?,?,?,?,?,?,?,?)", (action, sonarr_series_id, sonarr_episode_id, time.time(), description, video_path, language, diff --git a/views/systemlogs.html b/views/systemlogs.html index 7a92f4a40..bee69fac9 100644 --- a/views/systemlogs.html +++ b/views/systemlogs.html @@ -21,17 +21,19 @@ {% block bcright %}
- + - +
{% endblock bcright %} @@ -124,7 +126,26 @@ "searchable": false } ] - } ); + }); + + $('#refresh_button').on('click', function() { + table.ajax.reload(); + table.columns.adjust().draw(false); + }) + + $('#download_button').on('click', function(e) { + e.preventDefault(); + window.location.href = "{{ url_for('download_log') }}"; + }) + + $('#empty_button').on('click', function() { + $.ajax({ + url: "{{ url_for('emptylog') }}" + }).done(function (data) { + table.ajax.reload(); + table.columns.adjust().draw(false); + }) + }) }) {% endblock tail %}