mud_server.admin_tui.screens.dashboard
Dashboard screen for PipeWorks Admin TUI.
This module provides the main admin dashboard that displays server status and provides quick access to administrative actions.
The DashboardScreen shows: - Current server connection status - Active player count - Quick action buttons - User session information - User creation entry point (admin/superuser)
Classes
Main admin dashboard screen. |
Module Contents
- class mud_server.admin_tui.screens.dashboard.DashboardScreen
Bases:
textual.screen.ScreenMain admin dashboard screen.
Displays server status and provides administrative actions. Automatically refreshes status periodically.
- Key Bindings:
r: Refresh server status d: View database tables (superuser only) u: Create user (admin or superuser) c: View characters (admin or superuser) l: Logout ctrl+q: Quit application
- CSS Classes:
.dashboard-container: Main content container. .status-panel: Server status display panel. .actions-panel: Quick actions button panel. .info-label: Status information labels. .info-value: Status information values.
- BINDINGS
- CSS = Multiline-String
Show Value
""" DashboardScreen { layout: vertical; } .dashboard-container { padding: 1 2; } .status-panel { border: solid green; padding: 1 2; height: auto; margin-bottom: 1; } .status-title { text-style: bold; color: $accent; padding-bottom: 1; } .status-row { height: 1; } .info-label { width: 20; color: $text-muted; } .info-value { color: $text; } .actions-panel { border: solid $primary; padding: 1 2; height: auto; } .actions-title { text-style: bold; color: $accent; padding-bottom: 1; } .action-buttons { height: 3; } .action-button { margin-right: 1; } .user-info { dock: bottom; height: 3; padding: 1 2; background: $surface; border-top: solid $primary-darken-2; } .user-label { color: $text-muted; } .user-value { color: $success; text-style: bold; } """
- compose()
Create the dashboard layout.
Layout consists of: - Header with app title - Status panel showing server info - Actions panel with quick action buttons - User info bar at bottom - Footer with key bindings
- on_mount()
Initialize dashboard when mounted.
- on_key(event)
Handle user-configured keybindings for dashboard actions.
If a key is configured for an action, invoke the matching action method and stop further propagation.
- async refresh_status()
Refresh server status from API.
This is a background worker that fetches server health and updates the display. Uses @work decorator for async execution.
- handle_refresh_button()
Handle refresh button press.
- handle_database_button()
Handle database button press.
- async handle_logout_button()
Handle logout button press.
- handle_characters_button()
Handle characters button press.
- handle_create_user_button()
Handle create user button press.
- action_refresh()
Refresh server status (key: r).
- action_view_database()
View database tables (key: d). Requires superuser privileges.
- action_create_user()
Create a new user account (key: u). Requires admin or superuser.
- action_view_characters()
View all characters (key: c). Requires admin or superuser.
- async action_logout()
Logout and return to login screen (key: l).
- action_quit()
Quit the application (key: q).