Documentation
¶
Overview ¶
Package undo provides undo/redo functionality for LacyLights operations.
Index ¶
- type BulkFixturePositionSnapshot
- type BulkLookUpdateSnapshot
- type CueEffectSnapshot
- type CueListSnapshot
- type CuePlaybackSnapshot
- type CueSnapshot
- type EffectSnapshot
- type EntityType
- type FixtureInstanceSnapshot
- type FixturePositionEntry
- type LookBoardSnapshot
- type LookSnapshot
- type OperationType
- type PlaybackController
- type Service
- func (s *Service) CaptureBulkLookState(ctx context.Context, lookIDs []string) (*BulkLookUpdateSnapshot, error)
- func (s *Service) CaptureCueEffectState(ctx context.Context, cueID, effectID string) (*CueEffectSnapshot, error)
- func (s *Service) CaptureCueListState(ctx context.Context, cueListID string) (*CueListSnapshot, error)
- func (s *Service) CaptureCueState(ctx context.Context, cueID string) (*CueSnapshot, error)
- func (s *Service) CaptureEffectState(ctx context.Context, effectID string) (*EffectSnapshot, error)
- func (s *Service) CaptureFixturePositions(ctx context.Context, fixtureIDs []string) (*BulkFixturePositionSnapshot, error)
- func (s *Service) CaptureFixtureState(ctx context.Context, fixtureID string) (*FixtureInstanceSnapshot, error)
- func (s *Service) CaptureLookBoardState(ctx context.Context, lookBoardID string) (*LookBoardSnapshot, error)
- func (s *Service) CaptureLookState(ctx context.Context, lookID string) (*LookSnapshot, error)
- func (s *Service) ClearHistory(ctx context.Context, projectID string) error
- func (s *Service) DeleteEntityForUndo(ctx context.Context, entityType EntityType, entityID string) error
- func (s *Service) GetOperationHistory(ctx context.Context, projectID string, page, perPage int) ([]models.Operation, int64, error)
- func (s *Service) GetStatus(ctx context.Context, projectID string) (*repositories.UndoRedoStatus, error)
- func (s *Service) JumpToOperation(ctx context.Context, projectID, operationID string) (*UndoRedoResult, error)
- func (s *Service) RecordOperation(ctx context.Context, projectID string, opType OperationType, ...) error
- func (s *Service) Redo(ctx context.Context, projectID string) (*UndoRedoResult, error)
- func (s *Service) SetPlaybackController(pc PlaybackController)
- func (s *Service) Undo(ctx context.Context, projectID string) (*UndoRedoResult, error)
- type UndoRedoResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BulkFixturePositionSnapshot ¶
type BulkFixturePositionSnapshot struct {
Positions []FixturePositionEntry `json:"positions"`
}
BulkFixturePositionSnapshot captures multiple fixture positions for undo/redo.
type BulkLookUpdateSnapshot ¶
type BulkLookUpdateSnapshot struct {
Looks []LookSnapshot `json:"looks"`
}
BulkLookUpdateSnapshot captures multiple looks' state for atomic undo. Used by copyFixturesToLooks to restore all target looks in a single undo operation.
type CueEffectSnapshot ¶
type CueEffectSnapshot struct {
CueEffect *models.CueEffect `json:"cueEffect"`
CueID string `json:"cueId"`
EffectID string `json:"effectId"`
ProjectID string `json:"projectId"`
}
CueEffectSnapshot captures the state of a cue-effect relationship.
type CueListSnapshot ¶
type CueListSnapshot struct {
CueList *models.CueList `json:"cueList"`
Cues []models.Cue `json:"cues"`
}
CueListSnapshot captures the complete state of a cue list.
type CuePlaybackSnapshot ¶
type CuePlaybackSnapshot struct {
CueListID string `json:"cueListId"`
ProjectID string `json:"projectId"`
CueID *string `json:"cueId,omitempty"` // nil if not playing
CueNumber *float64 `json:"cueNumber,omitempty"` // nil if not playing
CueName *string `json:"cueName,omitempty"` // for description purposes
FadeInTime *float64 `json:"fadeInTime,omitempty"` // the fade time to use when restoring
IsPlaying bool `json:"isPlaying"`
CueListName string `json:"cueListName,omitempty"` // for description purposes
}
CuePlaybackSnapshot captures the playback state for undo/redo. This tracks which cue was playing (or if playback was stopped).
type CueSnapshot ¶
CueSnapshot captures the complete state of a cue.
type EffectSnapshot ¶
type EffectSnapshot struct {
Effect *models.Effect `json:"effect"`
EffectFixtures []models.EffectFixture `json:"effectFixtures"`
EffectChannels []models.EffectChannel `json:"effectChannels"`
}
EffectSnapshot captures the complete state of an effect.
type EntityType ¶
type EntityType string
EntityType represents the type of entity being operated on.
const ( EntityTypeLook EntityType = "Look" EntityTypeFixtureInstance EntityType = "FixtureInstance" EntityTypeCue EntityType = "Cue" EntityTypeCueList EntityType = "CueList" EntityTypeLookBoard EntityType = "LookBoard" EntityTypeLookBoardButton EntityType = "LookBoardButton" EntityTypeEffect EntityType = "Effect" EntityTypeCueEffect EntityType = "CueEffect" EntityTypeProject EntityType = "Project" EntityTypeCuePlayback EntityType = "CuePlayback" EntityTypeBulkFixturePosition EntityType = "BulkFixturePosition" EntityTypeBulkLookUpdate EntityType = "BulkLookUpdate" )
type FixtureInstanceSnapshot ¶
type FixtureInstanceSnapshot struct {
Fixture *models.FixtureInstance `json:"fixture"`
Channels []models.InstanceChannel `json:"channels"`
}
FixtureInstanceSnapshot captures the complete state of a fixture instance.
type FixturePositionEntry ¶
type FixturePositionEntry struct {
FixtureID string `json:"fixtureId"`
FixtureName string `json:"fixtureName"`
LayoutX *float64 `json:"layoutX,omitempty"`
LayoutY *float64 `json:"layoutY,omitempty"`
LayoutRotation *float64 `json:"layoutRotation,omitempty"`
}
FixturePositionEntry captures a single fixture's position for bulk operations.
type LookBoardSnapshot ¶
type LookBoardSnapshot struct {
LookBoard *models.LookBoard `json:"lookBoard"`
Buttons []models.LookBoardButton `json:"buttons"`
}
LookBoardSnapshot captures the complete state of a look board.
type LookSnapshot ¶
type LookSnapshot struct {
Look *models.Look `json:"look"`
FixtureValues []models.FixtureValue `json:"fixtureValues"`
}
LookSnapshot captures the complete state of a look for undo/redo.
type OperationType ¶
type OperationType string
OperationType represents the type of operation performed.
const ( OperationTypeCreate OperationType = "CREATE" OperationTypeUpdate OperationType = "UPDATE" OperationTypeDelete OperationType = "DELETE" OperationTypeBulk OperationType = "BULK" )
type PlaybackController ¶
type PlaybackController interface {
// GoToCueNumber jumps to a specific cue by number with optional fade time override.
GoToCueNumber(ctx context.Context, cueListID string, cueNumber float64, fadeInTimeOverride *float64) error
// StopCueList stops playback for a cue list.
StopCueList(cueListID string)
}
PlaybackController defines the interface for playback operations needed by undo. This avoids circular dependencies with the playback package.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides undo/redo functionality.
func NewService ¶
func NewService( opRepo *repositories.OperationRepository, lookRepo *repositories.LookRepository, fixtureRepo *repositories.FixtureRepository, cueRepo *repositories.CueRepository, cueListRepo *repositories.CueListRepository, lookBoardRepo *repositories.LookBoardRepository, effectRepo *repositories.EffectRepository, projectRepo *repositories.ProjectRepository, pubSub *pubsub.PubSub, ) *Service
NewService creates a new undo service.
func (*Service) CaptureBulkLookState ¶
func (s *Service) CaptureBulkLookState(ctx context.Context, lookIDs []string) (*BulkLookUpdateSnapshot, error)
CaptureBulkLookState captures the complete state of multiple looks for atomic undo. Used by copyFixturesToLooks to enable single-undo for multi-look updates.
func (*Service) CaptureCueEffectState ¶
func (s *Service) CaptureCueEffectState(ctx context.Context, cueID, effectID string) (*CueEffectSnapshot, error)
CaptureCueEffectState captures the state of a cue-effect relationship for undo.
func (*Service) CaptureCueListState ¶
func (s *Service) CaptureCueListState(ctx context.Context, cueListID string) (*CueListSnapshot, error)
CaptureCueListState captures the complete state of a cue list for undo.
func (*Service) CaptureCueState ¶
CaptureCueState captures the complete state of a cue for undo.
func (*Service) CaptureEffectState ¶
CaptureEffectState captures the complete state of an effect for undo. This includes all EffectFixtures and their EffectChannels.
func (*Service) CaptureFixturePositions ¶
func (s *Service) CaptureFixturePositions(ctx context.Context, fixtureIDs []string) (*BulkFixturePositionSnapshot, error)
CaptureFixturePositions captures positions of multiple fixtures for bulk undo.
func (*Service) CaptureFixtureState ¶
func (s *Service) CaptureFixtureState(ctx context.Context, fixtureID string) (*FixtureInstanceSnapshot, error)
CaptureFixtureState captures the complete state of a fixture instance for undo.
func (*Service) CaptureLookBoardState ¶
func (s *Service) CaptureLookBoardState(ctx context.Context, lookBoardID string) (*LookBoardSnapshot, error)
CaptureLookBoardState captures the complete state of a look board for undo.
func (*Service) CaptureLookState ¶
CaptureLookState captures the complete state of a look for undo.
func (*Service) ClearHistory ¶
ClearHistory removes all operation history for a project.
func (*Service) DeleteEntityForUndo ¶
func (s *Service) DeleteEntityForUndo(ctx context.Context, entityType EntityType, entityID string) error
DeleteEntityForUndo handles deletion during undo of a CREATE operation.
func (*Service) GetOperationHistory ¶
func (s *Service) GetOperationHistory(ctx context.Context, projectID string, page, perPage int) ([]models.Operation, int64, error)
GetOperationHistory returns paginated operation history for a project.
func (*Service) GetStatus ¶
func (s *Service) GetStatus(ctx context.Context, projectID string) (*repositories.UndoRedoStatus, error)
GetStatus returns the current undo/redo status for a project.
func (*Service) JumpToOperation ¶
func (s *Service) JumpToOperation(ctx context.Context, projectID, operationID string) (*UndoRedoResult, error)
JumpToOperation moves to a specific operation in the history. This applies or reverts operations to reach the target sequence.
func (*Service) RecordOperation ¶
func (s *Service) RecordOperation( ctx context.Context, projectID string, opType OperationType, entityType EntityType, entityID string, description string, prevState interface{}, newState interface{}, relatedIDs []string, ) error
RecordOperation records an operation for undo/redo. prevState and newState should be snapshot structs (e.g., LookSnapshot). relatedIDs is used for bulk operations to track all affected entity IDs.
func (*Service) Redo ¶
Redo re-applies the last undone operation for a project. This uses an atomic pattern: get operation, apply snapshot, then confirm pointer update. If the snapshot fails to apply, the pointer is not modified.
func (*Service) SetPlaybackController ¶
func (s *Service) SetPlaybackController(pc PlaybackController)
SetPlaybackController sets the playback controller for cue playback undo/redo. This is called after initialization to avoid circular dependencies.