mud_server.admin_tui.screens.database ===================================== .. py:module:: mud_server.admin_tui.screens.database .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: mud_server.admin_tui.screens.database.DatabaseScreen Module Contents --------------- .. py:class:: DatabaseScreen Bases: :py:obj:`textual.screen.Screen` Database 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. .. py:attribute:: BINDINGS .. py:attribute:: CSS :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ 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%; } """ .. raw:: html
.. py:method:: compose() Create the database viewer layout. .. py:method:: on_mount() Initialize the database viewer. .. py:method:: on_unmount() Stop auto-refresh when the screen unmounts. .. py:method:: 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. .. py:method:: action_toggle_tombstoned() Keyboard action to toggle tombstoned users from the users tab. .. py:method:: action_refresh() Refresh all tables (key: r). .. py:method:: action_kick() Kick the selected session (key: x). .. py:method:: action_remove_user() Deactivate or delete the selected user (key: d). .. py:method:: handle_tab_activated() Refresh the active tab when the user switches tabs. .. py:method:: action_back() Go back to dashboard (key: b). .. py:method:: action_quit() Quit the application (key: q). .. py:method:: action_next_tab() Switch to the next database tab. .. py:method:: action_prev_tab() Switch to the previous database tab. .. py:method:: action_cursor_up() Move selection up in the active table. .. py:method:: action_cursor_down() Move selection down in the active table. .. py:method:: action_cursor_left() Move selection left in the active table. .. py:method:: action_cursor_right() Move selection right in the active table. .. py:method:: action_select() Select the current row in the active table. .. py:method:: action_sort() Sort the users table by the current column. .. py:method:: on_data_table_row_selected(event) Open detail screens when a row is activated with mouse or Enter. .. py:method:: get_active_table() Get the DataTable for the currently active tab. Falls back to the focused widget if it is already a DataTable. .. py:method:: 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. .. py:method:: get_selected_user_target() Resolve the selected player from the players table. Returns (username, role) when a valid row is selected.