Admin Dashboard Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Admin Dashboard Configuration in SeaORM Pro defines the visual structure, data sourcing, and behavioral settings of the administrative interface. The configuration is primarily driven by TOML files located in a designated root folder (typically pro_admin), which are parsed into internal Rust data structures to serve the frontend via a specialized API.
The system encompasses site-wide branding, navigation menus, information cards, and dynamic chart widgets. It allows for the definition of "Raw Tables" for direct database interaction and "Composite Tables" for complex, related data views. Sources: sea-orm-pro/src/config.rs, sea-orm-pro/src/parser.rs:20-50
Configuration Architecture
The configuration is structured hierarchically, starting from a global site configuration and descending into specific dashboard layouts and table definitions.
Data Flow and Parsing
The ConfigParser is responsible for aggregating multiple TOML files into a unified JsonCfg object. It scans specific directories for table definitions and reads core configuration files for the site and dashboard.
The parser initializes with default values if specific files are missing, ensuring the admin panel remains functional. Sources: sea-orm-pro/src/parser.rs:18-55
Core Components
The configuration is split into four primary sections:
- Site Configuration: Handles themes, logos, and global menu titles.
- Dashboard Configuration: Defines the layout of the landing page, including info cards and charts.
- Raw Tables: Direct mappings to SeaORM entities for CRUD operations.
- Composite Tables: Managed views combining parent and child relationships.
Sources: sea-orm-pro/src/config.rs:7-19
Dashboard Layout and Visuals
The dashboard is configured via dashboard.toml and supports a grid-based layout for data visualization and information sharing.
Info Cards
Info cards provide high-level descriptions and external links. They are used to guide users or provide documentation links within the panel.
Sources: pro_admin/dashboard.toml:7-29
Row and Column Grid
The dashboard uses a 24-column grid system. Rows can have defined gutters, and columns specify their width via the span property.
| Option | Type | Description |
|---|---|---|
gutter | u32 | Spacing between columns in a row. |
span | u32 | The width of the column (out of 24). |
title | String | Header text for the chart or widget. |
Sources: sea-orm-pro/src/config.rs:105-120, pro_admin/dashboard.toml:34-40
Chart Configuration
Charts are the primary data visualization tool. They require a unique chart key which maps to a backend implementation in the admin controller.
Table Definitions
Tables are configured to control how database entities are displayed and edited.
Raw Table Configuration
Raw tables define the behavior for single entities. They include settings for column visibility, sorting, and CRUD permissions.
| Section | Key | Description |
|---|---|---|
table | all_columns | If true, shows all entity fields by default. |
table | page_size | Number of records per page. |
editor | enable | Enables the side-panel editor for records. |
create | enable | Allows adding new records. |
update | readonly_columns | List of fields that cannot be modified. |
Sources: sea-orm-pro/src/config.rs:170-220
Composite Tables
Composite tables allow managing a "Parent" record along with its "Children" (related entities) in a single view. For example, a sales_order_header (Parent) can be viewed with its sales_order_detail and customer (Children).
API Integration
The backend serves the configuration through the /admin/config endpoint. In development environments, the configuration is reloaded from disk on every request to facilitate rapid prototyping. In production, it is cached for performance.
pub async fn config(State(ctx): State<AppContext>) -> Result<Response> {
if ctx.environment == Environment::Production {
format::json(&*CONFIG)
} else {
let config = ConfigParser::new()
.load_config(CONFIG_ROOT)
.map_err(Into::<Box<dyn std::error::Error + Send + Sync>>::into)?;
format::json(config)
}
}
Sources: src/controllers/admin.rs:24-35
Conclusion
The Admin Dashboard Configuration system provides a declarative way to build professional management interfaces. By separating the visual layout (dashboard.toml), site identity (config.toml), and data structures (raw_tables and composite_tables), SeaORM Pro enables developers to customize the admin experience without writing frontend code.