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,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>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user