mud_server.admin_tui.screens.database
Database viewer screen for PipeWorks Admin TUI.
This module provides a database viewing interface that allows superusers to view the contents of various database tables (users, sessions, chat).
The DatabaseScreen shows: - Tabbed interface for different tables - DataTable widgets for viewing records - A table browser for any database table - Character locations view for room/zone occupancy - Refresh functionality for each table
Classes
Database viewer screen for superusers. |
Module Contents
- class mud_server.admin_tui.screens.database.DatabaseScreen
Bases:
textual.screen.ScreenDatabase viewer screen for superusers.
Displays database tables in a tabbed interface with DataTable widgets. Allows viewing of users, sessions, and chat messages.
- Key Bindings:
r: Refresh current table b: Go back to dashboard s: Sort users by selected column t: Toggle tombstoned users x: Kick selected session (connections/sessions tabs) d: Deactivate/delete selected user (users tab) ctrl+q: Quit application
- CSS Classes:
.database-container: Main content container. .table-container: Container for each table tab. .table-header: Header row styling for tables.
- BINDINGS
- CSS = Multiline-String
Show Value
""" DatabaseScreen { layout: vertical; } .database-container { height: 1fr; padding: 1 2; } .table-container { height: 100%; border: solid $primary; } .error-message { color: $error; padding: 1 2; text-align: center; } .loading-message { color: $text-muted; padding: 1 2; text-align: center; } DataTable { height: 100%; } DataTable > .datatable--header { text-style: bold; background: $primary; } .action-bar { height: 3; padding: 0 1; background: $surface; border-bottom: solid $primary-darken-2; } TabbedContent { height: 1fr; } TabPane { height: 1fr; } DataTable { height: 1fr; width: 100%; } """
- compose()
Create the database viewer layout.
- on_mount()
Initialize the database viewer.
- on_unmount()
Stop auto-refresh when the screen unmounts.
- on_key(event)
Handle user-configured keybindings.
We translate key presses into action methods for this screen. This keeps bindings scoped to the screen without relying on global app bindings, and avoids mutation of class-level BINDINGS.
- action_toggle_tombstoned()
Keyboard action to toggle tombstoned users from the users tab.
- action_refresh()
Refresh all tables (key: r).
- action_kick()
Kick the selected session (key: x).
- action_remove_user()
Deactivate or delete the selected user (key: d).
- handle_tab_activated()
Refresh the active tab when the user switches tabs.
- action_back()
Go back to dashboard (key: b).
- action_quit()
Quit the application (key: q).
- action_next_tab()
Switch to the next database tab.
- action_prev_tab()
Switch to the previous database tab.
- action_cursor_up()
Move selection up in the active table.
- action_cursor_down()
Move selection down in the active table.
- action_cursor_left()
Move selection left in the active table.
- action_cursor_right()
Move selection right in the active table.
- action_select()
Select the current row in the active table.
- action_sort()
Sort the users table by the current column.
- on_data_table_row_selected(event)
Open detail screens when a row is activated with mouse or Enter.
- get_active_table()
Get the DataTable for the currently active tab.
Falls back to the focused widget if it is already a DataTable.
- get_selected_session_target()
Resolve the selected session target for a kick action.
Returns (username, session_id) when a valid row is selected. Uses column positions based on the active tab’s table schema.
- get_selected_user_target()
Resolve the selected player from the players table.
Returns (username, role) when a valid row is selected.