studio

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package studio provides a built-in admin panel for Nimbus applications.

Studio auto-discovers GORM models and generates a full CRUD admin interface with listing, filtering, sorting, pagination, create/edit forms, and relationship management — all from a single plugin registration.

Usage:

app.RegisterPlugin(studio.NewPlugin(studio.Config{
    Path:   "/_studio",
    Models: []any{&models.User{}, &models.Post{}},
}))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Path prefix for the admin panel (default: "/_studio").
	Path string

	// Models to register in the admin panel.
	Models []any

	// DB is the GORM database connection.
	DB *lucid.DB

	// Title of the admin panel (default: "Nimbus Studio").
	Title string

	// BrandColor for the header (default: "#6366f1").
	BrandColor string

	// Auth middleware to protect the admin panel.
	Auth router.Middleware

	// ReadOnly prevents create/update/delete operations.
	ReadOnly bool

	// PerPage default pagination size (default: 25).
	PerPage int

	// CustomActions for models.
	CustomActions map[string][]ModelAction

	// Dashboard widgets.
	Widgets []Widget
}

Config configures the Studio admin panel.

type FieldMeta

type FieldMeta struct {
	Name       string `json:"name"`
	Column     string `json:"column"`
	Type       string `json:"type"`
	GoType     string `json:"go_type"`
	Primary    bool   `json:"primary,omitempty"`
	Required   bool   `json:"required,omitempty"`
	Unique     bool   `json:"unique,omitempty"`
	Nullable   bool   `json:"nullable,omitempty"`
	Hidden     bool   `json:"hidden,omitempty"`
	ReadOnly   bool   `json:"read_only,omitempty"`
	Sortable   bool   `json:"sortable"`
	Filterable bool   `json:"filterable"`
	Searchable bool   `json:"searchable"`
	InputType  string `json:"input_type"` // text, textarea, number, email, password, select, checkbox, date, datetime
	Relation   string `json:"relation,omitempty"`
}

FieldMeta describes a model field.

type ModelAction

type ModelAction struct {
	Name        string
	Label       string
	Icon        string
	Handler     func(db *lucid.DB, ids []uint) error
	Bulk        bool // can be applied to multiple records
	Destructive bool
}

ModelAction defines a custom action on a model.

type ModelMeta

type ModelMeta struct {
	Name       string       `json:"name"`
	Table      string       `json:"table"`
	Fields     []FieldMeta  `json:"fields"`
	Type       reflect.Type `json:"-"`
	Searchable []string     `json:"searchable"`
	Sortable   []string     `json:"sortable"`
	Filterable []string     `json:"filterable"`
}

ModelMeta holds introspected metadata about a registered model.

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin is the Nimbus Studio admin panel plugin.

func NewPlugin

func NewPlugin(cfg Config) *Plugin

NewPlugin creates a new Studio plugin.

func (*Plugin) Boot

func (p *Plugin) Boot(app interface{}) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Register

func (p *Plugin) Register(app interface{}) error

func (*Plugin) RegisterRoutes

func (p *Plugin) RegisterRoutes(r *router.Router)

RegisterRoutes mounts the Studio admin panel routes.

func (*Plugin) Version

func (p *Plugin) Version() string

type Widget

type Widget struct {
	Title string
	Type  string // "count", "chart", "list", "custom"
	Model string
	Query func(db *lucid.DB) (any, error)
	Width int // 1-4 (grid columns)
}

Widget is a dashboard widget.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL