Serve a local web UI from bangerd

Add a localhost-only web console so VM and image management no longer depends on the CLI for every inspection and lifecycle action.

Wire bangerd up to a configurable web listener, expose dashboard and async image-build state through the daemon, and serve CSRF-protected HTML pages with host-path picking, VM/image detail views, logs, ports, and progress polling for long-running operations.

Keep the browser path aligned with the existing sudo and host-owned artifact model: surface sudo readiness, print the web URL in daemon status, and document the new workflow. Polish the UI with resource usage cards, clearer clickable affordances, cancel paths, confirmation prompts, image-name links, and HTTP port links.

Validation: GOCACHE=/tmp/banger-gocache go test ./...
This commit is contained in:
Thales Maciel 2026-03-21 16:47:47 -03:00
parent 30f0c0b54a
commit 2362d0ae39
No known key found for this signature in database
GPG key ID: 33112E6833C34679
24 changed files with 3308 additions and 52 deletions

View file

@ -11,6 +11,7 @@ type Empty struct{}
type PingResult struct {
Status string `json:"status"`
PID int `json:"pid"`
WebURL string `json:"web_url,omitempty"`
}
type ShutdownResult struct {
@ -54,6 +55,33 @@ type VMCreateStatusResult struct {
Operation VMCreateOperation `json:"operation"`
}
type ImageBuildStatusParams struct {
ID string `json:"id"`
}
type ImageBuildOperation struct {
ID string `json:"id"`
ImageID string `json:"image_id,omitempty"`
ImageName string `json:"image_name,omitempty"`
Stage string `json:"stage,omitempty"`
Detail string `json:"detail,omitempty"`
BuildLogPath string `json:"build_log_path,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
Done bool `json:"done"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Image *model.Image `json:"image,omitempty"`
}
type ImageBuildBeginResult struct {
Operation ImageBuildOperation `json:"operation"`
}
type ImageBuildStatusResult struct {
Operation ImageBuildOperation `json:"operation"`
}
type VMRefParams struct {
IDOrName string `json:"id_or_name"`
}
@ -151,3 +179,42 @@ type ImageListResult struct {
type ImageShowResult struct {
Image model.Image `json:"image"`
}
type SudoStatus struct {
Available bool `json:"available"`
Command string `json:"command,omitempty"`
Error string `json:"error,omitempty"`
}
type HostSummary struct {
CPUCount int `json:"cpu_count"`
TotalMemoryBytes int64 `json:"total_memory_bytes"`
StateFilesystemTotalBytes int64 `json:"state_filesystem_total_bytes"`
StateFilesystemFreeBytes int64 `json:"state_filesystem_free_bytes"`
}
type BangerSummary struct {
ImageCount int `json:"image_count"`
ManagedImageCount int `json:"managed_image_count"`
VMCount int `json:"vm_count"`
RunningVMCount int `json:"running_vm_count"`
ConfiguredVCPUCount int `json:"configured_vcpu_count"`
ConfiguredMemoryBytes int64 `json:"configured_memory_bytes"`
ConfiguredDiskBytes int64 `json:"configured_disk_bytes"`
UsedSystemOverlayBytes int64 `json:"used_system_overlay_bytes"`
UsedWorkDiskBytes int64 `json:"used_work_disk_bytes"`
RunningCPUPercent float64 `json:"running_cpu_percent"`
RunningRSSBytes int64 `json:"running_rss_bytes"`
RunningVSZBytes int64 `json:"running_vsz_bytes"`
}
type DashboardSummary struct {
GeneratedAt time.Time `json:"generated_at"`
Host HostSummary `json:"host"`
Sudo SudoStatus `json:"sudo"`
Banger BangerSummary `json:"banger"`
}
type DashboardSummaryResult struct {
Summary DashboardSummary `json:"summary"`
}