Documentation
¶
Index ¶
- func RegisterDefaultWidgets(widgetSvc WidgetService, features FeatureFlags, registerProviders func() error) error
- func RegisterProviders(host ProviderHost, widgetSvc WidgetService, auth Authorizer, ...) error
- func RegisterWidgetAreas(registrar DashboardAreaRegistrar, widgetSvc WidgetService, ...) error
- type ActivityRecorder
- type Authorizer
- type CMSWidgetStore
- func (s *CMSWidgetStore) AssignInstance(ctx context.Context, input godash.AssignWidgetInput) error
- func (s *CMSWidgetStore) CreateInstance(ctx context.Context, input godash.CreateWidgetInstanceInput) (godash.WidgetInstance, error)
- func (s *CMSWidgetStore) DeleteInstance(ctx context.Context, instanceID string) error
- func (s *CMSWidgetStore) EnsureArea(ctx context.Context, def godash.WidgetAreaDefinition) (bool, error)
- func (s *CMSWidgetStore) EnsureDefinition(ctx context.Context, def godash.WidgetDefinition) (bool, error)
- func (s *CMSWidgetStore) GetInstance(ctx context.Context, instanceID string) (godash.WidgetInstance, error)
- func (s *CMSWidgetStore) ReorderArea(ctx context.Context, input godash.ReorderAreaInput) error
- func (s *CMSWidgetStore) ResolveArea(ctx context.Context, input godash.ResolveAreaInput) (godash.ResolvedArea, error)
- func (s *CMSWidgetStore) UpdateInstance(ctx context.Context, input godash.UpdateWidgetInstanceInput) (godash.WidgetInstance, error)
- type DashboardAreaRegistrar
- type DashboardPreferences
- type DashboardPreferencesWithContext
- type DashboardWidgetInstance
- type FeatureFlags
- type InMemoryDashboardPreferences
- type ProviderHost
- type WidgetAreaDefinition
- type WidgetDefinition
- type WidgetInstance
- type WidgetInstanceFilter
- type WidgetService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDefaultWidgets ¶
func RegisterDefaultWidgets(widgetSvc WidgetService, features FeatureFlags, registerProviders func() error) error
RegisterDefaultWidgets seeds default widget definitions and optionally invokes a provider registration callback.
func RegisterProviders ¶
func RegisterProviders(host ProviderHost, widgetSvc WidgetService, auth Authorizer, features FeatureFlags, register func() error) error
RegisterProviders wires dashboard dependencies before invoking the provided registration callback.
func RegisterWidgetAreas ¶
func RegisterWidgetAreas(registrar DashboardAreaRegistrar, widgetSvc WidgetService, features FeatureFlags) error
RegisterWidgetAreas seeds default widget areas into the dashboard or widget service.
Types ¶
type ActivityRecorder ¶
type ActivityRecorder interface {
RecordWidgetEvent(ctx context.Context, action string, inst godash.WidgetInstance)
}
ActivityRecorder captures widget lifecycle events for auditing/telemetry.
type Authorizer ¶
Authorizer determines whether a subject can perform an action on a resource.
type CMSWidgetStore ¶
type CMSWidgetStore struct {
// contains filtered or unexported fields
}
CMSWidgetStore adapts the admin CMSWidgetService to go-dashboard's WidgetStore interface. It uses the underlying service for persistence and maps fields between the two models.
func NewCMSWidgetStore ¶
func NewCMSWidgetStore(svc WidgetService) *CMSWidgetStore
NewCMSWidgetStore builds a widget store backed by the provided CMS widget service.
func NewCMSWidgetStoreWithActivity ¶
func NewCMSWidgetStoreWithActivity(svc WidgetService, recorder ActivityRecorder) *CMSWidgetStore
NewCMSWidgetStoreWithActivity wires an optional activity recorder for widget events.
func (*CMSWidgetStore) AssignInstance ¶
func (s *CMSWidgetStore) AssignInstance(ctx context.Context, input godash.AssignWidgetInput) error
AssignInstance associates a widget with an area and optional position.
func (*CMSWidgetStore) CreateInstance ¶
func (s *CMSWidgetStore) CreateInstance(ctx context.Context, input godash.CreateWidgetInstanceInput) (godash.WidgetInstance, error)
CreateInstance stores a widget instance.
func (*CMSWidgetStore) DeleteInstance ¶
func (s *CMSWidgetStore) DeleteInstance(ctx context.Context, instanceID string) error
DeleteInstance removes a widget instance.
func (*CMSWidgetStore) EnsureArea ¶
func (s *CMSWidgetStore) EnsureArea(ctx context.Context, def godash.WidgetAreaDefinition) (bool, error)
EnsureArea registers an area definition when missing.
func (*CMSWidgetStore) EnsureDefinition ¶
func (s *CMSWidgetStore) EnsureDefinition(ctx context.Context, def godash.WidgetDefinition) (bool, error)
EnsureDefinition registers a widget definition when missing.
func (*CMSWidgetStore) GetInstance ¶
func (s *CMSWidgetStore) GetInstance(ctx context.Context, instanceID string) (godash.WidgetInstance, error)
GetInstance fetches a widget instance by ID.
func (*CMSWidgetStore) ReorderArea ¶
func (s *CMSWidgetStore) ReorderArea(ctx context.Context, input godash.ReorderAreaInput) error
ReorderArea reassigns positions within an area.
func (*CMSWidgetStore) ResolveArea ¶
func (s *CMSWidgetStore) ResolveArea(ctx context.Context, input godash.ResolveAreaInput) (godash.ResolvedArea, error)
ResolveArea returns the widgets for an area.
func (*CMSWidgetStore) UpdateInstance ¶
func (s *CMSWidgetStore) UpdateInstance(ctx context.Context, input godash.UpdateWidgetInstanceInput) (godash.WidgetInstance, error)
UpdateInstance updates an existing widget instance.
type DashboardAreaRegistrar ¶
type DashboardAreaRegistrar interface {
Areas() []WidgetAreaDefinition
RegisterArea(def WidgetAreaDefinition)
}
DashboardAreaRegistrar exposes minimal area registration hooks.
type DashboardPreferences ¶
type DashboardPreferences interface {
ForUser(userID string) []DashboardWidgetInstance
Save(userID string, layout []DashboardWidgetInstance) error
}
DashboardPreferences stores per-user layouts.
type DashboardPreferencesWithContext ¶
type DashboardPreferencesWithContext interface {
DashboardPreferences
ForUserWithContext(ctx context.Context, userID string) []DashboardWidgetInstance
SaveWithContext(ctx context.Context, userID string, layout []DashboardWidgetInstance) error
}
DashboardPreferencesWithContext allows contextual access to preferences (for activity/locale-aware stores).
type DashboardWidgetInstance ¶
type DashboardWidgetInstance struct {
ID string `json:"id,omitempty"`
DefinitionCode string `json:"definition"`
AreaCode string `json:"area"`
Config map[string]any `json:"config,omitempty"`
Position int `json:"position,omitempty"`
Span int `json:"span,omitempty"`
Hidden bool `json:"hidden,omitempty"`
Locale string `json:"locale,omitempty"`
}
DashboardWidgetInstance represents a widget placed in an area.
func CloneDashboardInstances ¶
func CloneDashboardInstances(in []DashboardWidgetInstance) []DashboardWidgetInstance
CloneDashboardInstances copies widget instances.
type FeatureFlags ¶
FeatureFlags captures the minimal flags needed for dashboard helpers.
type InMemoryDashboardPreferences ¶
type InMemoryDashboardPreferences struct {
// contains filtered or unexported fields
}
InMemoryDashboardPreferences stores layouts in memory.
func NewInMemoryDashboardPreferences ¶
func NewInMemoryDashboardPreferences() *InMemoryDashboardPreferences
NewInMemoryDashboardPreferences constructs a preference store.
func (*InMemoryDashboardPreferences) ForUser ¶
func (p *InMemoryDashboardPreferences) ForUser(userID string) []DashboardWidgetInstance
ForUser returns the saved layout for a user.
func (*InMemoryDashboardPreferences) Save ¶
func (p *InMemoryDashboardPreferences) Save(userID string, layout []DashboardWidgetInstance) error
Save stores a user layout.
type ProviderHost ¶
type ProviderHost interface {
WithWidgetService(WidgetService)
WithAuthorizer(Authorizer)
}
ProviderHost exposes wiring hooks needed before registering providers.
type WidgetAreaDefinition ¶
WidgetAreaDefinition captures CMS widget area metadata.
type WidgetDefinition ¶
WidgetDefinition captures admin widget metadata.
type WidgetInstance ¶
type WidgetInstance struct {
ID string
DefinitionCode string
Area string
PageID string
Locale string
Config map[string]any
Position int
Span int
Hidden bool
}
WidgetInstance links a widget definition to a specific area/page.
type WidgetInstanceFilter ¶
WidgetInstanceFilter narrows widget instance queries.
type WidgetService ¶
type WidgetService interface {
RegisterAreaDefinition(ctx context.Context, def WidgetAreaDefinition) error
RegisterDefinition(ctx context.Context, def WidgetDefinition) error
DeleteDefinition(ctx context.Context, code string) error
Areas() []WidgetAreaDefinition
Definitions() []WidgetDefinition
SaveInstance(ctx context.Context, instance WidgetInstance) (*WidgetInstance, error)
DeleteInstance(ctx context.Context, id string) error
ListInstances(ctx context.Context, filter WidgetInstanceFilter) ([]WidgetInstance, error)
}
WidgetService registers dashboard widget areas/definitions and instances.