Documentation
¶
Index ¶
- Constants
- Variables
- func FormatMemUsage(memUsage, memPerc string) string
- func PageForShortcut(letter string) string
- func PageLabel(page string) string
- func PageShortcut(page string) string
- func SumContainerMemory(containers []DockerContainer) (int64, int)
- type CheckableServiceItem
- type ComposeFileItem
- type ContainerListItem
- type DockerContainer
- type GroupListItem
- type ListItem
- type ServiceListItem
- type ThemeItem
Constants ¶
const UngroupedGroup = "ungrouped"
UngroupedGroup is the reserved group name cais shows for every service that carries no profiles: key. It is spelled the way a Compose profile would be, and rendered verbatim like any other group name, so the groups list needs no special case for it.
Reserved on both counts: the name cannot be given to a real group (see groupnamemodal), and the group is read-only in the UI - there is no profile tag behind it, and its membership is derived rather than chosen. Every one of those decisions is a comparison against this constant, which is why there is no "synthetic" flag on the list item.
Variables ¶
var PageLabels = map[string]string{
"Home": "Groups",
"Services": "Services",
"Compose Files": "Files",
}
PageLabels maps page IDs to their display labels in the main menu. Page IDs are preserved for all state comparisons; only the label changes.
var PageTitles = []string{
"Home",
"Services",
"Compose Files",
"Backups",
}
PageTitles is the ordered list of page IDs used for navigation state.
Functions ¶
func FormatMemUsage ¶
FormatMemUsage formats memory usage as "Usage (Percent)", e.g., "21.71MiB / 31.02GiB" + "0.07%" -> "21.71MiB (0.07%)". If percent is empty, returns just the usage part (before "/").
It takes docker's raw strings, and is the one copy: the service list row and the details panel's runtime table both render through it, so the two never drift apart. Applying it twice is not idempotent - the second pass finds no "/" to split on and appends the percent again - so call it at render time and keep the raw values in the fields.
func PageForShortcut ¶
PageForShortcut returns the page a chord letter jumps to, or "" if the letter is not a page chord. When two labels share a first letter the first page wins - acceptable for an alias, since the digits are the primary scheme and are unambiguous.
func PageShortcut ¶
PageShortcut returns the letter of a page's alt+<letter> chord: the first letter of its display label, lowercased.
The chord is an alias. The digits are the primary page scheme, rendered on the tabs themselves; the chord stays for the terminals that send Option as Alt. It is still derived from the label rather than listed in a table, because a hand-maintained table drifts. Two labels may now share a first letter - the digits are unambiguous, and the alias simply resolves to the first matching page.
func SumContainerMemory ¶
func SumContainerMemory(containers []DockerContainer) (int64, int)
SumContainerMemory adds the used side of every container's MemUsage. Returns the total used bytes and how many containers reported one.
Types ¶
type CheckableServiceItem ¶
CheckableServiceItem is a list.Item for the service-selection checklist shown when creating a group.
func (CheckableServiceItem) FilterValue ¶
func (s CheckableServiceItem) FilterValue() string
func (CheckableServiceItem) Title ¶
func (s CheckableServiceItem) Title() string
type ComposeFileItem ¶
ComposeFileItem is a list.Item for the file picker on the Files page. Active marks the file currently loaded, so the picker can say which one the user is already looking at.
func (ComposeFileItem) FilterValue ¶
func (s ComposeFileItem) FilterValue() string
func (ComposeFileItem) Title ¶
func (s ComposeFileItem) Title() string
type ContainerListItem ¶
type ContainerListItem DockerContainer
func (ContainerListItem) Description ¶
func (i ContainerListItem) Description(isSelected bool) string
func (ContainerListItem) FilterValue ¶
func (i ContainerListItem) FilterValue() string
func (ContainerListItem) Title ¶
func (i ContainerListItem) Title() string
type DockerContainer ¶
type DockerContainer struct {
Command string
CreatedAt string
// docker compose ps names this field "Health". Without the tag, the
// field never binds and the HEALTH column reads "-" for every
// container, healthy ones included.
HealthStatus string `json:"Health"`
ID string
Image string
Labels string
LocalVolumes string
Mounts string
Names string
Networks string
Platforms struct {
// contains filtered or unexported fields
}
Ports string
RunningFor string
Service string
Size string
State string
Status string
// Runtime stats from `docker stats --no-stream`. These are populated
// by GetContainerStats, not by docker compose ps.
MemPerc string // e.g. "0.07%"
MemUsage string // e.g. "21.71MiB / 31.02GiB"
NetIO string // e.g. "3.22MB / 4.7kB"
BlockIO string // e.g. "70.3MB / 43.7MB"
CPUPerc string // e.g. "0.00%"
PIDs string // e.g. "19"
}
type GroupListItem ¶
GroupListItem is one row in the groups list. It carries the group's name plus how many of its member services are running, so the row can render a status dot (green when fully running, amber half-circle when mixed).
func (GroupListItem) FilterValue ¶
func (s GroupListItem) FilterValue() string
func (GroupListItem) Title ¶
func (s GroupListItem) Title() string
type ListItem ¶
type ListItem struct {
ItemTitle, ItemDesc string
}
func (ListItem) Description ¶
func (ListItem) FilterValue ¶
type ServiceListItem ¶
type ServiceListItem struct {
Service types.ServiceConfig
// Status reflects the docker container state for this service:
// "running", "stopped", or "" (unknown / no container yet). Set by
// ServicesListModel when a GetRunningContainersMsg arrives.
Status string
// MemUsage is the real-time memory usage from docker stats, exactly as
// docker reports it: "21.71MiB / 31.02GiB". Empty when stats are
// unavailable. Store it raw - FormatMemUsage is applied once, at render
// time, and formatting it on the way in instead would double-apply the
// percent suffix.
MemUsage string
// MemPerc is the memory usage percentage from docker stats, e.g. "0.07%"
MemPerc string
}
func (ServiceListItem) Description ¶
func (s ServiceListItem) Description(isActive bool) string
func (ServiceListItem) FilterValue ¶
func (s ServiceListItem) FilterValue() string
func (ServiceListItem) StatusPill ¶
func (s ServiceListItem) StatusPill() string
StatusPill returns a styled pill showing the service's current status. It uses the same visual language as the group's statusPill in GroupDetailsPanel, but for a single service.
func (ServiceListItem) Title ¶
func (s ServiceListItem) Title() string
type ThemeItem ¶
ThemeItem is a list.Item for the theme picker modal. Active marks the theme that was in effect when the modal opened, so the user can see which one they started from and Esc can restore it.