reinhardt-admin
Django-style admin panel functionality for Reinhardt framework.
Overview
This crate provides two main components:
- Panel: Web-based admin interface for managing database models
- CLI: Command-line tool for project management (available as
reinhardt-admin-cli)
Features
Admin Panel (reinhardt-panel)
- ✅ Model Management Interface: Web-based CRUD operations for database models
- ✅ Automatic Admin Discovery: Auto-generate admin interfaces from model definitions
- ✅ Customizable Admin Actions: Bulk operations and custom actions
- ✅ Search and Filtering: Advanced search capabilities with multiple filter types
- ✅ Permissions Integration: Role-based access control for admin operations
- ✅ Change Logging: Audit trail for all admin actions
- ✅ Inline Editing: Edit related models inline
- ✅ Drag-and-Drop Reordering: Reorder model instances with transaction-safe operations
- ✅ Responsive Design: Mobile-friendly admin interface with customizable templates
Command-Line Interface (reinhardt-admin-cli)
For project management commands (startproject, startapp), please use
reinhardt-admin-cli.
Installation
Add reinhardt to your Cargo.toml:
[]
= { = "0.1.0-alpha.1", = ["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 ;
use ;
Note: Admin features are included in the standard and full feature presets.
Quick Start
Using the Admin Panel
use ;
async
Customizing the Admin
use ModelAdmin;
Panel Architecture
The admin panel is built on several key components:
Database Layer
Advanced filtering and query building with SeaQuery integration:
- FilterOperator: Eq, Ne, Gt, Gte, Lt, Lte, Contains, StartsWith, EndsWith, In, NotIn, Between, Regex
- FilterCondition: AND/OR conditions for complex queries
- FilterValue: Type-safe value representation (String, Int, Float, Bool, Array)
For detailed database layer documentation, see the core::database module.
Handlers
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 data
Routing
Automatic route registration for models:
use AdminRouter;
let router = new
.with_favicon
.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.?;
For comprehensive panel documentation, see the core module.
Advanced Features
Drag-and-Drop Reordering
Enable drag-and-drop reordering for your models with transaction-safe operations:
use ;
use async_trait;
// 1. Configure drag-and-drop
let config = DragDropConfig ;
// 2. Implement ReorderableModel for your model
// 3. Create a reorder handler
let handler = new;
// 4. Process reorder requests
let reorder_items = vec!;
match handler.process_reorder.await
Key Features:
- Validation: Ensures order values are sequential, non-negative, and unique
- Transaction Safety: All updates are executed within a database transaction
- Error Handling: Detailed error messages for validation and database failures
- Bulk Updates: Efficient handling of multiple items in a single transaction
Implementation Details:
The ReorderHandler validates reorder operations by:
- Checking for negative order values
- Detecting duplicate order values
- Ensuring order values are sequential (0, 1, 2, ...)
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.
Feature Flags
panel(default): Web admin panelcli: Command-line interfaceall: All admin functionality
Documentation
- API Documentation (coming soon)
- Core Module Documentation
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.