Skip to content

Commit

Permalink
Merge pull request #137 from agrandville/GUIRefreshParameter
Browse files Browse the repository at this point in the history
Add PATROWL_REFRESH_ENGINE parameter to set GUI update frequency
  • Loading branch information
MaKyOtOx authored Jun 11, 2020
2 parents fd3155c + eb13a02 commit eba1dec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
3 changes: 3 additions & 0 deletions app/settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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__)))

Expand Down
9 changes: 5 additions & 4 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,10 +126,8 @@
if (running_scans > 1) {$('span.running-scans').append('&nbsp;-&nbsp;' + running_scans+' scans running <i class="glyphicon glyphicon-cog gly-spin"></i>');}
});
}
setInterval(function() {
//refresh_engines_status();
setTimeout(refresh_engines_status(), 4000);
}, 5000);



</script>
{% endif %}
Expand Down

0 comments on commit eba1dec

Please sign in to comment.