reinhardt-admin
Django-style admin panel functionality for Reinhardt framework.
Overview
This crate provides a web-based admin interface for managing database models, built as a WASM single-page application served by a Reinhardt server.
Features
- ✅ 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
- ✅ 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.2", = ["admin"] }
# Or use a preset:
# reinhardt = { version = "0.1.2", features = ["full"] } # All features
Then import admin features:
use ;
use ;
Quick Start
Configuring Admin Models
Register models with AdminSite in a dedicated configuration function:
use ;
Mounting Admin Routes
Admin routes are registered inside the routes() function decorated with
#[routes]. Use admin_routes_with_di() to mount the admin
panel with deferred DI registration:
use UnifiedRouter;
use ;
use routes;
use Arc;
The AdminDatabase is lazily constructed from DatabaseConnection at the
first request, so no database connection is needed during route setup.
Customizing the Admin
Use the #[admin] proc macro to register a model with the admin panel. The macro
automatically implements ModelAdmin — no manual impl block is needed:
use admin;
use crateUser;
,
list_per_page = 25,
)]
;
The #[admin(model, ...)] attribute expands to a full ModelAdmin implementation
at compile time, so you never need to write boilerplate field structs or
impl Default blocks.
Architecture
The admin panel is built on several key components:
Database Layer
Advanced filtering and query building with reinhardt-query 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.
Server Functions
All CRUD operations are implemented as reinhardt-pages server functions in
individual modules under src/server/:
get_dashboard— admin dashboard dataget_list— model list view with paginationget_detail— detail view for a single recordget_fields— field metadata for a modelcreate_record— create a new recordupdate_record— update an existing recorddelete_record— delete a single recordbulk_delete_records— bulk delete operationsexport_data— export data (CSV, JSON, XML)import_data— import dataadmin_login— admin authenticationadmin_logout— admin session termination
Routing
Route registration uses two free functions from core::router:
use ;
use UnifiedRouter;
use Arc;
// Default: uses AdminDefaultUser (table "auth_user")
let site = new;
let = admin_routes_with_di;
let assets = admin_static_routes;
let router = new
.mount
.mount
.with_di_registrations;
// Routes registered under /admin/:
// POST /admin/api/server_fn/get_dashboard
// POST /admin/api/server_fn/get_list
// POST /admin/api/server_fn/get_detail
// POST /admin/api/server_fn/get_fields
// POST /admin/api/server_fn/create_record
// POST /admin/api/server_fn/update_record
// POST /admin/api/server_fn/delete_record
// POST /admin/api/server_fn/bulk_delete_records
// POST /admin/api/server_fn/export_data
// POST /admin/api/server_fn/import_data
// POST /admin/api/server_fn/admin_login
// POST /admin/api/server_fn/admin_logout
// GET /admin/ (SPA shell)
// GET /admin/{*tail} (SPA client-side routing)
// Static assets registered under /static/admin/:
// GET /static/admin/{*path}
// HEAD /static/admin/{*path}
For comprehensive routing documentation, see the core::router module.
Feature Flags
| Feature | Description |
|---|---|
adapters |
Adapter layer utilities |
core |
Core admin functionality |
pages |
Page rendering support |
server |
Server-side request handling |
types |
Shared type definitions |
all |
All of the above (adapters, core, pages, server, types) |
file-uploads |
File upload support |
admin |
Admin feature marker |
full |
All features including file-uploads |
By default, no features are enabled (default = []).
Documentation
- API Documentation (coming soon)
- Core Module Documentation
License
Licensed under the BSD 3-Clause License.