dashboards

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColumnWidth14 = 14
	ColumnWidth15 = 15
	ColumnWidth20 = 20
	ColumnWidth24 = 24
	ColumnWidth25 = 25
	ColumnWidth30 = 30
	ColumnWidth33 = 33
	ColumnWidth49 = 49
	ColumnWidth99 = 20
	ColumnWidth19 = 19
	RowHeight14   = 14
)

Variables

View Source
var (
	ColumnsConfigNode = ColumnsConfig{

		enums.ColumnNameCurrentEpoch:          ColumnWidth33,
		enums.ColumnNameNetworkPeers:          ColumnWidth15,
		enums.ColumnNameUptime:                ColumnWidth25,
		enums.ColumnNameVersion:               ColumnWidth25,
		enums.ColumnNameCommit:                ColumnWidth25,
		enums.ColumnNameCheckpointExecBacklog: ColumnWidth33,
		enums.ColumnNameCheckpointSyncBacklog: ColumnWidth33,

		enums.ColumnNameTotalTransactionBlocks:       ColumnWidth33,
		enums.ColumnNameTotalTransactionCertificates: ColumnWidth33,
		enums.ColumnNameTotalTransactionEffects:      ColumnWidth33,
		enums.ColumnNameTXSyncPercentage:             ColumnWidth49,
		enums.ColumnNameTransactionsPerSecond:        ColumnWidth49,

		enums.ColumnNameLatestCheckpoint:        ColumnWidth24,
		enums.ColumnNameHighestKnownCheckpoint:  ColumnWidth24,
		enums.ColumnNameHighestSyncedCheckpoint: ColumnWidth24,
		enums.ColumnNameLastExecutedCheckpoint:  ColumnWidth24,
		enums.ColumnNameCheckSyncPercentage:     ColumnWidth49,
		enums.ColumnNameCheckpointsPerSecond:    ColumnWidth49,
	}

	RowsConfigNode = RowsConfig{
		0: {
			Height: RowHeight14,
			Columns: []enums.ColumnName{
				enums.ColumnNameNetworkPeers,
				enums.ColumnNameUptime,
				enums.ColumnNameVersion,
				enums.ColumnNameCommit,
			},
		},
		1: {
			Height: RowHeight14,
			Columns: []enums.ColumnName{
				enums.ColumnNameCurrentEpoch,
				enums.ColumnNameCheckpointExecBacklog,
				enums.ColumnNameCheckpointSyncBacklog,
			},
		},
		2: {
			Height: RowHeight14,
			Columns: []enums.ColumnName{
				enums.ColumnNameLatestCheckpoint,
				enums.ColumnNameHighestKnownCheckpoint,
				enums.ColumnNameHighestSyncedCheckpoint,
				enums.ColumnNameLastExecutedCheckpoint,
			},
		},
		3: {
			Height: RowHeight14,
			Columns: []enums.ColumnName{
				enums.ColumnNameCheckSyncPercentage,
				enums.ColumnNameCheckpointsPerSecond,
			},
		},
		4: {
			Height: RowHeight14,
			Columns: []enums.ColumnName{
				enums.ColumnNameTotalTransactionBlocks,
				enums.ColumnNameTotalTransactionCertificates,
				enums.ColumnNameTotalTransactionEffects,
			},
		},
		5: {
			Height: RowHeight14,
			Columns: []enums.ColumnName{
				enums.ColumnNameTXSyncPercentage,
				enums.ColumnNameTransactionsPerSecond,
			},
		},
	}

	CellsConfigNode = CellsConfig{
		enums.ColumnNameNetworkPeers:                 {"NETWORK PEERS", cell.ColorGreen},
		enums.ColumnNameUptime:                       {"UPTIME", cell.ColorGreen},
		enums.ColumnNameVersion:                      {"VERSION", cell.ColorGreen},
		enums.ColumnNameCommit:                       {"COMMIT", cell.ColorGreen},
		enums.ColumnNameCurrentEpoch:                 {"CURRENT EPOCH", cell.ColorGreen},
		enums.ColumnNameCheckpointExecBacklog:        {"CHECKPOINT EXEC BACKLOG", cell.ColorGreen},
		enums.ColumnNameCheckpointSyncBacklog:        {"CHECKPOINT SYNC BACKLOG", cell.ColorGreen},
		enums.ColumnNameHighestKnownCheckpoint:       {"HIGHEST KNOWN CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameHighestSyncedCheckpoint:      {"HIGHEST SYNCED CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameLastExecutedCheckpoint:       {"LAST EXECUTED CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameLatestCheckpoint:             {"LATEST CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameCheckSyncPercentage:          {"CHECKPOINTS SYNC PERCENTAGE", cell.ColorBlue},
		enums.ColumnNameCheckpointsPerSecond:         {"CHECKPOINTS VOLUME", cell.ColorBlue},
		enums.ColumnNameTotalTransactionBlocks:       {"TOTAL TRANSACTION BLOCKS", cell.ColorYellow},
		enums.ColumnNameTotalTransactionCertificates: {"TOTAL TRANSACTION CERTIFICATES", cell.ColorYellow},
		enums.ColumnNameTotalTransactionEffects:      {"TOTAL TRANSACTION EFFECTS", cell.ColorYellow},
		enums.ColumnNameTransactionsPerSecond:        {"TRANSACTIONS VOLUME", cell.ColorYellow},
		enums.ColumnNameTXSyncPercentage:             {"TRANSACTIONS SYNC PERCENTAGE", cell.ColorYellow},
	}
)
View Source
var (
	ColumnsConfigValidator = ColumnsConfig{

		enums.ColumnNameCurrentEpoch: ColumnWidth20,
		enums.ColumnNameUptime:       ColumnWidth25,
		enums.ColumnNameVersion:      ColumnWidth25,
		enums.ColumnNameCommit:       ColumnWidth25,

		enums.ColumnNameTotalTransactionCertificates: ColumnWidth33,
		enums.ColumnNameTotalTransactionEffects:      ColumnWidth33,
		enums.ColumnNameCertificatesCreated:          ColumnWidth33,
		enums.ColumnNameCertificatesPerSecond:        ColumnWidth49,

		enums.ColumnNameLastExecutedCheckpoint:  ColumnWidth33,
		enums.ColumnNameHighestKnownCheckpoint:  ColumnWidth33,
		enums.ColumnNameHighestSyncedCheckpoint: ColumnWidth33,
		enums.ColumnNameCheckSyncPercentage:     ColumnWidth49,
		enums.ColumnNameCheckpointsPerSecond:    ColumnWidth49,

		enums.ColumnNameCurrentRound:          ColumnWidth33,
		enums.ColumnNameHighestProcessedRound: ColumnWidth33,
		enums.ColumnNameLastCommittedRound:    ColumnWidth33,
		enums.ColumnNameRoundsPerSecond:       ColumnWidth49,

		enums.ColumnNameNetworkPeers:        ColumnWidth19,
		enums.ColumnNamePrimaryNetworkPeers: ColumnWidth19,
		enums.ColumnNameWorkerNetworkPeers:  ColumnWidth19,

		enums.ColumnNameSkippedConsensusTransactions: ColumnWidth19,
		enums.ColumnNameTotalSignatureErrors:         ColumnWidth19,
	}

	RowsConfigValidator = RowsConfig{
		0: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameCurrentEpoch,
				enums.ColumnNameUptime,
				enums.ColumnNameVersion,
				enums.ColumnNameCommit,
			},
		},
		1: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameNetworkPeers,
				enums.ColumnNamePrimaryNetworkPeers,
				enums.ColumnNameWorkerNetworkPeers,
				enums.ColumnNameSkippedConsensusTransactions,
				enums.ColumnNameTotalSignatureErrors,
			},
		},
		2: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameLastExecutedCheckpoint,
				enums.ColumnNameHighestKnownCheckpoint,
				enums.ColumnNameHighestSyncedCheckpoint,
			},
		},
		3: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameCheckSyncPercentage,
				enums.ColumnNameCheckpointsPerSecond,
			},
		},
		4: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameTotalTransactionCertificates,
				enums.ColumnNameTotalTransactionEffects,
				enums.ColumnNameCertificatesCreated,
			},
		},
		5: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameCurrentRound,
				enums.ColumnNameHighestProcessedRound,
				enums.ColumnNameLastCommittedRound,
			},
		},
		6: {
			Height: ColumnWidth14,
			Columns: []enums.ColumnName{
				enums.ColumnNameCertificatesPerSecond,
				enums.ColumnNameRoundsPerSecond,
			},
		},
	}

	CellsConfigValidator = CellsConfig{
		enums.ColumnNameCurrentEpoch:                            {"CURRENT EPOCH", cell.ColorGreen},
		enums.ColumnNameUptime:                                  {"UPTIME", cell.ColorGreen},
		enums.ColumnNameVersion:                                 {"VERSION", cell.ColorGreen},
		enums.ColumnNameCommit:                                  {"COMMIT", cell.ColorGreen},
		enums.ColumnNameNetworkPeers:                            {"SUI NETWORK PEERS", cell.ColorGreen},
		enums.ColumnNamePrimaryNetworkPeers:                     {"PRIMARY NETWORK PEERS", cell.ColorGreen},
		enums.ColumnNameWorkerNetworkPeers:                      {"WORKER NETWORK PEERS", cell.ColorGreen},
		enums.ColumnNameSkippedConsensusTransactions:            {"SKIPPED CONSENSUS TRANSACTIONS", cell.ColorGreen},
		enums.ColumnNameTotalSignatureErrors:                    {"TOTAL SIGNATURE ERRORS", cell.ColorGreen},
		enums.ColumnNameHighestKnownCheckpoint:                  {"HIGHEST KNOWN CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameHighestSyncedCheckpoint:                 {"HIGHEST SYNCED CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameLastExecutedCheckpoint:                  {"LAST EXECUTED CHECKPOINT", cell.ColorBlue},
		enums.ColumnNameCheckpointExecBacklog:                   {"CHECKPOINT EXEC BACKLOG", cell.ColorBlue},
		enums.ColumnNameCheckpointSyncBacklog:                   {"CHECKPOINT SYNC BACKLOG", cell.ColorBlue},
		enums.ColumnNameCheckSyncPercentage:                     {"CHECKPOINTS SYNC PERCENTAGE", cell.ColorBlue},
		enums.ColumnNameCheckpointsPerSecond:                    {"CHECKPOINTS VOLUME", cell.ColorBlue},
		enums.ColumnNameTotalTransactionCertificates:            {"TOTAL TRANSACTION CERTIFICATES", cell.ColorYellow},
		enums.ColumnNameTotalTransactionEffects:                 {"TOTAL TRANSACTION EFFECTS", cell.ColorYellow},
		enums.ColumnNameCertificatesCreated:                     {"CERTIFICATES CREATED", cell.ColorYellow},
		enums.ColumnNameCurrentRound:                            {"CURRENT ROUND", cell.ColorRed},
		enums.ColumnNameHighestProcessedRound:                   {"HIGHEST PROCESSED ROUND", cell.ColorRed},
		enums.ColumnNameLastCommittedRound:                      {"LAST COMMITTED ROUND", cell.ColorRed},
		enums.ColumnNameRoundsPerSecond:                         {"ROUNDS RATIO", cell.ColorRed},
		enums.ColumnNameCertificatesPerSecond:                   {"CERTIFICATES RATIO", cell.ColorYellow},
		enums.ColumnNameHandleCertificateNonConsensusLatencySum: {"CERTIFICATE NON CONSENSUS LATENCY", cell.ColorRed},
	}
)
View Source
var CellsConfigSystemState = CellsConfig{
	enums.ColumnNameCurrentEpoch:                                {"CURRENT EPOCH", cell.ColorGreen},
	enums.ColumnNameSystemEpochStartTimestamp:                   {"EPOCH START TIME UTC", cell.ColorGreen},
	enums.ColumnNameSystemEpochDuration:                         {"EPOCH DURATION", cell.ColorGreen},
	enums.ColumnNameSystemTimeTillNextEpoch:                     {"TIME TILL NEXT EPOCH", cell.ColorGreen},
	enums.ColumnNameSystemTotalStake:                            {"TOTAL STAKE, SUI", cell.ColorBlue},
	enums.ColumnNameSystemStorageFundTotalObjectStorageRebates:  {"STORAGE FUND TOTAL OBJECT REBATES, SUI", cell.ColorBlue},
	enums.ColumnNameSystemStorageFundNonRefundableBalance:       {"STORAGE FUND REFUNDABLE BALANCE, SUI", cell.ColorBlue},
	enums.ColumnNameSystemReferenceGasPrice:                     {"REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemMinReferenceGasPrice:                  {"MIN REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemMaxReferenceGasPrice:                  {"MAX REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemMeanReferenceGasPrice:                 {"MEAN REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemStakeWeightedMeanReferenceGasPrice:    {"STAKE WEIGHTED MEAN REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemMedianReferenceGasPrice:               {"MEDIAN REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemEstimatedReferenceGasPrice:            {"ESTIMATED REFERENCE GAS PRICE", cell.ColorYellow},
	enums.ColumnNameSystemStakeSubsidyBalance:                   {"STAKE SUBSIDY BALANCE, SUI", cell.ColorRed},
	enums.ColumnNameSystemStakeSubsidyStartEpoch:                {"STAKE SUBSIDY START EPOCH", cell.ColorRed},
	enums.ColumnNameSystemStakeSubsidyDistributionCounter:       {"STAKE SUBSIDY DISTRIBUTION COUNTER", cell.ColorRed},
	enums.ColumnNameSystemStakeSubsidyCurrentDistributionAmount: {"STAKE SUBSIDY DISTRIBUTION AMOUNT, SUI", cell.ColorRed},
	enums.ColumnNameSystemStakeSubsidyPeriodLength:              {"STAKE SUBSIDY PERIOD LENGTH", cell.ColorRed},
	enums.ColumnNameSystemStakeSubsidyDecreaseRate:              {"STAKE SUBSIDY DECREASE RATE", cell.ColorRed},
}

Functions

func NewColumnFixed

func NewColumnFixed(width int, elements ...grid.Element) grid.Element

NewColumnFixed creates a new column element with a fixed width and a list of sub-elements. The `width` parameter specifies the width of the column in pixels, and the `elements` parameter is a list of sub-elements that will be contained within the column.

func NewColumnPct

func NewColumnPct(width int, elements ...grid.Element) grid.Element

NewColumnPct creates a new column element with a width proportional to the total grid width and a list of sub-elements. The `width` parameter specifies the percentage of the grid width that the column should occupy, and the `elements` parameter is a list of sub-elements that will be contained within the column.

func NewRowFixed

func NewRowFixed(height int, elements ...grid.Element) grid.Element

NewRowFixed creates a new row element with a fixed height and a list of sub-elements. The `height` parameter specifies the height of the row in pixels, and the `elements` parameter is a list of sub-elements that will be contained within the row.

func NewRowPct

func NewRowPct(height int, elements ...grid.Element) grid.Element

NewRowPct creates a new row element with a height proportional to the total grid height and a list of sub-elements. The `height` parameter specifies the percentage of the grid height that the row should occupy, and the `elements` parameter is a list of sub-elements that will be contained within the row.

Types

type Cell

type Cell struct {
	LastUpdatedAt time.Time
	Widget        widgetapi.Widget
	Options       []container.Option
}

Cell is a struct that represents a single cell in a dashboard grid. It contains a widget and a list of options.

func NewCell

func NewCell(cellName string, color cell.Color, widget widgetapi.Widget) (*Cell, error)

NewCell is a function that creates a new Cell struct given a cellName and a widget. It returns a pointer to the new Cell and an error (if any).

func (Cell) GetWidget

func (c Cell) GetWidget() grid.Element

GetWidget is a method attached to the Cell struct that returns a widget that can be added to a dashboard grid.

func (*Cell) Write

func (c *Cell) Write(value any) error

Write writes a value to the cell widget. It accepts a value to write. The type of value must match the type expected by the cell widget. If the widget type is not recognized, the function returns nil.

type CellConfig

type CellConfig struct {
	Title string
	Color cell.Color
}

CellsConfig is a type that represents a mapping of column names to CellConfig.

type Cells

type Cells map[enums.ColumnName]*Cell

Cells is a type that represents a mapping of column names to pointers to Cell structs.

func GetCells

func GetCells(cellsConfig CellsConfig) (Cells, error)

GetCells creates a new set of cells based on the configuration provided. It accepts a CellsConfig object that maps column names to cell names, and a terminal object that represents the terminal where the cells will be displayed. It returns a Cells object and an error. The Cells object is a map that maps column names to cell objects.

type CellsConfig

type CellsConfig map[enums.ColumnName]CellConfig

CellsConfig is a type that represents a mapping of column names to CellConfig.

func GetCellsConfig

func GetCellsConfig(dashboard enums.TableType) (CellsConfig, error)

GetCellsConfig returns the cells configuration based on the specified dashboard type.

type ColumnOptions

type ColumnOptions map[enums.ColumnName]any

ColumnOptions represents a mapping between column names and their corresponding configuration options.

type ColumnValues

type ColumnValues map[enums.ColumnName]any

ColumnValues represents a mapping between column names and their corresponding values.

func GeSystemStateColumnValues

func GeSystemStateColumnValues(host *domainhost.Host) (ColumnValues, error)

GeSystemStateColumnValues returns a map of ColumnName values to corresponding values for a node at the specified index on the specified host. The function retrieves information about the node from the host's internal state and formats it into a map of NodeColumnName keys and corresponding values. The function also includes emoji values in the map if the specified flag is true.

func GetColumnsValues

func GetColumnsValues(dashboard enums.TableType, host *domainhost.Host) (ColumnValues, error)

GetColumnsValues returns the columns values based on the specified dashboard type and host.

func GetNodeColumnValues

func GetNodeColumnValues(host *domainhost.Host) (ColumnValues, error)

GetNodeColumnValues returns a map of ColumnName values to corresponding values for a node at the specified index on the specified host. The function retrieves information about the node from the host's internal state and formats it into a map of NodeColumnName keys and corresponding values. The function also includes emoji values in the map if the specified flag is true.

func GetRPCColumnValues

func GetRPCColumnValues(host *domainhost.Host) (ColumnValues, error)

GetRPCColumnValues returns a map of ColumnName values to corresponding values for a node at the specified index on the specified host. The function retrieves information about the node from the host's internal state and formats it into a map of NodeColumnName keys and corresponding values. The function also includes emoji values in the map if the specified flag is true.

func GetValidatorColumnValues

func GetValidatorColumnValues(host *domainhost.Host) (ColumnValues, error)

GetValidatorColumnValues returns a map of ColumnName values to corresponding values for a node at the specified index on the specified host. The function retrieves information about the node from the host's internal state and formats it into a map of NodeColumnName keys and corresponding values. The function also includes emoji values in the map if the specified flag is true.

type Columns

type Columns map[enums.ColumnName]grid.Element

Columns is a type that maps column names to their respective grid elements.

func GetColumns

func GetColumns(columnsConfig ColumnsConfig, cells Cells) (Columns, error)

GetColumns returns a slice of Columns based on the given ColumnsConfig and Cells.

type ColumnsConfig

type ColumnsConfig map[enums.ColumnName]int

ColumnsConfig is a type that maps column names to their respective widths.

func GetColumnsConfig

func GetColumnsConfig(dashboard enums.TableType) (ColumnsConfig, error)

GetColumnsConfig returns the columns configuration based on the specified dashboard type.

type RowConfig

type RowConfig struct {
	Columns []enums.ColumnName
	Height  int
}

RowConfig is a type that represents the configuration for a single row in a grid. It contains a height and a list of column names that should be included in the row.

type Rows

type Rows []grid.Element

Rows is a type that represents a set of grid rows, each of which is an element in the grid.

func GetRows

func GetRows(rowsConfig RowsConfig, columns Columns) (Rows, error)

GetRows creates a new set of rows based on the configuration provided. It accepts a RowsConfig object that specifies the height and columns for each row, a Cells object that maps cell names to cell objects, and a Columns object that maps column names to column objects. It returns a Rows object and an error. The Rows object is a slice of Row objects, where each Row object represents a row in the terminal grid.

type RowsConfig

type RowsConfig []RowConfig

RowsConfig is a type that represents the configuration for a set of rows in a grid. Each `RowConfig` contains a height and a list of column names that should be included in the row.

func GetRowsConfig

func GetRowsConfig(dashboard enums.TableType) (RowsConfig, error)

GetRowsConfig returns the rows configuration based on the specified dashboard type.

Jump to

Keyboard shortcuts

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