From 6fe18a679f95592cc26531fe64790c054f7b54a9 Mon Sep 17 00:00:00 2001 From: "contact@grandville.net" Date: Sat, 6 Jun 2020 07:28:46 +0200 Subject: [PATCH 1/2] Add PATROWL_REFRESH_ENGINE parameter --- app/context_processors.py | 3 ++- app/settings.py.sample | 3 +++ templates/base.html | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/context_processors.py b/app/context_processors.py index dc5fbfe1..b2f27e40 100644 --- a/app/context_processors.py +++ b/app/context_processors.py @@ -4,4 +4,5 @@ def selected_settings(request): # return the version value as a dictionary # you may add other values here as well - return {'PATROWL_VERSION': settings.PATROWL_VERSION} + return {'PATROWL_VERSION': settings.PATROWL_VERSION, + 'PATROWL_REFRESH_ENGINE': settings.PATROWL_REFRESH_ENGINE} diff --git a/app/settings.py.sample b/app/settings.py.sample index 5e5bb42a..45cc497d 100644 --- a/app/settings.py.sample +++ b/app/settings.py.sample @@ -7,6 +7,9 @@ from datetime import timedelta with open("VERSION") as v_file: PATROWL_VERSION = v_file.read() +# GUI update frequency (ms) +PATROWL_REFRESH_ENGINE = 10000 + # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/templates/base.html b/templates/base.html index 81fa856f..31b63fdd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -80,6 +80,9 @@ // Refresh engines status only if the user is authenticated {% if user.is_authenticated %} refresh_engines_status(); + if({{ PATROWL_REFRESH_ENGINE }}>0){ + setInterval(function() {refresh_engines_status();},({{ PATROWL_REFRESH_ENGINE }}>5000)?{{ PATROWL_REFRESH_ENGINE }}:5000); + } {% endif %} // On-demand refresh @@ -123,10 +126,8 @@ if (running_scans > 1) {$('span.running-scans').append(' - ' + running_scans+' scans running ');} }); } - setInterval(function() { - //refresh_engines_status(); - setTimeout(refresh_engines_status(), 4000); - }, 5000); + + {% endif %} From eb13a02860f3c41fc6c9622f67922c25d8325de5 Mon Sep 17 00:00:00 2001 From: "contact@grandville.net" Date: Sat, 6 Jun 2020 07:36:59 +0200 Subject: [PATCH 2/2] bind PATROWL_REFRESH_ENGINE to an environment variable --- app/settings.py.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/settings.py.sample b/app/settings.py.sample index 45cc497d..75897ab7 100644 --- a/app/settings.py.sample +++ b/app/settings.py.sample @@ -8,7 +8,7 @@ with open("VERSION") as v_file: PATROWL_VERSION = v_file.read() # GUI update frequency (ms) -PATROWL_REFRESH_ENGINE = 10000 +PATROWL_REFRESH_ENGINE = os.environ.get('PATROWL_REFRESH_ENGINE', 7000) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))