dashboard

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: GPL-3.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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) Columns

func (d *Dashboard) Columns() int

func (*Dashboard) CreatedAt

func (d *Dashboard) CreatedAt() time.Time

func (*Dashboard) Description

func (d *Dashboard) Description() string

func (*Dashboard) ID

func (d *Dashboard) ID() shared.ID

func (*Dashboard) IsDefault

func (d *Dashboard) IsDefault() bool

func (*Dashboard) Name

func (d *Dashboard) Name() string

func (*Dashboard) TenantID

func (d *Dashboard) TenantID() shared.ID

func (*Dashboard) Update

func (d *Dashboard) Update(name, description string, columns int, widgets []Widget) error

Update replaces the name, description, columns and widget layout after validation.

func (*Dashboard) UpdatedAt

func (d *Dashboard) UpdatedAt() time.Time

func (*Dashboard) UserID

func (d *Dashboard) UserID() shared.ID

func (*Dashboard) Widgets

func (d *Dashboard) Widgets() []Widget

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.

Jump to

Keyboard shortcuts

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