Files
firefrost-services/services
Claude (The Golden Chronicler #50) a459432b62 feat: Trinity Console Server Matrix - Real-time monitoring from Gemini
GEMINI DELIVERED THE SERVER MATRIX! 🎉

Complete real-time server monitoring with htmx polling, 60-second caching,
Fire/Frost node grouping, and instant sync controls.

GEMINI'S ARCHITECTURAL DECISIONS:
1. 60-second cache - Prevents Panel API rate limits (13+ servers = 13 API calls)
2. htmx polling every 15s - Simulates real-time without complex SSE
3. Sequential sync only - Prevents HTTP 429 (Too Many Requests)
4. Warn-only whitelist toggle - No auto-restart (dangerous during boss fights!)

SERVER MATRIX FEATURES:
- Dynamic server discovery from Panel API
- Grouped by node: TX1 (Dallas) and NC1 (Charlotte)
- Real-time status with glowing borders (green=healthy, red=error, gray=offline)
- Per-server controls: Force Sync, Toggle Whitelist
- Bulk actions: Sync All Dallas, Sync All Charlotte
- 60-second intelligent caching for RV low-bandwidth
- htmx auto-refresh every 15 seconds

SERVER CARD DETAILS:
- Server name + identifier
- Online/offline status with pulsing dot
- Whitelist enabled/disabled
- Last successful sync timestamp
- Error messages if sync failed
- Sync Now button (disabled when offline)
- Toggle Whitelist with restart warning

FILES ADDED:
- src/panel/files.js - Added readServerProperties() function
- src/routes/admin/servers.js - Complete server matrix router
- src/views/admin/servers/index.ejs - Server matrix shell with htmx
- src/views/admin/servers/_matrix_body.ejs - Two-column node grouping
- src/views/admin/servers/_server_card.ejs - Individual server cards

SERVER DISCOVERY:
- Uses existing getMinecraftServers() from panel/discovery.js
- Filters by MINECRAFT_NEST_IDS (nests 1, 6, 7)
- Enriches with server.properties whitelist status
- Joins with server_sync_log table for sync history

WHITELIST TOGGLE:
- Reads current server.properties
- Toggles white-list=true <-> white-list=false
- Writes back to Panel via File API
- Shows ⚠️ Requires Restart warning (hx-confirm modal)
- Clears cache for immediate UI update on next poll

FORCE SYNC:
- Fetches active/grace/lifetime players from database
- Writes whitelist.json to server
- Executes 'whitelist reload' command
- Updates server_sync_log with success/failure
- Shows  Synced or  Error inline via htmx

CACHING LOGIC:
In-memory cache refreshes every 60 seconds:
- Cache hit: Returns cached server data instantly
- Cache miss: Fetches fresh from Panel + reads server.properties
- Database sync logs: ALWAYS fetch fresh (never cached)

NODE GROUPING:
TX1 (Dallas): Filters by node === 'Node 3' OR name includes 'TX'
NC1 (Charlotte): Filters by node === 'Node 2' OR name includes 'NC'

HTMX MAGIC:
- hx-get="/admin/servers/matrix" hx-trigger="load, every 15s"
- Auto-loads matrix on page load
- Auto-refreshes every 15 seconds
- hx-post for sync actions (updates inline, no page reload)
- hx-confirm for whitelist toggle (browser confirmation modal)

VISUAL DESIGN:
- Green glow border: Server online + recent sync success
- Red glow border: Sync error detected
- Gray border: Server offline
- Pulsing green dot: Server is online
- Fire emoji 🔥 for Dallas node
- Frost emoji ❄️ for Charlotte node

INTEGRATION:
- Mounted in src/routes/admin/index.js
- Uses existing database.js for PostgreSQL
- Uses existing panel/discovery.js for server list
- Uses existing panel/files.js for whitelist writes
- Uses existing panel/commands.js for reload commands

NEXT FROM GEMINI:
- Financials/MRR tracker
- Grace Period dashboard
- Additional modules as needed

GEMINI'S WISDOM:
"The Server Matrix is the true bridge of the ship, giving you complete
visibility and control without having to log into the game panel."

Signed-off-by: The Golden Chronicler <claude@firefrostgaming.com>
Co-authored-by: Gemini AI <gemini@anthropic-partnership.ai>
2026-04-01 04:38:55 +00:00
..