Pavel Loginov 4 years ago
parent 79275a6360
commit a26482623f

@ -16,7 +16,7 @@ exgrep = form.getvalue('exgrep') if form.getvalue('exgrep') else ''
if form.getvalue('rows') is None:
rows = 10
else:
if form.getvalue('rows1') not is None:
if form.getvalue('rows1') is not None:
rows = form.getvalue('rows1')
else:
rows = form.getvalue('rows')
@ -46,7 +46,6 @@ template = template.render(h2 = 1,
title = title,
role = role,
user = user,
onclick = "showLog()",
select_id = "serv",
selects = servers,
serv = form.getvalue('serv'),

@ -6,7 +6,7 @@
<table class="overview">
<tr class="overviewHead">
<td class="padding10 first-collumn" style="width: 10%;">
{% if onclick == 'viewLogs()' %}
{% if select_id == 'viewlogs' %}
Log
{% else %}
Server
@ -15,19 +15,20 @@
{% if onclick != 'viewLogs()' and service != 'nginx' %}
<td style="width: 5%;">WAF logs</td>
{% endif %}
<td style="width: 10%;">Number rows</td>
<td class="padding10" style="width: 10%;">Ex for grep</td>
<td>Number rows</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%;">
<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_hour1', value=hour1, class='time-range', readonly='readonly') }}:{{ input('time_range_out_minut1', value=minut1, class='time-range', readonly='readonly') }}
</td>
<td style="width: 10%;"> </td>
<td></td>
</tr>
<tr>
<td class="padding10 first-collumn" style="width: 10%;">
<form action="" method="post">
{% if onclick == 'viewLogs()' %}
<form action="" method="post" id="show_log_form">
{% if select_id == 'viewlogs' %}
<select autofocus required name="serv" id="{{ select_id }}">
<option disabled selected>Choose log</option>
{% for select in selects %}
@ -42,29 +43,32 @@
{% include 'include/select.html' %}
{% endif %}
</td>
{% if onclick != 'viewLogs()' and service != 'nginx' %}
{% if select_id == 'viewlogs' and service != 'nginx' %}
<td>
{{ checkbox('waf') }}
</td>
{% endif %}
<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 class="padding10" style="width: 10%;">
{{ input('grep', value=grep) }}
</td>
<td class="padding10" style="width: 10%;">
{{ input('exgrep', value=exgrep) }}
</td>
<td class="padding10" style="width: 10%;">
<div id="time-range"></div>
</td>
<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>
</td>
</tr>
</table>
<div id="ajax">
</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>
viewLogs()
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 sql
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('templates/'), autoescape=True)
template = env.get_template('logs.html')
form = funct.form
@ -49,7 +50,8 @@ try:
if datetime.datetime.now() - file_modified > datetime.timedelta(hours=time_storage_hours):
os.remove(curpath)
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
try:
@ -57,7 +59,6 @@ try:
except:
pass
selects = funct.get_files(log_path, format="log")
selects.append(['fail2ban.log', 'fail2ban.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",
role=role,
user=user,
onclick = "viewLogs()",
serv=serv,
select_id="viewlogs",
selects=selects,

@ -718,6 +718,14 @@ $( function() {
} );
return false;
});
$('#show_log_form').submit(function() {
if(cur_url[0] == '/app/logs.py') {
showLog();
} else {
viewLogs();
}
return false;
});
var showUpdates = $( "#show-updates" ).dialog({
autoOpen: false,
resizable: false,

Loading…
Cancel
Save