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,68 +1,115 @@
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import {
|
||||
Box,
|
||||
Flex,
|
||||
Text,
|
||||
Menu,
|
||||
Button,
|
||||
HStack,
|
||||
IconButton,
|
||||
Tooltip,
|
||||
Portal,
|
||||
} from '@chakra-ui/react'
|
||||
import { FiSun, FiMoon, FiChevronDown } from 'react-icons/fi'
|
||||
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' },
|
||||
]
|
||||
import { FACTION_KEYS, getFactionName } from '../../themes'
|
||||
import type { FactionKey } from '../../themes/palettes'
|
||||
|
||||
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)
|
||||
}, [])
|
||||
const handleFactionChange = (key: FactionKey) => {
|
||||
dispatch({ type: 'SET_FACTION', payload: key })
|
||||
}
|
||||
|
||||
const toggleColorMode = () => {
|
||||
dispatch({
|
||||
type: 'SET_COLOR_MODE',
|
||||
payload: state.colorMode === 'day' ? 'night' : 'day',
|
||||
})
|
||||
}
|
||||
|
||||
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'
|
||||
}`}
|
||||
<HStack gap={1}>
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger asChild>
|
||||
<IconButton
|
||||
aria-label="Toggle color mode"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleColorMode}
|
||||
color="fg.muted"
|
||||
w={8}
|
||||
h={8}
|
||||
>
|
||||
{state.colorMode === 'day' ? <FiSun size={16} /> : <FiMoon size={16} />}
|
||||
</IconButton>
|
||||
</Tooltip.Trigger>
|
||||
<Tooltip.Positioner>
|
||||
<Tooltip.Content bg="card.bg" border="1px solid" borderColor="border" borderRadius="md" px={3} py={1}>
|
||||
{state.colorMode === 'day' ? 'Switch to Night' : 'Switch to Day'}
|
||||
</Tooltip.Content>
|
||||
</Tooltip.Positioner>
|
||||
</Tooltip.Root>
|
||||
|
||||
<Menu.Root>
|
||||
<Menu.Trigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
borderColor="border"
|
||||
color="fg"
|
||||
_hover={{ borderColor: 'primary.DEFAULT', color: 'primary.DEFAULT' }}
|
||||
gap={2}
|
||||
>
|
||||
<Box
|
||||
w={2.5}
|
||||
h={2.5}
|
||||
borderRadius="full"
|
||||
bg="primary.DEFAULT"
|
||||
/>
|
||||
<Text fontSize="xs">{getFactionName(state.faction)}</Text>
|
||||
<FiChevronDown size={12} />
|
||||
</Button>
|
||||
</Menu.Trigger>
|
||||
<Portal>
|
||||
<Menu.Positioner>
|
||||
<Menu.Content
|
||||
bg="card.bg"
|
||||
borderColor="border"
|
||||
borderRadius="lg"
|
||||
boxShadow="card"
|
||||
maxH="400px"
|
||||
overflowY="auto"
|
||||
>
|
||||
<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>
|
||||
<Menu.ItemGroup title="Factions">
|
||||
{FACTION_KEYS.map((key) => (
|
||||
<Menu.Item
|
||||
key={key}
|
||||
value={key}
|
||||
onClick={() => handleFactionChange(key)}
|
||||
bg={state.faction === key ? 'primary.subtle' : 'transparent'}
|
||||
color={state.faction === key ? 'primary.DEFAULT' : 'fg'}
|
||||
fontWeight={state.faction === key ? 'semibold' : 'normal'}
|
||||
_hover={{ bg: 'bg.subtle' }}
|
||||
cursor="pointer"
|
||||
py={2}
|
||||
>
|
||||
<Flex align="center" gap={3}>
|
||||
<Box
|
||||
w={3}
|
||||
h={3}
|
||||
borderRadius="full"
|
||||
bg="primary.DEFAULT"
|
||||
/>
|
||||
<Text>{getFactionName(key)}</Text>
|
||||
</Flex>
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu.ItemGroup>
|
||||
</Menu.Content>
|
||||
</Menu.Positioner>
|
||||
</Portal>
|
||||
</Menu.Root>
|
||||
</HStack>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user