mirror of https://github.com/Aidaho12/haproxy-wi
parent
79275a6360
commit
a26482623f
|
@ -16,7 +16,7 @@ exgrep = form.getvalue('exgrep') if form.getvalue('exgrep') else ''
|
||||||
if form.getvalue('rows') is None:
|
if form.getvalue('rows') is None:
|
||||||
rows = 10
|
rows = 10
|
||||||
else:
|
else:
|
||||||
if form.getvalue('rows1') not is None:
|
if form.getvalue('rows1') is not None:
|
||||||
rows = form.getvalue('rows1')
|
rows = form.getvalue('rows1')
|
||||||
else:
|
else:
|
||||||
rows = form.getvalue('rows')
|
rows = form.getvalue('rows')
|
||||||
|
@ -46,7 +46,6 @@ template = template.render(h2 = 1,
|
||||||
title = title,
|
title = title,
|
||||||
role = role,
|
role = role,
|
||||||
user = user,
|
user = user,
|
||||||
onclick = "showLog()",
|
|
||||||
select_id = "serv",
|
select_id = "serv",
|
||||||
selects = servers,
|
selects = servers,
|
||||||
serv = form.getvalue('serv'),
|
serv = form.getvalue('serv'),
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<table class="overview">
|
<table class="overview">
|
||||||
<tr class="overviewHead">
|
<tr class="overviewHead">
|
||||||
<td class="padding10 first-collumn" style="width: 10%;">
|
<td class="padding10 first-collumn" style="width: 10%;">
|
||||||
{% if onclick == 'viewLogs()' %}
|
{% if select_id == 'viewlogs' %}
|
||||||
Log
|
Log
|
||||||
{% else %}
|
{% else %}
|
||||||
Server
|
Server
|
||||||
|
@ -15,19 +15,20 @@
|
||||||
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
||||||
<td style="width: 5%;">WAF logs</td>
|
<td style="width: 5%;">WAF logs</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td style="width: 10%;">Number rows</td>
|
<td>Number rows</td>
|
||||||
<td class="padding10" style="width: 10%;">Ex for grep</td>
|
<td class="padding10"><span title="Find in log file(supports regular expressions)">Find (?)<span></td>
|
||||||
|
<td class="padding10"><span title="Exclude from search in log file(supports regular expressions)">Exclude (?)<span></td>
|
||||||
<td style="width: 10%;">
|
<td style="width: 10%;">
|
||||||
<label for="time_range_out_hour" style="padding: 0">Time range:</label>
|
<label for="time_range_out_hour" style="padding: 0">Time range:</label>
|
||||||
{{ input('time_range_out_hour', value=hour, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut', value=minut, class='time-range', readonly='readonly') }}
|
{{ input('time_range_out_hour', value=hour, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut', value=minut, class='time-range', readonly='readonly') }}
|
||||||
{{ input('time_range_out_hour1', value=hour1, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut1', value=minut1, class='time-range', readonly='readonly') }}
|
{{ input('time_range_out_hour1', value=hour1, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut1', value=minut1, class='time-range', readonly='readonly') }}
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 10%;"> </td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="padding10 first-collumn" style="width: 10%;">
|
<td class="padding10 first-collumn" style="width: 10%;">
|
||||||
<form action="" method="post">
|
<form action="" method="post" id="show_log_form">
|
||||||
{% if onclick == 'viewLogs()' %}
|
{% if select_id == 'viewlogs' %}
|
||||||
<select autofocus required name="serv" id="{{ select_id }}">
|
<select autofocus required name="serv" id="{{ select_id }}">
|
||||||
<option disabled selected>Choose log</option>
|
<option disabled selected>Choose log</option>
|
||||||
{% for select in selects %}
|
{% for select in selects %}
|
||||||
|
@ -42,29 +43,32 @@
|
||||||
{% include 'include/select.html' %}
|
{% include 'include/select.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if onclick != 'viewLogs()' and service != 'nginx' %}
|
{% if select_id == 'viewlogs' and service != 'nginx' %}
|
||||||
<td>
|
<td>
|
||||||
{{ checkbox('waf') }}
|
{{ checkbox('waf') }}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="padding10" style="width: 10%;">
|
<td class="padding10" style="width: 10%;">
|
||||||
{{ input('rows', type='number', value=rows, required='required') }}
|
{{ input('rows', type='number', value=rows, required='required', size='5') }}
|
||||||
</td>
|
</td>
|
||||||
<td class="padding10" style="width: 10%;">
|
<td class="padding10" style="width: 10%;">
|
||||||
{{ input('grep', value=grep) }}
|
{{ input('grep', value=grep) }}
|
||||||
</td>
|
</td>
|
||||||
|
<td class="padding10" style="width: 10%;">
|
||||||
|
{{ input('exgrep', value=exgrep) }}
|
||||||
|
</td>
|
||||||
<td class="padding10" style="width: 10%;">
|
<td class="padding10" style="width: 10%;">
|
||||||
<div id="time-range"></div>
|
<div id="time-range"></div>
|
||||||
</td>
|
</td>
|
||||||
<td class="padding10 first-collumn" style="width: 10%;">
|
<td class="padding10 first-collumn" style="width: 10%;">
|
||||||
<a class="ui-button ui-widget ui-corner-all" id="show" title="Show logs" onclick="{{ onclick }}">Show</a>
|
<button type="submit" name="Show log" value="Show" id="show_log_button">Show</button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div id="ajax">
|
<div id="ajax">
|
||||||
</div>
|
</div>
|
||||||
{% if onclick == 'viewLogs()' and serv != '' and viewlogs != '' and viewlogs != 'haproxy-wi.error.log' and viewlogs != 'haproxy-wi.access.log' %}
|
{% if select_id == 'viewlogs' and serv != '' and viewlogs != '' and viewlogs != 'haproxy-wi.error.log' and viewlogs != 'haproxy-wi.access.log' %}
|
||||||
<script>
|
<script>
|
||||||
viewLogs()
|
viewLogs()
|
||||||
if (window.matchMedia('(max-width: 786px)').matches || window.matchMedia('(max-width: 1024px)').matches || window.matchMedia('(max-width: 667px)').matches) {
|
if (window.matchMedia('(max-width: 786px)').matches || window.matchMedia('(max-width: 1024px)').matches || window.matchMedia('(max-width: 667px)').matches) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import datetime
|
||||||
import funct
|
import funct
|
||||||
import sql
|
import sql
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
|
||||||
template = env.get_template('logs.html')
|
template = env.get_template('logs.html')
|
||||||
form = funct.form
|
form = funct.form
|
||||||
|
@ -49,7 +50,8 @@ try:
|
||||||
if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours):
|
if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours):
|
||||||
os.remove(curpath)
|
os.remove(curpath)
|
||||||
except:
|
except:
|
||||||
print('<center><div class="alert alert-danger" style="margin: 0; margin-bottom: 10px;">Can\'t delete old logs file. <br> Please check "log_time_storage" in config and <br>exist directory </div></center>')
|
print(
|
||||||
|
'<center><div class="alert alert-danger" style="margin: 0; margin-bottom: 10px;">Can\'t delete old logs file. <br> Please check "log_time_storage" in config and <br>exist directory </div></center>')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -57,7 +59,6 @@ try:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
selects = funct.get_files(log_path, format="log")
|
selects = funct.get_files(log_path, format="log")
|
||||||
selects.append(['fail2ban.log', 'fail2ban.log'])
|
selects.append(['fail2ban.log', 'fail2ban.log'])
|
||||||
selects.append(['haproxy-wi.error.log', 'error.log'])
|
selects.append(['haproxy-wi.error.log', 'error.log'])
|
||||||
|
@ -67,7 +68,6 @@ output_from_parsed_template = template.render(h2 = 1,
|
||||||
title="View internal logs",
|
title="View internal logs",
|
||||||
role=role,
|
role=role,
|
||||||
user=user,
|
user=user,
|
||||||
onclick = "viewLogs()",
|
|
||||||
serv=serv,
|
serv=serv,
|
||||||
select_id="viewlogs",
|
select_id="viewlogs",
|
||||||
selects=selects,
|
selects=selects,
|
||||||
|
|
|
@ -718,6 +718,14 @@ $( function() {
|
||||||
} );
|
} );
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
$('#show_log_form').submit(function() {
|
||||||
|
if(cur_url[0] == '/app/logs.py') {
|
||||||
|
showLog();
|
||||||
|
} else {
|
||||||
|
viewLogs();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
var showUpdates = $( "#show-updates" ).dialog({
|
var showUpdates = $( "#show-updates" ).dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
|
Loading…
Reference in New Issue