models

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalState = State{
	SearchStates:          make(map[string]*SearchState),
	FilteredNodes:         make([]*api.Node, 0),
	FilteredVMs:           make([]*api.VM, 0),
	FilteredTasks:         make([]*api.ClusterTask, 0),
	OriginalNodes:         make([]*api.Node, 0),
	OriginalVMs:           make([]*api.VM, 0),
	OriginalTasks:         make([]*api.ClusterTask, 0),
	PendingVMOperations:   make(map[string]string),
	PendingNodeOperations: make(map[string]string),
}

GlobalState is the singleton instance for UI state.

Functions

func FilterNodes

func FilterNodes(filter string)

FilterNodes filters the nodes based on the given search string.

func FilterTasks

func FilterTasks(filter string)

FilterTasks filters the tasks based on the given search string.

func FilterVMs

func FilterVMs(filter string)

FilterVMs filters the VMs based on the given search string.

func GetUILogger

func GetUILogger() interfaces.Logger

GetUILogger returns the UI logger, with fallback if not set.

func SetUILogger

func SetUILogger(logger interfaces.Logger)

SetUILogger sets the shared logger instance for UI components.

Types

type SearchState

type SearchState struct {
	CurrentPage   string
	Filter        string
	SelectedIndex int
}

SearchState holds the state for a search operation.

type State

type State struct {
	NodeList     tview.Primitive
	VMList       tview.Primitive
	SearchStates map[string]*SearchState

	// Current filtered lists
	FilteredNodes []*api.Node
	FilteredVMs   []*api.VM
	FilteredTasks []*api.ClusterTask

	// Original lists
	OriginalNodes []*api.Node
	OriginalVMs   []*api.VM
	OriginalTasks []*api.ClusterTask

	// Pending operations tracking
	PendingVMOperations   map[string]string // Key: "node:vmid", Value: operation description
	PendingNodeOperations map[string]string // Key: "nodename", Value: operation description
	// contains filtered or unexported fields
}

State holds all UI state components.

func (*State) CanVMPerformActions added in v1.0.6

func (s *State) CanVMPerformActions(vm *api.VM) bool

CanVMPerformActions checks if a VM can perform actions (no pending operations). Returns true if the VM can perform actions, false otherwise.

func (*State) ClearNodePending

func (s *State) ClearNodePending(node *api.Node)

ClearNodePending removes the pending operation status for a node.

func (*State) ClearVMPending

func (s *State) ClearVMPending(vm *api.VM)

ClearVMPending removes the pending operation status for a VM.

func (*State) GetSearchState

func (s *State) GetSearchState(component string) *SearchState

GetSearchState returns the search state for a given component.

func (*State) GetVMPendingOperation added in v1.0.6

func (s *State) GetVMPendingOperation(vm *api.VM) string

GetVMPendingOperation returns the pending operation description for a VM if any. Returns empty string if no operation is pending.

func (*State) HasPendingOperations

func (s *State) HasPendingOperations() bool

HasPendingOperations checks if there are any pending VM or node operations.

func (*State) IsNodePending

func (s *State) IsNodePending(node *api.Node) (bool, string)

IsNodePending checks if a node has a pending operation.

func (*State) IsVMPending

func (s *State) IsVMPending(vm *api.VM) (bool, string)

IsVMPending checks if a VM has a pending operation.

func (*State) SetNodePending

func (s *State) SetNodePending(node *api.Node, operation string)

SetNodePending marks a node as having a pending operation.

func (*State) SetVMPending

func (s *State) SetVMPending(vm *api.VM, operation string)

SetVMPending marks a VM as having a pending operation.

Jump to

Keyboard shortcuts

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