v8.2: Refactor log handling and cleanup unused code

Convert WAF parameter from string to integer for consistency. Update JavaScript comparison operators for strict equality checks. Remove unused functions and intro.js library to streamline and simplify the codebase.
pull/399/head
Aidaho 2024-10-08 15:56:13 +03:00
parent b3b6f7f596
commit ca1a39ed96
5 changed files with 8 additions and 19 deletions

View File

@ -44,13 +44,12 @@ def show_log(stdout, **kwargs):
def show_roxy_log( def show_roxy_log(
serv, rows='10', waf='0', grep=None, exgrep=None, hour='00', serv, rows='10', waf=0, grep=None, exgrep=None, hour='00',
minute='00', hour1='24', minute1='00', service='haproxy', log_file='123', **kwargs minute='00', hour1='24', minute1='00', service='haproxy', log_file='123', **kwargs
) -> str: ) -> str:
date = checkAjaxInput(hour) + ':' + checkAjaxInput(minute) date = checkAjaxInput(hour) + ':' + checkAjaxInput(minute)
date1 = checkAjaxInput(hour1) + ':' + checkAjaxInput(minute1) date1 = checkAjaxInput(hour1) + ':' + checkAjaxInput(minute1)
rows = checkAjaxInput(rows) rows = checkAjaxInput(rows)
waf = checkAjaxInput(waf)
cmd = '' cmd = ''
awk_column = 3 awk_column = 3
grep_act = '' grep_act = ''
@ -90,7 +89,7 @@ def show_roxy_log(
if syslog_server is None or syslog_server == '': if syslog_server is None or syslog_server == '':
raise Exception('error: Syslog server is enabled, but there is no IP for syslog server') raise Exception('error: Syslog server is enabled, but there is no IP for syslog server')
if waf == "1": if waf:
local_path_logs = '/var/log/waf.log' local_path_logs = '/var/log/waf.log'
commands = "sudo cat %s |tail -%s %s %s" % (local_path_logs, rows, grep_act, exgrep_act) commands = "sudo cat %s |tail -%s %s %s" % (local_path_logs, rows, grep_act, exgrep_act)

View File

@ -112,8 +112,8 @@ def show_remote_log_files(service, serv):
) )
@bp.route('/<service>/<serv>/<rows>', defaults={'waf': '0'}, methods=['GET', 'POST']) @bp.route('/<service>/<serv>/<rows>', defaults={'waf': 0}, methods=['GET', 'POST'])
@bp.route('/<service>/waf/<serv>/<rows>', defaults={'waf': '1'}, methods=['GET', 'POST']) @bp.route('/<service>/waf/<serv>/<rows>', defaults={'waf': 1}, methods=['GET', 'POST'])
def show_logs(service, serv, rows, waf): def show_logs(service, serv, rows, waf):
grep = request.form.get('grep') or request.args.get('grep') grep = request.form.get('grep') or request.args.get('grep')
exgrep = request.form.get('exgrep') or request.args.get('exgrep') exgrep = request.form.get('exgrep') or request.args.get('exgrep')

View File

@ -228,15 +228,15 @@ function confirmAjaxAction(action, service, id, name) {
text: action_word, text: action_word,
click: function () { click: function () {
$(this).dialog("close"); $(this).dialog("close");
if (service == "haproxy") { if (service === "haproxy") {
ajaxActionServers(action, id, service); ajaxActionServers(action, id, service);
if (action == "restart" || action == "reload") { if (action === "restart" || action === "reload") {
if (localStorage.getItem('restart')) { if (localStorage.getItem('restart')) {
localStorage.removeItem('restart'); localStorage.removeItem('restart');
$("#apply").css('display', 'none'); $("#apply").css('display', 'none');
} }
} }
} else if (service == "waf") { } else if (service === "waf") {
ajaxActionServers(action, id, 'waf_haproxy'); ajaxActionServers(action, id, 'waf_haproxy');
} else { } else {
ajaxActionServers(action, id, service); ajaxActionServers(action, id, service);

View File

@ -165,13 +165,6 @@ function openVersions() {
let win = window.open(url,"_self"); let win = window.open(url,"_self");
win.focus(); win.focus();
} }
function openSection() {
let serv = $("#serv").val();
let section = $("#section").val();
let url = "/config/section/haproxy/"+serv+"/"+section;
let win = window.open(url,"_self");
win.focus();
}
function showLog() { function showLog() {
let waf = cur_url[0].split('?')[0]; let waf = cur_url[0].split('?')[0];
let file = $('#log_files').val(); let file = $('#log_files').val();
@ -197,7 +190,7 @@ function showLog() {
if (service === 'None') { if (service === 'None') {
service = 'haproxy'; service = 'haproxy';
} }
if (waf) { if (waf && waf != 'haproxy' && waf != 'nginx' && waf != 'apache' && waf != 'keepalived') {
url = "/logs/" + service + "/waf/" + serv + "/" + rows; url = "/logs/" + service + "/waf/" + serv + "/" + rows;
waf = 1; waf = 1;
} }

View File

@ -27,9 +27,6 @@
<script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" data-auto-replace-svg="nest"></script> <script src="https://use.fontawesome.com/releases/v5.15.4/js/all.js" data-auto-replace-svg="nest"></script>
<script>FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };</script> <script>FontAwesomeConfig = { searchPseudoElements: true, observeMutations: false };</script>
<script defer src="/static/js/ion.sound.min.js"></script> <script defer src="/static/js/ion.sound.min.js"></script>
<script defer src="/static/js/intro/introjs.min.js"></script>
<link href="/static/js/intro/introjs.min.css" rel="stylesheet">
<link href="/static/js/intro/introjs-modern.css" rel="stylesheet">
<link href="{{ url_for('static', filename='css/awesome-6.3.9.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/awesome-6.3.9.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/styles.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/nprogress.css') }}" rel="stylesheet"> <link href="{{ url_for('static', filename='css/nprogress.css') }}" rel="stylesheet">