mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-05-13 10:55:04 +00:00
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:
85
dDashboardServer/templates/moderation/pets.html
Normal file
85
dDashboardServer/templates/moderation/pets.html
Normal file
@@ -0,0 +1,85 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1 class="mb-4"><i class="bi bi-paw"></i> Pet Name Moderation</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">Pending Pet Names</div>
|
||||
<div class="card-body">
|
||||
<table id="pets-table" class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Character</th>
|
||||
<th>Pet Name</th>
|
||||
<th>Submitted</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let petsTable = null;
|
||||
|
||||
function loadPets() {
|
||||
API.get('/api/moderation/pets').then(res => {
|
||||
const data = Array.isArray(res.data) ? res.data : (res || []);
|
||||
|
||||
if ($.fn.DataTable.isDataTable('#pets-table')) {
|
||||
const table = $('#pets-table').DataTable();
|
||||
table.clear();
|
||||
table.rows.add(data);
|
||||
table.draw(false);
|
||||
petsTable = table;
|
||||
} else {
|
||||
petsTable = $('#pets-table').DataTable({
|
||||
data: data,
|
||||
columns: [
|
||||
{ data: 'id' },
|
||||
{ data: 'character_name' },
|
||||
{ data: 'pet_name' },
|
||||
{ data: 'submitted', render: d => d ? new Date(d * 1000).toLocaleString() : '-' },
|
||||
{ data: null, orderable: false, render: function(data, type, row) {
|
||||
return `
|
||||
<button class="btn btn-sm btn-success" onclick="approvePet(${row.id})">Approve</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="rejectPet(${row.id})">Reject</button>
|
||||
`;
|
||||
} }
|
||||
],
|
||||
order: [[0, 'desc']],
|
||||
pageLength: 25
|
||||
});
|
||||
}
|
||||
|
||||
}).catch(err => { alert(err && err.message ? err.message : 'Failed to load pets'); });
|
||||
}
|
||||
|
||||
// Initialize when libraries are ready
|
||||
safeInit(function($) {
|
||||
loadPets();
|
||||
}, { requireApi: true, timeout: 8000 });
|
||||
|
||||
window.approvePet = async function(id) {
|
||||
if (!confirm('Approve this pet name?')) return;
|
||||
try {
|
||||
const res = await API.post(`/api/moderation/pets/${id}/approve`);
|
||||
if (res && res.success) { loadPets(); alert('Approved'); } else { alert(res.error || 'Failed'); }
|
||||
} catch (err) { alert(err.message); }
|
||||
};
|
||||
|
||||
window.rejectPet = async function(id) {
|
||||
if (!confirm('Reject this pet name?')) return;
|
||||
try {
|
||||
const res = await API.post(`/api/moderation/pets/${id}/reject`);
|
||||
if (res && res.success) { loadPets(); alert('Rejected'); } else { alert(res.error || 'Failed'); }
|
||||
} catch (err) { alert(err.message); }
|
||||
};
|
||||
</script>
|
||||
82
dDashboardServer/templates/moderation/properties.html
Normal file
82
dDashboardServer/templates/moderation/properties.html
Normal file
@@ -0,0 +1,82 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1 class="mb-4"><i class="bi bi-house"></i> Property Moderation</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">Pending Properties</div>
|
||||
<div class="card-body">
|
||||
<table id="properties-table" class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Owner (Character)</th>
|
||||
<th>Property Name</th>
|
||||
<th>Submitted</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let propertiesTable = null;
|
||||
|
||||
function loadProperties() {
|
||||
API.get('/api/moderation/properties').then(res => {
|
||||
const data = Array.isArray(res.data) ? res.data : (res || []);
|
||||
|
||||
if ($.fn.DataTable.isDataTable('#properties-table')) {
|
||||
const table = $('#properties-table').DataTable();
|
||||
table.clear();
|
||||
table.rows.add(data);
|
||||
table.draw(false);
|
||||
propertiesTable = table;
|
||||
} else {
|
||||
propertiesTable = $('#properties-table').DataTable({
|
||||
data: data,
|
||||
columns: [
|
||||
{ data: 'id' },
|
||||
{ data: 'character_name' },
|
||||
{ data: 'property_name' },
|
||||
{ data: 'submitted', render: d => d ? new Date(d * 1000).toLocaleString() : '-' },
|
||||
{ data: null, orderable: false, render: function(data, type, row) {
|
||||
return `
|
||||
<button class="btn btn-sm btn-success" onclick="approveProperty(${row.id})">Approve</button>
|
||||
<button class="btn btn-sm btn-danger" onclick="rejectProperty(${row.id})">Reject</button>
|
||||
`;
|
||||
} }
|
||||
],
|
||||
order: [[0, 'desc']],
|
||||
pageLength: 25
|
||||
});
|
||||
}
|
||||
}).catch(err => { alert(err && err.message ? err.message : 'Failed to load properties'); });
|
||||
}
|
||||
|
||||
// Initialize when libraries are ready
|
||||
safeInit(function($) { loadProperties(); }, { requireApi: true, timeout: 8000 });
|
||||
|
||||
window.approveProperty = async function(id) {
|
||||
if (!confirm('Approve this property?')) return;
|
||||
try {
|
||||
const res = await API.post(`/api/moderation/properties/${id}/approve`);
|
||||
if (res && res.success) { loadProperties(); alert('Approved'); } else { alert(res.error || 'Failed'); }
|
||||
} catch (err) { alert(err.message); }
|
||||
};
|
||||
|
||||
window.rejectProperty = async function(id) {
|
||||
if (!confirm('Reject this property?')) return;
|
||||
try {
|
||||
const res = await API.post(`/api/moderation/properties/${id}/reject`);
|
||||
if (res && res.success) { loadProperties(); alert('Rejected'); } else { alert(res.error || 'Failed'); }
|
||||
} catch (err) { alert(err.message); }
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user