3.1 KiB
3.1 KiB
DASH-004: Administrative Control Panel
Status: Done Created: 2026-01-08 Tags: dashboard, control-panel, bot-actions, operations
1. Context & User Story
- As a: Bot Administrator
- I want to: Execute common maintenance tasks directly from the dashboard buttons.
- So that: I don't have to use terminal commands or Discord slash commands for system-level operations.
2. Technical Requirements
Data Model Changes
- N/A.
API / Interface
POST /api/actions/reload-commands: Triggers the bot's command loader.POST /api/actions/clear-cache: Clears internal bot caches.POST /api/actions/maintenance-mode: Toggles a maintenance flag for the bot.
3. Constraints & Validations (CRITICAL)
- Input Validation: Standard JSON body with optional
reasonfield. - System Constraints:
- Actions must be idempotent where possible.
- Actions must provide a response within 10 seconds.
- Business Logic Guardrails:
- SECURITY: This endpoint MUST require high-privilege authentication (currently we have single admin assumption, but token-based check should be planned).
- Maintenance mode toggle must be logged to the event feed.
4. Acceptance Criteria
- Given a "Quick Actions" card, When the "Reload Commands" button is clicked, Then the bot reloads its local command files and posts a "Success" event to the feed.
- Given a running bot, When the "Clear Cache" button is pushed, Then the bot flushes its internal memory maps and the memory usage metric reflects the drop.
5. Implementation Plan
- Step 1: Create an
action.service.tsto handle the logic of triggering bot-specific functions. - Step 2: Implement the
/api/actionsroute group. - Step 3: Design a "Quick Actions" card with premium styled buttons in
Dashboard.tsx. - Step 4: Add loading states to buttons to show when an operation is "In Progress."
Implementation Notes
Successfully implemented the Administrative Control Panel with the following changes:
- Backend Service: Created
shared/modules/admin/action.service.tsto coordinate actions like reloading commands, clearing cache, and toggling maintenance mode. - System Bus: Updated
shared/lib/events.tswith new action events. - API Endpoints: Added
POST /api/actions/*routes to the web server inweb/src/server.ts. - Bot Integration:
- Updated
AuroraClientinbot/lib/BotClient.tsto listen for system action events. - Implemented
maintenanceModeflag inAuroraClient. - Updated
CommandHandler.tsto respect maintenance mode, blocking user commands with a helpful error embed.
- Updated
- Frontend UI:
- Created
ControlPanel.tsxcomponent with a premium glassmorphic design and real-time state feedback. - Integrated
ControlPanelinto theDashboard.tsxpage. - Updated
use-dashboard-statshook and shared types to include maintenance mode status.
- Created
- Verification: Created 3 new test suites covering the service, the bot listener, and the command handler enforcement. All tests passing.