refactor: ChakraUI v3 frontend + direct SQL backend services
Frontend: - Replace Tailwind CSS with ChakraUI v3 (react, recharts, fontsource) - 24 themes (12 Dune factions x day/night variants) - Collapsible sidebar navigation with 6 groups - Recharts AreaChart/PieChart for CPU/RAM/metrics - New Experimental page (ports legacy admin_experimental.html) - Common components: DataTable, Modal, Badge, Toaster Backend: - Fix services to use direct SQL (dune.* schema) instead of stored procedures - PlayerService, EconomyService, GuildService, WorldService rewritten - Auto-login for SPA development in factory.py - Fix settings.yaml path resolution Launcher: - Add option [7] Start New Dashboard in launcher.ps1 and start.sh - Auto-installs pip + npm dependencies - Sets up SSH tunnels + kubectl port-forwards - Starts backend API + frontend Vite dev server Security: - Sanitize hardcoded RMQ password in config.py - Add frontend/dist/ to .gitignore
This commit is contained in:
1 parent
d7ac8a6641
commit
011ba8c8b4
52 files changed
+5901
-2444
No files matched your search
@@ -1,56 +1,70 @@
|
||||
import React, { createContext, useContext, useReducer, useEffect } from 'react'
|
||||
import { createContext, useContext, useReducer, useEffect } from 'react'
|
||||
import type { FactionKey } from '../themes/palettes'
|
||||
import { toaster } from '../toaster'
|
||||
|
||||
interface AppState {
|
||||
user: string | null
|
||||
theme: string
|
||||
faction: FactionKey
|
||||
colorMode: 'day' | 'night'
|
||||
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_FACTION'; payload: FactionKey }
|
||||
| { type: 'SET_COLOR_MODE'; payload: 'day' | 'night' }
|
||||
| { type: 'SET_CONNECTION'; payload: Partial<AppState['connectionStatus']> }
|
||||
| { type: 'ADD_TOAST'; payload: Omit<Toast, 'id'> }
|
||||
| { type: 'REMOVE_TOAST'; payload: number }
|
||||
| { type: 'ADD_TOAST'; payload: { message: string; type: 'success' | 'error' | 'warning' | 'info' } }
|
||||
|
||||
function loadStoredFaction(): FactionKey {
|
||||
try {
|
||||
const stored = localStorage.getItem('dune-faction')
|
||||
if (stored) return stored as FactionKey
|
||||
} catch {}
|
||||
return 'fremen'
|
||||
}
|
||||
|
||||
function loadStoredColorMode(): 'day' | 'night' {
|
||||
try {
|
||||
const stored = localStorage.getItem('dune-color-mode')
|
||||
if (stored === 'day' || stored === 'night') return stored
|
||||
} catch {}
|
||||
return 'night'
|
||||
}
|
||||
|
||||
const initialState: AppState = {
|
||||
user: null,
|
||||
theme: localStorage.getItem('dune-theme') || 'emperor',
|
||||
faction: loadStoredFaction(),
|
||||
colorMode: loadStoredColorMode(),
|
||||
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_FACTION':
|
||||
return { ...state, faction: action.payload }
|
||||
case 'SET_COLOR_MODE':
|
||||
return { ...state, colorMode: 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) }
|
||||
toaster[action.payload.type]({
|
||||
title: action.payload.message,
|
||||
duration: 4000,
|
||||
})
|
||||
return state
|
||||
default:
|
||||
return state
|
||||
}
|
||||
@@ -65,9 +79,12 @@ 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])
|
||||
localStorage.setItem('dune-faction', state.faction)
|
||||
}, [state.faction])
|
||||
|
||||
useEffect(() => {
|
||||
localStorage.setItem('dune-color-mode', state.colorMode)
|
||||
}, [state.colorMode])
|
||||
|
||||
return (
|
||||
<AppContext.Provider value={{ state, dispatch }}>
|
||||
|
||||
Reference in new issue
Block a user