Documentation
¶
Overview ¶
Package dashboard provides domain models for per-user customizable dashboards (RFC-021). A user owns 0..N saved dashboards, each a name plus a JSON widget layout. Everything is self-scoped: a dashboard always belongs to exactly one (tenant, user), and the persistence layer filters every query by both.
Index ¶
- type Dashboard
- func (d *Dashboard) Columns() int
- func (d *Dashboard) CreatedAt() time.Time
- func (d *Dashboard) Description() string
- func (d *Dashboard) ID() shared.ID
- func (d *Dashboard) IsDefault() bool
- func (d *Dashboard) Name() string
- func (d *Dashboard) TenantID() shared.ID
- func (d *Dashboard) Update(name, description string, columns int, widgets []Widget) error
- func (d *Dashboard) UpdatedAt() time.Time
- func (d *Dashboard) UserID() shared.ID
- func (d *Dashboard) Widgets() []Widget
- type Repository
- type Widget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dashboard ¶
type Dashboard struct {
// contains filtered or unexported fields
}
Dashboard is a user's saved dashboard layout.
func NewDashboard ¶
func NewDashboard(tenantID, userID shared.ID, name, description string, columns int, widgets []Widget) (*Dashboard, error)
NewDashboard creates a validated Dashboard for the given (tenant, user).
func Reconstruct ¶
func Reconstruct( id, tenantID, userID shared.ID, name, description string, columns int, isDefault bool, widgets []Widget, createdAt, updatedAt time.Time, ) *Dashboard
Reconstruct rebuilds a Dashboard from persistence without re-validating.
func (*Dashboard) Description ¶
type Repository ¶
type Repository interface {
ListByUser(ctx context.Context, tenantID, userID shared.ID) ([]*Dashboard, error)
GetByID(ctx context.Context, tenantID, userID, id shared.ID) (*Dashboard, error)
Create(ctx context.Context, d *Dashboard) error
Update(ctx context.Context, d *Dashboard) error
Delete(ctx context.Context, tenantID, userID, id shared.ID) error
// SetDefault clears any other default for the user and marks id as the
// single default, atomically. Returns shared.ErrNotFound if id is absent.
SetDefault(ctx context.Context, tenantID, userID, id shared.ID) error
}
Repository persists user dashboards. EVERY method is scoped by both tenant_id and user_id so a dashboard can never leak across users or tenants.
type Widget ¶
type Widget struct {
WidgetType string `json:"widget_type"`
X int `json:"x"`
Y int `json:"y"`
W int `json:"w"`
H int `json:"h"`
Config map[string]any `json:"config,omitempty"`
}
Widget is one placed tile on a dashboard grid. Coordinates and sizes are grid units, bounded to keep a stored layout sane.