view

package
v0.0.0-...-b6a6e00 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NODES_PAGE    = "nodes"
	JOBS_PAGE     = "jobs"
	SACCTMGR_PAGE = "sacctmgr"
	SACCT_PAGE    = "sacct"
	SDIAG_PAGE    = "sdiag"
	COMMAND_PAGE  = "command_modal"
)
View Source
const (
	SORT_NONE = 0
	SORT_ASC  = 1
	SORT_DESC = -1
)
View Source
const (
	// These constants make tview code more readable in column/row assignment operations.
	FRST_ROW = 0
	SCND_ROW = 1
	THRD_ROW = 2
	FRTH_ROW = 3
	FFTH_ROW = 4
	FRST_COL = 0
	SCND_COL = 1
	THRD_COL = 2
	FRTH_COL = 3
	FFTH_COL = 4
)
View Source
const (
	NO_KEY_FOUND = -1
)

Variables

View Source
var (
	BAD_STATE_COLOR      = tcell.ColorRed
	MID_STATE_COLOR      = tcell.ColorOrange
	SUCCESS_STATE_COLOR  = tcell.ColorSpringGreen
	RESUMING_STATE_COLOR = tcell.ColorLightCyan
	INACTIVE_STATE_COLOR = tcell.Color248 // Light Gray

	// StatePriorityList defines the order of precedence for color-coding states.
	// Earlier entries in the list take priority over later ones.
	StatePriorityList = []struct {
		State string
		Color tcell.Color
	}{

		{"POWERING_UP", RESUMING_STATE_COLOR},
		{"RESUMING", RESUMING_STATE_COLOR},
		{"REBOOTING", RESUMING_STATE_COLOR},

		{"BOOT_FAIL", BAD_STATE_COLOR},
		{"CANCELLED", BAD_STATE_COLOR},
		{"DEADLINE", BAD_STATE_COLOR},
		{"FAILED", BAD_STATE_COLOR},
		{"NODE_FAIL", BAD_STATE_COLOR},
		{"OUT_OF_MEMORY", BAD_STATE_COLOR},
		{"PREEMPTED", BAD_STATE_COLOR},
		{"TIMEOUT", BAD_STATE_COLOR},
		{"DOWN", BAD_STATE_COLOR},
		{"DRAINED", BAD_STATE_COLOR},
		{"DRAIN", BAD_STATE_COLOR},
		{"UNKNOWN", BAD_STATE_COLOR},
		{"UNK", BAD_STATE_COLOR},
		{"FAIL", BAD_STATE_COLOR},

		{"POWERED_DOWN", INACTIVE_STATE_COLOR},
		{"FUTURE", INACTIVE_STATE_COLOR},

		{"NO_RESPOND", BAD_STATE_COLOR},
		{"NOT_RESPONDING", BAD_STATE_COLOR},

		{"SUSPENDED", MID_STATE_COLOR},
		{"PENDING", MID_STATE_COLOR},
		{"DRAINING", MID_STATE_COLOR},
		{"POWERING_DOWN", MID_STATE_COLOR},
		{"POWER_DOWN", MID_STATE_COLOR},
		{"MAINT", MID_STATE_COLOR},
		{"BLOCKED", MID_STATE_COLOR},

		{"COMPLETED", SUCCESS_STATE_COLOR},
	}

	StatePatterns []StatePattern
)

Functions

func FormatNumberWithCommas

func FormatNumberWithCommas(n int) string

FormatNumberWithCommas adds thousand separators to an integer e.g., 1000 -> "1,000", 1000000 -> "1,000,000"

func GetKeyboardShortcutHelperForPage

func GetKeyboardShortcutHelperForPage(page string) string

Update helper keybinds

func GetStateColorMapping

func GetStateColorMapping(text string) (color tcell.Color, hasMapping bool)

func PadSelectorTitle

func PadSelectorTitle(title string) string

Types

type App

type App struct {
	App            *tview.Application
	Pages          *tview.Pages
	PagesContainer *tview.Flex // Container for pages with border title

	CurrentTableView    *tview.Table // Points to current table view
	FirstRenderComplete bool

	// Base app components
	HeaderGrid              *tview.Grid
	HeaderGridInnerContents *tview.Grid
	MainFlex                *tview.Flex
	FooterGrid              *tview.Grid

	// Footer
	HeaderLineOne   *tview.TextView
	HeaderLineTwo   *tview.TextView
	HeaderLineThree *tview.TextView

	// Current tab indicators
	TabNodesBox         *tview.TextView
	TabJobsBox          *tview.TextView
	TabSchedulerBox     *tview.TextView
	TabAccountingMgrBox *tview.TextView
	TabAccountingBox    *tview.TextView

	// Dropdown selectors
	PartitionSelector      *tview.DropDown
	SacctMgrEntitySelector *tview.DropDown
	NodeStateSelector      *tview.DropDown
	JobStateSelector       *tview.DropDown
	SortSelector           *tview.DropDown

	// Search state
	SearchBox     *tview.InputField
	SearchActive  bool
	SearchPattern string

	// Command modal state
	CommandModalOpen bool

	// Data  and providers
	PartitionsData     *model.TableData
	PartitionsProvider model.DataProvider[*model.TableData]
	NodesProvider      model.DataProvider[*model.TableData]
	JobsProvider       model.DataProvider[*model.TableData]
	SacctMgrProvider   model.DataProvider[*model.TableData]
	SacctProvider      model.DataProvider[*model.TableData]
	SdiagProvider      model.DataProvider[*model.TextData]

	// New style views
	NodesView    *StuiView
	JobsView     *StuiView
	SacctMgrView *StuiView
	SacctView    *StuiView
	SchedView    *tview.TextView // Special case, text only
	// contains filtered or unexported fields
}

func InitializeApplication

func InitializeApplication() *App

Initializes a `stui` instance tview Application using the config module

func (*App) ApplyHighlighting

func (a *App) ApplyHighlighting(text string) string

func (*App) ClearSelectionFromCurrentView

func (a *App) ClearSelectionFromCurrentView()

func (*App) CloseCommandModal

func (a *App) CloseCommandModal(commandPageName string, targetPage string, previousFocus tview.Primitive)

func (*App) ExecutePluginForShortcut

func (a *App) ExecutePluginForShortcut(key tcell.Key, page string, rowId string)

Exec a plugin command when on a particular page

func (*App) GetCurrentPage

func (a *App) GetCurrentPage() *tview.Primitive

func (*App) GetCurrentPageName

func (a *App) GetCurrentPageName() string

func (*App) GetCurrentStuiView

func (a *App) GetCurrentStuiView() *StuiView

func (*App) GetProviderForPage

func (a *App) GetProviderForPage(page string) model.DataProvider[*model.TableData]

func (*App) HideSearchBox

func (a *App) HideSearchBox()

func (*App) ParsePluginCommand

func (a *App) ParsePluginCommand(command string, data map[string]string, page string) string

func (*App) RefreshAndRenderCurrentView

func (a *App) RefreshAndRenderCurrentView()

func (*App) RefreshAndRenderPage

func (a *App) RefreshAndRenderPage(pageName string)

func (*App) RefreshClusterMetadata

func (a *App) RefreshClusterMetadata()

func (*App) RenderCurrentView

func (a *App) RenderCurrentView()

func (*App) SetHeaderGridInnerContents

func (a *App) SetHeaderGridInnerContents(content ...tview.Primitive)

Add each given primitive as a row to the top-left header area.

func (*App) SetupJobStateSelector

func (a *App) SetupJobStateSelector()

func (*App) SetupKeybinds

func (a *App) SetupKeybinds()

func (*App) SetupNodeStateSelector

func (a *App) SetupNodeStateSelector()

func (*App) SetupPartitionSelector

func (a *App) SetupPartitionSelector()

func (*App) SetupSacctMgrEntitySelector

func (a *App) SetupSacctMgrEntitySelector()

func (*App) SetupSearchBox

func (a *App) SetupSearchBox()

func (*App) SetupSortSelector

func (a *App) SetupSortSelector()

func (*App) SetupViews

func (a *App) SetupViews()

func (*App) ShowCommandModal

func (a *App) ShowCommandModal(command string, pageName string, executeImmediately bool, closeAfterExecute bool)

func (*App) ShowJobDetails

func (a *App) ShowJobDetails(jobID string)

func (*App) ShowModalPopupMinimal

func (a *App) ShowModalPopupMinimal(details string)

func (*App) ShowModalPopupString

func (a *App) ShowModalPopupString(title, details string)

func (*App) ShowModalPopupTable

func (a *App) ShowModalPopupTable(title string, table *tview.Table)

func (*App) ShowNodeDetails

func (a *App) ShowNodeDetails(nodeName string)

func (*App) ShowNotification

func (a *App) ShowNotification(text string, after time.Duration)

func (*App) ShowSacctJobDetails

func (a *App) ShowSacctJobDetails(jobID string)

func (*App) ShowSearchBox

func (a *App) ShowSearchBox(grid *tview.Grid)

func (*App) ShowStandardCommandModal

func (a *App) ShowStandardCommandModal(command string, selectedMap map[string]bool, pageName string)

func (*App) StartRefresh

func (a *App) StartRefresh()

Starts periodic background processes to refresh data

func (*App) SwitchToPage

func (a *App) SwitchToPage(pageName string)

func (*App) UpdateAppTitle

func (a *App) UpdateAppTitle()

func (*App) UpdateHeaderLineOne

func (a *App) UpdateHeaderLineOne(v string)

func (*App) UpdateHeaderLineTwo

func (a *App) UpdateHeaderLineTwo(v string)

type StatePattern

type StatePattern struct {
	State  string
	Color  tcell.Color
	Regexp *regexp.Regexp
}

type StuiView

type StuiView struct {
	// View components
	Table     *tview.Table
	Grid      *tview.Grid
	Selection map[string]bool
	// contains filtered or unexported fields
}

func NewStuiView

func NewStuiView(
	title string,
	provider model.DataProvider[*model.TableData],
	updateTitleFunc func(string) *tview.Box,
	errorNotifyFunc func(string),
	dataStateNotifyFunc func(string),
	cellClickFunction func(string),
	headerClickFunction func(int) *tview.DropDown,
	searchStringPointer *string,
) *StuiView

func (*StuiView) FetchAndRender

func (s *StuiView) FetchAndRender()

func (*StuiView) FetchIfStaleAndRender

func (s *StuiView) FetchIfStaleAndRender(since time.Duration)

func (*StuiView) Render

func (s *StuiView) Render()

func (*StuiView) SetFilter

func (s *StuiView) SetFilter(filter string)

func (*StuiView) SetSearchEnabled

func (s *StuiView) SetSearchEnabled(value bool)

func (*StuiView) SetTitleHeader

func (s *StuiView) SetTitleHeader(v string)

type StuiViewInt

type StuiViewInt interface {
	// Renders this component in tview, without affecting underlying data
	Render()

	// Sets regex filter for rows filtering
	SetFilter()

	// Sets search status
	SetSearchEnabled(bool)

	// Updates data from provider and renders the view
	FetchAndRender()
}

Jump to

Keyboard shortcuts

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