Documentation
¶
Overview ¶
Package admin provides the admin panel coordinator as a burrow contrib app. It handles layout, navigation, dashboard rendering, and acts as the mount point for ModelAdmin instances that provide per-model CRUD views.
Index ¶
- func DefaultLayout() string
- func RequestPathFromContext(ctx context.Context) string
- func WithNavGroups(ctx context.Context, groups []NavGroup) context.Context
- func WithRequestPath(ctx context.Context, path string) context.Context
- type App
- func (a *App) Dependencies() []string
- func (a *App) FuncMap() template.FuncMap
- func (a *App) Name() string
- func (a *App) Register(cfg *burrow.AppConfig) error
- func (a *App) RequestFuncMap(r *http.Request) template.FuncMap
- func (a *App) Routes(r chi.Router)
- func (a *App) TemplateFS() fs.FS
- func (a *App) TranslationFS() fs.FS
- type DashboardRenderer
- type NavGroup
- type Option
- type SidebarGroup
- type SidebarItem
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultLayout ¶
func DefaultLayout() string
DefaultLayout returns the template name for the built-in admin layout.
func RequestPathFromContext ¶
RequestPathFromContext retrieves the current request path from the context.
func WithNavGroups ¶
WithNavGroups stores nav groups in the context.
func WithRequestPath ¶
WithRequestPath stores the current request path in the context.
Example ¶
package main
import (
"context"
"fmt"
"github.com/oliverandrich/burrow/contrib/admin"
)
func main() {
ctx := admin.WithRequestPath(context.Background(), "/admin/users/42")
fmt.Println(admin.RequestPathFromContext(ctx))
}
Output: /admin/users/42
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App implements the admin coordinator contrib app.
func New ¶
New creates a new admin app with the given options. By default, the built-in HTML layout and dashboard renderer are used. Use WithLayout() and WithDashboardRenderer() to override.
func (*App) Dependencies ¶
func (*App) RequestFuncMap ¶ added in v0.4.0
RequestFuncMap returns request-scoped template functions for the admin sidebar.
func (*App) Routes ¶
Routes creates the /admin group with auth middleware and delegates to all HasAdmin apps.
func (*App) TemplateFS ¶
TemplateFS returns the embedded HTML template files.
func (*App) TranslationFS ¶
TranslationFS returns the embedded translation files (modeladmin UI labels).
type DashboardRenderer ¶
type DashboardRenderer interface {
DashboardPage(w http.ResponseWriter, r *http.Request) error
}
DashboardRenderer renders the admin dashboard page.
func DefaultDashboardRenderer ¶
func DefaultDashboardRenderer() DashboardRenderer
DefaultDashboardRenderer returns a DashboardRenderer that uses the built-in HTML templates for the admin dashboard page.
type NavGroup ¶
type NavGroup struct {
}
NavGroup groups navigation items belonging to one admin app. Each HasAdmin app contributes one group to the admin sidebar.
func NavGroupsFromContext ¶
NavGroupsFromContext retrieves nav groups from the context.
type Option ¶
type Option func(*App)
Option configures the admin app.
func WithDashboardRenderer ¶
func WithDashboardRenderer(r DashboardRenderer) Option
WithDashboardRenderer sets the dashboard page renderer.
func WithLayout ¶
WithLayout sets the layout template name for admin pages.
type SidebarGroup ¶
type SidebarGroup struct {
AppName string
Label string
Items []SidebarItem
}
SidebarGroup holds pre-computed sidebar data for template rendering.
func PrepareSidebar ¶
func PrepareSidebar(ctx context.Context, groups []NavGroup) []SidebarGroup
PrepareSidebar pre-computes sidebar groups with translated labels and active-state CSS classes, ready for template rendering.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package modeladmin provides a generic, Django-style ModelAdmin for auto-generating CRUD admin views from Bun models.
|
Package modeladmin provides a generic, Django-style ModelAdmin for auto-generating CRUD admin views from Bun models. |
|
templates
Package templates provides the default HTML template renderer for modeladmin CRUD views.
|
Package templates provides the default HTML template renderer for modeladmin CRUD views. |