ui

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Text Format
	TitleFmt = " [lightcyan::b]%s "

	// Table Titles
	AlertsTableTitle          = "[ ALERTS ]"
	TrigerredAlertsTableTitle = "[ TRIGERRED ALERTS ]"
	HighAlertsTableTitle      = "[ TRIGERRED ALERTS - HIGH ]"
	LowAlertsTableTitle       = "[ TRIGERRED ALERTS - LOW ]"
	AlertMetadataViewTitle    = "[ ALERT DATA ]"
	IncidentsTableTitle       = "[ TRIGERRED INCIDENTS ]"
	AckIncidentsTableTitle    = "[ ACKNOWLEDGED INCIDENTS ]"
	OncallTableTitle          = "ONCALL"
	NextOncallTableTitle      = "[ NEXT ONCALL ]"
	AllTeamsOncallTableTitle  = "[ ALL TEAMS ONCALL ]"

	// Page Titles
	AlertsPageTitle          = "Alerts"
	AlertDataPageTitle       = "Metadata"
	AlertMetadata            = "AlertData"
	TrigerredAlertsPageTitle = "Trigerred"
	HighAlertsPageTitle      = "High Alerts"
	LowAlertsPageTitle       = "Low Alerts"
	IncidentsPageTitle       = "Incidents"
	AckIncidentsPageTitle    = "AckIncidents"
	OncallPageTitle          = "Oncall Layer"
	NextOncallPageTitle      = "Next Oncall"
	AllTeamsOncallPageTitle  = "All Teams Oncall"
	ServiceLogsPageTitle     = "Service Logs"

	//Footer
	FooterText                = "[Esc] Go Back"
	FooterTextAlerts          = "[R] Refresh Alerts | [1] Acknowledged Incidents | [2] Trigerred Incidents\n" + FooterText
	FooterTextTrigerredAlerts = "[1] Acknowledged Incidents | [2] Trigerred Incidents\n" + FooterText
	FooterTextIncidents       = "[ENTER] Select Incident | [CTRL+A] Acknowledge Incidents\n" + FooterText
	FooterTextOncall          = "[N] Your Next Oncall Schedule | [A] All Teams Oncall | [<-] Previous Layer Oncall | [->] Next Layer Oncall \n" + FooterText
	TerminalFooterText        = "" /* 164-byte string literal not displayed */
	TerminalFooterEscapeState = "Enter the Slide Number to Switch To : "

	// Colors
	TableTitleColor                = tcell.ColorLightCyan
	BorderColor                    = tcell.ColorLightGray
	FooterTextColor                = tcell.ColorGray
	InfoTextColor                  = tcell.ColorLightSlateGray
	ErrorTextColor                 = tcell.ColorRed
	PromptTextColor                = tcell.ColorLightGreen
	LoggerTextColor                = tcell.ColorGreen
	TerminalFooterTextColor        = tcell.ColorGreen
	TerminalFooterEscapeStateColor = tcell.ColorDarkGreen
)

Variables

View Source
var CurrentActivePage int = 0
View Source
var CursorPos int
View Source
var TotalPageCount int = 0

Functions

func AddNewSlide added in v0.1.0

func AddNewSlide(tui *TUI, name string, command string, args []string, isCluster bool)

Adds a slide to the end of currently present slides

func AddSOPSlide added in v0.1.0

func AddSOPSlide(name string, textView *tview.TextView, tui *TUI)

Adds a SOP slide to the end of currently present slides

func InitTerminalMux added in v0.1.0

func InitTerminalMux(tui *TUI, kiteTab *TerminalTab) *tview.Flex

Init the Layout for Terminal Multiplexer

func NextSlide added in v0.1.0

func NextSlide(tui *TUI)

Move to the next slide

func PreviousSlide added in v0.1.0

func PreviousSlide(tui *TUI)

Move to the previous slide

func RemoveSlide added in v0.1.0

func RemoveSlide(s int, tui *TUI)

Remove the slide with the given index Exit the app if only one slide is present

func SwitchToSlide added in v0.1.0

func SwitchToSlide(slideNum int, tui *TUI)

Navigate to the specified slide

func ViewAlertSOP added in v0.1.0

func ViewAlertSOP(tui *TUI, URL string)

App Setup

Types

type TUI

type TUI struct {

	// Main UI elements
	App                 *tview.Application
	AlertMetadata       *tview.TextView
	Table               *tview.Table
	IncidentsTable      *tview.Table
	NextOncallTable     *tview.Table
	AllTeamsOncallTable *tview.Table
	Pages               *tview.Pages
	SecondaryWindow     *tview.TextView
	LogWindow           *tview.TextView
	Layout              *tview.Flex
	Footer              *tview.TextView
	ServiceLogView      *tview.TextView
	FrontPage           string

	// API related
	Client       client.PagerDutyClient
	IncidentOpts pagerduty.ListIncidentsOptions
	Alerts       []pdcli.Alert

	// Internals
	SelectedIncidents map[string]string
	Incidents         [][]string
	AckIncidents      []string
	AssignedTo        string
	Username          string
	Role              string
	Columns           string
	ClusterID         string
	ClusterName       string
	CurrentOnCallPage int

	// SOP Related
	SOPLink  string
	NumLinks int
	SOPView  *tview.TextView

	// Multi-Window Terminals Related
	TerminalLayout      *tview.Flex
	TerminalPages       *tview.Pages
	TerminalPageBar     *tview.TextView
	TerminalFixedFooter *tview.TextView
	TerminalTabs        []TerminalTab
	TerminalUIRegionIDs []int
	TerminalInputBuffer []rune
	TerminalLastChars   []rune
}

func (*TUI) Init

func (tui *TUI) Init()

Init initializes all the TUI main elements.

func (*TUI) InitAlertDataSecondaryView added in v0.1.0

func (tui *TUI) InitAlertDataSecondaryView()

func (*TUI) InitAlertsSecondaryView added in v0.1.0

func (tui *TUI) InitAlertsSecondaryView()

func (*TUI) InitAlertsUI

func (tui *TUI) InitAlertsUI(alerts []pdcli.Alert, tableTitle string, pageTitle string)

InitAlertsUI initializes TUI table component. It adds the returned table as a new TUI page view.

func (*TUI) InitIncidentsUI

func (tui *TUI) InitIncidentsUI(incidents [][]string, tableTitle string, pageTitle string, isSelectable bool)

InitIncidentsUI initializes TUI table component. It adds the returned table as a new TUI page view.

func (*TUI) InitOnCallSecondaryView added in v0.1.0

func (tui *TUI) InitOnCallSecondaryView(user string, primary string, secondary string)

func (*TUI) InitTable

func (tui *TUI) InitTable(headers []string, data [][]string, isSelectable bool, isFirstColSelectable bool, title string) *tview.Table

InitTable initializes TUI table component with the given data and retuns a tview table primitive.

func (*TUI) SeedAckIncidentsUI

func (tui *TUI) SeedAckIncidentsUI()

SeedAckIncidentsUI fetches acknlowedged incidents and initializes a TUI table/page component.

func (*TUI) SeedAlertsUI added in v0.0.2

func (tui *TUI) SeedAlertsUI()

SeedIncidentsUI fetches acknowledged incident alerts and initializes a TUI table/page component.

func (*TUI) SeedIncidentsUI

func (tui *TUI) SeedIncidentsUI()

SeedIncidentsUI fetches trigerred incidents and initializes a TUI table/page component.

func (*TUI) SetAlertsTableEvents

func (tui *TUI) SetAlertsTableEvents(alerts []pdcli.Alert)

SetAlertsTableEvents is the event handler for the alerts table. It handles the program flow when a table selection is made.

func (*TUI) SetIncidentsTableEvents

func (tui *TUI) SetIncidentsTableEvents()

SetIncidentsTableEvents is the event handler for the incidents table in ack mode. It handles the program flow when a table selection is made.

func (*TUI) StartApp

func (t *TUI) StartApp() error

StartApp sets the UI layout and renders all the TUI elements.

type TerminalTab added in v0.1.0

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

Declares the tab struct

func InitKiteTab added in v0.1.0

func InitKiteTab(tui *TUI, layout *tview.Flex) *TerminalTab

Creates and return a new kite tab

func InitSOPTab added in v0.1.0

func InitSOPTab(name string, layout *tview.TextView, tui *TUI) *TerminalTab

Creates and returns a SOP tab

func NewTab added in v0.1.0

func NewTab(name string, command string, args []string, tui *TUI) *TerminalTab

Creates and return a new tab

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳