ui2

package
v1.3.106 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package ui2 pkg/visor/ui2/apps.go c3-vis-core

templ: version: v0.3.1070

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/contacts.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/dmsg.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/i18n.go c3-vis-core

Package ui2 pkg/visor/ui2/info.go c3-vis-core

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/logs.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/mail.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/nodes.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/paging.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/rewards.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/routing.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/settings.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/tabs.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/transports.go c3-vis-core

templ: version: v0.3.1070

Package ui2 pkg/visor/ui2/ui2.go c3-vis-core

Package ui2 is a server rendered hypervisor UI built with templ and htmx. It only renders. The hypervisor handlers fetch the data from the visor API and hand it here, so the package carries no visor dependency.

Never use html/template or text/template here: they panic under TinyGo.

Package ui2 pkg/visor/ui2/uptime.go c3-vis-core

templ: version: v0.3.1070

templ: version: v0.3.1070

Index

Constants

View Source
const (
	FolderInbox  = "INBOX"
	FolderSent   = "Sent"
	FolderOutbox = "Outbox"
)

Mail folders, as the visor names them.

View Source
const HTMXVersion = "2.0.11"

HTMXVersion is the vendored static/htmx.min.js, checked against the npm tarball integrity of htmx.org@2.0.11.

View Source
const LangCookie = "ui2-lang"

LangCookie holds the chosen language. ui2.js keeps it in step with the Angular UI's "lang" localStorage entry.

View Source
const ListPageSize = 100

ListPageSize is how many rows a long list renders at once.

View Source
const LogMax = 1000

LogMax is how many entries the tab keeps, as the Angular one does.

Variables

View Source
var Langs = []Lang{
	{"en", "English"},
	{"es", "Español"},
	{"de", "Deutsch"},
	{"pt", "Português (Brazil)"},
	{"zh", "中文"},
}

Langs follows the languages list of the Angular UI (static/skywire-manager-src/src/app/app.config.ts).

View Source
var LogLevels = []struct {
	Level LogLevel
	Label string
}{
	{LevelUnknown, "All"}, {LevelDebug, "Debug+"}, {LevelInfo, "Info+"}, {LevelWarn, "Warn+"},
	{LevelError, "Error+"}, {LevelFatal, "Fatal+"}, {LevelPanic, "Panic"},
}

LogLevels are the filter buttons, as the Angular tab labels them.

View Source
var RoutingViews = []string{"rules", "groups", "find", "calc", "policies"}

RoutingViews are the routing tab's sub views, after routing.component.html. The mux tree is the route visualizer page.

View Source
var UptimeTiers = []string{"process", "dmsg", "skynet"}

UptimeTiers is the order the Angular tab draws the tiers in.

View Source
var VisorTabs = []Tab{
	{"info", "node.tabs.info", "info"},
	{"routing", "node.tabs.routing", "shuffle"},
	{"transports", "node.tabs.transports", "swap_horiz"},
	{"bandwidth", "node.tabs.bandwidth", "equalizer"},
	{"uptime", "node.tabs.uptime", "schedule"},
	{"apps", "node.tabs.apps", "apps"},
	{"chat", "node.tabs.chat", "forum"},
	{"mail", "node.tabs.mail", "mail"},
	{"contacts", "node.tabs.contacts", "contacts"},
	{"rewards", "node.tabs.rewards", "monetization_on"},
	{"dmsg", "node.tabs.dmsg", "device_hub"},
	{"skynet", "node.tabs.skynet", "public"},
	{"web-proxy", "node.tabs.web-proxy", "language"},
	{"vpn", "node.tabs.vpn", "vpn_lock"},
	{"resources", "node.tabs.resources", "memory"},
	{"terminal", "node.tabs.terminal", "code"},
	{"wallet", "node.tabs.wallet", "account_balance_wallet"},
	{"logs", "node.tabs.logs", "description"},
	{"settings", "node.tabs.settings", "tune"},
}

VisorTabs follows the Angular UI's node tabs (static/skywire-manager-src/src/app/utils/node-tabs.ts), with the DMSG tab that Angular reaches by route. A tab without its own ui2 route renders a link to the classic one.

Functions

func Addrs

func Addrs(s string) []string

Addrs splits an address field on commas, semicolons and spaces.

func AppHelp

func AppHelp(text, errMsg string) templ.Component

AppHelp is an app's --help output.

func AppLogs

func AppLogs(pk, name string, lines []string, errMsg string) templ.Component

AppLogs is the recent log of one app.

func AppSettings

func AppSettings(pk string, x App, errMsg string) templ.Component

AppSettings is the settings form of one app: its args, environment, launcher mode and autostart, as the Angular settings panel edits them.

func AppsPage

func AppsPage(a Apps) templ.Component

AppsPage is the apps tab: the lists, and a panel for one app's settings or logs.

func AppsRows

func AppsRows(a Apps) templ.Component

AppsRows is both lists. It polls itself so a started app shows as running.

func AppsRowsOOB

func AppsRowsOOB(a Apps) templ.Component

AppsRowsOOB is AppsRows as an out of band swap.

func ArgsString

func ArgsString(args []string) string

ArgsString joins args into one shell-like line, quoting the ones with spaces or quotes, as app-settings.component.ts does.

func Asset

func Asset(name string) string

Asset is the URL of a static file, relative to the page's <base>, carrying its content hash so it can be cached for good.

func AssetVersion

func AssetVersion(name string) string

AssetVersion is the content hash of a static file, or "" if there is none.

func BaseFor

func BaseFor(path string) string

BaseFor is the relative path from the request path back to the root. Every URL in a page is relative to it, so pages keep working under the /vnet/<port>/ prefix the in-tab visor's service worker adds.

func Bytes

func Bytes(n uint64) string

Bytes prints a byte count with a binary unit.

func ChatPage

func ChatPage(pk string) templ.Component

ChatPage hosts the Angular UI's chat tab in its chrome-less embed mode, as the wasm desktop's chat window does. Chat and voice are not reimplemented. The skychat page behind the proxy cannot be hosted: it asks for /sse at the root.

func ClassicURL

func ClassicURL(pk, seg string) string

ClassicURL is the Angular UI's route for the same visor tab.

func ConfigEdit

func ConfigEdit(pk, raw, errMsg string) templ.Component

ConfigEdit is the runtime config in a text area.

func ConfigView

func ConfigView(pk, raw, msg string) templ.Component

ConfigView shows the runtime config, read only.

func ContactsPage

func ContactsPage(l List) templ.Component

ContactsPage is the contacts tab. Fragments below replace parts of it.

func Count

func Count(n int, oob bool) templ.Component

func DmsgClients

func DmsgClients(d Dmsg) templ.Component

DmsgClients lists each client's sessions, refreshed every 5 seconds as the Angular tab does.

func DmsgOf

DmsgOf lists the clients a visor runs, main first.

func DmsgPage

func DmsgPage(d Dmsg) templ.Component

DmsgPage is the dmsg tab.

func DmsgResult

func DmsgResult(d Dmsg) templ.Component

DmsgResult is the outcome of connect-all or of a new sessions_count.

func EnvLines

func EnvLines(s string) []string

EnvLines is the non-blank lines of the environment textarea.

func ErrorBox

func ErrorBox(msg string) templ.Component

ErrorBox shows an error the page could not avoid, such as a visor that did not answer.

func Folder

func Folder(s string) string

Folder is a known folder name, INBOX for anything else.

func FormView

func FormView(f Form) templ.Component

FormView is the panel in edit mode.

func GroupsView

func GroupsView(groups []Group, errMsg string) templ.Component

GroupsView is the active route groups table.

func HealthClass

func HealthClass(s string) string

HealthClass names a health value: ok, bad, or still waiting.

func InfoLive

func InfoLive(i Info) templ.Component

InfoLive is the part of the info tab that refreshes itself.

func InfoPage

func InfoPage(i Info) templ.Component

InfoPage is the info tab: the live overview, then the visor's ports, router settings and runtime config, and the restart and turn off actions.

func Latency

func Latency(d time.Duration) string

Latency prints a dmsg server's latency, or "" when not measured.

func LatencyClass

func LatencyClass(d time.Duration) string

LatencyClass marks slow servers the way the Angular tab does.

func Layout

func Layout(title, classic string) templ.Component

Layout is the whole document around a page. classic is the same page's route in the Angular UI.

func ListSearch

func ListSearch(url, target, scope, placeholder string, q ListQuery) templ.Component

ListSearch is the filter box of a paged list. scope holds the box and the list, so a redraw keeps the sort and the page asks for page one.

func ListState

func ListState(p Pager) templ.Component

ListState carries the sort and page of a paged list into the next request.

func ListText

func ListText(pks []cipher.PubKey, def bool) string

ListText is a helper or relay list for its textarea: empty for the default, "none" for an empty list.

func ListView

func ListView(l List) templ.Component

ListView is the panel in list mode: the bar and the rows.

func LogBody

func LogBody(l Logs) templ.Component

LogBody is the list and its poller, swapped whole when a filter changes.

func LogMore

func LogMore(l Logs) templ.Component

LogMore is one poll: the new entries, appended out of band, and the next poller.

func LoginPage

func LoginPage(create bool, errMsg string) templ.Component

LoginPage logs in, or with create set makes the first account. It posts as a plain form, so it works before any script has loaded.

func LogsPage

func LogsPage(l Logs) templ.Component

LogsPage is the runtime log viewer.

func MailAPI

func MailAPI(pk, folder, id, rest string) string

MailAPI is a JSON mail route for a message, such as its raw download.

func MailBody

func MailBody(m Mail) templ.Component

MailBody is the whole tab below the tab bar. Every action swaps it, so the counts in the folder bar stay current.

func MailPage

func MailPage(m Mail) templ.Component

MailPage is the mail tab.

func MailURL

func MailURL(pk, rest string, kv ...string) string

MailURL is a mail tab URL with query pairs.

func Millis

func Millis(d time.Duration) string

Millis prints a duration as whole milliseconds, or "" for zero.

func MinHops

func MinHops(pk, minHops string, edit bool, errMsg string) templ.Component

MinHops shows the visor's minimum hops, or with edit set the form that changes it.

func NodeRows

func NodeRows(ns []Node, errMsg string, oob bool) templ.Component

NodeRows is the table, which polls itself every 10 seconds as the Angular list does by default. ui2.js applies the Angular UI's labels and the filter after every swap.

func NodesPage

func NodesPage(ns []Node, errMsg string) templ.Component

NodesPage is the list of visors this hypervisor manages.

func NotPorted

func NotPorted(pk, seg string) templ.Component

NotPorted stands in for a tab the new UI does not have yet.

func PKLines

func PKLines(pks []cipher.PubKey) string

PKLines is keys one per line.

func PagerNav

func PagerNav(p Pager, url, target string) templ.Component

PagerNav shows which rows are on screen and moves between pages.

func ParsePKList

func ParsePKList(s string) ([]cipher.PubKey, error)

ParsePKList reads one key per line or comma separated.

func PathView

func PathView(q PathQuery) templ.Component

PathView is the route find or the route calculation form, with the paths it returned.

func Pct

func Pct(p float64) string

Pct prints a percentage with one decimal.

func PctClass

func PctClass(p float64) string

PctClass colors a percentage: good, fair or poor.

func PickLang

func PickLang(cookie, accept string) string

PickLang is the language named by the cookie, else the first supported one in an Accept-Language header, else English.

func PoliciesView

func PoliciesView(p Policies, errMsg string) templ.Component

PoliciesView is the routing policies view.

func Protocol

Protocol is how the client reached server pk, or "".

func RewardAddress

func RewardAddress(rw Rewards) templ.Component

RewardAddress shows the address, and with Editing set the form for it.

func RewardHistoryView

func RewardHistoryView(h RewardHistory) templ.Component

RewardHistoryView is what the reward system paid the visor.

func RewardRules

func RewardRules(text string) templ.Component

RewardRules is the binary's own copy of the reward rules.

func RewardsPage

func RewardsPage(rw Rewards) templ.Component

RewardsPage is the rewards tab: the reward address, the rules, and the reward system's history of the visor, loaded after the page.

func RoleKey

func RoleKey(role string) string

RoleKey names a dmsg client's role, as the Angular tab words it.

func RouterForm

func RouterForm(pk string, s *visorapi.RouterSettings, errMsg string) templ.Component

RouterForm edits the visor-wide dial settings.

func RoutingPage

func RoutingPage(pk string, minHops string, view string) templ.Component

RoutingPage is the routing tab: the min hops setting, then one sub view.

func Rows

func Rows(l List) templ.Component

Rows is the table the filter swaps.

func RulesList

func RulesList(r Rules) templ.Component

RulesList is one page of the routing rules table.

func RulesView

func RulesView(r Rules) templ.Component

RulesView is the routing rules view: the filter box and the list.

func SameRelease

func SameRelease(version, configVersion string) bool

SameRelease reports whether a visor version and the version that wrote its config are one release: a build adds its commit to the version the config records, which is not a mismatch.

func ServiceUptimes

func ServiceUptimes(rows []ServiceUptime) templ.Component

ServiceUptimes is the per-service table, loaded after the page.

func SettingsPage

func SettingsPage(s Settings) templ.Component

SettingsPage is the settings tab.

func SettingsPanel

func SettingsPanel(s Settings) templ.Component

SettingsPanel is the form, or the review of it.

func ShortTx

func ShortTx(id string) string

ShortTx is the start of a transaction id.

func Size

func Size(n int64) string

Size prints a byte count.

func SortNodes

func SortNodes(ns []Node)

SortNodes puts the hypervisor first, then online visors, then by name.

func SortTh

func SortTh(label, key string, p Pager, url, target string, num bool) templ.Component

SortTh is a column head that sorts the list by key.

func Static

func Static() fs.FS

Static is the CSS, JS and htmx the pages load, rooted at static/.

func T

func T(ctx context.Context, key string, args ...string) string

T translates key into the page language. args are name, value pairs that fill {{ name }} placeholders, as ngx-translate does.

func TerminalPage

func TerminalPage(pk string) templ.Component

TerminalPage hosts the hypervisor's dmsgpty terminal page.

func TimeOnline

func TimeOnline(ctx context.Context, secs float64) string

TimeOnline is the visor's uptime in the largest whole unit, as the Angular tab words it.

func Toast

func Toast(msg string, isErr bool) templ.Component

func TransportsBody

func TransportsBody(t Transports) templ.Component

TransportsBody is the part that polls: one page of the filtered list, and the summary out of band.

func TransportsPage

func TransportsPage(t Transports) templ.Component

TransportsPage is the transports tab: the summary and toggles, the add form and the list.

func TransportsSummary

func TransportsSummary(t Transports, oob bool) templ.Component

TransportsSummary is the count per type and the two switches. The list redraws it out of band, so one poll keeps both current.

func UptimeBars

func UptimeBars(u Uptime) templ.Component

UptimeBars is the window picker and the day bars. It refreshes every minute: the visor samples every five.

func UptimeOf

func UptimeOf(resp *visorapi.LocalUptimeResponse, now time.Time) ([]UpDay, []TierPct)

UptimeOf lays out the visor's tier bitmaps. A '.' slot was up; a slot of today at or after now has not happened yet.

func UptimePage

func UptimePage(u Uptime) templ.Component

UptimePage is the uptime tab: the visor's own tier bitmaps, then what the deployment services recorded of it.

func VisorError

func VisorError(pk, seg, msg string) templ.Component

VisorError is a visor tab whose visor could not be reached.

func VisorLayout

func VisorLayout(pk, seg string) templ.Component

VisorLayout is a visor page: its key, the tab bar and the tab's card.

func VisorURL

func VisorURL(pk, seg string) string

VisorURL is the ui2 URL of a visor tab, relative to the page's <base>.

func WalletPage

func WalletPage(pk string) templ.Component

WalletPage opens the dashboard's wallet and hosts its node settings page, as the Angular wallet tab does.

func When

func When(t time.Time) string

When prints a time in local time, or "" for the zero time.

func With

func With(ctx context.Context, p Page, c *Catalog) context.Context

With returns ctx carrying p, rendering with the catalog c.

Types

type Alert

type Alert struct {
	Warn bool
	Text string
}

Alert is one line of the overview's attention list.

type App

type App struct {
	Name         string
	Status       int
	Detail       string
	Port         string
	AutoStart    bool
	OTP          string
	Args         string
	Env          string
	LauncherMode string
}

App is one row of the apps tab.

func (App) Running

func (a App) Running() bool

Running reports whether the app is up or coming up, as the Angular list tells start from stop.

type Apps

type Apps struct {
	PK       string
	Official []App
	Other    []App
	Err      string
	// Open is the app whose settings panel is shown.
	Open string
}

Apps is the apps tab: the official apps and the rest, as the Angular tab splits them.

func AppsOf

func AppsOf(pk string, states []*appserver.AppState) Apps

AppsOf sorts the visor's apps into the two lists, by name.

func (Apps) Find

func (a Apps) Find(name string) (App, bool)

Find is the app named name.

type Catalog

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

Catalog is the Angular UI's translation files, flattened to dotted keys.

func NewCatalog

func NewCatalog(fsys fs.FS) *Catalog

NewCatalog reads assets/i18n/<lang>.json from fsys as each language is first asked for. A nil fsys gives the keys themselves.

func (*Catalog) Get

func (c *Catalog) Get(lang, key string) string

Get is key in lang, else in English, else the key itself.

type Dmsg

type Dmsg struct {
	PK      string
	Clients []*visorapi.DmsgClientSessionInfo
	Count   int // the main client's sessions, the form's starting value
	Err     string
	Fetched string
	// Result and Action are the last connect-all or sessions_count outcome.
	Result *visorapi.DmsgConnectAllResult
	Action string
}

Dmsg is the dmsg tab: the visor's dmsg clients and their server sessions.

type Draft

type Draft struct {
	To, Cc, Subject, Body, InReplyTo string
}

Draft is the compose form.

func Reply

func Reply(folder string, m *skymail.Rendered) Draft

Reply fills a draft answering m, as the Angular tab does.

type Field

type Field struct {
	skyenvform.Row
	Draft   string
	Problem string
}

Field is one row of the form with what the user typed.

func FieldsOf

func FieldsOf(rows []skyenvform.Row, drafts map[string]string) ([]Field, int)

FieldsOf pairs the rows with the drafts, the file's values where the form gave none, and the problem each draft has.

func (Field) DefaultLabel

func (f Field) DefaultLabel() string

DefaultLabel is the bool select's default option.

func (Field) FilterText

func (f Field) FilterText() string

FilterText is what the filter box matches a field against.

func (Field) InputType

func (f Field) InputType() string

InputType hides a secret's value.

func (Field) Placeholder

func (f Field) Placeholder() string

Placeholder is a text field's hint while it is empty.

type Form

type Form struct {
	PK       string
	UID      string
	Name     string
	Keys     string
	Mail     string
	Payments string
	Groups   string
	Notes    string
	Err      string
}

Form is the edit form, with list fields as one entry per line.

func FormOf

func FormOf(pk string, c contacts.Contact) Form

FormOf fills the form from a contact.

func (Form) Contact

func (f Form) Contact() (contacts.Contact, error)

Contact parses the form back into a contact.

type Group

type Group struct {
	Initiator  bool
	Remote     string
	Ports      string
	FwdRID     string
	ConsumeRID string
	Hops       int
	NextTP     string
}

Group is one active route group row.

func GroupsOf

func GroupsOf(gs []visorapi.RouteGroupInfo) []Group

GroupsOf turns the visor's route groups into rows.

type Hypervisor

type Hypervisor struct {
	PK    string
	Local bool   // the hypervisor serving this page
	State string // connected, disconnected or runtime
}

Hypervisor is one hypervisor key the visor knows, and how.

type Info

type Info struct {
	PK        string
	Sum       visorapi.Summary
	Err       string
	Ports     []KV
	Router    *visorapi.RouterSettings
	RouterErr string
}

Info is the info tab: the visor's summary and the settings shown under it.

func (Info) Alerts

func (i Info) Alerts(ctx context.Context) []Alert

Alerts follows overviewAlerts of the Angular overview.

func (Info) AppCounts

func (i Info) AppCounts() (running, autostart, failed int)

AppCounts is how many apps run, start with the visor, and failed.

func (Info) Directions

func (i Info) Directions() (in, out int)

Directions counts incoming and outgoing transports.

func (Info) Hypervisors

func (i Info) Hypervisors(local string) []Hypervisor

Hypervisors merges the configured and the connected hypervisors.

func (Info) MeshName

func (i Info) MeshName() string

MeshName is the visor's .skynet and .dmsg host name.

func (Info) TransportTypes

func (i Info) TransportTypes() []TypeCount

TransportTypes counts the transports by type, most first.

func (Info) Version

func (i Info) Version() string

Version is the running build's version, or "".

type KV

type KV struct{ Name, Value string }

KV is one extra field of a log line.

func PortRows

func PortRows(ports map[string]visorapi.PortDetail) []KV

PortRows sorts the visor's ports for display.

type Lang

type Lang struct {
	Code string
	Name string
}

Lang is a language the pages offer.

type List

type List struct {
	PK     string
	All    []contacts.Contact
	Filter string
	Err    string
}

List is the contact list view.

func (List) Shown

func (l List) Shown() []contacts.Contact

Shown is the contacts whose name, key, mail address or group contains the filter, as the Angular tab matched them.

type ListQuery

type ListQuery struct {
	Q    string
	Sort string
	Desc bool
	Page int
}

ListQuery is the filter text, sort column and page a long list was asked for. The pages send it back with every request that redraws the list.

func ParseListQuery

func ParseListQuery(get func(string) string) ListQuery

ParseListQuery reads q, sort, desc and page through get, which is usually a request's FormValue.

func (ListQuery) Match

func (q ListQuery) Match(fields ...string) bool

Match reports whether the filter text is in any of fields, ignoring case.

type LogEntry

type LogEntry struct {
	Time   string
	Level  LogLevel
	Msg    string
	Func   string
	Module string
	Extra  []KV
}

LogEntry is one runtime log line.

func FilterLogs

func FilterLogs(raws []string, f LogFilter) (out []LogEntry, more bool)

FilterLogs parses raw lines and keeps those f matches, the last LogMax.

func ParseLogEntry

func ParseLogEntry(raw string) (LogEntry, bool)

ParseLogEntry decodes one JSON log line. ok is false for a malformed one.

func (LogEntry) LevelClass

func (e LogEntry) LevelClass() string

LevelClass is the CSS class for the level chip.

func (LogEntry) LevelName

func (e LogEntry) LevelName() string

LevelName is the level as the chip shows it.

type LogFilter

type LogFilter struct {
	MinLevel LogLevel
	Module   string
	Text     string
	Paused   bool
	// contains filtered or unexported fields
}

LogFilter is the level, module and text filter of the tab.

func ParseLogFilter

func ParseLogFilter(q url.Values) (LogFilter, error)

ParseLogFilter reads the filter from a query. A bad module regex is returned as the error and filters nothing.

func (LogFilter) Match

func (f LogFilter) Match(e LogEntry) bool

Match reports whether e passes the filter.

func (LogFilter) Query

func (f LogFilter) Query(extra ...string) string

Query is the filter as URL query parameters, with extra pairs appended.

type LogLevel

type LogLevel int

LogLevel orders log levels as the Angular logs tab does.

const (
	LevelUnknown LogLevel = iota + 1
	LevelTrace
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelPanic
)

The levels, lowest first.

type Logs

type Logs struct {
	PK      string
	Filter  LogFilter
	Entries []LogEntry
	Cursor  int64
	Dropped int64
	Total   int64
	More    bool // older entries were cut to LogMax
	Err     string
}

Logs is a batch of entries for the tab.

type Mail

type Mail struct {
	PK        string
	Status    *visorapi.MailStatus
	StatusErr string
	Folder    string
	View      string
	List      []skymail.Summary
	Msg       *skymail.Rendered
	MsgID     string
	Queue     *skymail.Queued
	Draft     Draft
	Report    []skymail.RcptResult
	Err       string
}

Mail is what the mail tab shows. View is "list", "message", "compose" or "settings".

type Node

type Node struct {
	PK          string
	Hostname    string
	Version     string
	Online      bool
	IsHV        bool
	PublicIP    string
	LocalIP     string
	Location    string
	Transports  int
	Apps        int
	AppsRunning int
	Routes      int
	DmsgServer  string
	DmsgPing    string
	Reward      string
	LastSeen    string

	// ViaSub is a visor only a sub-hypervisor manages, so its pages do not
	// open here. Children are the visors of a sub-hypervisor, and SubErr
	// why they could not be listed.
	ViaSub   bool
	Children []Node
	SubErr   string
}

Node is one row of the visor list.

func NodeOf

func NodeOf(s visorapi.Summary) Node

NodeOf turns a visor summary into a row.

func (Node) Name

func (n Node) Name() string

Name is the hostname, else an IP, as the Angular UI's default label.

func (Node) SearchText

func (n Node) SearchText() string

SearchText is what the list's search box matches, in lower case.

func (Node) ShortVersion

func (n Node) ShortVersion() string

ShortVersion is the release part of a version such as v1.3.104-76-gc08475bdb, which fits the list on one line.

type Page

type Page struct {
	Base   string
	Lang   string
	Auth   bool
	HVPK   string
	Remote bool
	TPViz  bool
	// contains filtered or unexported fields
}

Page is what every page and fragment needs to render: where the root is, the language, and whether there is a session to log out of.

func From

func From(ctx context.Context) *Page

From is the Page in ctx, or an English page rooted at "./".

type Pager

type Pager struct {
	ListQuery
	Total int
	Size  int
}

Pager is one page of a filtered list.

func Paginate

func Paginate[T any](rows []T, q ListQuery, size int) ([]T, Pager)

Paginate keeps the rows of the page q asks for, moving an out of range page to the nearest one.

func (Pager) From

func (p Pager) From() int

From is the 1 based index of the page's first row, 0 for an empty list.

func (Pager) Pages

func (p Pager) Pages() int

Pages is the number of pages, at least one.

func (Pager) To

func (p Pager) To() int

To is the 1 based index of the page's last row.

type Path

type Path struct {
	Hops []string
	Dst  string
}

Path is one route a route find or calculation returned: the visors it passes, ending at the destination.

type PathQuery

type PathQuery struct {
	PK      string
	Calc    bool
	Dst     string
	MinHops string
	MaxHops string
	Count   string
	Paths   []Path
	Ran     bool
	Err     string
}

PathQuery is a route find or calculation form and its answer.

type Policies

type Policies struct {
	Default *visorapi.RoutingPolicyInfo
	Apps    []string
	PerApp  map[string]*visorapi.RoutingPolicyInfo
}

Policies is the routing policies view.

func PoliciesOf

PoliciesOf sorts the per-app policies by app name.

type RewardDay

type RewardDay struct {
	Date   string  `json:"date"`
	Amount float64 `json:"amount"`
	Share  float64 `json:"share"`
	Sent   bool    `json:"sent"`
	TxID   string  `json:"txid,omitempty"`
}

RewardDay is one day of the reward system's history for a visor.

func ParseRewardHistory

func ParseRewardHistory(body []byte) ([]RewardDay, float64, error)

ParseRewardHistory reads the reward system's visor history answer.

func (RewardDay) DateLabel

func (d RewardDay) DateLabel() string

DateLabel prints the day like "Nov 3, 2026".

func (RewardDay) Status

func (d RewardDay) Status() string

Status is a day's state as the Angular tab classes it.

type RewardHistory

type RewardHistory struct {
	PK    string
	Days  int
	List  []RewardDay
	Total float64
	Err   string
}

RewardHistory is the history part of the rewards tab.

type Rewards

type Rewards struct {
	PK      string
	Address string
	IsXpub  bool
	// Addresses are the first the xpub derives, where its rewards go.
	Addresses []string
	XpubErr   string
	// Spent: the address has sent coins, so its public key is on chain.
	Spent   bool
	Balance string
	Err     string
	Editing bool
	Draft   string
}

Rewards is the reward address part of the rewards tab.

type Rule

type Rule struct {
	Key        string
	Type       string
	LocalPort  string
	RemotePK   string
	RemotePort string
	NextRID    string
	NextTP     string
	KeepAlive  string
}

Rule is one routing rule row.

func RulesOf

func RulesOf(rules []routing.Rule) []Rule

RulesOf turns the visor's rules into rows, by key.

type Rules

type Rules struct {
	PK    string
	Total int
	Rows  []Rule
	Pager Pager
	Err   string
}

Rules is one page of the routing rules view.

func SelectRules

func SelectRules(pk string, all []Rule, q ListQuery, errMsg string) Rules

SelectRules filters, sorts and pages rules for q.

type Run

type Run struct {
	State    string
	N        int
	From, To string
}

Run is a stretch of slots in one state: on, off or future.

type ServiceUptime

type ServiceUptime struct {
	Service string
	Days    []TierPct // Name is the date; newest first
	Err     string
}

ServiceUptime is one deployment service's daily uptime of the visor.

type Settings

type Settings struct {
	PK       string
	Path     string
	Exists   bool
	Writable bool
	Fields   []Field
	Err      string

	Reviewing bool
	Changes   []skyenvform.Change
	Command   string
	Saved     bool
}

Settings is the settings tab: the visor's skywire.conf as a form, and the review of what a filled-in form changes.

type Tab

type Tab struct {
	Seg   string
	Label string
	Icon  string
}

Tab is one entry of the per-visor navigation.

func TabOf

func TabOf(seg string) (Tab, bool)

TabOf is the tab with segment seg.

type TierPct

type TierPct struct {
	Name string
	Pct  float64
}

TierPct is a tier's share of known slots online over the window.

func ParseServiceUptimes

func ParseServiceUptimes(body []byte, pk string) ([]TierPct, error)

ParseServiceUptimes picks the visor's daily percentages out of a service's /uptimes?v=v2 answer, keeping the newest seven days.

type Transport

type Transport struct {
	ID         string
	Remote     string
	Type       string
	Label      string
	Latency    string
	Throughput string
	Sent       string
	Recv       string
	Persistent bool
	Offline    bool
	// contains filtered or unexported fields
}

Transport is one row of the transports tab. A persistent transport that is not up has no ID and Offline set, as the Angular list shows it.

type Transports

type Transports struct {
	PK          string
	List        []Transport
	Rows        []Transport
	Pager       Pager
	ByType      []TypeCount
	Types       []string
	Autoconnect bool
	IsPublic    bool
	Err         string
}

Transports is the transports tab.

func TransportsOf

func TransportsOf(pk string, tps []*visorapi.TransportSummary, persistent []transport.PersistentTransports) Transports

TransportsOf builds the tab from the visor's transports and its persistent list.

func (Transports) Online

func (t Transports) Online() int

Online is the number of transports that are up.

func (*Transports) Select

func (t *Transports) Select(q ListQuery)

Select filters, sorts and pages the list for q into Rows and Pager.

func (Transports) TypeSummary

func (t Transports) TypeSummary() string

TypeSummary is the count per type, as "dmsg: 3, stcpr: 1".

type TypeCount

type TypeCount struct {
	Type  string
	Count int
}

TypeCount is how many transports of one type there are.

type UpDay

type UpDay struct {
	Date  string
	Today bool
	Tiers []UpTier
}

UpDay is one UTC day, newest first.

type UpTier

type UpTier struct {
	Name  string
	Runs  []Run
	Pct   float64
	Empty bool
}

UpTier is one tier's bar for a day, as runs of the same state.

type Uptime

type Uptime struct {
	PK      string
	Days    int // the window, 1, 7 or 30
	List    []UpDay
	Summary []TierPct
	Fetched string
	Err     string
}

Uptime is the uptime tab.

Jump to

Keyboard shortcuts

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