feat: complete React + Flask rebuild of dashboard

Backend:
- New Flask 3 app with service-layer architecture
- Pydantic v2 models and unified API response format
- psycopg3 connection pool with stored procedure support
- 14 services: DB, SSH, K8s, BGD, RMQ (admin + game), realtime, player, economy, guild, world, progression, character, audit, chat
- 30+ API endpoints covering players, guilds, economy, world, admin, server, files, director, chat
- SSE real-time events for battlegroup, chat, metrics, connection status
- SocketIO remote shell (xterm.js compatible)
- Settings CRUD, moderation (ban/kick/unban), audit logging
- Security: CSRF, rate limiting, CSP, HSTS, read-only SQL enforcement

Frontend:
- Vite + React 18 + TypeScript + Tailwind CSS
- 14 Dune house themes via CSS custom properties
- SWR for server state, Axios API client with interceptors
- 14 pages: Overview, Player Explorer + Detail, Guild Manager, Vehicles, Buildings, Map Viewer, Accounts, Server Control, Admin Tools (7 tabs), Chat Monitor, Remote Shell, File Browser, Director, Settings
- Player Detail with 6 tabs: overview, inventory, vehicles, buildings, progression, actions
- Admin Tools: broadcast, economy, world, character, functions, raw query, audit log
- Interactive canvas map viewer with zoom/pan/filter
- Toast notifications, connection badges, theme switcher

Other:
- Updated .gitignore for frontend/backend structure
- Updated README with new architecture, development guide, and project structure
- Legacy app/ templates/ static/ remain untouched
This commit is contained in:
Reditus committed 2026-05-23 07:08:30 +01:00
1 parent fa620f4da9
commit be845f76f1
76 files changed
+8410 -10

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
# Audit logging service — persistent PostgreSQL storage.
import logging
from datetime import datetime
from app.services.database import DatabaseService
logger = logging.getLogger(__name__)
class AuditService:
def __init__(self, db: DatabaseService):
self.db = db
def log(self, action: str, user: str, details: dict | None = None,
target_player_id: int | None = None, severity: str = "info",
source_ip: str | None = None) -> bool:
try:
self.db.execute_mutation(
"""INSERT INTO dashboard.audit_log
(action_type, user_name, target_player_id, details, source_ip, severity, created_at)
VALUES (%s, %s, %s, %s, %s, %s, NOW())""",
[action, user, target_player_id, details or {}, source_ip, severity],
)
logger.info("Audit: %s by %s", action, user)
return True
except Exception as e:
logger.error("Audit log failed: %s", e)
return False
def get_logs(self, action: str | None = None, user: str | None = None,
target_player_id: int | None = None, limit: int = 100,
offset: int = 0) -> list[dict]:
sql = """SELECT id, action_type, user_name, target_player_id, details,
source_ip, severity, created_at
FROM dashboard.audit_log WHERE 1=1"""
params = []
if action:
sql += " AND action_type = %s"
params.append(action)
if user:
sql += " AND user_name = %s"
params.append(user)
if target_player_id:
sql += " AND target_player_id = %s"
params.append(target_player_id)
sql += " ORDER BY created_at DESC LIMIT %s OFFSET %s"
params.extend([limit, offset])
return self.db.execute_readonly(sql, params)
def get_stats(self) -> dict:
rows = self.db.execute_readonly(
"""SELECT action_type, COUNT(*) as cnt FROM dashboard.audit_log
GROUP BY action_type"""
)
return {r["action_type"]: r["cnt"] for r in rows}
def cleanup_old(self, days: int = 90) -> int:
result = self.db.execute_mutation(
"DELETE FROM dashboard.audit_log WHERE created_at < NOW() - INTERVAL '%s days'",
[days],
)
logger.info("Audit cleanup: removed %d entries older than %d days", result, days)
return result