mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 02:39:26 +08:00
update
This commit is contained in:
@@ -21,8 +21,8 @@ def index():
|
||||
return render_template('files.html', data={})
|
||||
|
||||
# 获取文件内容
|
||||
@blueprint.route('/get_body', endpoint='getFileBody', methods=['POST'])
|
||||
def getFileBody():
|
||||
@blueprint.route('/get_body', endpoint='get_file_body', methods=['POST'])
|
||||
def get_file_body():
|
||||
path = request.form.get('path', '')
|
||||
|
||||
if not os.path.exists(path):
|
||||
@@ -55,8 +55,8 @@ def getFileBody():
|
||||
return mw.returnData(True, 'OK', data)
|
||||
|
||||
# 获取文件内容
|
||||
@blueprint.route('/save_body', endpoint='saveBody', methods=['POST'])
|
||||
def saveBody():
|
||||
@blueprint.route('/save_body', endpoint='save_body', methods=['POST'])
|
||||
def save_body():
|
||||
path = request.form.get('path', '')
|
||||
data = request.form.get('data', '')
|
||||
encoding = request.form.get('encoding', '')
|
||||
@@ -79,8 +79,8 @@ def saveBody():
|
||||
return mw.returnData(False, '文件保存错误:' + str(ex))
|
||||
|
||||
# 获取文件内容(最新行数)
|
||||
@blueprint.route('/get_last_body', endpoint='getFileLastBody', methods=['POST'])
|
||||
def getFileLastBody():
|
||||
@blueprint.route('/get_last_body', endpoint='get_file_last_body', methods=['POST'])
|
||||
def get_file_last_body():
|
||||
path = request.form.get('path', '')
|
||||
line = request.form.get('line', '100')
|
||||
|
||||
@@ -94,6 +94,29 @@ def getFileLastBody():
|
||||
return mw.returnData(False, '无法正确读取文件!' + str(ex))
|
||||
|
||||
|
||||
# 获取文件列表
|
||||
@blueprint.route('/get_dir', endpoint='get_dir', methods=['POST'])
|
||||
def get_dir():
|
||||
path = request.form.get('path', '')
|
||||
if not os.path.exists(path):
|
||||
path = mw.getRootDir() + "/wwwroot"
|
||||
search = request.args.get('search', '').strip().lower()
|
||||
search_all = request.args.get('all', '').strip().lower()
|
||||
page = request.args.get('p', '1').strip().lower()
|
||||
row = request.args.get('row', '10')
|
||||
order = request.form.get('order', '')
|
||||
|
||||
print(path,search,search_all,page,row,order)
|
||||
if not os.path.exists(path):
|
||||
return mw.returnData(False, '文件不存在', (path,))
|
||||
|
||||
try:
|
||||
data = mw.getLastLine(path, int(line))
|
||||
return mw.returnData(True, 'OK', data)
|
||||
except Exception as ex:
|
||||
return mw.returnData(False, '无法正确读取文件!' + str(ex))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,15 @@
|
||||
|
||||
|
||||
from flask import Blueprint, render_template
|
||||
from flask import request
|
||||
|
||||
from admin.user_login_check import panel_login_required
|
||||
from admin.model import db, Logs
|
||||
|
||||
import core.mw as mw
|
||||
import utils.adult_log as adult_log
|
||||
|
||||
# 日志页面
|
||||
blueprint = Blueprint('logs', __name__, url_prefix='/logs', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
def index():
|
||||
@@ -23,10 +29,60 @@ def index():
|
||||
@blueprint.route('/get_log_list', endpoint='get_log_list', methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_log_list():
|
||||
return []
|
||||
p = request.form.get('p', '1').strip()
|
||||
size = request.form.get('limit', '10').strip()
|
||||
search = request.form.get('search', '').strip()
|
||||
|
||||
# 审计日志列表
|
||||
count = Logs.query.filter_by().count()
|
||||
if search != '':
|
||||
pagination = Logs.query.filter_by(Logs.type.like(search) or Logs.log.like(search)).paginate(page=int(p), per_page=int(size))
|
||||
else:
|
||||
pagination = Logs.query.filter_by().paginate(page=int(p), per_page=int(size))
|
||||
|
||||
rows = []
|
||||
for item in pagination.items:
|
||||
t = {}
|
||||
t['id'] = item.id
|
||||
t['type'] = item.type
|
||||
t['log'] = item.log
|
||||
t['uid'] = item.uid
|
||||
t['add_time'] = item.add_time
|
||||
rows.append(t)
|
||||
|
||||
data = {}
|
||||
data['data'] = rows
|
||||
data['page'] = mw.getPage({'count':count,'tojs':'getLogs','p':p})
|
||||
return data
|
||||
|
||||
# 日志清空
|
||||
@blueprint.route('/del_panel_logs', endpoint='del_panel_logs', methods=['POST'])
|
||||
@panel_login_required
|
||||
def del_panel_logs():
|
||||
db.session.query(Logs).filter(Logs.id > 0).delete()
|
||||
# db.session.execute('truncate table logs;')
|
||||
db.session.commit()
|
||||
mw.writeLog('面板设置', '面板操作日志已清空!')
|
||||
return mw.returnData(True, '面板操作日志已清空!')
|
||||
|
||||
# 系统审计日志列表
|
||||
@blueprint.route('/get_audit_logs_files', endpoint='get_audit_logs_files', methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_audit_logs_files():
|
||||
return []
|
||||
logs_file = adult_log.getAuditLogsFiles()
|
||||
return logs_file
|
||||
|
||||
# 系统审计日志列表
|
||||
@blueprint.route('/get_audit_file', endpoint='get_audit_file', methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_audit_file():
|
||||
name = request.form.get('log_name', '').strip()
|
||||
return adult_log.getAuditLogsName(name)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
import json
|
||||
|
||||
from admin.model import db, Logs
|
||||
import core.mw as mw
|
||||
|
||||
def add(type, log, uid=1) -> str:
|
||||
add_time = mw.formatDate()
|
||||
add_logs = Logs(
|
||||
uid=uid,
|
||||
log=log,
|
||||
type=type,
|
||||
add_time=add_time)
|
||||
db.session.add(add_logs)
|
||||
db.session.commit()
|
||||
return True
|
||||
Reference in New Issue
Block a user