app

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package app contains the main application logic and UI model.

Index

Constants

View Source
const (
	TabAlerts = 0
	TabHosts  = 1
	TabEvents = 2
	TabGraphs = 3
	TabCount  = 4
)

Tab constants.

View Source
const (
	LogoutTimeout     = 5  // Seconds to wait for logout on shutdown
	MinTerminalWidth  = 60 // Minimum terminal width for usable UI
	MinTerminalHeight = 12 // Minimum terminal height for usable UI

	// Adaptive pane width thresholds
	NarrowTerminalWidth   = 80  // Below this, use narrow proportions
	StandardTerminalWidth = 120 // Above this, use wide proportions
)

Layout constants for UI rendering.

View Source
const (
	ObjectTypeTrigger = "0" // Trigger-based problem
)

Zabbix object type constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcknowledgeResultMsg

type AcknowledgeResultMsg struct {
	EventID string
	Success bool
	Err     error
}

AcknowledgeResultMsg is sent after acknowledging a problem.

type ClearErrorMsg

type ClearErrorMsg struct{}

ClearErrorMsg clears the current error display.

type CloseResultMsg added in v0.6.0

type CloseResultMsg struct {
	EventID string
	Success bool
	Err     error
}

CloseResultMsg is sent after closing a problem.

type ConnectedMsg

type ConnectedMsg struct {
	Version string
	Client  *zabbix.Client
}

ConnectedMsg is sent when successfully connected to Zabbix.

type DisconnectedMsg

type DisconnectedMsg struct {
	Err error
}

DisconnectedMsg is sent when disconnected from Zabbix.

type ErrorMsg

type ErrorMsg struct {
	Title   string
	Message string
	Err     error
}

ErrorMsg represents an error to be displayed to the user.

type EventsLoadedMsg

type EventsLoadedMsg struct {
	Events []zabbix.Event
	Err    error
}

EventsLoadedMsg is sent when events are loaded from Zabbix.

type HostCountsLoadedMsg

type HostCountsLoadedMsg struct {
	Counts *zabbix.HostCounts
	Err    error
}

HostCountsLoadedMsg is sent when host counts are loaded from Zabbix.

type HostHistoryLoadedMsg

type HostHistoryLoadedMsg struct {
	HostID  string
	History map[string][]zabbix.History
	Err     error
}

HostHistoryLoadedMsg is sent when history for a specific host is loaded.

type HostMacrosLoadedMsg

type HostMacrosLoadedMsg struct {
	HostID string
	Macros []zabbix.HostMacro
	Err    error
}

HostMacrosLoadedMsg is sent when macros for a host are loaded.

type HostTriggersLoadedMsg

type HostTriggersLoadedMsg struct {
	HostID          string
	Triggers        []zabbix.Trigger
	SelectTriggerID string // Optional: pre-select this trigger
	Err             error
}

HostTriggersLoadedMsg is sent when triggers for a host are loaded.

type HostUpdateResultMsg

type HostUpdateResultMsg struct {
	HostID  string
	Action  string // "enable", "disable", "update"
	Success bool
	Err     error
}

HostUpdateResultMsg is sent after a host update operation.

type HostsLoadedMsg

type HostsLoadedMsg struct {
	Hosts []zabbix.Host
	Err   error
}

HostsLoadedMsg is sent when hosts are loaded from Zabbix.

type IgnoreResultMsg added in v0.4.1

type IgnoreResultMsg struct {
	Added   bool   // true if added, false if removed
	Message string // status message to display
	Err     error
}

IgnoreResultMsg is sent after an ignore operation completes.

type ItemsLoadedMsg

type ItemsLoadedMsg struct {
	Items []zabbix.Item
	Err   error
}

ItemsLoadedMsg is sent when items are loaded from Zabbix.

type KeyMap

type KeyMap struct {
	// Navigation
	Up       key.Binding
	Down     key.Binding
	Left     key.Binding
	Right    key.Binding
	PageUp   key.Binding
	PageDown key.Binding
	Home     key.Binding
	End      key.Binding

	// Tab navigation
	NextTab key.Binding
	PrevTab key.Binding
	Tab1    key.Binding
	Tab2    key.Binding
	Tab3    key.Binding
	Tab4    key.Binding

	// Pane navigation
	NextPane key.Binding
	PrevPane key.Binding

	// Actions
	Select      key.Binding
	Acknowledge key.Binding
	AckMessage  key.Binding
	Refresh     key.Binding

	// Host editing
	EditTriggers  key.Binding
	EditMacros    key.Binding
	ToggleMonitor key.Binding

	// Alert ignoring
	Ignore      key.Binding
	ListIgnores key.Binding

	// Alert closing
	CloseAlert key.Binding

	// Filtering
	Filter         key.Binding
	ClearFilter    key.Binding
	SeverityFilter key.Binding

	// Modes
	Command key.Binding
	Help    key.Binding
	Escape  key.Binding
	Quit    key.Binding
}

KeyMap defines all key bindings for the application.

func DefaultKeyMap

func DefaultKeyMap() KeyMap

DefaultKeyMap returns the default key bindings.

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

FullHelp returns key bindings for the full help view.

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

ShortHelp returns key bindings for the short help view.

type MacroUpdateResultMsg

type MacroUpdateResultMsg struct {
	MacroID string
	Action  string // "create", "update", "delete"
	Success bool
	Err     error
}

MacroUpdateResultMsg is sent after a macro update operation.

type Mode

type Mode int

Mode represents the current input mode.

const (
	ModeNormal Mode = iota
	ModeFilter
	ModeCommand
	ModeAckMessage
)

Mode constants for input handling.

type Model

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

Model is the main application model.

func New

func New(cfg *config.Config, t *theme.Theme) *Model

New creates a new application model.

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the application.

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

SetSize updates the window dimensions.

func (*Model) Shutdown

func (m *Model) Shutdown()

Shutdown performs cleanup.

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles all incoming messages and updates the model accordingly.

func (Model) View

func (m Model) View() string

View renders the entire application UI.

type Pane

type Pane int

Pane represents a focusable pane in the UI.

const (
	PaneList Pane = iota // PaneList is the left pane (alerts or hosts list)
	PaneDetail
)

Pane constants for UI focus management.

type ProblemsLoadedMsg

type ProblemsLoadedMsg struct {
	Problems []zabbix.Problem
	Err      error
}

ProblemsLoadedMsg is sent when problems are loaded from Zabbix.

type RefreshTickMsg

type RefreshTickMsg struct{}

RefreshTickMsg is sent periodically to trigger data refresh.

type TriggerUpdateResultMsg

type TriggerUpdateResultMsg struct {
	TriggerID string
	Action    string // "enable", "disable", "update"
	Success   bool
	Err       error
}

TriggerUpdateResultMsg is sent after a trigger update operation.

Jump to

Keyboard shortcuts

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