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:
1 parent
fa620f4da9
commit
be845f76f1
76 files changed
+8410
-10
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
const THEMES = [
|
||||
{ key: 'default', label: 'Classic Dune' },
|
||||
{ key: 'atreides', label: 'House Atreides' },
|
||||
{ key: 'harkonnen', label: 'House Harkonnen' },
|
||||
{ key: 'fremen', label: 'Fremen' },
|
||||
{ key: 'bene-gesserit', label: 'Bene Gesserit' },
|
||||
{ key: 'spacing-guild', label: 'Spacing Guild' },
|
||||
{ key: 'emperor', label: 'Emperor' },
|
||||
{ key: 'corrino', label: 'House Corrino' },
|
||||
{ key: 'mentat', label: 'Mentat' },
|
||||
{ key: 'sardaukar', label: 'Sardaukar' },
|
||||
{ key: 'tleilax', label: 'Bene Tleilax' },
|
||||
{ key: 'ordos', label: 'House Ordos' },
|
||||
{ key: 'ix', label: 'Ix' },
|
||||
{ key: 'choam', label: 'CHOAM' },
|
||||
]
|
||||
|
||||
export default function ThemeSwitcher() {
|
||||
const { state, dispatch } = useApp()
|
||||
const [open, setOpen] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
function handleClick(e: MouseEvent) {
|
||||
if (ref.current && !ref.current.contains(e.target as Node)) {
|
||||
setOpen(false)
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousedown', handleClick)
|
||||
return () => document.removeEventListener('mousedown', handleClick)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="relative" ref={ref}>
|
||||
<button
|
||||
onClick={() => setOpen(!open)}
|
||||
className="w-6 h-6 rounded-full"
|
||||
style={{ background: 'linear-gradient(135deg, var(--primary) 50%, var(--bg) 50%)' }}
|
||||
title="Change theme"
|
||||
/>
|
||||
{open && (
|
||||
<div className="absolute right-0 mt-2 w-56 bg-card-bg border border-border rounded-lg shadow-xl z-50 py-2">
|
||||
{THEMES.map((t) => (
|
||||
<button
|
||||
key={t.key}
|
||||
onClick={() => {
|
||||
dispatch({ type: 'SET_THEME', payload: t.key })
|
||||
setOpen(false)
|
||||
}}
|
||||
className={`w-full text-left px-4 py-2 text-sm flex items-center gap-3 hover:bg-hover transition-colors ${
|
||||
state.theme === t.key ? 'text-primary font-semibold' : 'text-text-secondary'
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className="w-4 h-4 rounded border border-border"
|
||||
style={{ background: `linear-gradient(135deg, var(--primary) 50%, var(--bg) 50%)` }}
|
||||
/>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user