日志功能从防火墙提出来

This commit is contained in:
midoks
2023-08-26 00:24:04 +08:00
parent f9f1b1a113
commit b3120f3435
8 changed files with 225 additions and 77 deletions
+19
View File
@@ -0,0 +1,19 @@
# coding: utf-8
# ---------------------------------------------------------------------------------
# MW-Linux面板
# ---------------------------------------------------------------------------------
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
# ---------------------------------------------------------------------------------
# Author: midoks <midoks@163.com>
# ---------------------------------------------------------------------------------
# ---------------------------------------------------------------------------------
# 日志类操作
# ---------------------------------------------------------------------------------
class logs_api:
def __init__(self):
pass
+2 -2
View File
@@ -513,7 +513,7 @@ def index(reqClass=None, reqAction=None, reqData=None):
if reqClass == None:
reqClass = 'index'
pageFile = ('config', 'control', 'crontab', 'files', 'firewall',
pageFile = ('config', 'control', 'crontab', 'files', 'logs', 'firewall',
'index', 'plugins', 'login', 'system', 'site', 'cert', 'ssl', 'task', 'soft')
if reqClass == 'login':
@@ -553,7 +553,7 @@ def index(reqClass=None, reqAction=None, reqData=None):
return 'error request!'
# API请求
classFile = ('config_api', 'crontab_api', 'files_api', 'firewall_api',
classFile = ('config_api', 'crontab_api', 'files_api', 'logs_api', 'firewall_api',
'plugins_api', 'system_api', 'site_api', 'task_api', 'vip_api')
className = reqClass + '_api'
if not className in classFile:
-41
View File
@@ -6,10 +6,6 @@ setTimeout(function(){
showAccept(1);
},1000);
setTimeout(function(){
getLogs(1);
},1500);
$(function(){
// start
@@ -124,7 +120,6 @@ function getSshInfo(){
$("#firewall_status").html(fStatus);
showAccept(1);
getLogs(1);
},'json');
}
@@ -371,39 +366,3 @@ function delAcceptPort(id, port) {
},'json');
});
}
/**
* 取回数据
* @param {Int} page 分页号
*/
function getLogs(page,search) {
search = search == undefined ? '':search;
var loadT = layer.load();
$.post('/firewall/get_log_list','limit=10&p=' + page+"&search="+search, function(data) {
layer.close(loadT);
var body = '';
for (var i = 0; i < data.data.length; i++) {
body += "<tr>\
<td><em class='dlt-num'>" + data.data[i].id + "</em></td>\
<td>" + data.data[i].type + "</td>\
<td>" + data.data[i].log + "</td>\
<td>" + data.data[i].addtime + "</td>\
</tr>";
}
$("#logsBody").html(body);
$("#logsPage").html(data.page);
},'json');
}
//清理面板日志
function delLogs(){
layer.confirm('即将清空面板日志,继续吗?',{title:'清空日志',closeBtn:2},function(){
var loadT = layer.msg('正在清理,请稍候...',{icon:16});
$.post('/firewall/del_panel_logs','',function(rdata){
layer.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:2});
getLogs(1);
},'json');
});
}
+59
View File
@@ -0,0 +1,59 @@
$(document).ready(function(){
getLogs(1);
logsLoad();
});
function changeLogsViewH(){
var l = $(window).height();
$('.container-fluid .tab-view-box').css('max-height',l-80-60);
}
function logsLoad(){
changeLogsViewH();
$(window).resize(function(){
changeLogsViewH();
});
}
$('#panelLogs .refresh').click(function(){
getLogs(1);
});
$('#panelLogs .clear').click(function(){
delLogs(1);
});
function getLogs(page,search) {
search = search == undefined ? '':search;
var loadT = layer.load();
$.post('/firewall/get_log_list','limit=10&p=' + page+"&search="+search, function(data) {
layer.close(loadT);
var body = '';
for (var i = 0; i < data.data.length; i++) {
body += "<tr>\
<td><em class='dlt-num'>" + data.data[i].id + "</em></td>\
<td>" + data.data[i].type + "</td>\
<td>" + data.data[i].log + "</td>\
<td>" + data.data[i].addtime + "</td>\
</tr>";
}
$("#operationLog tbody").html(body);
$("#panelLogs .page").html(data.page);
},'json');
}
function delLogs(){
layer.confirm('即将清空面板日志,继续吗?',{title:'清空日志',closeBtn:2},function(){
var loadT = layer.msg('正在清理,请稍候...',{icon:16});
$.post('/firewall/del_panel_logs','',function(rdata){
layer.close(loadT);
layer.msg(rdata.msg,{icon:rdata.status?1:2});
getLogs(1);
},'json');
});
}
File diff suppressed because one or more lines are too long
+1 -30
View File
@@ -106,36 +106,7 @@
</div>
</div>
</div>
<div class="white-black-ip bgw mtb15">
<div class="black-ip">
<div class="def-log">
<div class="title c6 plr15">
<h3 class="f16">面板操作日志</h3>
<a class="btn btn-default btn-sm" onclick="delLogs();" style="margin-top: 1px;">清空</a>
</div>
<div class="divtable pd15">
<div class="tablescroll">
<table class="table table-hover" style="min-width: 640px;border: 0 none;">
<thead>
<tr>
<th>编号</th>
<th>操作类型</th>
<th>详情</th>
<th>操作时间</th>
</tr>
</thead>
<tbody id="logsBody"></tbody>
</table>
</div>
<div class="dataTables_paginate paging_bootstrap pagination">
<ul id="logsPage" class="page"></ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="/static/app/firewall.js?v={{config.version}}"></script>
+1
View File
@@ -53,6 +53,7 @@
<li id="memuAcontrol"><a class="menu_control" href="/control">监控</a></li>
<li id="memuAfirewall"><a class="menu_firewall" href="/firewall">安全</a></li>
<li id="memuAfiles"><a class="menu_folder" href="/files">文件</a></li>
<li id="memuAlogs"><a class="menu_logs" href="/logs">日志</a></li>
<li id="memuAcrontab"><a class="menu_day" href="/crontab">计划任务</a></li>
<!-- 插件设置的菜单 -->
{% for menu in data['hook_menu'] %}
+61
View File
@@ -0,0 +1,61 @@
{% extends "layout.html" %}
{% block content %}
<style type="text/css">
#operationLog thead th:nth-child(1),
#operationLog tbody tr td:nth-child(1){width:100px;}
#operationLog thead th:nth-child(2),
#operationLog tbody tr td:nth-child(2){width:130px;}
#operationLog thead th:nth-child(4),
#operationLog tbody tr td:nth-child(4){width:150px;}
</style>
<div class="main-content" style="min-height: 389px;">
<div class="container-fluid" style="padding-bottom: 50px;">
<div id="cutTab" class="pos-box bgw mtb15" style="height:45px">
<div class="tab-list">
<div class="tabs-item active" data-name="panelLogs">面板日志</div>
<div class="tabs-item" data-name="logAudit">日志审计</div>
</div>
</div>
<div class="bgw mtb15 pd15 tab-view-box firewall-tab-view">
<!-- logs start -->
<div class="tab-con show w-full" id="panelLogs" style="padding: 0px;">
<div id="operationLog" style="position: relative;">
<div class="tootls_group tootls_top">
<div class="pull-left">
<button type="button" title="刷新日志" class="refresh btn btn-success btn-sm mr5">
<span>刷新日志</span>
</button>
<button type="button" title="清空日志" class="clear btn btn-default btn-sm mr5">
<span>清空日志</span>
</button>
</div>
</div>
<div class="divtable mtb10">
<table class="table table-hover">
<thead style="position: relative;z-index: 1;"><tr>
<th><span>编号</span></th>
<th><span>操作类型</span></th>
<th><span>详情</span></th>
<th><span>操作时间</span></th>
</tr></thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="dataTables_paginate paging_bootstrap page operationLog">
<div><span class="Pcurrent">1</span><span class="Pcount">共1条</span></div>
</div>
</div>
<!-- logs end -->
</div>
</div>
</div>
<script src="/static/app/logs.js?v={{config.version}}"></script>
{% endblock %}