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

+83
View File
@@ -0,0 +1,83 @@
import React, { createContext, useContext, useReducer, useEffect } from 'react'
interface AppState {
user: string | null
theme: string
connectionStatus: {
database: boolean
ssh: boolean
bgd: boolean
rmq: boolean
}
toasts: Toast[]
}
interface Toast {
id: number
message: string
type: 'success' | 'error' | 'warning' | 'info'
}
type Action =
| { type: 'SET_USER'; payload: string | null }
| { type: 'SET_THEME'; payload: string }
| { type: 'SET_CONNECTION'; payload: Partial<AppState['connectionStatus']> }
| { type: 'ADD_TOAST'; payload: Omit<Toast, 'id'> }
| { type: 'REMOVE_TOAST'; payload: number }
const initialState: AppState = {
user: null,
theme: localStorage.getItem('dune-theme') || 'emperor',
connectionStatus: {
database: true,
ssh: true,
bgd: true,
rmq: true,
},
toasts: [],
}
let toastId = 0
function reducer(state: AppState, action: Action): AppState {
switch (action.type) {
case 'SET_USER':
return { ...state, user: action.payload }
case 'SET_THEME':
return { ...state, theme: action.payload }
case 'SET_CONNECTION':
return { ...state, connectionStatus: { ...state.connectionStatus, ...action.payload } }
case 'ADD_TOAST':
return { ...state, toasts: [...state.toasts.slice(-2), { ...action.payload, id: ++toastId }] }
case 'REMOVE_TOAST':
return { ...state, toasts: state.toasts.filter((t) => t.id !== action.payload) }
default:
return state
}
}
const AppContext = createContext<{
state: AppState
dispatch: React.Dispatch<Action>
} | null>(null)
export function AppProvider({ children }: { children: React.ReactNode }) {
const [state, dispatch] = useReducer(reducer, initialState)
useEffect(() => {
document.documentElement.dataset.theme = state.theme
localStorage.setItem('dune-theme', state.theme)
}, [state.theme])
return (
<AppContext.Provider value={{ state, dispatch }}>
{children}
</AppContext.Provider>
)
}
export function useApp() {
const ctx = useContext(AppContext)
if (!ctx) throw new Error('useApp must be used within AppProvider')
return ctx
}