diff --git a/app/log.py b/app/log.py index f5a5426..5fb5ce8 100644 --- a/app/log.py +++ b/app/log.py @@ -1,6 +1,6 @@ from flask import render_template, Blueprint, request, url_for from flask_user import login_required, current_user -from app.models import CommandLog, ActivityLog, db, Account, CharacterInfo +from app.models import CommandLog, ActivityLog, db, Account, CharacterInfo, AuditLog from datatables import ColumnDT, DataTables import time from app import gm_level @@ -21,6 +21,20 @@ def command(): return render_template('logs/command.html.j2') +@log_blueprint.route('/errors') +@gm_level(8) +def error(): + with open('nexus_dashboard.log', 'r') as file: + logs = ''.join(file.read().split('\n')[-100:]) + return render_template('logs/error.html.j2', logs=logs) + + +@log_blueprint.route('/audits') +@gm_level(8) +def audit(): + return render_template('logs/audit.html.j2') + + @log_blueprint.route('/get_activities', methods=['GET']) @login_required @gm_level(8) @@ -96,3 +110,33 @@ def get_commands(): """ return data + + +@log_blueprint.route('/get_audits', methods=['GET']) +@login_required +@gm_level(8) +def get_audits(): + columns = [ + ColumnDT(AuditLog.id), # 0 + ColumnDT(AuditLog.account_id), # 1 + ColumnDT(AuditLog.action), # 2 + ColumnDT(AuditLog.date), # 2 + ] + + query = db.session.query().select_from(AuditLog) + + params = request.args.to_dict() + + rowTable = DataTables(params, query, columns) + + data = rowTable.output_result() + for audit in data["data"]: + char_id = audit["1"] + audit["1"] = f""" + + {Account.query.filter(Account.id==audit['1']).first().username} + + """ + + return data diff --git a/app/main.py b/app/main.py index 95b8f33..4da900a 100644 --- a/app/main.py +++ b/app/main.py @@ -40,11 +40,3 @@ def favicon(): 'favicon.ico', mimetype='image/vnd.microsoft.icon' ) - -@main_blueprint.route('/logs') -@gm_level(9) -def logs(): - with open('nexus_dashboard.log', 'r') as file: - logs = ''.join(file.read().split('\n')[-100:]) - return render_template('main/logs.html.j2', logs=logs) - return ''.join(all_read_text.splitlines()[-total_lines_wanted:]) diff --git a/app/templates/header.html.j2 b/app/templates/header.html.j2 index fe1bb93..0e35694 100644 --- a/app/templates/header.html.j2 +++ b/app/templates/header.html.j2 @@ -52,22 +52,24 @@ Tools
diff --git a/app/templates/logs/audit.html.j2 b/app/templates/logs/audit.html.j2 new file mode 100644 index 0000000..2ea8d72 --- /dev/null +++ b/app/templates/logs/audit.html.j2 @@ -0,0 +1,46 @@ +{% extends 'base.html.j2' %} + +{% block title %} + Audit Log +{% endblock title %} + +{% block content_before %} + Audit Log +{% endblock content_before %} + +{% block content %} + {% if message %} +ID | +Account | +Command | +Date | +
---|
- {{ logs }}
-
+
+ {{ logs }}
+
+