feat: add missing frontend routes and components
- Add PlayerDetail route and all new page routes to App.tsx - Add Vehicles, Buildings, Map, Accounts, Files, Director, Settings to NavBar - Include Accounts page component - Include Director page component
This commit is contained in:
1 parent
c472e5428a
commit
b220792b40
4 files changed
+223
-3
No files matched your search
@@ -4,11 +4,19 @@ import { useRealtime } from './hooks/useRealtime'
|
|||||||
import AppShell from './components/layout/AppShell'
|
import AppShell from './components/layout/AppShell'
|
||||||
import Overview from './components/overview/Overview'
|
import Overview from './components/overview/Overview'
|
||||||
import PlayerExplorer from './components/players/PlayerExplorer'
|
import PlayerExplorer from './components/players/PlayerExplorer'
|
||||||
|
import PlayerDetail from './components/players/PlayerDetail'
|
||||||
import GuildManager from './components/guilds/GuildManager'
|
import GuildManager from './components/guilds/GuildManager'
|
||||||
|
import Vehicles from './components/vehicles/Vehicles'
|
||||||
|
import Buildings from './components/buildings/Buildings'
|
||||||
|
import MapViewer from './components/map/MapViewer'
|
||||||
|
import Accounts from './components/accounts/Accounts'
|
||||||
import ServerControl from './components/server/ServerControl'
|
import ServerControl from './components/server/ServerControl'
|
||||||
import AdminTools from './components/admin/AdminTools'
|
import AdminTools from './components/admin/AdminTools'
|
||||||
import ChatMonitor from './components/chat/ChatMonitor'
|
import ChatMonitor from './components/chat/ChatMonitor'
|
||||||
import Terminal from './components/shell/Terminal'
|
import Terminal from './components/shell/Terminal'
|
||||||
|
import FileBrowser from './components/files/FileBrowser'
|
||||||
|
import Director from './components/director/Director'
|
||||||
|
import Settings from './components/settings/Settings'
|
||||||
|
|
||||||
function RealtimeInit() {
|
function RealtimeInit() {
|
||||||
useRealtime()
|
useRealtime()
|
||||||
@@ -24,11 +32,19 @@ function App() {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Overview />} />
|
<Route path="/" element={<Overview />} />
|
||||||
<Route path="/players" element={<PlayerExplorer />} />
|
<Route path="/players" element={<PlayerExplorer />} />
|
||||||
|
<Route path="/players/:accountId" element={<PlayerDetail />} />
|
||||||
<Route path="/guilds" element={<GuildManager />} />
|
<Route path="/guilds" element={<GuildManager />} />
|
||||||
|
<Route path="/vehicles" element={<Vehicles />} />
|
||||||
|
<Route path="/buildings" element={<Buildings />} />
|
||||||
|
<Route path="/map" element={<MapViewer />} />
|
||||||
|
<Route path="/accounts" element={<Accounts />} />
|
||||||
<Route path="/server" element={<ServerControl />} />
|
<Route path="/server" element={<ServerControl />} />
|
||||||
<Route path="/admin" element={<AdminTools />} />
|
<Route path="/admin" element={<AdminTools />} />
|
||||||
<Route path="/chat" element={<ChatMonitor />} />
|
<Route path="/chat" element={<ChatMonitor />} />
|
||||||
<Route path="/shell" element={<Terminal />} />
|
<Route path="/shell" element={<Terminal />} />
|
||||||
|
<Route path="/files" element={<FileBrowser />} />
|
||||||
|
<Route path="/director" element={<Director />} />
|
||||||
|
<Route path="/settings" element={<Settings />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</AppShell>
|
</AppShell>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
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 Account {
|
||||||
|
id: number
|
||||||
|
email: string
|
||||||
|
funcom_id: string
|
||||||
|
character_count: number
|
||||||
|
is_demo: boolean
|
||||||
|
is_cheater: boolean
|
||||||
|
last_login: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Accounts() {
|
||||||
|
const [search, setSearch] = useState('')
|
||||||
|
const { dispatch } = useApp()
|
||||||
|
|
||||||
|
const { data: accountsData, isLoading } = useSWR(
|
||||||
|
search.length >= 2 ? `/accounts?q=${encodeURIComponent(search)}&limit=50` : '/accounts?limit=100',
|
||||||
|
fetcher,
|
||||||
|
{ refreshInterval: 30000 }
|
||||||
|
)
|
||||||
|
|
||||||
|
const accountList: Account[] = accountsData?.success ? accountsData.data : []
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1 className="font-serif text-3xl text-primary mb-6">Accounts</h1>
|
||||||
|
|
||||||
|
<div className="mb-6">
|
||||||
|
<div className="relative max-w-md">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={search}
|
||||||
|
onChange={(e) => setSearch(e.target.value)}
|
||||||
|
placeholder="Search accounts..."
|
||||||
|
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: 'Email', accessor: 'email' },
|
||||||
|
{ header: 'Funcom ID', accessor: 'funcom_id' },
|
||||||
|
{ header: 'Characters', accessor: 'character_count' },
|
||||||
|
{ header: 'Last Login', accessor: 'last_login' },
|
||||||
|
]}
|
||||||
|
data={accountList}
|
||||||
|
loading={isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import useSWR from 'swr'
|
||||||
|
import client from '../../api/client'
|
||||||
|
import { useApp } from '../../stores/AppContext'
|
||||||
|
|
||||||
|
const fetcher = (url: string) => client.get(url).then((r) => r.data)
|
||||||
|
|
||||||
|
export default function Director() {
|
||||||
|
const [tab, setTab] = useState<'battlegroup' | 'config' | 'transfer' | 'fls'>('battlegroup')
|
||||||
|
const { dispatch } = useApp()
|
||||||
|
|
||||||
|
const { data: bgData } = useSWR('/director/battlegroup', fetcher, { refreshInterval: 15000 })
|
||||||
|
|
||||||
|
const handlePost = 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>
|
||||||
|
<h1 className="font-serif text-3xl text-primary mb-6">Director Control</h1>
|
||||||
|
|
||||||
|
<div className="flex gap-1 mb-6 border-b border-border">
|
||||||
|
{([
|
||||||
|
{ key: 'battlegroup', label: 'Battlegroup' },
|
||||||
|
{ key: 'config', label: 'Config' },
|
||||||
|
{ key: 'transfer', label: 'Transfer' },
|
||||||
|
{ key: 'fls', label: 'FLS' },
|
||||||
|
] 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 ${
|
||||||
|
tab === t.key
|
||||||
|
? 'text-primary border-primary'
|
||||||
|
: 'text-text-muted border-transparent hover:text-text-primary'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{t.label}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{tab === 'battlegroup' && (
|
||||||
|
<div className="bg-card-bg border border-border rounded-lg p-5">
|
||||||
|
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">Battlegroup State</h3>
|
||||||
|
{bgData?.success ? (
|
||||||
|
<pre className="text-xs text-text-secondary font-mono bg-code-bg p-4 rounded overflow-auto max-h-[60vh]">
|
||||||
|
{JSON.stringify(bgData.data, null, 2)}
|
||||||
|
</pre>
|
||||||
|
) : (
|
||||||
|
<div className="text-text-muted">Loading battlegroup data...</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{tab === 'config' && (
|
||||||
|
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4 max-w-xl">
|
||||||
|
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">Update Config</h3>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm text-text-muted mb-2">Map Name</label>
|
||||||
|
<input
|
||||||
|
id="config-map"
|
||||||
|
className="w-full bg-card-bg border border-border rounded-lg px-4 py-2 text-sm"
|
||||||
|
placeholder="e.g., HaggaBasin"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm text-text-muted mb-2">Config JSON</label>
|
||||||
|
<textarea
|
||||||
|
id="config-json"
|
||||||
|
rows={6}
|
||||||
|
className="w-full bg-card-bg border border-border rounded-lg px-4 py-3 text-sm font-mono"
|
||||||
|
placeholder='{"maxPlayers": 100}'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
const map = (document.getElementById('config-map') as HTMLInputElement).value
|
||||||
|
const json = (document.getElementById('config-json') as HTMLTextAreaElement).value
|
||||||
|
handlePost('/director/config', { map, config: JSON.parse(json) })
|
||||||
|
}}
|
||||||
|
className="px-4 py-2 bg-primary text-white rounded-lg text-sm font-medium"
|
||||||
|
>
|
||||||
|
Update Config
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => handlePost('/director/config/clear', {})}
|
||||||
|
className="px-4 py-2 bg-danger/10 border border-danger/30 text-danger rounded-lg text-sm font-medium"
|
||||||
|
>
|
||||||
|
Clear Config
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{tab === 'transfer' && (
|
||||||
|
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4 max-w-xl">
|
||||||
|
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">Transfer Rules</h3>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => handlePost('/director/transfer/clear', {})}
|
||||||
|
className="px-4 py-2 bg-danger/10 border border-danger/30 text-danger rounded-lg text-sm font-medium"
|
||||||
|
>
|
||||||
|
Clear Overrides
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{tab === 'fls' && (
|
||||||
|
<div className="bg-card-bg border border-border rounded-lg p-5 space-y-4 max-w-xl">
|
||||||
|
<h3 className="text-text-muted text-xs uppercase tracking-wider mb-4">FLS Settings</h3>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button
|
||||||
|
onClick={() => handlePost('/director/fls/clear', {})}
|
||||||
|
className="px-4 py-2 bg-danger/10 border border-danger/30 text-danger rounded-lg text-sm font-medium"
|
||||||
|
>
|
||||||
|
Clear FLS Overrides
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -7,9 +7,16 @@ const NAV_ITEMS = [
|
|||||||
{ path: '/', label: 'Overview' },
|
{ path: '/', label: 'Overview' },
|
||||||
{ path: '/players', label: 'Players' },
|
{ path: '/players', label: 'Players' },
|
||||||
{ path: '/guilds', label: 'Guilds' },
|
{ path: '/guilds', label: 'Guilds' },
|
||||||
|
{ path: '/vehicles', label: 'Vehicles' },
|
||||||
|
{ path: '/buildings', label: 'Buildings' },
|
||||||
|
{ path: '/map', label: 'Map' },
|
||||||
|
{ path: '/accounts', label: 'Accounts' },
|
||||||
{ path: '/server', label: 'Server' },
|
{ path: '/server', label: 'Server' },
|
||||||
{ path: '/chat', label: 'Chat' },
|
{ path: '/chat', label: 'Chat' },
|
||||||
{ path: '/admin', label: 'Admin' },
|
{ path: '/admin', label: 'Admin' },
|
||||||
|
{ path: '/files', label: 'Files' },
|
||||||
|
{ path: '/director', label: 'Director' },
|
||||||
|
{ path: '/settings', label: 'Settings' },
|
||||||
{ path: '/shell', label: 'Shell' },
|
{ path: '/shell', label: 'Shell' },
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -24,13 +31,13 @@ export default function NavBar() {
|
|||||||
<span className="text-nav-text text-xs uppercase tracking-widest">Admin</span>
|
<span className="text-nav-text text-xs uppercase tracking-widest">Admin</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1 overflow-x-auto no-scrollbar">
|
||||||
{NAV_ITEMS.map((item) => (
|
{NAV_ITEMS.map((item) => (
|
||||||
<Link
|
<Link
|
||||||
key={item.path}
|
key={item.path}
|
||||||
to={item.path}
|
to={item.path}
|
||||||
className={`px-4 h-[52px] flex items-center text-[13px] font-medium border-b-2 transition-colors ${
|
className={`px-4 h-[52px] flex items-center text-[13px] font-medium border-b-2 transition-colors whitespace-nowrap ${
|
||||||
location.pathname === item.path
|
location.pathname === item.path || (item.path !== '/' && location.pathname.startsWith(item.path))
|
||||||
? 'text-nav-active border-nav-active'
|
? 'text-nav-active border-nav-active'
|
||||||
: 'text-nav-text border-transparent hover:text-white hover:bg-white/5'
|
: 'text-nav-text border-transparent hover:text-white hover:bg-white/5'
|
||||||
}`}
|
}`}
|
||||||
|
|||||||
Reference in new issue
Block a user