dashboard

package
v0.0.0-...-0301fe8 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 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

Index

Constants

View Source
const AlreadyCurrentCode = "already_current"
View Source
const BuildOriginMetaKey = "io.pitot/build-origin"
View Source
const OwnerMetaKey = "io.pitot/owner-id"

OwnerMetaKey carries the dashboard owner's user ID in MCP request _meta.

Trust model (three-file invariant): io.pitot/owner-id and io.pitot/build-origin are client-suppliable metadata. Dashboard tools trust these values ONLY on the in-process path with authenticated owner injection from internal/agent/tools.go. ProtectMCP and ProtectBrowserMCP (internal/api/oauth.go) guarantee OAuth TokenInfo on both HTTP mounts; remote TokenInfo takes precedence, and remote metadata cannot fabricate ownership or conversation provenance.

View Source
const RowHeight = 40

RowHeight is the grid row height in pixels; ui/host/src/dashboards/grid.tsx uses the same value.

View Source
const VersionNotFoundCode = "dashboard_version_not_found"

Variables

View Source
var (
	ErrNotFound = errors.New("dashboard not found")
	ErrConflict = errors.New("a dashboard with that name already exists")
	ErrStale    = errors.New("the dashboard changed since it was read")
)
View Source
var ErrAlreadyCurrent = errors.New("dashboard version is already current")
View Source
var ErrVersionNotFound = errors.New("dashboard version not found")

Functions

func Apply

func Apply(spec query.Dashboard, ops []Operation) (query.Dashboard, bool, error)

Apply runs operations in order on a copy of spec. The bool reports whether panels were moved or resized, which requires a fresh pack. Additions keep existing coordinates and receive their own placement in prepare.

func Compact

func Compact(panels []query.Panel)

Compact repairs unusable grids, then closes vertical gaps without changing usable columns or dimensions. Work depends on panel count, never grid Y.

func DefaultSpec

func DefaultSpec() query.Dashboard

DefaultSpec is every owner's first dashboard: the shape of the whole system, filterable to one service.

func MarkSaveCommitted

func MarkSaveCommitted(ctx context.Context)

MarkSaveCommitted records a confirmed database commit or successful remote mutation result before any subsequent receipt/encoding work can panic.

func OwnerFromContext

func OwnerFromContext(ctx context.Context) string

func PackMissing

func PackMissing(panels []query.Panel)

PackMissing preserves every valid, non-overlapping supplied grid and packs only panels without usable coordinates around them.

func SaveCommitted

func SaveCommitted(ctx context.Context) bool

func TrackSave

func TrackSave(ctx context.Context) context.Context

TrackSave starts a per-call observation, shared with nested service work. It is never serialized or accepted as client-supplied metadata.

func WithBuildOrigin

func WithBuildOrigin(ctx context.Context, origin BuildOrigin) context.Context

func WithOwner

func WithOwner(ctx context.Context, ownerID string) context.Context

func WithSaveCheck

func WithSaveCheck(ctx context.Context, check func(context.Context, query.Dashboard) error) context.Context

WithSaveCheck adds a transport-specific check of the exact spec before each write attempt, including edits retried against a concurrent version.

Types

type Author

type Author struct {
	Kind string // user, agent or system
	ID   string
}

type BuildOrigin

type BuildOrigin struct {
	ThreadID       string `json:"thread_id"`
	MessageID      string `json:"message_id"`
	RequestExcerpt string `json:"request_excerpt"`
}

func BuildOriginFromContext

func BuildOriginFromContext(ctx context.Context) (BuildOrigin, bool)

type ChangeSet

type ChangeSet struct {
	Panels          []PanelChange `json:"panels"`
	LayoutChanged   bool          `json:"layout_changed"`
	DashboardFields []string      `json:"dashboard_fields,omitempty"`
}

func Changes

func Changes(before, after query.Dashboard) ChangeSet

Changes compares normalized committed snapshots. Physical packing is reported once; authored fields and only panels outside the longest common surviving order get panel chips. Normalization applies to copies for diffing only.

type Mutation

type Mutation struct {
	Record      Record
	Before      query.Dashboard
	BaseVersion int
}

Mutation identifies exactly one committed save and its successful optimistic base.

type Operation

type Operation struct {
	Op          string          `json:"op" jsonschema:"add_panel, update_panel, remove_panel, move_panel, set_variable, remove_variable, set_time or rename"`
	ID          string          `json:"id,omitempty" jsonschema:"update_panel, remove_panel, move_panel: the panel id"`
	After       string          `` /* 144-byte string literal not displayed */
	Panel       *query.Panel    `json:"panel,omitempty" jsonschema:"add_panel: the complete new panel"`
	Set         map[string]any  `` /* 143-byte string literal not displayed */
	Variable    *query.Variable `json:"variable,omitempty" jsonschema:"set_variable: the variable, added or replaced by name"`
	Name        string          `json:"name,omitempty" jsonschema:"remove_variable: the variable name; rename: the new dashboard name"`
	Description *string         `json:"description,omitempty" jsonschema:"rename: the new description"`
	Time        *query.Time     `json:"time,omitempty" jsonschema:"set_time: the new default time"`
}

Operation is one typed edit. Panels are addressed by their stable id, never by position, so an edit lands on exactly the panel it names.

type PanelChange

type PanelChange struct {
	PanelID         string   `json:"panel_id"`
	Title           string   `json:"title"`
	Kind            string   `json:"kind"`
	Fields          []string `json:"fields,omitempty"`
	PositionChanged bool     `json:"position_changed,omitempty"`
}

type Record

type Record struct {
	ID          string          `json:"id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	IsDefault   bool            `json:"is_default"`
	Version     int             `json:"version"`
	Spec        query.Dashboard `json:"spec"`
	CreatedAt   string          `json:"created_at"`
	UpdatedAt   string          `json:"updated_at"`
}

type Service

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

func New

func New(db *sql.DB, validator Validator) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, ownerID string, spec query.Dashboard, author Author) (Record, error)

func (*Service) CreateWithChanges

func (s *Service) CreateWithChanges(ctx context.Context, ownerID string, spec query.Dashboard, author Author) (Mutation, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, ownerID, id string) error

func (*Service) Edit

func (s *Service) Edit(ctx context.Context, ownerID, id string, ops []Operation, baseVersion int, author Author, message string) (Record, error)

Edit applies typed operations atomically. baseVersion 0 means "the latest".

func (*Service) EditWithChanges

func (s *Service) EditWithChanges(ctx context.Context, ownerID, id string, ops []Operation, baseVersion int, author Author, message string) (Mutation, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, ownerID, id string) (Record, error)

func (*Service) List

func (s *Service) List(ctx context.Context, ownerID string) ([]Summary, error)

func (*Service) Replace

func (s *Service) Replace(ctx context.Context, ownerID, id string, spec query.Dashboard, baseVersion int, author Author, message string) (Record, error)

Replace stores a whole new spec. baseVersion 0 means "the latest".

func (*Service) ReplaceWithChanges

func (s *Service) ReplaceWithChanges(ctx context.Context, ownerID, id string, spec query.Dashboard, baseVersion int, author Author, message string) (Mutation, error)

func (*Service) Restore

func (s *Service) Restore(ctx context.Context, ownerID, id string, version int, author Author) (Record, error)

func (*Service) RestoreWithChanges

func (s *Service) RestoreWithChanges(ctx context.Context, ownerID, id string, version int, author Author) (Mutation, error)

RestoreWithChanges appends a historical spec as a new save against the latest optimistic base, retaining the committed snapshots for the shared diff.

func (*Service) VersionRecord

func (s *Service) VersionRecord(ctx context.Context, owner, id string, version int) (VersionRecord, error)

VersionRecord reads immutable historical content and its shared save diff. IsDefault describes the current owned board; UpdatedAt is the version time.

func (*Service) Versions

func (s *Service) Versions(ctx context.Context, ownerID, id string) ([]VersionInfo, error)

type Summary

type Summary struct {
	Origin      *BuildOrigin `json:"origin,omitempty"`
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	IsDefault   bool         `json:"is_default"`
	Version     int          `json:"version"`
	PanelCount  int          `json:"panel_count"`
	UpdatedAt   string       `json:"updated_at"`
}

type Validator

type Validator interface {
	Validate(ctx context.Context, d *query.Dashboard) error
}

Validator checks a spec completely, including its filters and SQL. *panel.Executor implements it.

type VersionInfo

type VersionInfo struct {
	Version    int    `json:"version"`
	AuthorKind string `json:"author_kind"`
	AuthorID   string `json:"author_id,omitempty"`
	Message    string `json:"message,omitempty"`
	CreatedAt  string `json:"created_at"`
}

type VersionRecord

type VersionRecord struct {
	Dashboard        Record        `json:"dashboard"`
	AuthorKind       string        `json:"author_kind"`
	AuthorID         string        `json:"author_id,omitempty"`
	Message          string        `json:"message,omitempty"`
	CreatedAt        string        `json:"created_at"`
	Changes          []PanelChange `json:"changes"`
	LayoutChanged    bool          `json:"layout_changed"`
	DashboardFields  []string      `json:"dashboard_fields"`
	ChangesAvailable bool          `json:"changes_available"`
}

Jump to

Keyboard shortcuts

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