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,15 @@
|
||||
import { ReactNode } from 'react'
|
||||
import NavBar from './NavBar'
|
||||
import ToastProvider from '../common/ToastProvider'
|
||||
|
||||
export default function AppShell({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="min-h-screen bg-background text-text-primary">
|
||||
<NavBar />
|
||||
<main className="p-6 max-w-[1600px] mx-auto">
|
||||
<ToastProvider />
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
export default function ConnectionBadge() {
|
||||
const { state } = useApp()
|
||||
const { database, ssh, bgd, rmq } = state.connectionStatus
|
||||
const allOk = database && ssh && bgd && rmq
|
||||
const someDown = !allOk && (database || ssh || bgd || rmq)
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<div
|
||||
className="w-2.5 h-2.5 rounded-full"
|
||||
style={{
|
||||
backgroundColor: allOk ? '#27ae60' : someDown ? '#f39c12' : '#c0392b',
|
||||
boxShadow: `0 0 6px ${allOk ? '#27ae60' : someDown ? '#f39c12' : '#c0392b'}`,
|
||||
}}
|
||||
title={`DB: ${database ? 'OK' : 'DOWN'} | SSH: ${ssh ? 'OK' : 'DOWN'} | BGD: ${bgd ? 'OK' : 'DOWN'} | RMQ: ${rmq ? 'OK' : 'DOWN'}`}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Link, useLocation } from 'react-router-dom'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import ThemeSwitcher from './ThemeSwitcher'
|
||||
import ConnectionBadge from './ConnectionBadge'
|
||||
|
||||
const NAV_ITEMS = [
|
||||
{ path: '/', label: 'Overview' },
|
||||
{ path: '/players', label: 'Players' },
|
||||
{ path: '/guilds', label: 'Guilds' },
|
||||
{ path: '/server', label: 'Server' },
|
||||
{ path: '/chat', label: 'Chat' },
|
||||
{ path: '/admin', label: 'Admin' },
|
||||
{ path: '/shell', label: 'Shell' },
|
||||
]
|
||||
|
||||
export default function NavBar() {
|
||||
const location = useLocation()
|
||||
const { state } = useApp()
|
||||
|
||||
return (
|
||||
<nav className="sticky top-0 z-50 h-[52px] bg-nav-bg flex items-center px-6 shadow-md border-b border-border">
|
||||
<div className="flex items-center gap-2 mr-8">
|
||||
<span className="text-primary font-serif font-bold text-lg tracking-wide">Dune</span>
|
||||
<span className="text-nav-text text-xs uppercase tracking-widest">Admin</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
{NAV_ITEMS.map((item) => (
|
||||
<Link
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
className={`px-4 h-[52px] flex items-center text-[13px] font-medium border-b-2 transition-colors ${
|
||||
location.pathname === item.path
|
||||
? 'text-nav-active border-nav-active'
|
||||
: 'text-nav-text border-transparent hover:text-white hover:bg-white/5'
|
||||
}`}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="ml-auto flex items-center gap-4">
|
||||
<ConnectionBadge />
|
||||
<ThemeSwitcher />
|
||||
{state.user && (
|
||||
<span className="text-nav-text text-xs">{state.user}</span>
|
||||
)}
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
@@ -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