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,39 @@
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
||||
import { AppProvider } from './stores/AppContext'
|
||||
import { useRealtime } from './hooks/useRealtime'
|
||||
import AppShell from './components/layout/AppShell'
|
||||
import Overview from './components/overview/Overview'
|
||||
import PlayerExplorer from './components/players/PlayerExplorer'
|
||||
import GuildManager from './components/guilds/GuildManager'
|
||||
import ServerControl from './components/server/ServerControl'
|
||||
import AdminTools from './components/admin/AdminTools'
|
||||
import ChatMonitor from './components/chat/ChatMonitor'
|
||||
import Terminal from './components/shell/Terminal'
|
||||
|
||||
function RealtimeInit() {
|
||||
useRealtime()
|
||||
return null
|
||||
}
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<AppProvider>
|
||||
<BrowserRouter>
|
||||
<RealtimeInit />
|
||||
<AppShell>
|
||||
<Routes>
|
||||
<Route path="/" element={<Overview />} />
|
||||
<Route path="/players" element={<PlayerExplorer />} />
|
||||
<Route path="/guilds" element={<GuildManager />} />
|
||||
<Route path="/server" element={<ServerControl />} />
|
||||
<Route path="/admin" element={<AdminTools />} />
|
||||
<Route path="/chat" element={<ChatMonitor />} />
|
||||
<Route path="/shell" element={<Terminal />} />
|
||||
</Routes>
|
||||
</AppShell>
|
||||
</BrowserRouter>
|
||||
</AppProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
@@ -0,0 +1,21 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const client = axios.create({
|
||||
baseURL: '/api',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
timeout: 30000,
|
||||
})
|
||||
|
||||
client.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (error.response?.status === 401) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
export default client
|
||||
@@ -0,0 +1,419 @@
|
||||
import { useState } from 'react'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
const SCOPE_OPTIONS = ['all', 'server', 'partition']
|
||||
const SERVER_OPTIONS = ['na', 'eu', 'sea', 'sa', 'oc']
|
||||
const PARTITION_OPTIONS = ['parrish', 'sietch', 'bazar']
|
||||
|
||||
export default function AdminTools() {
|
||||
const [tab, setTab] = useState<'broadcast' | 'economy' | 'world' | 'character' | 'functions' | 'raw' | 'audit'>('broadcast')
|
||||
const { dispatch } = useApp()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Admin Tools</h1>
|
||||
|
||||
<div className="flex gap-1 mb-6 border-b border-border overflow-x-auto no-scrollbar">
|
||||
{([
|
||||
{ key: 'broadcast', label: 'Broadcast' },
|
||||
{ key: 'economy', label: 'Economy' },
|
||||
{ key: 'world', label: 'World' },
|
||||
{ key: 'character', label: 'Character' },
|
||||
{ key: 'functions', label: 'Functions' },
|
||||
{ key: 'raw', label: 'Raw Query' },
|
||||
{ key: 'audit', label: 'Audit Log' },
|
||||
] as const).map((t) => (
|
||||
<button
|
||||
key={t.key}
|
||||
onClick={() => setTab(t.key as any)}
|
||||
className={`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${
|
||||
tab === t.key
|
||||
? 'text-primary border-primary'
|
||||
: 'text-text-muted border-transparent hover:text-text-primary'
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{tab === 'broadcast' && <BroadcastTab dispatch={dispatch} />}
|
||||
{tab === 'economy' && <EconomyTab dispatch={dispatch} />}
|
||||
{tab === 'world' && <WorldTab dispatch={dispatch} />}
|
||||
{tab === 'character' && <CharacterTab dispatch={dispatch} />}
|
||||
{tab === 'functions' && <FunctionsTab dispatch={dispatch} />}
|
||||
{tab === 'raw' && <RawQueryTab dispatch={dispatch} />}
|
||||
{tab === 'audit' && <AuditLogTab dispatch={dispatch} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function BroadcastTab({ dispatch }: { dispatch: any }) {
|
||||
const [message, setMessage] = useState('')
|
||||
const [scope, setScope] = useState('all')
|
||||
const [server, setServer] = useState('na')
|
||||
const [partition, setPartition] = useState('parrish')
|
||||
const [sending, setSending] = useState(false)
|
||||
|
||||
const handleSend = async () => {
|
||||
if (!message.trim()) return
|
||||
setSending(true)
|
||||
try {
|
||||
const payload: any = { message: message.trim() }
|
||||
if (scope === 'server') payload.server = server
|
||||
if (scope === 'partition') {
|
||||
payload.server = server
|
||||
payload.partition = partition
|
||||
}
|
||||
const res = await client.post('/broadcast', payload)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Broadcast sent', type: 'success' } })
|
||||
setMessage('')
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
} finally {
|
||||
setSending(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-xl">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Scope</label>
|
||||
<div className="flex gap-2">
|
||||
{SCOPE_OPTIONS.map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
onClick={() => setScope(s)}
|
||||
className={`px-3 py-1.5 rounded text-xs font-medium border capitalize ${
|
||||
scope === s
|
||||
? 'bg-primary/10 border-primary text-primary'
|
||||
: 'bg-card-bg border-border text-text-muted hover:text-text-primary'
|
||||
}`}
|
||||
>
|
||||
{s}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{scope !== 'all' && (
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Server</label>
|
||||
<select value={server} onChange={(e) => setServer(e.target.value)} className="bg-card-bg border border-border rounded px-3 py-2 text-sm text-text-primary">
|
||||
{SERVER_OPTIONS.map((s) => <option key={s} value={s}>{s.toUpperCase()}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{scope === 'partition' && (
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Partition</label>
|
||||
<select value={partition} onChange={(e) => setPartition(e.target.value)} className="bg-card-bg border border-border rounded px-3 py-2 text-sm text-text-primary">
|
||||
{PARTITION_OPTIONS.map((p) => <option key={p} value={p}>{p}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Message</label>
|
||||
<textarea value={message} onChange={(e) => setMessage(e.target.value)} rows={4} className="w-full bg-card-bg border border-border rounded-lg px-4 py-3 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary resize-y" placeholder="Enter broadcast message..." />
|
||||
</div>
|
||||
|
||||
<button onClick={handleSend} disabled={sending || !message.trim()} className="px-4 py-2 bg-primary text-white rounded-lg text-sm font-medium hover:bg-primary-dark disabled:opacity-50 transition-colors">
|
||||
{sending ? 'Sending...' : 'Send Broadcast'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function EconomyTab({ dispatch }: { dispatch: any }) {
|
||||
const [playerId, setPlayerId] = useState('')
|
||||
const [itemForm, setItemForm] = useState({ template_id: '', stack_size: '1', quality: '0', inventory_id: '' })
|
||||
const [editForm, setEditForm] = useState({ item_id: '', field: 'stack_size', value: '' })
|
||||
|
||||
const post = async (endpoint: string, payload: any) => {
|
||||
try {
|
||||
const res = await client.post(endpoint, payload)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Success', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Add Item</h3>
|
||||
<input value={playerId} onChange={(e) => setPlayerId(e.target.value)} placeholder="Player ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input value={itemForm.template_id} onChange={(e) => setItemForm({ ...itemForm, template_id: e.target.value })} placeholder="Template ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input value={itemForm.stack_size} onChange={(e) => setItemForm({ ...itemForm, stack_size: e.target.value })} placeholder="Stack Size" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input value={itemForm.quality} onChange={(e) => setItemForm({ ...itemForm, quality: e.target.value })} placeholder="Quality" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input value={itemForm.inventory_id} onChange={(e) => setItemForm({ ...itemForm, inventory_id: e.target.value })} placeholder="Inventory ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<button onClick={() => post('/items/add', { player_id: parseInt(playerId), template_id: itemForm.template_id, stack_size: parseInt(itemForm.stack_size), quality_level: parseInt(itemForm.quality), inventory_id: parseInt(itemForm.inventory_id) || undefined })} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Add Item</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Edit Item</h3>
|
||||
<input value={editForm.item_id} onChange={(e) => setEditForm({ ...editForm, item_id: e.target.value })} placeholder="Item ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<select value={editForm.field} onChange={(e) => setEditForm({ ...editForm, field: e.target.value })} className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm">
|
||||
{['stack_size', 'quality_level', 'durability', 'ammo'].map((f) => <option key={f} value={f}>{f}</option>)}
|
||||
</select>
|
||||
<input value={editForm.value} onChange={(e) => setEditForm({ ...editForm, value: e.target.value })} placeholder="New value" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<div className="flex gap-2">
|
||||
<button onClick={() => post(`/items/${editForm.item_id}`, { [editForm.field]: editForm.value })} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Update</button>
|
||||
<button onClick={() => post(`/items/${editForm.item_id}`, {})} className="px-3 py-1.5 rounded text-xs bg-danger/10 border border-danger/30 text-danger">Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function WorldTab({ dispatch }: { dispatch: any }) {
|
||||
const [tpForm, setTpForm] = useState({ fls_id: '', partition: '', x: '', y: '', z: '' })
|
||||
|
||||
const post = async (endpoint: string, payload: any) => {
|
||||
try {
|
||||
const res = await client.post(endpoint, payload)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Success', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Teleport Player</h3>
|
||||
<input value={tpForm.fls_id} onChange={(e) => setTpForm({ ...tpForm, fls_id: e.target.value })} placeholder="FLS ID / Account ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input value={tpForm.partition} onChange={(e) => setTpForm({ ...tpForm, partition: e.target.value })} placeholder="Partition ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
<input type="number" value={tpForm.x} onChange={(e) => setTpForm({ ...tpForm, x: e.target.value })} placeholder="X" className="bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input type="number" value={tpForm.y} onChange={(e) => setTpForm({ ...tpForm, y: e.target.value })} placeholder="Y" className="bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input type="number" value={tpForm.z} onChange={(e) => setTpForm({ ...tpForm, z: e.target.value })} placeholder="Z" className="bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
</div>
|
||||
<button onClick={() => post('/teleport', { fls_id: parseInt(tpForm.fls_id), partition_id: tpForm.partition, x: parseFloat(tpForm.x) || 0, y: parseFloat(tpForm.y) || 0, z: parseFloat(tpForm.z) || 0 })} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Teleport</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Spice Control</h3>
|
||||
<div className="flex gap-2">
|
||||
<button onClick={() => post('/spice/reset', {})} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Reset Spice Fields</button>
|
||||
<button onClick={() => post('/spice/spawn', {})} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Force Spawn</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Partitions</h3>
|
||||
<button onClick={() => client.get('/partitions').then((r) => dispatch({ type: 'ADD_TOAST', payload: { message: `Partitions loaded`, type: 'info' } }))} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">List Partitions</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function CharacterTab({ dispatch }: { dispatch: any }) {
|
||||
const [charId, setCharId] = useState('')
|
||||
const [newName, setNewName] = useState('')
|
||||
const [demoState, setDemoState] = useState('true')
|
||||
|
||||
const post = async (endpoint: string, payload: any) => {
|
||||
try {
|
||||
const res = await client.post(endpoint, payload)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Success', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Rename Character</h3>
|
||||
<input value={charId} onChange={(e) => setCharId(e.target.value)} placeholder="Account ID / Character ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<input value={newName} onChange={(e) => setNewName(e.target.value)} placeholder="New Name" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<button onClick={() => post(`/characters/${charId}/name`, { name: newName })} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Rename</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Demo State</h3>
|
||||
<input value={charId} onChange={(e) => setCharId(e.target.value)} placeholder="Account ID" className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm" />
|
||||
<select value={demoState} onChange={(e) => setDemoState(e.target.value)} className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm">
|
||||
<option value="true">Demo</option>
|
||||
<option value="false">Normal</option>
|
||||
</select>
|
||||
<button onClick={() => post(`/accounts/${charId}/demo`, { demo: demoState === 'true' })} className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary">Set Demo State</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-3">
|
||||
<h3 className="font-medium text-text-primary">Danger Zone</h3>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button onClick={() => { if (confirm('Delete character?')) post(`/characters/${charId}`, {}) }} className="px-3 py-1.5 rounded text-xs bg-danger/10 border border-danger/30 text-danger">Delete Character</button>
|
||||
<button onClick={() => { if (confirm('Delete account?')) post(`/accounts/${charId}`, {}) }} className="px-3 py-1.5 rounded text-xs bg-danger/10 border border-danger/30 text-danger">Delete Account</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function FunctionsTab({ dispatch }: { dispatch: any }) {
|
||||
const [schema, setSchema] = useState('')
|
||||
const [funcName, setFuncName] = useState('')
|
||||
const [args, setArgs] = useState('{}')
|
||||
const [result, setResult] = useState('')
|
||||
const [running, setRunning] = useState(false)
|
||||
|
||||
const handleExecute = async () => {
|
||||
setRunning(true)
|
||||
try {
|
||||
const parsedArgs = JSON.parse(args || '{}')
|
||||
const res = await client.post('/functions/execute', { schema: schema || undefined, function: funcName, args: parsedArgs })
|
||||
if (res.data.success) {
|
||||
setResult(JSON.stringify(res.data.data, null, 2))
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Function executed', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.message, type: 'error' } })
|
||||
} finally {
|
||||
setRunning(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-2xl">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Schema (optional)</label>
|
||||
<input value={schema} onChange={(e) => setSchema(e.target.value)} className="w-full bg-card-bg border border-border rounded-lg px-4 py-2 text-sm text-text-primary" placeholder="e.g., public" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Function Name</label>
|
||||
<input value={funcName} onChange={(e) => setFuncName(e.target.value)} className="w-full bg-card-bg border border-border rounded-lg px-4 py-2 text-sm text-text-primary" placeholder="e.g., get_player_stats" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm text-text-muted mb-2">Arguments (JSON)</label>
|
||||
<textarea value={args} onChange={(e) => setArgs(e.target.value)} rows={4} className="w-full bg-card-bg border border-border rounded-lg px-4 py-3 text-sm font-mono text-text-primary focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary resize-y" />
|
||||
</div>
|
||||
<button onClick={handleExecute} disabled={running || !funcName} className="px-4 py-2 bg-primary text-white rounded-lg text-sm font-medium hover:bg-primary-dark disabled:opacity-50 transition-colors">
|
||||
{running ? 'Running...' : 'Execute'}
|
||||
</button>
|
||||
{result && <pre className="mt-4 text-xs font-mono bg-code-bg p-4 rounded overflow-auto text-text-secondary">{result}</pre>}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function RawQueryTab({ dispatch }: { dispatch: any }) {
|
||||
const [query, setQuery] = useState('')
|
||||
const [result, setResult] = useState('')
|
||||
const [running, setRunning] = useState(false)
|
||||
|
||||
const handleRun = async () => {
|
||||
setRunning(true)
|
||||
try {
|
||||
const res = await client.post('/query', { query })
|
||||
if (res.data.success) {
|
||||
setResult(JSON.stringify(res.data.data, null, 2))
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Query executed', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || e.message, type: 'error' } })
|
||||
} finally {
|
||||
setRunning(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-sm text-text-muted">SQL Query (Read-Only SELECT)</label>
|
||||
<span className="text-[10px] text-text-muted uppercase tracking-wider bg-danger/10 px-2 py-0.5 rounded border border-danger/20">Read Only</span>
|
||||
</div>
|
||||
<textarea value={query} onChange={(e) => setQuery(e.target.value)} rows={6} className="w-full bg-card-bg border border-border rounded-lg px-4 py-3 text-sm font-mono text-text-primary focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary resize-y" placeholder="SELECT * FROM public.characters LIMIT 10;" />
|
||||
<button onClick={handleRun} disabled={running || !query.trim()} className="px-4 py-2 bg-primary text-white rounded-lg text-sm font-medium hover:bg-primary-dark disabled:opacity-50 transition-colors">
|
||||
{running ? 'Running...' : 'Run Query'}
|
||||
</button>
|
||||
{result && <pre className="mt-4 text-xs font-mono bg-code-bg p-4 rounded overflow-auto text-text-secondary">{result}</pre>}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function AuditLogTab({ dispatch }: { dispatch: any }) {
|
||||
const [limit, setLimit] = useState(50)
|
||||
const [logs, setLogs] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const load = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await client.get(`/audit/logs?limit=${limit}`)
|
||||
if (res.data.success) setLogs(res.data.data)
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center gap-4 mb-4">
|
||||
<button onClick={load} disabled={loading} className="px-4 py-2 bg-primary text-white rounded-lg text-sm font-medium hover:bg-primary-dark disabled:opacity-50 transition-colors">
|
||||
{loading ? 'Loading...' : 'Load Logs'}
|
||||
</button>
|
||||
<select value={limit} onChange={(e) => setLimit(Number(e.target.value))} className="bg-card-bg border border-border rounded px-3 py-2 text-sm text-text-primary">
|
||||
{[10, 25, 50, 100, 250].map((n) => <option key={n} value={n}>{n} entries</option>)}
|
||||
</select>
|
||||
</div>
|
||||
<div className="overflow-x-auto rounded-lg border border-border">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Time</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Admin</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Action</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Target</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Details</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{logs.map((log, i) => (
|
||||
<tr key={i} className="border-b border-border last:border-0 hover:bg-hover/50">
|
||||
<td className="px-4 py-3 text-text-muted text-xs">{new Date(log.timestamp).toLocaleString()}</td>
|
||||
<td className="px-4 py-3">{log.admin_name}</td>
|
||||
<td className="px-4 py-3"><span className="px-2 py-0.5 rounded text-[11px] font-semibold bg-primary/10 text-primary border border-primary/20">{log.action}</span></td>
|
||||
<td className="px-4 py-3">{log.target_type}: {log.target_id}</td>
|
||||
<td className="px-4 py-3 text-xs text-text-muted max-w-md truncate">{JSON.stringify(log.details)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import DataTable from '../common/DataTable'
|
||||
import Badge from '../common/Badge'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
interface Building {
|
||||
id: number
|
||||
class_name: string
|
||||
map: string
|
||||
owner_name: string
|
||||
is_powered: boolean
|
||||
power_level: number | null
|
||||
instance_count: number
|
||||
}
|
||||
|
||||
export default function Buildings() {
|
||||
const [search, setSearch] = useState('')
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const { data: buildingsData, isLoading } = useSWR(
|
||||
search.length >= 2 ? `/buildings?q=${encodeURIComponent(search)}&limit=50` : '/buildings?limit=100',
|
||||
fetcher,
|
||||
{ refreshInterval: 30000 }
|
||||
)
|
||||
|
||||
const buildingList: Building[] = buildingsData?.success ? buildingsData.data : []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Buildings</h1>
|
||||
|
||||
<div className="mb-6">
|
||||
<div className="relative max-w-md">
|
||||
<input
|
||||
type="text"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="Search buildings..."
|
||||
className="w-full bg-card-bg border border-border rounded-lg px-4 py-2.5 pl-10 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary"
|
||||
/>
|
||||
<svg className="absolute left-3 top-3 w-4 h-4 text-text-muted" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
columns={[
|
||||
{ header: 'Class', accessor: 'class_name' },
|
||||
{ header: 'Map', accessor: 'map' },
|
||||
{ header: 'Owner', accessor: 'owner_name' },
|
||||
{
|
||||
header: 'Power',
|
||||
accessor: (row) => (
|
||||
<div className="flex gap-1">
|
||||
{row.is_powered ? <Badge label="Powered" variant="success" /> : <Badge label="Unpowered" variant="default" />}
|
||||
{row.power_level != null && <Badge label={`Lv ${row.power_level}`} variant="default" />}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{ header: 'Instances', accessor: 'instance_count' },
|
||||
]}
|
||||
data={buildingList}
|
||||
loading={isLoading}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import client from '../../api/client'
|
||||
|
||||
interface ChatMessage {
|
||||
id: string
|
||||
channel: string
|
||||
sender: string
|
||||
message: string
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
const CHANNELS = ['Global', 'Guild', 'System', 'Combat']
|
||||
|
||||
export default function ChatMonitor() {
|
||||
const [channel, setChannel] = useState('Global')
|
||||
const [messages, setMessages] = useState<ChatMessage[]>([])
|
||||
const bottomRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
try {
|
||||
const res = await client.get(`/chat/history?channel=${channel}&limit=100`)
|
||||
if (res.data.success) {
|
||||
setMessages(res.data.data)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
load()
|
||||
}, [channel])
|
||||
|
||||
useEffect(() => {
|
||||
const es = new EventSource('/api/events/stream')
|
||||
es.addEventListener('chat_message', (e) => {
|
||||
try {
|
||||
const msg: ChatMessage = JSON.parse(e.data)
|
||||
if (msg.channel === channel || channel === 'Global') {
|
||||
setMessages((prev) => [...prev.slice(-199), msg])
|
||||
}
|
||||
} catch {}
|
||||
})
|
||||
return () => es.close()
|
||||
}, [channel])
|
||||
|
||||
useEffect(() => {
|
||||
bottomRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||
}, [messages])
|
||||
|
||||
return (
|
||||
<div className="h-[calc(100vh-140px)] flex flex-col">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h1 className="font-serif text-3xl text-primary">Chat Monitor</h1>
|
||||
<div className="flex gap-2">
|
||||
{CHANNELS.map((c) => (
|
||||
<button
|
||||
key={c}
|
||||
onClick={() => setChannel(c)}
|
||||
className={`px-3 py-1.5 rounded text-xs font-medium border ${
|
||||
channel === c
|
||||
? 'bg-primary/10 border-primary text-primary'
|
||||
: 'bg-card-bg border-border text-text-muted hover:text-text-primary'
|
||||
}`}
|
||||
>
|
||||
{c}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 bg-card-bg border border-border rounded-lg overflow-hidden flex flex-col">
|
||||
<div className="flex-1 overflow-y-auto p-4 space-y-2 font-mono text-sm">
|
||||
{messages.map((msg) => (
|
||||
<div key={msg.id} className="flex gap-3">
|
||||
<span className="text-text-muted text-xs whitespace-nowrap">
|
||||
{new Date(msg.timestamp).toLocaleTimeString()}
|
||||
</span>
|
||||
<span className="text-primary font-semibold whitespace-nowrap">[{msg.channel}]</span>
|
||||
<span className="text-accent font-semibold whitespace-nowrap">{msg.sender}:</span>
|
||||
<span className="text-text-secondary break-all">{msg.message}</span>
|
||||
</div>
|
||||
))}
|
||||
<div ref={bottomRef} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
interface BadgeProps {
|
||||
label: string
|
||||
variant?: 'default' | 'success' | 'warning' | 'danger'
|
||||
}
|
||||
|
||||
export default function Badge({ label, variant = 'default' }: BadgeProps) {
|
||||
const classes: Record<string, string> = {
|
||||
default: 'bg-primary/10 text-primary border-primary/20',
|
||||
success: 'bg-success/10 text-success border-success/20',
|
||||
warning: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',
|
||||
danger: 'bg-danger/10 text-danger border-danger/20',
|
||||
}
|
||||
return (
|
||||
<span
|
||||
className={`inline-block px-2 py-0.5 rounded text-[11px] font-semibold border uppercase tracking-wide ${classes[variant]}`}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
import { ReactNode, useState } from 'react'
|
||||
|
||||
interface Column<T> {
|
||||
header: string
|
||||
accessor: keyof T | ((row: T) => ReactNode)
|
||||
width?: string
|
||||
}
|
||||
|
||||
interface DataTableProps<T> {
|
||||
columns: Column<T>[]
|
||||
data: T[]
|
||||
onRowClick?: (row: T) => void
|
||||
loading?: boolean
|
||||
}
|
||||
|
||||
export default function DataTable<T extends object>({
|
||||
columns,
|
||||
data,
|
||||
onRowClick,
|
||||
loading,
|
||||
}: DataTableProps<T>) {
|
||||
const [sortCol, setSortCol] = useState<string | null>(null)
|
||||
const [sortDir, setSortDir] = useState<'asc' | 'desc'>('asc')
|
||||
|
||||
const handleSort = (header: string) => {
|
||||
if (sortCol === header) {
|
||||
setSortDir(sortDir === 'asc' ? 'desc' : 'asc')
|
||||
} else {
|
||||
setSortCol(header)
|
||||
setSortDir('asc')
|
||||
}
|
||||
}
|
||||
|
||||
let sorted = [...data]
|
||||
if (sortCol) {
|
||||
const col = columns.find((c) => c.header === sortCol)
|
||||
if (col && typeof col.accessor === 'string') {
|
||||
sorted.sort((a: any, b: any) => {
|
||||
const av = a[col.accessor]
|
||||
const bv = b[col.accessor]
|
||||
if (av == null && bv == null) return 0
|
||||
if (av == null) return sortDir === 'asc' ? 1 : -1
|
||||
if (bv == null) return sortDir === 'asc' ? -1 : 1
|
||||
if (typeof av === 'string') {
|
||||
return sortDir === 'asc'
|
||||
? av.localeCompare(bv)
|
||||
: bv.localeCompare(av)
|
||||
}
|
||||
if (typeof av === 'number') {
|
||||
return sortDir === 'asc' ? av - bv : bv - av
|
||||
}
|
||||
return 0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-x-auto rounded-lg border border-border">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
{columns.map((col) => (
|
||||
<th
|
||||
key={col.header}
|
||||
className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase tracking-wider cursor-pointer hover:text-text-primary select-none"
|
||||
style={{ width: col.width }}
|
||||
onClick={() => handleSort(col.header)}
|
||||
>
|
||||
<div className="flex items-center gap-1">
|
||||
{col.header}
|
||||
{sortCol === col.header && (
|
||||
<span className="text-primary">
|
||||
{sortDir === 'asc' ? ' ▲' : ' ▼'}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loading ? (
|
||||
<tr>
|
||||
<td colSpan={columns.length} className="px-4 py-8 text-center text-text-muted">
|
||||
Loading...
|
||||
</td>
|
||||
</tr>
|
||||
) : sorted.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={columns.length} className="px-4 py-8 text-center text-text-muted">
|
||||
No results found
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
sorted.map((row, i) => (
|
||||
<tr
|
||||
key={i}
|
||||
onClick={() => onRowClick?.(row)}
|
||||
className={`border-b border-border last:border-0 transition-colors ${
|
||||
onRowClick ? 'cursor-pointer hover:bg-hover' : 'hover:bg-hover/50'
|
||||
}`}
|
||||
>
|
||||
{columns.map((col) => (
|
||||
<td key={col.header} className="px-4 py-3 whitespace-nowrap">
|
||||
{typeof col.accessor === 'function'
|
||||
? col.accessor(row)
|
||||
: String(row[col.accessor] ?? '')}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
interface ModalProps {
|
||||
open: boolean
|
||||
title: string
|
||||
onClose: () => void
|
||||
children: React.ReactNode
|
||||
maxWidth?: string
|
||||
}
|
||||
|
||||
export default function Modal({ open, title, onClose, children, maxWidth = '500px' }: ModalProps) {
|
||||
if (!open) return null
|
||||
return (
|
||||
<div className="fixed inset-0 z-[70] flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
||||
<div
|
||||
className="bg-card-bg border border-border rounded-xl shadow-2xl w-full mx-4"
|
||||
style={{ maxWidth }}
|
||||
>
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-border">
|
||||
<h3 className="font-serif text-lg text-text-primary">{title}</h3>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="text-text-muted hover:text-text-primary text-xl leading-none"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-5 max-h-[80vh] overflow-auto">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { useEffect } from 'react'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
export default function ToastProvider() {
|
||||
const { state, dispatch } = useApp()
|
||||
|
||||
useEffect(() => {
|
||||
if (state.toasts.length === 0) return
|
||||
const timers = state.toasts.map((t) =>
|
||||
setTimeout(() => {
|
||||
dispatch({ type: 'REMOVE_TOAST', payload: t.id })
|
||||
}, 4000)
|
||||
)
|
||||
return () => timers.forEach(clearTimeout)
|
||||
}, [state.toasts, dispatch])
|
||||
|
||||
if (state.toasts.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="fixed top-16 right-6 z-[100] flex flex-col gap-2">
|
||||
{state.toasts.map((t) => (
|
||||
<div
|
||||
key={t.id}
|
||||
className={`px-4 py-3 rounded-lg shadow-lg text-sm font-medium min-w-[240px] max-w-md border ${
|
||||
t.type === 'success'
|
||||
? 'bg-success/10 border-success/30 text-success'
|
||||
: t.type === 'error'
|
||||
? 'bg-danger/10 border-danger/30 text-danger'
|
||||
: t.type === 'warning'
|
||||
? 'bg-yellow-500/10 border-yellow-500/30 text-yellow-400'
|
||||
: 'bg-primary/10 border-primary/30 text-primary'
|
||||
}`}
|
||||
>
|
||||
{t.message}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
interface FileEntry {
|
||||
name: string
|
||||
path: string
|
||||
size: number
|
||||
is_dir: boolean
|
||||
mod_time: string
|
||||
}
|
||||
|
||||
export default function FileBrowser() {
|
||||
const [path, setPath] = useState('/')
|
||||
const [files, setFiles] = useState<FileEntry[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [viewFile, setViewFile] = useState<{ path: string; content: string } | null>(null)
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const load = async (targetPath: string) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await client.post('/files/list', { path: targetPath })
|
||||
if (res.data.success) {
|
||||
setFiles(res.data.data)
|
||||
setPath(targetPath)
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
load('/')
|
||||
}, [])
|
||||
|
||||
const view = async (filePath: string) => {
|
||||
try {
|
||||
const res = await client.get(`/files/view?path=${encodeURIComponent(filePath)}`)
|
||||
if (res.data.success) {
|
||||
setViewFile({ path: filePath, content: res.data.data })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
const breadcrumbs = path.split('/').filter(Boolean)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">File Browser</h1>
|
||||
|
||||
<div className="flex items-center gap-2 mb-4 text-sm">
|
||||
<button
|
||||
onClick={() => load('/')}
|
||||
className="text-primary hover:underline"
|
||||
>
|
||||
/
|
||||
</button>
|
||||
{breadcrumbs.map((crumb, i) => {
|
||||
const crumbPath = '/' + breadcrumbs.slice(0, i + 1).join('/')
|
||||
return (
|
||||
<span key={i} className="flex items-center gap-2">
|
||||
<span className="text-text-muted">/</span>
|
||||
<button
|
||||
onClick={() => load(crumbPath)}
|
||||
className="text-primary hover:underline"
|
||||
>
|
||||
{crumb}
|
||||
</button>
|
||||
</span>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Name</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Size</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Modified</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{path !== '/' && (
|
||||
<tr
|
||||
className="border-b border-border hover:bg-hover/50 cursor-pointer"
|
||||
onClick={() => {
|
||||
const parent = path.substring(0, path.lastIndexOf('/')) || '/'
|
||||
load(parent)
|
||||
}}
|
||||
>
|
||||
<td className="px-4 py-3 text-text-primary">..</td>
|
||||
<td className="px-4 py-3">-</td>
|
||||
<td className="px-4 py-3">-</td>
|
||||
<td className="px-4 py-3">-</td>
|
||||
</tr>
|
||||
)}
|
||||
{loading ? (
|
||||
<tr><td colSpan={4} className="px-4 py-8 text-center text-text-muted">Loading...</td></tr>
|
||||
) : (
|
||||
files.map((f) => (
|
||||
<tr
|
||||
key={f.path}
|
||||
className="border-b border-border last:border-0 hover:bg-hover/50 cursor-pointer"
|
||||
onClick={() => f.is_dir && load(f.path)}
|
||||
>
|
||||
<td className="px-4 py-3 text-text-primary">
|
||||
{f.is_dir ? '📁' : '📄'} {f.name}
|
||||
</td>
|
||||
<td className="px-4 py-3 text-text-muted">{f.is_dir ? '-' : formatBytes(f.size)}</td>
|
||||
<td className="px-4 py-3 text-text-muted">{new Date(f.mod_time).toLocaleString()}</td>
|
||||
<td className="px-4 py-3">
|
||||
{!f.is_dir && (
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); view(f.path) }}
|
||||
className="text-xs text-primary hover:underline"
|
||||
>
|
||||
View
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{viewFile && (
|
||||
<div className="fixed inset-0 z-[70] flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
||||
<div className="bg-card-bg border border-border rounded-xl shadow-2xl w-full mx-4 max-w-4xl max-h-[80vh] flex flex-col">
|
||||
<div className="flex items-center justify-between px-5 py-4 border-b border-border">
|
||||
<h3 className="font-serif text-lg text-text-primary truncate">{viewFile.path}</h3>
|
||||
<button
|
||||
onClick={() => setViewFile(null)}
|
||||
className="text-text-muted hover:text-text-primary text-xl leading-none"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<pre className="p-5 overflow-auto flex-1 text-xs font-mono text-text-secondary bg-code-bg">
|
||||
{viewFile.content}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes === 0) return '0 B'
|
||||
const k = 1024
|
||||
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
import { useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import DataTable from '../common/DataTable'
|
||||
import Modal from '../common/Modal'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
interface Guild {
|
||||
guild_id: number
|
||||
guild_name: string
|
||||
guild_description: string | null
|
||||
faction_name: string | null
|
||||
member_count: number
|
||||
online_count: number
|
||||
}
|
||||
|
||||
interface GuildMember {
|
||||
player_id: number
|
||||
role_id: number
|
||||
role_name: string
|
||||
player_name: string
|
||||
online_status: string
|
||||
}
|
||||
|
||||
export default function GuildManager() {
|
||||
const [search, setSearch] = useState('')
|
||||
const [selected, setSelected] = useState<Guild | null>(null)
|
||||
const [detail, setDetail] = useState<any>(null)
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const { data: guilds, isLoading } = useSWR(
|
||||
search.length >= 2 ? `/guilds?q=${encodeURIComponent(search)}&limit=25` : null,
|
||||
fetcher,
|
||||
{ refreshInterval: 30000 }
|
||||
)
|
||||
|
||||
const loadDetail = async (guildId: number) => {
|
||||
try {
|
||||
const res = await client.get(`/guilds/${guildId}`)
|
||||
if (res.data.success) setDetail(res.data.data)
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
const handleDisband = async () => {
|
||||
try {
|
||||
const res = await client.delete(`/guilds/${selected!.guild_id}`)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Guild disbanded', type: 'success' } })
|
||||
setSelected(null)
|
||||
setDetail(null)
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
const handleMemberAction = async (action: string, playerId: number, roleId?: number) => {
|
||||
try {
|
||||
let res
|
||||
if (action === 'remove') {
|
||||
res = await client.delete(`/guilds/${selected!.guild_id}/members/${playerId}`)
|
||||
} else {
|
||||
res = await client.put(`/guilds/${selected!.guild_id}/members/${playerId}/role`, { action, role_id: roleId })
|
||||
}
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Member updated', type: 'success' } })
|
||||
loadDetail(selected!.guild_id)
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
const guildList: Guild[] = guilds?.success ? guilds.data : []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Guild Manager</h1>
|
||||
|
||||
<div className="mb-6">
|
||||
<div className="relative max-w-md">
|
||||
<input
|
||||
type="text"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="Search guilds..."
|
||||
className="w-full bg-card-bg border border-border rounded-lg px-4 py-2.5 pl-10 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary"
|
||||
/>
|
||||
<svg className="absolute left-3 top-3 w-4 h-4 text-text-muted" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
columns={[
|
||||
{ header: 'Name', accessor: 'guild_name' },
|
||||
{ header: 'Faction', accessor: 'faction_name' },
|
||||
{ header: 'Members', accessor: 'member_count' },
|
||||
{ header: 'Online', accessor: 'online_count' },
|
||||
]}
|
||||
data={guildList}
|
||||
onRowClick={(row) => { setSelected(row); loadDetail(row.guild_id) }}
|
||||
loading={isLoading}
|
||||
/>
|
||||
|
||||
<Modal open={!!selected} title={selected?.guild_name || ''} onClose={() => { setSelected(null); setDetail(null) }} maxWidth="700px">
|
||||
{selected && detail && (
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-4 text-sm">
|
||||
<InfoRow label="Guild ID" value={selected.guild_id} />
|
||||
<InfoRow label="Members" value={selected.member_count} />
|
||||
<InfoRow label="Faction" value={selected.faction_name || 'None'} />
|
||||
<InfoRow label="Description" value={selected.guild_description || 'None'} />
|
||||
</div>
|
||||
|
||||
<div className="border-t border-border pt-4">
|
||||
<h4 className="text-text-muted text-xs uppercase tracking-wider mb-3">Members</h4>
|
||||
<div className="overflow-x-auto rounded-lg border border-border max-h-64 overflow-y-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-card-bg">
|
||||
<tr className="border-b border-border">
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Name</th>
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Role</th>
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Status</th>
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(detail.members || []).map((m: GuildMember) => (
|
||||
<tr key={m.player_id} className="border-b border-border last:border-0">
|
||||
<td className="px-3 py-2">{m.player_name}</td>
|
||||
<td className="px-3 py-2"><span className="px-2 py-0.5 rounded text-[10px] bg-primary/10 text-primary border border-primary/20">{m.role_name}</span></td>
|
||||
<td className="px-3 py-2 text-xs">{m.online_status}</td>
|
||||
<td className="px-3 py-2 flex gap-1">
|
||||
<button onClick={() => handleMemberAction('promote', m.player_id, 90)} className="text-[10px] text-primary hover:underline">Promote</button>
|
||||
<button onClick={() => handleMemberAction('demote', m.player_id, 50)} className="text-[10px] text-text-muted hover:underline">Demote</button>
|
||||
<button onClick={() => handleMemberAction('remove', m.player_id)} className="text-[10px] text-danger hover:underline">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2 pt-4 border-t border-border">
|
||||
<button onClick={handleDisband} className="px-3 py-1.5 rounded text-xs font-medium bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20">Disband Guild</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function InfoRow({ label, value }: { label: string; value: any }) {
|
||||
return (
|
||||
<div>
|
||||
<div className="text-text-muted text-xs uppercase tracking-wider">{label}</div>
|
||||
<div className="text-text-primary font-mono">{value ?? 'N/A'}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
interface MapMarker {
|
||||
id: string
|
||||
name: string
|
||||
x: number
|
||||
y: number
|
||||
type: 'player' | 'vehicle' | 'building' | 'landclaim'
|
||||
}
|
||||
|
||||
export default function MapViewer() {
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
||||
const [markers, setMarkers] = useState<MapMarker[]>([])
|
||||
const [filter, setFilter] = useState<string>('all')
|
||||
const [selected, setSelected] = useState<MapMarker | null>(null)
|
||||
const [scale, setScale] = useState(1)
|
||||
const [offset, setOffset] = useState({ x: 0, y: 0 })
|
||||
const [isDragging, setIsDragging] = useState(false)
|
||||
const dragStart = useRef({ x: 0, y: 0 })
|
||||
|
||||
const { data: mapData } = useSWR('/partitions', fetcher, { refreshInterval: 60000 })
|
||||
|
||||
useEffect(() => {
|
||||
const allMarkers: MapMarker[] = []
|
||||
if (mapData?.success) {
|
||||
(mapData.data || []).forEach((p: any) => {
|
||||
if (p.center_x != null && p.center_y != null) {
|
||||
allMarkers.push({
|
||||
id: `partition-${p.partition_id}`,
|
||||
name: p.name || `Partition ${p.partition_id}`,
|
||||
x: p.center_x,
|
||||
y: p.center_y,
|
||||
type: 'building',
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
setMarkers(allMarkers)
|
||||
}, [mapData])
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current
|
||||
if (!canvas) return
|
||||
const ctx = canvas.getContext('2d')
|
||||
if (!ctx) return
|
||||
|
||||
const dpr = window.devicePixelRatio || 1
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
canvas.width = rect.width * dpr
|
||||
canvas.height = rect.height * dpr
|
||||
ctx.scale(dpr, dpr)
|
||||
|
||||
ctx.fillStyle = '#1a1a1a'
|
||||
ctx.fillRect(0, 0, rect.width, rect.height)
|
||||
|
||||
ctx.strokeStyle = '#333'
|
||||
ctx.lineWidth = 1
|
||||
const gridSize = 50 * scale
|
||||
for (let x = offset.x % gridSize; x < rect.width; x += gridSize) {
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(x, 0)
|
||||
ctx.lineTo(x, rect.height)
|
||||
ctx.stroke()
|
||||
}
|
||||
for (let y = offset.y % gridSize; y < rect.height; y += gridSize) {
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(0, y)
|
||||
ctx.lineTo(rect.width, y)
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
const filtered = filter === 'all' ? markers : markers.filter((m) => m.type === filter)
|
||||
|
||||
filtered.forEach((m) => {
|
||||
const sx = rect.width / 2 + (m.x * 0.001 * scale) + offset.x
|
||||
const sy = rect.height / 2 + (m.y * 0.001 * scale) + offset.y
|
||||
|
||||
ctx.beginPath()
|
||||
ctx.arc(sx, sy, 6, 0, Math.PI * 2)
|
||||
ctx.fillStyle = m.type === 'player' ? '#27ae60' : m.type === 'vehicle' ? '#4a90d9' : '#d4af37'
|
||||
ctx.fill()
|
||||
ctx.strokeStyle = '#fff'
|
||||
ctx.lineWidth = 1
|
||||
ctx.stroke()
|
||||
|
||||
ctx.fillStyle = '#c0c0c0'
|
||||
ctx.font = '10px Inter'
|
||||
ctx.fillText(m.name, sx + 10, sy + 3)
|
||||
})
|
||||
}, [markers, filter, scale, offset])
|
||||
|
||||
const handleWheel = (e: React.WheelEvent) => {
|
||||
e.preventDefault()
|
||||
const newScale = Math.max(0.1, Math.min(10, scale + (e.deltaY > 0 ? -0.1 : 0.1)))
|
||||
setScale(newScale)
|
||||
}
|
||||
|
||||
const handleMouseDown = (e: React.MouseEvent) => {
|
||||
setIsDragging(true)
|
||||
dragStart.current = { x: e.clientX - offset.x, y: e.clientY - offset.y }
|
||||
}
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent) => {
|
||||
if (!isDragging) return
|
||||
setOffset({ x: e.clientX - dragStart.current.x, y: e.clientY - dragStart.current.y })
|
||||
}
|
||||
|
||||
const handleMouseUp = () => setIsDragging(false)
|
||||
|
||||
return (
|
||||
<div className="h-[calc(100vh-140px)] flex flex-col">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h1 className="font-serif text-3xl text-primary">Map Viewer</h1>
|
||||
<div className="flex gap-2">
|
||||
{(['all', 'player', 'vehicle', 'building'] as const).map((f) => (
|
||||
<button
|
||||
key={f}
|
||||
onClick={() => setFilter(f)}
|
||||
className={`px-3 py-1.5 rounded text-xs font-medium border capitalize ${
|
||||
filter === f
|
||||
? 'bg-primary/10 border-primary text-primary'
|
||||
: 'bg-card-bg border-border text-text-muted hover:text-text-primary'
|
||||
}`}
|
||||
>
|
||||
{f}
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
onClick={() => { setScale(1); setOffset({ x: 0, y: 0 }) }}
|
||||
className="px-3 py-1.5 rounded text-xs font-medium border bg-card-bg border-border text-text-muted hover:text-text-primary"
|
||||
>
|
||||
Reset View
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 bg-card-bg border border-border rounded-lg overflow-hidden relative">
|
||||
<canvas
|
||||
ref={canvasRef}
|
||||
className="w-full h-full cursor-grab active:cursor-grabbing"
|
||||
onWheel={handleWheel}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseUp={handleMouseUp}
|
||||
onMouseLeave={handleMouseUp}
|
||||
/>
|
||||
<div className="absolute bottom-4 left-4 bg-card-bg/90 border border-border rounded px-3 py-2 text-xs text-text-muted">
|
||||
Zoom: {scale.toFixed(1)}x | Markers: {markers.length}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
interface Metrics {
|
||||
total_players: number
|
||||
online_players: number
|
||||
guild_count: number
|
||||
active_guilds: number
|
||||
server_count: number
|
||||
partition_count: number
|
||||
total_worth: number
|
||||
total_flavor_text: number
|
||||
}
|
||||
|
||||
export default function Overview() {
|
||||
const [metrics, setMetrics] = useState<Metrics | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const { dispatch } = useApp()
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
try {
|
||||
const res = await client.get('/stats')
|
||||
if (res.data.success) {
|
||||
setMetrics(res.data.data)
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
load()
|
||||
|
||||
const es = new EventSource('/api/events/stream')
|
||||
es.addEventListener('metrics', (e) => {
|
||||
try {
|
||||
setMetrics(JSON.parse(e.data))
|
||||
} catch {}
|
||||
})
|
||||
return () => es.close()
|
||||
}, [])
|
||||
|
||||
const statCards = metrics
|
||||
? [
|
||||
{ label: 'Total Players', value: metrics.total_players.toLocaleString(), icon: '👥' },
|
||||
{ label: 'Online Players', value: metrics.online_players.toLocaleString(), icon: '🟢' },
|
||||
{ label: 'Guilds', value: metrics.guild_count.toLocaleString(), icon: '🛡️' },
|
||||
{ label: 'Active Guilds', value: metrics.active_guilds.toLocaleString(), icon: '⚔️' },
|
||||
{ label: 'Servers', value: metrics.server_count.toLocaleString(), icon: '🖥️' },
|
||||
{ label: 'Partitions', value: metrics.partition_count.toLocaleString(), icon: '🗺️' },
|
||||
{ label: 'Total Worth', value: '$' + Math.round(metrics.total_worth).toLocaleString(), icon: '💰' },
|
||||
{ label: 'Flavor Text', value: metrics.total_flavor_text.toLocaleString(), icon: '📝' },
|
||||
]
|
||||
: []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Dashboard Overview</h1>
|
||||
|
||||
{loading ? (
|
||||
<div className="text-text-muted">Loading metrics...</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
{statCards.map((card) => (
|
||||
<div
|
||||
key={card.label}
|
||||
className="bg-card-bg border border-border rounded-lg p-5 shadow-card"
|
||||
>
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-2xl">{card.icon}</span>
|
||||
</div>
|
||||
<div className="text-2xl font-bold text-text-primary mb-1">{card.value}</div>
|
||||
<div className="text-sm text-text-muted">{card.label}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="mt-8 grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 shadow-card">
|
||||
<h2 className="font-serif text-xl text-primary mb-4">Quick Actions</h2>
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<QuickAction label="Broadcast Message" onClick={() => {}} />
|
||||
<QuickAction label="Player Search" onClick={() => {}} />
|
||||
<QuickAction label="Guild Lookup" onClick={() => {}} />
|
||||
<QuickAction label="Server Restart" onClick={() => {}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 shadow-card">
|
||||
<h2 className="font-serif text-xl text-primary mb-4">System Health</h2>
|
||||
<div className="space-y-3">
|
||||
<HealthRow label="Database" status="ok" detail="Connected" />
|
||||
<HealthRow label="SSH Tunnel" status="ok" detail="Connected" />
|
||||
<HealthRow label="BG Director" status="ok" detail="Connected" />
|
||||
<HealthRow label="RMQ Game" status="ok" detail="Connected" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function QuickAction({ label, onClick }: { label: string; onClick: () => void }) {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
className="px-4 py-3 bg-primary/10 border border-primary/20 rounded-lg text-primary text-sm font-medium hover:bg-primary/20 transition-colors text-left"
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
function HealthRow({ label, status, detail }: { label: string; status: 'ok' | 'warn' | 'error'; detail: string }) {
|
||||
const dotColor = status === 'ok' ? '#27ae60' : status === 'warn' ? '#f39c12' : '#c0392b'
|
||||
return (
|
||||
<div className="flex items-center justify-between text-sm">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-2 h-2 rounded-full" style={{ backgroundColor: dotColor }} />
|
||||
<span className="text-text-secondary">{label}</span>
|
||||
</div>
|
||||
<span className="text-text-muted">{detail}</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,575 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import Badge from '../common/Badge'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
export default function PlayerDetail() {
|
||||
const { accountId } = useParams<{ accountId: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { dispatch } = useApp()
|
||||
const [activeTab, setActiveTab] = useState('overview')
|
||||
|
||||
const { data: detail } = useSWR(
|
||||
accountId ? `/players/${accountId}` : null,
|
||||
fetcher,
|
||||
{ refreshInterval: 30000 }
|
||||
)
|
||||
|
||||
const player = detail?.success ? detail.data : null
|
||||
|
||||
const handleAction = async (endpoint: string, payload: any = {}) => {
|
||||
try {
|
||||
const res = await client.post(endpoint, payload)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Action successful', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Action failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
if (!player) {
|
||||
return <div className="text-text-muted">Loading player details...</div>
|
||||
}
|
||||
|
||||
const tabs = [
|
||||
{ key: 'overview', label: 'Overview' },
|
||||
{ key: 'inventory', label: 'Inventory' },
|
||||
{ key: 'vehicles', label: 'Vehicles' },
|
||||
{ key: 'buildings', label: 'Buildings' },
|
||||
{ key: 'progression', label: 'Progression' },
|
||||
{ key: 'actions', label: 'Actions' },
|
||||
]
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center gap-4 mb-6">
|
||||
<button
|
||||
onClick={() => navigate('/players')}
|
||||
className="text-text-muted hover:text-text-primary text-sm"
|
||||
>
|
||||
← Back to Players
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary">{player.character_name}</h1>
|
||||
<div className="flex items-center gap-2 mt-1">
|
||||
<Badge
|
||||
label={player.online_status}
|
||||
variant={player.is_online ? 'success' : 'default'}
|
||||
/>
|
||||
{player.faction_name && (
|
||||
<span className="text-sm text-text-secondary">{player.faction_name}</span>
|
||||
)}
|
||||
{player.tags?.map((tag: string) => (
|
||||
<Badge key={tag} label={tag} variant="warning" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-1 mb-6 border-b border-border">
|
||||
{tabs.map((t) => (
|
||||
<button
|
||||
key={t.key}
|
||||
onClick={() => setActiveTab(t.key)}
|
||||
className={`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors ${
|
||||
activeTab === t.key
|
||||
? 'text-primary border-primary'
|
||||
: 'text-text-muted border-transparent hover:text-text-primary'
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{activeTab === 'overview' && <OverviewTab player={player} />}
|
||||
{activeTab === 'inventory' && <InventoryTab player={player} />}
|
||||
{activeTab === 'vehicles' && <VehiclesTab player={player} />}
|
||||
{activeTab === 'buildings' && <BuildingsTab player={player} />}
|
||||
{activeTab === 'progression' && <ProgressionTab player={player} />}
|
||||
{activeTab === 'actions' && <ActionsTab player={player} onAction={handleAction} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function OverviewTab({ player }: { player: any }) {
|
||||
const vitals = player.vitals || {}
|
||||
const currency = player.currency || []
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Character Info</h3>
|
||||
<div className="grid grid-cols-2 gap-4 text-sm">
|
||||
<InfoRow label="Account ID" value={player.account_id} />
|
||||
<InfoRow label="Controller ID" value={player.player_controller_id} />
|
||||
<InfoRow label="Pawn ID" value={player.player_pawn_id} />
|
||||
<InfoRow label="Email" value={player.account_email} />
|
||||
<InfoRow label="Funcom ID" value={player.funcom_id} />
|
||||
<InfoRow label="Map" value={player.map} />
|
||||
<InfoRow label="Life State" value={player.life_state} />
|
||||
<InfoRow label="Last Login" value={player.last_login_time} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Vitals</h3>
|
||||
<div className="grid grid-cols-2 gap-4 text-sm">
|
||||
<InfoRow label="Health" value={`${vitals.current_health ?? '?'}/${vitals.max_health ?? '?'}`} />
|
||||
<InfoRow label="Hydration" value={vitals.current_hydration ?? '?'} />
|
||||
<InfoRow label="Dehydration" value={vitals.dehydration_penalty ?? '?'} />
|
||||
<InfoRow label="Spice" value={vitals.current_spice ?? '?'} />
|
||||
<InfoRow label="Addiction" value={vitals.spice_addiction_level ?? '?'} />
|
||||
<InfoRow label="Tolerance" value={vitals.spice_tolerance ?? '?'} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Currency</h3>
|
||||
<div className="space-y-2">
|
||||
{currency.length === 0 && <span className="text-text-muted text-sm">No currency data</span>}
|
||||
{currency.map((c: any) => (
|
||||
<div key={c.currency_id} className="flex justify-between text-sm">
|
||||
<span className="text-text-secondary">{c.currency_label}</span>
|
||||
<span className="text-text-primary font-mono">{c.balance}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Landsraad</h3>
|
||||
<div className="grid grid-cols-2 gap-4 text-sm">
|
||||
{player.landsraad ? (
|
||||
<>
|
||||
<InfoRow label="Daily Charges" value={player.landsraad.daily_reward_charges} />
|
||||
<InfoRow label="Last Term" value={player.landsraad.last_viewed_term_id} />
|
||||
</>
|
||||
) : (
|
||||
<span className="text-text-muted">No landsraad data</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Faction Reputation</h3>
|
||||
<div className="space-y-2">
|
||||
{(player.faction_reputation || []).length === 0 && <span className="text-text-muted text-sm">No reputation data</span>}
|
||||
{(player.faction_reputation || []).map((r: any) => (
|
||||
<div key={r.faction_id} className="flex justify-between text-sm">
|
||||
<span className="text-text-secondary">{r.faction_name || `Faction ${r.faction_id}`}</span>
|
||||
<span className="text-text-primary font-mono">{r.reputation_amount}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function InfoRow({ label, value }: { label: string; value: any }) {
|
||||
return (
|
||||
<div>
|
||||
<div className="text-text-muted text-xs uppercase tracking-wider">{label}</div>
|
||||
<div className="text-text-primary font-mono">{value ?? 'N/A'}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function InventoryTab({ player }: { player: any }) {
|
||||
const inventories = player.inventories || []
|
||||
const [selectedInv, setSelectedInv] = useState<any>(null)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h3 className="font-serif text-xl text-primary mb-4">Inventories</h3>
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
|
||||
{inventories.map((inv: any) => (
|
||||
<button
|
||||
key={inv.inventory_id}
|
||||
onClick={() => setSelectedInv(inv)}
|
||||
className={`text-left p-4 rounded-lg border transition-colors ${
|
||||
selectedInv?.inventory_id === inv.inventory_id
|
||||
? 'bg-primary/10 border-primary'
|
||||
: 'bg-card-bg border-border hover:bg-hover'
|
||||
}`}
|
||||
>
|
||||
<div className="text-sm font-medium text-text-primary">{inv.inventory_type_label}</div>
|
||||
<div className="text-xs text-text-muted mt-1">ID: {inv.inventory_id}</div>
|
||||
<div className="text-xs text-text-muted">Items: {inv.items?.length || 0}</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{selectedInv && (
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h4 className="text-text-primary font-medium mb-3">
|
||||
{selectedInv.inventory_type_label} Items
|
||||
</h4>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Item</th>
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Stack</th>
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Quality</th>
|
||||
<th className="text-left px-3 py-2 text-text-muted text-[11px] uppercase">Durability</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(selectedInv.items || []).map((item: any, i: number) => (
|
||||
<tr key={i} className="border-b border-border last:border-0">
|
||||
<td className="px-3 py-2">{item.template_id}</td>
|
||||
<td className="px-3 py-2 font-mono">{item.stack_size}</td>
|
||||
<td className="px-3 py-2 font-mono">{item.quality_level}</td>
|
||||
<td className="px-3 py-2 font-mono">
|
||||
{item.durability != null ? `${Math.round(item.durability)}/${Math.round(item.max_durability)}` : 'N/A'}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function VehiclesTab({ player }: { player: any }) {
|
||||
const vehicles = player.vehicles || []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h3 className="font-serif text-xl text-primary mb-4">Vehicles</h3>
|
||||
{vehicles.length === 0 ? (
|
||||
<div className="text-text-muted">No vehicles found.</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{vehicles.map((v: any) => (
|
||||
<div key={v.id} className="bg-card-bg border border-border rounded-lg p-4">
|
||||
<div className="text-text-primary font-medium">{v.display_name || v.class_name}</div>
|
||||
<div className="text-xs text-text-muted mt-1">Map: {v.map || 'Unknown'}</div>
|
||||
<div className="text-xs text-text-muted font-mono">ID: {v.id}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function BuildingsTab({ player }: { player: any }) {
|
||||
const buildings = player.buildings || []
|
||||
const landclaims = player.landclaims || []
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h3 className="font-serif text-xl text-primary mb-4">Buildings</h3>
|
||||
{buildings.length === 0 ? (
|
||||
<div className="text-text-muted">No buildings found.</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{buildings.map((b: any) => (
|
||||
<div key={b.id} className="bg-card-bg border border-border rounded-lg p-4">
|
||||
<div className="text-text-primary font-medium">{b.class_name}</div>
|
||||
<div className="text-xs text-text-muted mt-1">Map: {b.map || 'Unknown'}</div>
|
||||
<div className="flex gap-2 mt-2">
|
||||
{b.is_powered && <Badge label="Powered" variant="success" />}
|
||||
{b.power_level != null && <Badge label={`Power ${b.power_level}`} variant="default" />}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-serif text-xl text-primary mb-4">Landclaims</h3>
|
||||
{landclaims.length === 0 ? (
|
||||
<div className="text-text-muted">No landclaims found.</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
{landclaims.map((l: any) => (
|
||||
<div key={l.id} className="bg-card-bg border border-border rounded-lg p-4">
|
||||
<div className="text-text-primary font-medium">{l.class_name}</div>
|
||||
<div className="text-xs text-text-muted mt-1">Map: {l.map || 'Unknown'}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ProgressionTab({ player }: { player: any }) {
|
||||
const specs = player.specialization || []
|
||||
const keystones = player.keystones || []
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Specialization Tracks</h3>
|
||||
{specs.length === 0 ? (
|
||||
<div className="text-text-muted">No specialization data.</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{specs.map((s: any, i: number) => (
|
||||
<div key={i} className="flex items-center justify-between">
|
||||
<span className="text-text-secondary text-sm">{s.track_type}</span>
|
||||
<div className="flex items-center gap-4">
|
||||
<span className="text-text-muted text-xs">XP: {s.xp_amount}</span>
|
||||
<Badge label={`Lv ${s.level}`} variant="default" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="font-serif text-lg text-primary mb-4">Keystones</h3>
|
||||
{keystones.length === 0 ? (
|
||||
<div className="text-text-muted">No keystones.</div>
|
||||
) : (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{keystones.map((k: any) => (
|
||||
<Badge key={k.id} label={k.name} variant="default" />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ActionsTab({ player, onAction }: { player: any; onAction: (endpoint: string, payload?: any) => Promise<void> }) {
|
||||
const accountId = player.account_id
|
||||
const [newName, setNewName] = useState('')
|
||||
const [currencyForm, setCurrencyForm] = useState({ currency_id: '0', amount: '' })
|
||||
const [vitalsForm, setVitalsForm] = useState({ health: '', hydration: '', spice: '' })
|
||||
const [teleportForm, setTeleportForm] = useState({ partition: '', x: '', y: '', z: '' })
|
||||
const [banReason, setBanReason] = useState('')
|
||||
const [banDuration, setBanDuration] = useState('0')
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<ActionCard title="Currency">
|
||||
<div className="space-y-2">
|
||||
<select
|
||||
value={currencyForm.currency_id}
|
||||
onChange={(e) => setCurrencyForm({ ...currencyForm, currency_id: e.target.value })}
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
>
|
||||
<option value="0">Solari Credits</option>
|
||||
<option value="1">House Script</option>
|
||||
<option value="2">Spice</option>
|
||||
</select>
|
||||
<input
|
||||
type="number"
|
||||
value={currencyForm.amount}
|
||||
onChange={(e) => setCurrencyForm({ ...currencyForm, amount: e.target.value })}
|
||||
placeholder="Amount"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={() => onAction(`/currency/adjust`, { player_id: accountId, currency_id: parseInt(currencyForm.currency_id), amount: parseFloat(currencyForm.amount) })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary"
|
||||
>
|
||||
Adjust
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onAction(`/currency/set`, { player_id: accountId, currency_id: parseInt(currencyForm.currency_id), amount: parseFloat(currencyForm.amount) })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary"
|
||||
>
|
||||
Set Exact
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ActionCard>
|
||||
|
||||
<ActionCard title="Vitals">
|
||||
<div className="space-y-2">
|
||||
<input
|
||||
type="number"
|
||||
value={vitalsForm.health}
|
||||
onChange={(e) => setVitalsForm({ ...vitalsForm, health: e.target.value })}
|
||||
placeholder="Health"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
value={vitalsForm.hydration}
|
||||
onChange={(e) => setVitalsForm({ ...vitalsForm, hydration: e.target.value })}
|
||||
placeholder="Hydration"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
value={vitalsForm.spice}
|
||||
onChange={(e) => setVitalsForm({ ...vitalsForm, spice: e.target.value })}
|
||||
placeholder="Spice"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<button
|
||||
onClick={() => onAction(`/vitals/set`, { player_id: accountId, health: parseFloat(vitalsForm.health) || undefined, hydration: parseFloat(vitalsForm.hydration) || undefined, spice: parseFloat(vitalsForm.spice) || undefined })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary"
|
||||
>
|
||||
Set Vitals
|
||||
</button>
|
||||
</div>
|
||||
</ActionCard>
|
||||
|
||||
<ActionCard title="Teleport">
|
||||
<div className="space-y-2">
|
||||
<input
|
||||
value={teleportForm.partition}
|
||||
onChange={(e) => setTeleportForm({ ...teleportForm, partition: e.target.value })}
|
||||
placeholder="Partition ID"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
<input
|
||||
type="number"
|
||||
value={teleportForm.x}
|
||||
onChange={(e) => setTeleportForm({ ...teleportForm, x: e.target.value })}
|
||||
placeholder="X"
|
||||
className="bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
value={teleportForm.y}
|
||||
onChange={(e) => setTeleportForm({ ...teleportForm, y: e.target.value })}
|
||||
placeholder="Y"
|
||||
className="bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
value={teleportForm.z}
|
||||
onChange={(e) => setTeleportForm({ ...teleportForm, z: e.target.value })}
|
||||
placeholder="Z"
|
||||
className="bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => onAction(`/teleport`, { fls_id: accountId, partition_id: teleportForm.partition, x: parseFloat(teleportForm.x) || 0, y: parseFloat(teleportForm.y) || 0, z: parseFloat(teleportForm.z) || 0 })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary"
|
||||
>
|
||||
Teleport
|
||||
</button>
|
||||
</div>
|
||||
</ActionCard>
|
||||
|
||||
<ActionCard title="Character">
|
||||
<div className="space-y-2">
|
||||
<input
|
||||
value={newName}
|
||||
onChange={(e) => setNewName(e.target.value)}
|
||||
placeholder="New character name"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
onClick={() => onAction(`/characters/${accountId}/name`, { name: newName })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-primary/10 border border-primary/20 text-primary"
|
||||
>
|
||||
Rename
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onAction(`/accounts/${accountId}/demo`, { demo: true })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-warning/10 border border-warning/20 text-warning"
|
||||
>
|
||||
Set Demo
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onAction(`/accounts/${accountId}/demo`, { demo: false })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-warning/10 border border-warning/20 text-warning"
|
||||
>
|
||||
Clear Demo
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (confirm('Delete this character? This cannot be undone.')) {
|
||||
onAction(`/characters/${accountId}`, {})
|
||||
}
|
||||
}}
|
||||
className="px-3 py-1.5 rounded text-xs bg-danger/10 border border-danger/30 text-danger"
|
||||
>
|
||||
Delete Character
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (confirm('Delete this entire account? This cannot be undone.')) {
|
||||
onAction(`/accounts/${accountId}`, {})
|
||||
}
|
||||
}}
|
||||
className="px-3 py-1.5 rounded text-xs bg-danger/10 border border-danger/30 text-danger"
|
||||
>
|
||||
Delete Account
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ActionCard>
|
||||
|
||||
<ActionCard title="Moderation">
|
||||
<div className="space-y-2">
|
||||
<input
|
||||
value={banReason}
|
||||
onChange={(e) => setBanReason(e.target.value)}
|
||||
placeholder="Ban reason"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
value={banDuration}
|
||||
onChange={(e) => setBanDuration(e.target.value)}
|
||||
placeholder="Duration (hours, 0 = permanent)"
|
||||
className="w-full bg-card-bg border border-border rounded px-3 py-2 text-sm"
|
||||
/>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
onClick={() => onAction(`/players/${accountId}/ban`, { reason: banReason, duration_hours: parseInt(banDuration) || 0 })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-danger/10 border border-danger/30 text-danger"
|
||||
>
|
||||
Ban Player
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onAction(`/players/${accountId}/unban`, {})}
|
||||
className="px-3 py-1.5 rounded text-xs bg-success/10 border border-success/30 text-success"
|
||||
>
|
||||
Unban Player
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onAction(`/players/${accountId}/kick`, { reason: banReason })}
|
||||
className="px-3 py-1.5 rounded text-xs bg-warning/10 border border-warning/20 text-warning"
|
||||
>
|
||||
Kick Player
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</ActionCard>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ActionCard({ title, children }: { title: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h4 className="text-text-primary font-medium mb-3">{title}</h4>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import { useDebounce } from '../../hooks/useDebounce'
|
||||
import DataTable from '../common/DataTable'
|
||||
import Badge from '../common/Badge'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
interface Player {
|
||||
player_controller_id: number | null
|
||||
account_id: number | null
|
||||
character_name: string
|
||||
account_email: string | null
|
||||
funcom_id: string | null
|
||||
faction_name: string | null
|
||||
map: string | null
|
||||
online_status: string
|
||||
life_state: string | null
|
||||
last_login_time: string | null
|
||||
}
|
||||
|
||||
export default function PlayerExplorer() {
|
||||
const [search, setSearch] = useState('')
|
||||
const debouncedSearch = useDebounce(search, 300)
|
||||
const navigate = useNavigate()
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const { data: players, isLoading } = useSWR(
|
||||
debouncedSearch.length >= 2
|
||||
? `/players?q=${encodeURIComponent(debouncedSearch)}&limit=25`
|
||||
: null,
|
||||
fetcher,
|
||||
{ refreshInterval: 30000 }
|
||||
)
|
||||
|
||||
const handleAction = async (accountId: number, action: string, payload: Record<string, unknown> = {}) => {
|
||||
try {
|
||||
let res
|
||||
if (action === 'cheater') {
|
||||
res = await client.post(`/players/${accountId}/cheater`, payload)
|
||||
} else if (action === 'tags') {
|
||||
res = await client.put(`/players/${accountId}/tags`, payload)
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: `Action "${action}" not yet implemented`, type: 'warning' } })
|
||||
return
|
||||
}
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Action successful', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Action failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Action failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
const playerList: Player[] = players?.success ? players.data : []
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Player Explorer</h1>
|
||||
|
||||
<div className="mb-6">
|
||||
<div className="relative max-w-md">
|
||||
<input
|
||||
type="text"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="Search by name, email, or Funcom ID..."
|
||||
className="w-full bg-card-bg border border-border rounded-lg px-4 py-2.5 pl-10 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary"
|
||||
/>
|
||||
<svg className="absolute left-3 top-3 w-4 h-4 text-text-muted" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
columns={[
|
||||
{ header: 'Name', accessor: 'character_name' },
|
||||
{
|
||||
header: 'Status',
|
||||
accessor: (row) => (
|
||||
<Badge
|
||||
label={row.online_status}
|
||||
variant={row.online_status === 'Online' ? 'success' : 'default'}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{ header: 'Funcom ID', accessor: 'funcom_id' },
|
||||
{ header: 'Faction', accessor: 'faction_name' },
|
||||
{ header: 'Map', accessor: 'map' },
|
||||
{
|
||||
header: 'Quick Actions',
|
||||
accessor: (row) => (
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleAction(row.account_id || row.player_controller_id || 0, 'cheater', { cheat_type: 'exploit' }) }}
|
||||
className="text-[10px] text-primary hover:underline"
|
||||
>
|
||||
Cheater
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleAction(row.account_id || row.player_controller_id || 0, 'tags', { add: ['reviewed'] }) }}
|
||||
className="text-[10px] text-primary hover:underline"
|
||||
>
|
||||
Tag
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
data={playerList}
|
||||
onRowClick={(row) => navigate(`/players/${row.account_id || row.player_controller_id || 0}`)}
|
||||
loading={isLoading}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import Badge from '../common/Badge'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
interface Pod {
|
||||
name: string
|
||||
namespace: string
|
||||
status: string
|
||||
restarts: number
|
||||
age: string
|
||||
}
|
||||
|
||||
interface Deployment {
|
||||
name: string
|
||||
namespace: string
|
||||
replicas: number
|
||||
available: number
|
||||
}
|
||||
|
||||
interface MetricPoint {
|
||||
timestamp: string
|
||||
cpu_percent: number
|
||||
memory_percent: number
|
||||
}
|
||||
|
||||
export default function ServerControl() {
|
||||
const [tab, setTab] = useState<'pods' | 'deployments' | 'metrics' | 'firewall' | 'rmq'>('pods')
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const { data: pods, mutate: mutatePods } = useSWR('/server/pods', fetcher, { refreshInterval: 15000 })
|
||||
const { data: deployments } = useSWR('/server/deployments', fetcher, { refreshInterval: 30000 })
|
||||
const { data: metrics } = useSWR('/server/metrics?hours=24', fetcher, { refreshInterval: 60000 })
|
||||
const { data: firewall } = useSWR('/server/firewall/status', fetcher, { refreshInterval: 30000 })
|
||||
const { data: rmq } = useSWR('/server/rmq/overview', fetcher, { refreshInterval: 30000 })
|
||||
|
||||
const podList: Pod[] = pods?.success ? pods.data : []
|
||||
const deploymentList: Deployment[] = deployments?.success ? deployments.data : []
|
||||
const metricList: MetricPoint[] = metrics?.success ? metrics.data : []
|
||||
|
||||
const handleRestart = async (deployment: string) => {
|
||||
try {
|
||||
const res = await client.post(`/server/deployments/${deployment}/restart`)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Restart initiated', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
const handleScale = async (deployment: string, replicas: number) => {
|
||||
try {
|
||||
const res = await client.post(`/server/deployments/${deployment}/scale`, { replicas })
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Scaled successfully', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Server Control</h1>
|
||||
|
||||
<div className="flex gap-1 mb-6 border-b border-border">
|
||||
{(['pods', 'deployments', 'metrics', 'firewall', 'rmq'] as const).map((t) => (
|
||||
<button
|
||||
key={t}
|
||||
onClick={() => setTab(t)}
|
||||
className={`px-4 py-2.5 text-sm font-medium border-b-2 transition-colors capitalize ${
|
||||
tab === t
|
||||
? 'text-primary border-primary'
|
||||
: 'text-text-muted border-transparent hover:text-text-primary'
|
||||
}`}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{tab === 'pods' && (
|
||||
<div className="overflow-x-auto rounded-lg border border-border">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Name</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Namespace</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Status</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Restarts</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Age</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{podList.map((pod) => (
|
||||
<tr key={pod.name} className="border-b border-border last:border-0 hover:bg-hover/50">
|
||||
<td className="px-4 py-3 font-mono text-xs">{pod.name}</td>
|
||||
<td className="px-4 py-3">{pod.namespace}</td>
|
||||
<td className="px-4 py-3">
|
||||
<Badge
|
||||
label={pod.status}
|
||||
variant={pod.status === 'Running' ? 'success' : pod.status === 'Pending' ? 'warning' : 'danger'}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-4 py-3">{pod.restarts}</td>
|
||||
<td className="px-4 py-3">{pod.age}</td>
|
||||
<td className="px-4 py-3">
|
||||
<button
|
||||
onClick={() => handleRestart(pod.name)}
|
||||
className="text-xs text-primary hover:underline"
|
||||
>
|
||||
Restart
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'deployments' && (
|
||||
<div className="overflow-x-auto rounded-lg border border-border">
|
||||
<table className="w-full text-sm">
|
||||
<thead>
|
||||
<tr className="border-b border-border">
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Name</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Namespace</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Replicas</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Available</th>
|
||||
<th className="text-left px-4 py-3 text-text-muted font-semibold text-[11px] uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{deploymentList.map((dep) => (
|
||||
<tr key={dep.name} className="border-b border-border last:border-0 hover:bg-hover/50">
|
||||
<td className="px-4 py-3 font-mono text-xs">{dep.name}</td>
|
||||
<td className="px-4 py-3">{dep.namespace}</td>
|
||||
<td className="px-4 py-3">{dep.replicas}</td>
|
||||
<td className="px-4 py-3">{dep.available}</td>
|
||||
<td className="px-4 py-3 flex gap-2">
|
||||
<button
|
||||
onClick={() => handleScale(dep.name, dep.replicas + 1)}
|
||||
className="text-xs px-2 py-1 bg-primary/10 border border-primary/20 rounded text-primary"
|
||||
>
|
||||
+1
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleScale(dep.name, Math.max(0, dep.replicas - 1))}
|
||||
className="text-xs px-2 py-1 bg-primary/10 border border-primary/20 rounded text-primary"
|
||||
>
|
||||
-1
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleRestart(dep.name)}
|
||||
className="text-xs px-2 py-1 bg-danger/10 border border-danger/20 rounded text-danger"
|
||||
>
|
||||
Restart
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'metrics' && (
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">Server Metrics (24h)</h3>
|
||||
{metricList.length === 0 ? (
|
||||
<div className="text-text-muted text-sm">No metrics available</div>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{metricList.slice(-20).map((m, i) => (
|
||||
<div key={i} className="flex items-center gap-4 text-sm">
|
||||
<span className="text-text-muted w-32">{new Date(m.timestamp).toLocaleTimeString()}</span>
|
||||
<div className="flex-1 flex items-center gap-2">
|
||||
<span className="text-text-muted w-8">CPU</span>
|
||||
<div className="flex-1 h-2 bg-border rounded overflow-hidden">
|
||||
<div
|
||||
className="h-full bg-primary"
|
||||
style={{ width: `${Math.min(100, m.cpu_percent)}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="text-text-secondary w-10 text-right">{m.cpu_percent}%</span>
|
||||
</div>
|
||||
<div className="flex-1 flex items-center gap-2">
|
||||
<span className="text-text-muted w-12">Mem</span>
|
||||
<div className="flex-1 h-2 bg-border rounded overflow-hidden">
|
||||
<div
|
||||
className="h-full bg-success"
|
||||
style={{ width: `${Math.min(100, m.memory_percent)}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="text-text-secondary w-10 text-right">{m.memory_percent}%</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'firewall' && (
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">Firewall Status</h3>
|
||||
{firewall?.success ? (
|
||||
<pre className="text-xs text-text-secondary font-mono bg-code-bg p-4 rounded overflow-auto">
|
||||
{JSON.stringify(firewall.data, null, 2)}
|
||||
</pre>
|
||||
) : (
|
||||
<div className="text-text-muted text-sm">No firewall data available</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === 'rmq' && (
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">RMQ Overview</h3>
|
||||
{rmq?.success ? (
|
||||
<pre className="text-xs text-text-secondary font-mono bg-code-bg p-4 rounded overflow-auto">
|
||||
{JSON.stringify(rmq.data, null, 2)}
|
||||
</pre>
|
||||
) : (
|
||||
<div className="text-text-muted text-sm">No RMQ data available</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
|
||||
export default function Settings() {
|
||||
const [settings, setSettings] = useState<Record<string, string>>({})
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const load = async () => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const res = await client.get('/settings')
|
||||
if (res.data.success) {
|
||||
setSettings(res.data.data)
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed to load settings', type: 'error' } })
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [])
|
||||
|
||||
const handleSave = async () => {
|
||||
setSaving(true)
|
||||
try {
|
||||
const res = await client.post('/settings', settings)
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Settings saved', type: 'success' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed to save', type: 'error' } })
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
const handleChange = (key: string, value: string) => {
|
||||
setSettings({ ...settings, [key]: value })
|
||||
}
|
||||
|
||||
const addKey = () => {
|
||||
const key = prompt('Enter new setting key:')
|
||||
if (key) {
|
||||
setSettings({ ...settings, [key]: '' })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Settings</h1>
|
||||
|
||||
<div className="flex items-center gap-4 mb-6">
|
||||
<button
|
||||
onClick={load}
|
||||
disabled={loading}
|
||||
className="px-4 py-2 bg-primary text-white rounded-lg text-sm font-medium hover:bg-primary-dark disabled:opacity-50"
|
||||
>
|
||||
{loading ? 'Loading...' : 'Reload'}
|
||||
</button>
|
||||
<button
|
||||
onClick={handleSave}
|
||||
disabled={saving}
|
||||
className="px-4 py-2 bg-success text-white rounded-lg text-sm font-medium hover:bg-success/80 disabled:opacity-50"
|
||||
>
|
||||
{saving ? 'Saving...' : 'Save Settings'}
|
||||
</button>
|
||||
<button
|
||||
onClick={addKey}
|
||||
className="px-4 py-2 bg-card-bg border border-border text-text-primary rounded-lg text-sm font-medium hover:bg-hover"
|
||||
>
|
||||
Add Key
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4 max-w-2xl">
|
||||
{Object.entries(settings).length === 0 && !loading && (
|
||||
<div className="text-text-muted">No settings found.</div>
|
||||
)}
|
||||
{Object.entries(settings).map(([key, value]) => (
|
||||
<div key={key} className="grid grid-cols-[200px_1fr] gap-4 items-center">
|
||||
<label className="text-sm text-text-secondary truncate" title={key}>{key}</label>
|
||||
<input
|
||||
value={value}
|
||||
onChange={(e) => handleChange(key, e.target.value)}
|
||||
className="bg-card-bg border border-border rounded px-3 py-2 text-sm text-text-primary"
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { Terminal as XTerm } from 'xterm'
|
||||
import { FitAddon } from 'xterm-addon-fit'
|
||||
import { io, Socket } from 'socket.io-client'
|
||||
import 'xterm/css/xterm.css'
|
||||
|
||||
export default function Terminal() {
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const termRef = useRef<XTerm | null>(null)
|
||||
const fitAddonRef = useRef<FitAddon | null>(null)
|
||||
const socketRef = useRef<Socket | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!containerRef.current) return
|
||||
|
||||
const term = new XTerm({
|
||||
cursorBlink: true,
|
||||
fontSize: 14,
|
||||
fontFamily: 'Roboto Mono, monospace',
|
||||
theme: {
|
||||
background: '#1a1a1a',
|
||||
foreground: '#f0f0f0',
|
||||
cursor: '#d4af37',
|
||||
selectionBackground: '#404040',
|
||||
black: '#1a1a1a',
|
||||
red: '#c0392b',
|
||||
green: '#27ae60',
|
||||
yellow: '#f39c12',
|
||||
blue: '#4a90d9',
|
||||
magenta: '#9966cc',
|
||||
cyan: '#20b2aa',
|
||||
white: '#f0f0f0',
|
||||
brightBlack: '#404040',
|
||||
brightRed: '#ff6b6b',
|
||||
brightGreen: '#6abf6a',
|
||||
brightYellow: '#e8c962',
|
||||
brightBlue: '#6baee8',
|
||||
brightMagenta: '#c8a8e8',
|
||||
brightCyan: '#7de8d8',
|
||||
brightWhite: '#ffffff',
|
||||
},
|
||||
})
|
||||
|
||||
const fitAddon = new FitAddon()
|
||||
term.loadAddon(fitAddon)
|
||||
term.open(containerRef.current)
|
||||
fitAddon.fit()
|
||||
|
||||
termRef.current = term
|
||||
fitAddonRef.current = fitAddon
|
||||
|
||||
const socket = io({
|
||||
transports: ['websocket'],
|
||||
})
|
||||
socketRef.current = socket
|
||||
|
||||
socket.on('connect', () => {
|
||||
term.writeln('Connecting to remote shell...')
|
||||
socket.emit('shell_create', { type: 'vm' })
|
||||
})
|
||||
|
||||
socket.on('shell_created', (data: any) => {
|
||||
if (data.success) {
|
||||
term.writeln('\r\nConnected to remote shell.')
|
||||
} else {
|
||||
term.writeln(`\r\nFailed to create shell: ${data.error || 'Unknown error'}`)
|
||||
}
|
||||
})
|
||||
|
||||
socket.on('shell_output', (data: any) => {
|
||||
if (data.data) {
|
||||
term.write(data.data)
|
||||
}
|
||||
})
|
||||
|
||||
socket.on('disconnect', () => {
|
||||
term.writeln('\r\n[Disconnected]')
|
||||
})
|
||||
|
||||
term.onData((data) => {
|
||||
socket.emit('shell_input', { data })
|
||||
})
|
||||
|
||||
const handleResize = () => {
|
||||
fitAddon.fit()
|
||||
}
|
||||
window.addEventListener('resize', handleResize)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
socket.emit('shell_disconnect')
|
||||
socket.disconnect()
|
||||
term.dispose()
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="h-[calc(100vh-140px)] flex flex-col">
|
||||
<h1 className="font-serif text-3xl text-primary mb-4">Remote Shell</h1>
|
||||
<div
|
||||
ref={containerRef}
|
||||
className="flex-1 bg-[#1a1a1a] rounded-lg border border-border overflow-hidden"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { useState } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import client from '../../api/client'
|
||||
import { useApp } from '../../stores/AppContext'
|
||||
import DataTable from '../common/DataTable'
|
||||
|
||||
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||
|
||||
interface Vehicle {
|
||||
id: number
|
||||
class_name: string
|
||||
display_name: string
|
||||
map: string
|
||||
owner_name: string
|
||||
online_status: string
|
||||
}
|
||||
|
||||
export default function Vehicles() {
|
||||
const [search, setSearch] = useState('')
|
||||
const { dispatch } = useApp()
|
||||
|
||||
const { data: vehiclesData, isLoading } = useSWR(
|
||||
search.length >= 2 ? `/vehicles?q=${encodeURIComponent(search)}&limit=50` : '/vehicles?limit=100',
|
||||
fetcher,
|
||||
{ refreshInterval: 30000 }
|
||||
)
|
||||
|
||||
const vehicleList: Vehicle[] = vehiclesData?.success ? vehiclesData.data : []
|
||||
|
||||
const handleAction = async (id: number, action: string) => {
|
||||
try {
|
||||
const res = await client.post(`/vehicles/${id}/${action}`, {})
|
||||
if (res.data.success) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: 'Action successful', type: 'success' } })
|
||||
} else {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
} catch (e: any) {
|
||||
dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } })
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="font-serif text-3xl text-primary mb-6">Vehicles</h1>
|
||||
|
||||
<div className="mb-6">
|
||||
<div className="relative max-w-md">
|
||||
<input
|
||||
type="text"
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="Search vehicles..."
|
||||
className="w-full bg-card-bg border border-border rounded-lg px-4 py-2.5 pl-10 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary"
|
||||
/>
|
||||
<svg className="absolute left-3 top-3 w-4 h-4 text-text-muted" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
columns={[
|
||||
{ header: 'Name', accessor: 'display_name' },
|
||||
{ header: 'Class', accessor: 'class_name' },
|
||||
{ header: 'Map', accessor: 'map' },
|
||||
{ header: 'Owner', accessor: 'owner_name' },
|
||||
{
|
||||
header: 'Actions',
|
||||
accessor: (row) => (
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleAction(row.id, 'repair') }}
|
||||
className="text-xs text-primary hover:underline"
|
||||
>
|
||||
Repair
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => { e.stopPropagation(); handleAction(row.id, 'destroy') }}
|
||||
className="text-xs text-danger hover:underline"
|
||||
>
|
||||
Destroy
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
data={vehicleList}
|
||||
loading={isLoading}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
export function useDebounce<T>(value: T, delay: number = 300): T {
|
||||
const [debounced, setDebounced] = useState(value)
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setDebounced(value), delay)
|
||||
return () => clearTimeout(timer)
|
||||
}, [value, delay])
|
||||
return debounced
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useApp } from '../stores/AppContext'
|
||||
|
||||
export function useRealtime() {
|
||||
const { dispatch } = useApp()
|
||||
const evtSource = useRef<EventSource | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const es = new EventSource('/api/events/stream')
|
||||
evtSource.current = es
|
||||
|
||||
es.onopen = () => {
|
||||
console.log('[SSE] Connected')
|
||||
}
|
||||
|
||||
es.addEventListener('battlegroup_update', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data)
|
||||
console.log('[SSE] battlegroup_update', data)
|
||||
} catch {}
|
||||
})
|
||||
|
||||
es.addEventListener('rmq_health', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data)
|
||||
console.log('[SSE] rmq_health', data)
|
||||
} catch {}
|
||||
})
|
||||
|
||||
es.addEventListener('connection_status', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data)
|
||||
dispatch({ type: 'SET_CONNECTION', payload: data })
|
||||
} catch {}
|
||||
})
|
||||
|
||||
es.addEventListener('chat_message', (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.data)
|
||||
console.log('[SSE] chat_message', data)
|
||||
} catch {}
|
||||
})
|
||||
|
||||
es.onerror = () => {
|
||||
console.warn('[SSE] Connection error')
|
||||
}
|
||||
|
||||
return () => {
|
||||
es.close()
|
||||
}
|
||||
}, [dispatch])
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import App from './App'
|
||||
import './styles/index.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
)
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
@import './themes.css';
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
--primary: #d4af37;
|
||||
--primary-dark: #b8962f;
|
||||
--primary-light: #e8c962;
|
||||
--bg: #1a1a1a;
|
||||
--card-bg: #2a2a2a;
|
||||
--text: #f0f0f0;
|
||||
--text-light: #c0c0c0;
|
||||
--text-muted: #808080;
|
||||
--border: #404040;
|
||||
--accent: #d4af37;
|
||||
--danger: #c0392b;
|
||||
--success: #27ae60;
|
||||
--nav-bg: #0d0d0d;
|
||||
--nav-text: #d4d4d4;
|
||||
--nav-active: #d4af37;
|
||||
--hover: #333333;
|
||||
--shadow: 0 2px 8px rgba(0,0,0,0.4);
|
||||
--table-header: #333333;
|
||||
--code-bg: #222222;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: 'Playfair Display', serif;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
/* Dune Theme System — 14 themes */
|
||||
|
||||
[data-theme="default"] {
|
||||
--primary: #c9a24e;
|
||||
--primary-dark: #a8862e;
|
||||
--primary-light: #e0c97a;
|
||||
--bg: #f4f1ea;
|
||||
--card-bg: #ffffff;
|
||||
--text: #2c1810;
|
||||
--text-light: #6b5a4a;
|
||||
--text-muted: #9a8a7a;
|
||||
--border: #e0d5c7;
|
||||
--accent: #8b4513;
|
||||
--danger: #c0392b;
|
||||
--success: #27ae60;
|
||||
--nav-bg: #1a1a2e;
|
||||
--nav-text: #c9c4d0;
|
||||
--nav-active: #c9a24e;
|
||||
--hover: #f0ebe0;
|
||||
--shadow: 0 2px 8px rgba(44,24,16,0.08);
|
||||
}
|
||||
|
||||
[data-theme="atreides"] {
|
||||
--primary: #2d5a27;
|
||||
--primary-dark: #1e3d19;
|
||||
--primary-light: #4a8c42;
|
||||
--bg: #f0f5ed;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1a2e1a;
|
||||
--text-light: #3d4d3d;
|
||||
--text-muted: #6b7c6b;
|
||||
--border: #d4ddd4;
|
||||
--accent: #1e3d19;
|
||||
--danger: #8b2500;
|
||||
--success: #2d5a27;
|
||||
--nav-bg: #1a2e1a;
|
||||
--nav-text: #d4ddd4;
|
||||
--nav-active: #6abf6a;
|
||||
--hover: #e2ebe2;
|
||||
--shadow: 0 2px 8px rgba(30,61,25,0.1);
|
||||
}
|
||||
|
||||
[data-theme="harkonnen"] {
|
||||
--primary: #ff6b00;
|
||||
--primary-dark: #cc5500;
|
||||
--primary-light: #ff8c33;
|
||||
--bg: #1a1a1a;
|
||||
--card-bg: #2d2d2d;
|
||||
--text: #e8e8e8;
|
||||
--text-light: #b0b0b0;
|
||||
--text-muted: #808080;
|
||||
--border: #404040;
|
||||
--accent: #ff4500;
|
||||
--danger: #ff0000;
|
||||
--success: #00cc44;
|
||||
--nav-bg: #000000;
|
||||
--nav-text: #cccccc;
|
||||
--nav-active: #ff6b00;
|
||||
--hover: #333333;
|
||||
--shadow: 0 2px 8px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
[data-theme="fremen"] {
|
||||
--primary: #d4a853;
|
||||
--primary-dark: #b8913f;
|
||||
--primary-light: #e8c87a;
|
||||
--bg: #e8dcc8;
|
||||
--card-bg: #f5efe3;
|
||||
--text: #3d3428;
|
||||
--text-light: #5c4f3d;
|
||||
--text-muted: #8a7d66;
|
||||
--border: #d4cbb8;
|
||||
--accent: #8b6914;
|
||||
--danger: #a04000;
|
||||
--success: #6b8e23;
|
||||
--nav-bg: #2c2418;
|
||||
--nav-text: #d4cbb8;
|
||||
--nav-active: #d4a853;
|
||||
--hover: #e8dcc8;
|
||||
--shadow: 0 2px 8px rgba(44,36,24,0.1);
|
||||
}
|
||||
|
||||
[data-theme="bene-gesserit"] {
|
||||
--primary: #a8a8a8;
|
||||
--primary-dark: #888888;
|
||||
--primary-light: #c8c8c8;
|
||||
--bg: #f8f8f8;
|
||||
--card-bg: #ffffff;
|
||||
--text: #2a2a2a;
|
||||
--text-light: #505050;
|
||||
--text-muted: #787878;
|
||||
--border: #e0e0e0;
|
||||
--accent: #606060;
|
||||
--danger: #c41e3a;
|
||||
--success: #2e8b57;
|
||||
--nav-bg: #1a1a1a;
|
||||
--nav-text: #d0d0d0;
|
||||
--nav-active: #ffffff;
|
||||
--hover: #f0f0f0;
|
||||
--shadow: 0 2px 8px rgba(0,0,0,0.08);
|
||||
}
|
||||
|
||||
[data-theme="spacing-guild"] {
|
||||
--primary: #4a90d9;
|
||||
--primary-dark: #2e6ab3;
|
||||
--primary-light: #6baee8;
|
||||
--bg: #1a1a2e;
|
||||
--card-bg: #252540;
|
||||
--text: #e0e0f0;
|
||||
--text-light: #a0a0c0;
|
||||
--text-muted: #707090;
|
||||
--border: #3a3a50;
|
||||
--accent: #6b5b95;
|
||||
--danger: #d94545;
|
||||
--success: #45d985;
|
||||
--nav-bg: #0f0f1a;
|
||||
--nav-text: #b0b0d0;
|
||||
--nav-active: #4a90d9;
|
||||
--hover: #2a2a40;
|
||||
--shadow: 0 2px 8px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
[data-theme="emperor"] {
|
||||
--primary: #d4af37;
|
||||
--primary-dark: #b8962f;
|
||||
--primary-light: #e8c962;
|
||||
--bg: #1a1a1a;
|
||||
--card-bg: #2a2a2a;
|
||||
--text: #f0f0f0;
|
||||
--text-light: #c0c0c0;
|
||||
--text-muted: #808080;
|
||||
--border: #404040;
|
||||
--accent: #d4af37;
|
||||
--danger: #c0392b;
|
||||
--success: #27ae60;
|
||||
--nav-bg: #0d0d0d;
|
||||
--nav-text: #d4d4d4;
|
||||
--nav-active: #d4af37;
|
||||
--hover: #333333;
|
||||
--shadow: 0 2px 8px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
[data-theme="corrino"] {
|
||||
--primary: #8b0000;
|
||||
--primary-dark: #5c0000;
|
||||
--primary-light: #c43030;
|
||||
--bg: #f5f0f0;
|
||||
--card-bg: #ffffff;
|
||||
--text: #2a1515;
|
||||
--text-light: #5a3535;
|
||||
--text-muted: #8a5555;
|
||||
--border: #e0d5d5;
|
||||
--accent: #a01010;
|
||||
--danger: #8b0000;
|
||||
--success: #2d5a27;
|
||||
--nav-bg: #1a0a0a;
|
||||
--nav-text: #d4c4c4;
|
||||
--nav-active: #ff6b6b;
|
||||
--hover: #f0e8e8;
|
||||
--shadow: 0 2px 8px rgba(90,0,0,0.1);
|
||||
}
|
||||
|
||||
[data-theme="mentat"] {
|
||||
--primary: #008b8b;
|
||||
--primary-dark: #006666;
|
||||
--primary-light: #20b2aa;
|
||||
--bg: #e8f4f4;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1a2a2a;
|
||||
--text-light: #3d5050;
|
||||
--text-muted: #6b8080;
|
||||
--border: #d4e0e0;
|
||||
--accent: #006666;
|
||||
--danger: #c44569;
|
||||
--success: #008b8b;
|
||||
--nav-bg: #0a1a1a;
|
||||
--nav-text: #c4d4d4;
|
||||
--nav-active: #00ced1;
|
||||
--hover: #e0f0f0;
|
||||
--shadow: 0 2px 8px rgba(0,60,60,0.1);
|
||||
}
|
||||
|
||||
[data-theme="sardaukar"] {
|
||||
--primary: #cd853f;
|
||||
--primary-dark: #a0522d;
|
||||
--primary-light: #deb887;
|
||||
--bg: #f5ebe0;
|
||||
--card-bg: #ffffff;
|
||||
--text: #2a2018;
|
||||
--text-light: #5a4a38;
|
||||
--text-muted: #8a7a68;
|
||||
--border: #e0d5c8;
|
||||
--accent: #8b4513;
|
||||
--danger: #8b0000;
|
||||
--success: #6b8e23;
|
||||
--nav-bg: #1a140c;
|
||||
--nav-text: #d4c8b8;
|
||||
--nav-active: #cd853f;
|
||||
--hover: #f0e8e0;
|
||||
--shadow: 0 2px 8px rgba(60,40,20,0.1);
|
||||
}
|
||||
|
||||
[data-theme="tleilax"] {
|
||||
--primary: #4a0080;
|
||||
--primary-dark: #2d0050;
|
||||
--primary-light: #6b20b0;
|
||||
--bg: #1a1a24;
|
||||
--card-bg: #252530;
|
||||
--text: #e0e0e8;
|
||||
--text-light: #a0a0b0;
|
||||
--text-muted: #707080;
|
||||
--border: #404050;
|
||||
--accent: #6b0099;
|
||||
--danger: #c41e3a;
|
||||
--success: #00c080;
|
||||
--nav-bg: #0a0a10;
|
||||
--nav-text: #b0b0c0;
|
||||
--nav-active: #9966cc;
|
||||
--hover: #2a2a38;
|
||||
--shadow: 0 2px 8px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
[data-theme="ordos"] {
|
||||
--primary: #2e8b57;
|
||||
--primary-dark: #1c5c3a;
|
||||
--primary-light: #3cb371;
|
||||
--bg: #e8f5f0;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1a2e22;
|
||||
--text-light: #3d5045;
|
||||
--text-muted: #6b8075;
|
||||
--border: #d4e0d8;
|
||||
--accent: #1c5c3a;
|
||||
--danger: #c45c3a;
|
||||
--success: #2e8b57;
|
||||
--nav-bg: #0a1a12;
|
||||
--nav-text: #c4d8d0;
|
||||
--nav-active: #3cb371;
|
||||
--hover: #e0f0e8;
|
||||
--shadow: 0 2px 8px rgba(20,60,40,0.1);
|
||||
}
|
||||
|
||||
[data-theme="ix"] {
|
||||
--primary: #4169e1;
|
||||
--primary-dark: #2c4db8;
|
||||
--primary-light: #6495ed;
|
||||
--bg: #e8edf8;
|
||||
--card-bg: #ffffff;
|
||||
--text: #1a2248;
|
||||
--text-light: #3d4470;
|
||||
--text-muted: #6b7098;
|
||||
--border: #d0d8e8;
|
||||
--accent: #2c4db8;
|
||||
--danger: #c44569;
|
||||
--success: #32cd32;
|
||||
--nav-bg: #0a1028;
|
||||
--nav-text: #c0c8d8;
|
||||
--nav-active: #6495ed;
|
||||
--hover: #e0e8f0;
|
||||
--shadow: 0 2px 8px rgba(30,50,100,0.15);
|
||||
}
|
||||
|
||||
[data-theme="choam"] {
|
||||
--primary: #b8860b;
|
||||
--primary-dark: #8b6508;
|
||||
--primary-light: #daa520;
|
||||
--bg: #faf8f0;
|
||||
--card-bg: #ffffff;
|
||||
--text: #2a2820;
|
||||
--text-light: #5a5848;
|
||||
--text-muted: #8a8878;
|
||||
--border: #e8e4d8;
|
||||
--accent: #8b6508;
|
||||
--danger: #b22222;
|
||||
--success: #228b22;
|
||||
--nav-bg: #1a180c;
|
||||
--nav-text: #d4d0c0;
|
||||
--nav-active: #daa520;
|
||||
--hover: #f0ece0;
|
||||
--shadow: 0 2px 8px rgba(60,50,20,0.1);
|
||||
}
|
||||
Reference in new issue
Block a user