banners

package
v0.0.0-...-c77a6e9 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Banners

type Banners struct {
	observable.Implementation
	// contains filtered or unexported fields
}

Banners fetches banner information from remote.

func NewBanners

func NewBanners(devServers bool) *Banners

NewBanners makes a new Banners instance.

func (*Banners) Activate

func (banners *Banners) Activate(key MessageKey)

Activate invokes showing the message for the given key.

func (*Banners) Deactivate

func (banners *Banners) Deactivate(key MessageKey)

Deactivate removes the message key from the active map and makes the frontend reload the banner.

func (*Banners) GetMessage

func (banners *Banners) GetMessage(key MessageKey) *Message

GetMessage gets a message for a key if it was activated. nil otherwise, or if no msg exists.

func (*Banners) Init

func (banners *Banners) Init(httpClient *http.Client)

Init fetches the remote banners info. Should be called in a go-routine to be non-blocking.

type Message

type Message struct {
	// map of language code to message.
	Message map[string]string `json:"message"`
	// ID is a unique id of the message.
	ID string `json:"id"`
	// Link, if present, will be appended to the message.
	Link *struct {
		Href string  `json:"href"`
		Text *string `json:"text"`
	} `json:"link"`
	// Dismissible: if true the ID field will be the key of config.frontend map to keep
	// trace of dismissed banners (see status.tsx for details).
	Dismissible *bool     `json:"dismissible"`
	Type        *TypeCode `json:"type"`
}

Message is one entry in the banners json.

type MessageKey

type MessageKey string

MessageKey enumerates the possible keys in the banners json.

const (
	// KeyBitBox01 is the message key for the event when a BitBox01 gets connected.
	KeyBitBox01 MessageKey = "bitbox01"
	// KeyBitBox02 is the message key for the event when a BitBox02 gets connected.
	KeyBitBox02 MessageKey = "bitbox02"
	// KeyBitBox02Nova is the message key for the event when a BitBox02 Nova gets connected.
	KeyBitBox02Nova MessageKey = "bitbox02nova"
)

type TypeCode

type TypeCode string

TypeCode determines the type of banner.

const (
	// TypeWarning means the banner will be shown and styled as a warning.
	TypeWarning TypeCode = "warning"
	// TypeSuccess means the banner will be shown and styled as a success message.
	TypeSuccess TypeCode = "success"
	// TypeInfo means the banner will be shown and styled as an info.
	TypeInfo TypeCode = "info"
)

Jump to

Keyboard shortcuts

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