mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-25 15:07:18 +00:00
Merge pull request #19 from DarkflameUniverse/v1-polish
This commit is contained in:
commit
e9aef0219e
46
app/log.py
46
app/log.py
@ -1,6 +1,6 @@
|
|||||||
from flask import render_template, Blueprint, request, url_for
|
from flask import render_template, Blueprint, request, url_for
|
||||||
from flask_user import login_required, current_user
|
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
|
from datatables import ColumnDT, DataTables
|
||||||
import time
|
import time
|
||||||
from app import gm_level
|
from app import gm_level
|
||||||
@ -21,6 +21,20 @@ def command():
|
|||||||
return render_template('logs/command.html.j2')
|
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 = '</br>'.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'])
|
@log_blueprint.route('/get_activities', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
@gm_level(8)
|
@gm_level(8)
|
||||||
@ -96,3 +110,33 @@ def get_commands():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
return data
|
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"""
|
||||||
|
<a role="button" class="btn btn-primary btn btn-block"
|
||||||
|
href='{url_for('accounts.view', id=char_id)}'>
|
||||||
|
{Account.query.filter(Account.id==audit['1']).first().username}
|
||||||
|
</a>
|
||||||
|
"""
|
||||||
|
|
||||||
|
return data
|
||||||
|
@ -40,11 +40,3 @@ def favicon():
|
|||||||
'favicon.ico',
|
'favicon.ico',
|
||||||
mimetype='image/vnd.microsoft.icon'
|
mimetype='image/vnd.microsoft.icon'
|
||||||
)
|
)
|
||||||
|
|
||||||
@main_blueprint.route('/logs')
|
|
||||||
@gm_level(9)
|
|
||||||
def logs():
|
|
||||||
with open('nexus_dashboard.log', 'r') as file:
|
|
||||||
logs = '</br>'.join(file.read().split('\n')[-100:])
|
|
||||||
return render_template('main/logs.html.j2', logs=logs)
|
|
||||||
return '</br>'.join(all_read_text.splitlines()[-total_lines_wanted:])
|
|
||||||
|
@ -52,22 +52,24 @@
|
|||||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Tools</a>
|
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Tools</a>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
|
|
||||||
<a class="dropdown-item" href='{{ url_for('mail.send') }}'>Send Mail</a>
|
<a class="dropdown-item text-center" href='{{ url_for('mail.send') }}'>Send Mail</a>
|
||||||
<hr/>
|
<hr/>
|
||||||
<h6 class="text-center">Moderation</h6>
|
<h3 class="text-center">Moderation</h3>
|
||||||
<a class="dropdown-item" href='{{ url_for('moderation.index', status='unapproved') }}'>View Unapproved Items</a>
|
<a class="dropdown-item text-center" href='{{ url_for('moderation.index', status='unapproved') }}'>Unapproved Items</a>
|
||||||
<a class="dropdown-item" href='{{ url_for('moderation.index', status='approved') }}'>View Approved Items</a>
|
<a class="dropdown-item text-center" href='{{ url_for('moderation.index', status='approved') }}'>Approved Items</a>
|
||||||
<a class="dropdown-item" href='{{ url_for('moderation.index', status='all') }}'>View All Items</a>
|
<a class="dropdown-item text-center" href='{{ url_for('moderation.index', status='all') }}'>All Items</a>
|
||||||
<hr/>
|
<hr/>
|
||||||
<h6 class="text-center">Bug Reports</h6>
|
<h3 class="text-center">Bug Reports</h3>
|
||||||
<a class="dropdown-item" href='{{ url_for('bug_reports.index', status='unresolved') }}'>View Unresolved Reports</a>
|
<a class="dropdown-item text-center" href='{{ url_for('bug_reports.index', status='unresolved') }}'>Unresolved Reports</a>
|
||||||
<a class="dropdown-item" href='{{ url_for('bug_reports.index', status='resolved') }}'>View Resolved Reports</a>
|
<a class="dropdown-item text-center" href='{{ url_for('bug_reports.index', status='resolved') }}'>Resolved Reports</a>
|
||||||
<a class="dropdown-item" href='{{ url_for('bug_reports.index', status='all') }}'>View All Reports</a>
|
<a class="dropdown-item text-center" href='{{ url_for('bug_reports.index', status='all') }}'>All Reports</a>
|
||||||
{% if current_user.is_authenticated and current_user.gm_level >= 8 %}
|
{% if current_user.is_authenticated and current_user.gm_level >= 8 %}
|
||||||
<hr/>
|
<hr/>
|
||||||
<h6 class="text-center">Logs</h6>
|
<h3 class="text-center">Logs</h3>
|
||||||
<a class="dropdown-item" href='{{ url_for('log.activity') }}'>Command Log</a>
|
<a class="dropdown-item text-center" href='{{ url_for('log.activity') }}'>Command Log</a>
|
||||||
<a class="dropdown-item" href='{{ url_for('log.command') }}'>Activity Log</a>
|
<a class="dropdown-item text-center" href='{{ url_for('log.command') }}'>Activity Log</a>
|
||||||
|
<a class="dropdown-item text-center" href='{{ url_for('log.audit') }}'>Audit Log</a>
|
||||||
|
<a class="dropdown-item text-center" href='{{ url_for('log.error') }}'>Error Log</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
46
app/templates/logs/audit.html.j2
Normal file
46
app/templates/logs/audit.html.j2
Normal file
@ -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 %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col text-center">
|
||||||
|
<h3>{{ message }}</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
{% endif %}
|
||||||
|
<table class="table table-dark table-striped table-bordered table-hover" id="audit_table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Account</th>
|
||||||
|
<th>Command</th>
|
||||||
|
<th>Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ super () }}
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
let audit_table = $('#audit_table').DataTable({
|
||||||
|
"order": [[0, "desc"]],
|
||||||
|
"processing": true,
|
||||||
|
"serverSide": true,
|
||||||
|
"ajax": "{{ url_for('log.get_audits') }}",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
@ -7,7 +7,9 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content_override %}
|
{% block content_override %}
|
||||||
|
<div class="bg-white mx-5 p-3 rounded">
|
||||||
<code>
|
<code>
|
||||||
{{ logs }}
|
{{ logs }}
|
||||||
</code>
|
</code>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user