Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions internal/web/assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package web

import (
"embed"
"html/template"
"io/fs"
)

// Embedded webroot assets - included at build time
var (
// HTML Templates
//go:embed templates/*.html
templatesFS embed.FS

// Static assets (CSS, JS, images)
//go:embed static/*
staticFS embed.FS
)

// GetTemplates loads and parses embedded HTML templates
func GetTemplates() (*template.Template, error) {
return template.ParseFS(templatesFS, "templates/*.html")
}

// GetStaticFS returns the embedded static file system
func GetStaticFS() fs.FS {
staticSubFS, err := fs.Sub(staticFS, "static")
if err != nil {
panic("failed to create static subdirectory: " + err.Error())
}
return staticSubFS
}
73 changes: 73 additions & 0 deletions internal/web/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package web

import (
"time"
)

// DashboardData represents data for the dashboard template
type DashboardData struct {
Title string `json:"title"`
Version string `json:"version"`
Uptime string `json:"uptime"`
SystemStatus string `json:"system_status"`
MinionCount int `json:"minion_count"`
MinionPort int `json:"minion_port"`
ConsolePort int `json:"console_port"`
WebPort int `json:"web_port"`
Minions []MinionInfo `json:"minions"`
}

// MinionInfo represents information about a connected minion
type MinionInfo struct {
ID string `json:"id"`
Status string `json:"status"`
ConnectedAt time.Time `json:"connected_at"`
LastSeen time.Time `json:"last_seen"`
}

// StatusResponse represents the API status response
type StatusResponse struct {
Version string `json:"version"`
Uptime string `json:"uptime"`
Timestamp string `json:"timestamp"`
Servers ServerStatusInfo `json:"servers"`
Database DatabaseStatus `json:"database"`
}

// ServerStatusInfo represents server status information
type ServerStatusInfo struct {
Minion ServerInfo `json:"minion"`
Console ServerInfo `json:"console"`
Web ServerInfo `json:"web"`
}

// ServerInfo represents individual server information
type ServerInfo struct {
Port int `json:"port"`
Status string `json:"status"`
Connections int `json:"connections,omitempty"`
}

// DatabaseStatus represents database connection status
type DatabaseStatus struct {
Status string `json:"status"`
Host string `json:"host"`
}

// MinionsResponse represents the API minions response
type MinionsResponse struct {
Count int `json:"count"`
Minions []MinionInfo `json:"minions"`
}

// HealthResponse represents the API health response
type HealthResponse struct {
Status string `json:"status"`
Timestamp string `json:"timestamp"`
}

// ErrorResponse represents an API error response
type ErrorResponse struct {
Error string `json:"error"`
Message string `json:"message"`
}
Loading
Loading