| Crates.io | reinhardt-admin |
| lib.rs | reinhardt-admin |
| version | 0.1.0-alpha.1 |
| created_at | 2026-01-23 10:18:18.169145+00 |
| updated_at | 2026-01-23 10:18:18.169145+00 |
| description | Admin panel functionality for Reinhardt framework |
| homepage | |
| repository | https://github.com/kent8192/reinhardt-rs |
| max_upload_size | |
| id | 2064035 |
| size | 415,761 |
Django-style admin panel functionality for Reinhardt framework.
This crate provides two main components:
reinhardt-admin-cli)reinhardt-panel)reinhardt-admin-cli)For project management commands (startproject, startapp), please use
reinhardt-admin-cli.
Add reinhardt to your Cargo.toml:
[dependencies]
reinhardt = { version = "0.1.0-alpha.1", features = ["admin"] }
# Or use a preset:
# reinhardt = { version = "0.1.0-alpha.1", features = ["standard"] } # Recommended
# reinhardt = { version = "0.1.0-alpha.1", features = ["full"] } # All features
Then import admin features:
use reinhardt::admin::{AdminSite, ModelAdmin};
use reinhardt::admin::types::{ListQueryParams, AdminError};
Note: Admin features are included in the standard and full feature presets.
use reinhardt::admin::{AdminSite, ModelAdmin};
#[tokio::main]
async fn main() {
let mut admin = AdminSite::new("My Admin");
// Register your models
admin.register::<User>(UserAdmin::default()).await;
// Start admin server
admin.serve("127.0.0.1:8001").await.unwrap();
}
use reinhardt::admin::ModelAdmin;
struct UserAdmin {
list_display: Vec<String>,
list_filter: Vec<String>,
search_fields: Vec<String>,
}
impl Default for UserAdmin {
fn default() -> Self {
Self {
list_display: vec!["username".to_string(), "email".to_string(), "is_active".to_string()],
list_filter: vec!["is_active".to_string()],
search_fields: vec!["username".to_string(), "email".to_string()],
}
}
}
The admin panel is built on several key components:
Advanced filtering and query building with SeaQuery integration:
For detailed database layer documentation, see the core::database module.
HTTP request handlers for all CRUD operations:
AdminHandlers::dashboard() - Admin dashboardAdminHandlers::list() - Model list view with paginationAdminHandlers::detail() - Detail viewAdminHandlers::create() - Create new instanceAdminHandlers::update() - Update instanceAdminHandlers::delete() - Delete instanceAdminHandlers::bulk_delete() - Bulk delete operationsAdminHandlers::export() - Export data (CSV, JSON, XML)AdminHandlers::import() - Import dataAutomatic route registration for models:
use reinhardt::admin::router::AdminRouter;
let router = AdminRouter::new(site, db)
.with_favicon("static/favicon.ico")
.build();
// Automatically creates routes:
// GET /admin/<model>/
// GET /admin/<model>/{id}/
// POST /admin/<model>/
// PUT /admin/<model>/{id}/
// DELETE /admin/<model>/{id}/
// DELETE /admin/<model>/bulk/
// GET /admin/<model>/export/
// POST /admin/<model>/import/
router.register_model_routes::<User>("/admin/user/")?;
For comprehensive panel documentation, see the core module.
Enable drag-and-drop reordering for your models with transaction-safe operations:
use reinhardt::admin::{DragDropConfig, ReorderableModel, ReorderHandler};
use async_trait::async_trait;
// 1. Configure drag-and-drop
let config = DragDropConfig {
order_field: "display_order".to_string(),
enabled: true,
custom_js: None, // Or provide custom JavaScript for client-side handling
};
// 2. Implement ReorderableModel for your model
#[async_trait]
impl ReorderableModel for MenuItem {
async fn get_order(&self) -> i32 {
self.display_order
}
async fn set_order(&mut self, new_order: i32) {
self.display_order = new_order;
}
fn get_id(&self) -> String {
self.id.to_string()
}
}
// 3. Create a reorder handler
let handler = ReorderHandler::new(
config,
connection.clone(),
"menu_items", // table name
"id", // primary key field
);
// 4. Process reorder requests
let reorder_items = vec![
("item_1".to_string(), 0),
("item_2".to_string(), 1),
("item_3".to_string(), 2),
];
match handler.process_reorder(reorder_items).await {
result if result.is_success() => {
println!("Reordered {} items successfully", result.items_updated);
}
result => {
eprintln!("Reorder failed: {}", result.message);
}
}
Key Features:
Implementation Details:
The ReorderHandler validates reorder operations by:
All database updates are performed using SeaQuery v1.0.0-rc within a transaction, ensuring atomicity.
For a complete implementation example, see the core::database module.
panel (default): Web admin panelcli: Command-line interfaceall: All admin functionalityLicensed under either of Apache License, Version 2.0 or MIT license at your option.