Add dashboard audit log and configuration management

- Implemented dashboard audit logging with InsertAuditLog, GetRecentAuditLogs, GetAuditLogsByIP, and CleanupOldAuditLogs methods.
- Created dashboard configuration management with GetDashboardConfig and SetDashboardConfig methods.
- Added new tables for dashboard_audit_log and dashboard_config in both MySQL and SQLite migrations.
- Updated CMakeLists to include Crow and ASIO for dashboard server functionality.
- Enhanced existing database classes to support new dashboard features, including character, play key, and property management.
- Added new methods for retrieving and managing play keys, properties, and pet names.
- Updated TestSQLDatabase to include stubs for new dashboard-related methods.
- Modified shared and dashboard configuration files for new settings.
This commit is contained in:
Aaron Kimbrell
2026-04-22 11:01:41 -05:00
parent d532a9b063
commit e3467465b4
92 changed files with 9133 additions and 77 deletions

View File

@@ -0,0 +1,143 @@
<!doctype html>
<html lang='en'>
<head>
<!-- Title -->
<title>{{#title}}{{title}}{{/title}}{{^title}}Dashboard{{/title}} - {{config.APP_NAME}}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{{! CSS }}
<style>
.required:after {
content:" *";
color: red;
}
.error {
color: red;
}
</style>
<!-- Bootstrap 5 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
<!-- DataTables CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css">
<!-- Custom CSS consolidated -->
<link rel="stylesheet" href="/static/css/dashboard.css">
</head>
<body class="bg-dark text-white">
{{> header}}
<!-- Content -->
<div class="container py-0">
<!-- Text -->
<div class="text-center">
<span class="h3 mb-0"><br/>{{content_before}}<br/><br/></span>
</div>
<!-- Flashed messages: expect `messages` to be an array of {category, message} -->
{! TODO: make this dynamic toasts !!}
{{#messages}}
<div class="alert alert-{{category}}" role="alert">
{{message}}
</div>
{{/messages}}
</div>
<div class='container mt-4'>
{{content}}
</div>
<div class='container mt-4'>
{{content_after}}
</div>
<footer>
{{#footer}}
<hr class="my-5"/>
{{/footer}}
</footer>
{{! JS assets }}
<!-- Bootstrap JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- jQuery (optional fallback for older scripts) -->
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<!-- DataTables JS -->
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<!-- Shared helper: wait for jQuery/DataTables (keeps pages resilient to CDN timing) -->
<script src="/static/js/wait-for-jq-dt.js"></script>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<!-- Custom JS -->
<script src="/static/js/api.js"></script>
<script src="/static/js/dashboard.js"></script>
<script src="/static/js/login.js"></script>
<script>
// set the active nav-link item (use vanilla JS, fallback to jQuery)
(function(){
var endpoint = '{{request_endpoint}}' || '';
try{
var target_nav = '#' + endpoint.replace(/\./g, '-');
var el = document.querySelector(target_nav);
if(el) el.classList.add('active');
else if(window.jQuery) $(target_nav).addClass('active');
}catch(e){}
})();
// initialize Bootstrap 5 tooltips (no jQuery required)
(function(){
try{
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.forEach(function (tooltipTriggerEl) {
new bootstrap.Tooltip(tooltipTriggerEl);
});
}catch(e){
// fallback for legacy attribute name if still used
// legacy jQuery tooltip fallback (only runs if bootstrap init failed and jQuery tooltip is present)
if(window.jQuery && window.jQuery.fn && window.jQuery.fn.tooltip) $(function(){ $('[data-toggle="tooltip"]').tooltip(); });
}
})();
function setInnerHTML(elm, html) {
elm.innerHTML = html;
// re-init Bootstrap tooltips inside newly injected content
try{
var tooltipTriggerList = [].slice.call(elm.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.forEach(function (tooltipTriggerEl) {
new bootstrap.Tooltip(tooltipTriggerEl);
});
}catch(e){
if(window.jQuery && window.jQuery.fn && window.jQuery.fn.tooltip) $("body").tooltip({ selector: '[data-toggle=tooltip]' });
}
Array.from(elm.querySelectorAll("script")).forEach(function(oldScriptEl) {
var newScriptEl = document.createElement("script");
Array.from(oldScriptEl.attributes).forEach(function(attr) {
newScriptEl.setAttribute(attr.name, attr.value);
});
var scriptText = document.createTextNode(oldScriptEl.innerHTML || '');
newScriptEl.appendChild(scriptText);
oldScriptEl.parentNode.replaceChild(newScriptEl, oldScriptEl);
});
}
</script>
</body>
</html>

View File

@@ -0,0 +1,113 @@
{{! Navigation brand, nav toggle bar }}
<nav class='navbar navbar-expand-sm navbar-dark bg-primary flex-row pb-3'>
<div class='container md-0 flex-nowrap'>
{{! Logo and App Name }}
<nav class="navbar">
<a class="navbar-brand" href="{{url.main_index}}">
<img src="{{static.logo}}" width="30" height="30" class="d-inline-block align-top" alt="">
{{config.APP_NAME}}
</a>
</nav>
{{! Navigation brand, nav toggle bar }}
<nav class='navbar navbar-expand-sm navbar-dark bg-primary flex-row pb-3'>
<div class='container md-0 flex-nowrap'>
{{! Logo and App Name }}
<nav class="navbar">
<a class="navbar-brand" href="{{url.main_index}}">
<img src="{{static.logo}}" width="30" height="30" class="d-inline-block align-top" alt="">
{{config.APP_NAME}}
</a>
</nav>
{{! Visible only on large devices }}
<nav class='navbar-nav'>
<div class='collapse navbar-collapse'>
{{#current_user_authenticated}}
{{#USER_ENABLE_INVITE_USER}}
<a class='btn-nav-dashboard me-2' href='{{url.user_invite_user}}'>Invite</a>
{{/USER_ENABLE_INVITE_USER}}
<a class='btn-nav-dashboard' href='{{url.user_logout}}'><i class='fas fa-sign-out-alt me-1'></i>Logout</a>
{{/current_user_authenticated}}
</div>
</nav>
<button class='navbar-toggler' type='button' data-bs-toggle='collapse' data-bs-target='#navbarSupportedContent' aria-controls='navbarSupportedContent' aria-expanded='false' aria-label='Toggle navigation'>
<span class='navbar-toggler-icon'></span>
</button>
</div>
</nav>
{{! Navigation menu / links bar }}
<nav class='navbar navbar-expand-sm navbar-dark bg-primary p-sm-0 py-0 {{#navbar_shadow}}shadow-sm{{/navbar_shadow}}'>
<div class='container mt-0 pt-0'>
<div class='collapse navbar-collapse' id='navbarSupportedContent' style='margin-top: -16px;'>
<nav class='navbar-nav me-auto'>
<a id='main-index' class='nav-link' href='{{url.main_index}}'>Home</a>
{{#gm_ge_3}}
{{! General Moderation Links }}
<a id='accounts-index' class='nav-link' href='{{url.accounts_index}}'>Accounts</a>
<a id='character-index' class='nav-link' href='{{url.characters_index}}'>Characters</a>
<a id='property-index' class='nav-link' href='{{url.properties_index}}'>Properties</a>
{{/gm_ge_3}}
{{#gm_ge_5_require_play_key}}
{{! Play Keys }}
<a id='play_keys-index' class='nav-link' href='{{url.play_keys_index}}'>Play Keys</a>
{{/gm_ge_5_require_play_key}}
{{#gm_ge_2}}
<a id='report-index' class='nav-link' href='{{url.reports_index}}'>Reports</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Tools</a>
<div class="dropdown-menu">
<a class="dropdown-item text-center" href='{{url.mail_send}}'>Send Mail</a>
<hr/>
<h3 class="text-center">Moderation</h3>
<a class="dropdown-item text-center" href='{{url.moderation_unapproved}}'>Unapproved Items</a>
<a class="dropdown-item text-center" href='{{url.moderation_approved}}'>Approved Items</a>
<a class="dropdown-item text-center" href='{{url.moderation_all}}'>All Items</a>
<hr/>
<h3 class="text-center">Bug Reports</h3>
<a class="dropdown-item text-center" href='{{url.bug_reports_unresolved}}'>Unresolved Reports</a>
<a class="dropdown-item text-center" href='{{url.bug_reports_resolved}}'>Resolved Reports</a>
<a class="dropdown-item text-center" href='{{url.bug_reports_all}}'>All Reports</a>
{{#gm_ge_8}}
<hr/>
<h3 class="text-center">Logs</h3>
<a class="dropdown-item text-center" href='{{url.log_command}}'>Command Log</a>
<a class="dropdown-item text-center" href='{{url.log_activity}}'>Activity Log</a>
<a class="dropdown-item text-center" href='{{url.log_audit}}'>Audit Log</a>
<a class="dropdown-item text-center" href='{{url.log_system}}'>System Log</a>
{{/gm_ge_8}}
</div>
</li>
{{/gm_ge_2}}
{{#gm_eq_0}}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Bug Reports</a>
<div class="dropdown-menu">
<a class="dropdown-item text-center" href='{{url.bug_reports_unresolved}}'>Unresolved Reports</a>
<a class="dropdown-item text-center" href='{{url.bug_reports_resolved}}'>Resolved Reports</a>
<a class="dropdown-item text-center" href='{{url.bug_reports_all}}'>All Reports</a>
</div>
</li>
{{/gm_eq_0}}
{{#current_user_authenticated}}
<a id='main-about' class='nav-link' href='{{url.main_about}}'>About</a>
{{/current_user_authenticated}}
{{#current_user_authenticated}}
<a class='nav-link d-sm-none' href='{{url.user_logout}}'><i class='fas fa-sign-out-alt me-1'></i>Logout</a>
{{/current_user_authenticated}}
</nav>
</div>
</div>
</nav>