Documentation
¶
Overview ¶
Package graphs provides the graphs tree component for displaying Zabbix items.
Index ¶
- func ExtractCategory(key string, categories []string) string
- func FormatCategoryName(prefix string) string
- type HostExpandedMsg
- type Model
- func (m *Model) ClickNode(visibleIndex int) tea.Cmd
- func (m *Model) CollapseAll()
- func (m Model) Count() (total, visible int)
- func (m *Model) ExpandAll()
- func (m Model) GetHistory(itemID string) []zabbix.History
- func (m Model) GetHostItems(hostID string) []zabbix.Item
- func (m *Model) GoToBottom()
- func (m *Model) GoToTop()
- func (m Model) HasHostHistory(hostID string) bool
- func (m Model) Init() tea.Cmd
- func (m Model) IsHostLoading(hostID string) bool
- func (m *Model) MergeHistory(history map[string][]zabbix.History)
- func (m *Model) MoveDown()
- func (m *Model) MoveUp()
- func (m *Model) PageDown()
- func (m *Model) PageUp()
- func (m *Model) Scroll(delta int)
- func (m Model) Selected() *TreeNode
- func (m Model) SelectedItem() *zabbix.Item
- func (m *Model) SetFocused(focused bool)
- func (m *Model) SetHistory(history map[string][]zabbix.History)
- func (m *Model) SetHostLoading(hostID string, loading bool)
- func (m *Model) SetItems(items []zabbix.Item, categories []string)
- func (m *Model) SetSize(width, height int)
- func (m *Model) SetStyles(styles *theme.Styles)
- func (m *Model) SetTextFilter(filter string)
- func (m *Model) Toggle() string
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) VisibleNodeCount() int
- type NodeType
- type Tree
- func (t *Tree) CollapseAll()
- func (t *Tree) ExpandAll()
- func (t *Tree) FindNodeIndex(id string) int
- func (t *Tree) GetNode(id string) *TreeNode
- func (t *Tree) GetVisibleNode(index int) *TreeNode
- func (t *Tree) ItemCount() int
- func (t *Tree) RebuildFlatList()
- func (t *Tree) ToggleNode(id string)
- func (t *Tree) VisibleCount() int
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractCategory ¶
ExtractCategory determines the category for an item based on its key. Returns the matching category prefix or "Other" if no match.
func FormatCategoryName ¶
FormatCategoryName formats a category key prefix into a display name.
Types ¶
type HostExpandedMsg ¶
type HostExpandedMsg struct {
HostID string
}
HostExpandedMsg is sent when a host node is expanded and needs history loading.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model represents the graphs tree component.
func (*Model) ClickNode ¶
ClickNode handles a click on a tree node at the given visible index. It selects the node and toggles expansion if it's a parent node. Returns a command if history needs to be loaded.
func (Model) GetHistory ¶
GetHistory returns the history data for an item.
func (Model) GetHostItems ¶
GetHostItems returns all items belonging to a specific host.
func (*Model) GoToBottom ¶
func (m *Model) GoToBottom()
GoToBottom moves the cursor to the last item.
func (Model) HasHostHistory ¶
HasHostHistory returns true if history has been loaded for any item of the host.
func (Model) IsHostLoading ¶
IsHostLoading returns true if the host is currently loading history.
func (*Model) MergeHistory ¶
MergeHistory adds history data for items without clearing existing data.
func (Model) SelectedItem ¶
SelectedItem returns the currently selected item (if the selection is an item node).
func (*Model) SetFocused ¶
SetFocused sets the focus state.
func (*Model) SetHistory ¶
SetHistory updates history data for items and regenerates sparklines.
func (*Model) SetHostLoading ¶
SetHostLoading sets the loading state for a host.
func (*Model) SetItems ¶
SetItems updates the items and rebuilds the tree, preserving expanded state.
func (*Model) SetStyles ¶ added in v0.5.0
SetStyles updates the component's styles (for runtime theme changes).
func (*Model) SetTextFilter ¶
SetTextFilter sets the text filter (not implemented for tree yet).
func (*Model) Toggle ¶
Toggle toggles expand/collapse of the current node. Returns the host ID if a host was expanded and needs history loading, empty string otherwise.
func (Model) VisibleNodeCount ¶
VisibleNodeCount returns the number of currently visible nodes.
type Tree ¶
type Tree struct {
Roots []*TreeNode // Top-level host nodes
FlatList []*TreeNode // Flattened visible nodes (for rendering)
AllNodes map[string]*TreeNode // All nodes by ID
ItemsByHost map[string][]zabbix.Item
}
Tree represents a collapsible tree of hosts, categories, and items.
func BuildTree ¶
BuildTree constructs a tree from items grouped by host and category. Items are organized as: Host -> Category -> Item
func (*Tree) FindNodeIndex ¶
FindNodeIndex returns the visible index of a node by ID.
func (*Tree) GetVisibleNode ¶
GetVisibleNode returns the node at the given visible index.
func (*Tree) RebuildFlatList ¶
func (t *Tree) RebuildFlatList()
RebuildFlatList regenerates the flattened list of visible nodes.
func (*Tree) ToggleNode ¶
ToggleNode toggles the collapsed state of a node.
func (*Tree) VisibleCount ¶
VisibleCount returns the number of visible nodes.
type TreeNode ¶
type TreeNode struct {
ID string // Unique identifier
Name string // Display name
Type NodeType // Type of node
Collapsed bool // Whether children are hidden
Children []*TreeNode // Child nodes
Depth int // Nesting depth
Item *zabbix.Item // For item nodes, the actual item
HostID string // Host ID for category/item nodes
Category string // Category name for item nodes
}
TreeNode represents a node in the tree structure.