Skip to content

Modern Docker Management, Designed for Everyone

feat: updated dashboard layout with action items (#1761)

Kyle Mendell60b435eaa136
diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go
index c508d96e9..610018d9a 100644
--- a/backend/internal/bootstrap/router_bootstrap.go
+++ b/backend/internal/bootstrap/router_bootstrap.go
@@ -152,6 +152,7 @@ func setupRouter(ctx context.Context, cfg *config.Config, appServices *Services)
GitRepository: appServices.GitRepository,
GitOpsSync: appServices.GitOpsSync,
Vulnerability: appServices.Vulnerability,
+ Dashboard: appServices.Dashboard,
Config: cfg,
}
diff --git a/backend/internal/bootstrap/services_bootstrap.go b/backend/internal/bootstrap/services_bootstrap.go
index 80e8751f1..3252722db 100644
--- a/backend/internal/bootstrap/services_bootstrap.go
+++ b/backend/internal/bootstrap/services_bootstrap.go
@@ -42,6 +42,7 @@ type Services struct {
GitOpsSync *services.GitOpsSyncService
Font *services.FontService
Vulnerability *services.VulnerabilityService
+ Dashboard *services.DashboardService
}
func initializeServices(ctx context.Context, db *database.DB, cfg *config.Config, httpClient *http.Client) (svcs *Services, dockerSrvice *services.DockerClientService, err error) {
@@ -64,6 +65,7 @@ func initializeServices(ctx context.Context, db *database.DB, cfg *config.Config
svcs.Notification = services.NewNotificationService(db, cfg)
svcs.Apprise = services.NewAppriseService(db, cfg)
svcs.Vulnerability = services.NewVulnerabilityService(db, svcs.Docker, svcs.Event, svcs.Settings, svcs.Notification)
+ svcs.Dashboard = services.NewDashboardService(db, svcs.Docker, svcs.Vulnerability)
svcs.ImageUpdate = services.NewImageUpdateService(db, svcs.Settings, svcs.ContainerRegistry, svcs.Docker, svcs.Event, svcs.Notification)
svcs.Image = services.NewImageService(db, svcs.Docker, svcs.ContainerRegistry, svcs.ImageUpdate, svcs.Vulnerability, svcs.Event)
svcs.Project = services.NewProjectService(db, svcs.Settings, svcs.Event, svcs.Image, svcs.Docker)
diff --git a/backend/internal/huma/handlers/dashboard.go b/backend/internal/huma/handlers/dashboard.go
new file mode 100644
index 000000000..78e543068
--- /dev/null
+++ b/backend/internal/huma/handlers/dashboard.go
@@ -0,0 +1,70 @@
+package handlers
+
+import (
+ "context"
+ "net/http"
+
+ "github.com/danielgtaylor/huma/v2"
+ "github.com/getarcaneapp/arcane/backend/internal/services"
+ "github.com/getarcaneapp/arcane/types/base"
+ dashboardtypes "github.com/getarcaneapp/arcane/types/dashboard"
+)
+
+type DashboardHandler struct {
+ dashboardService *services.DashboardService
+}
+
+type GetDashboardActionItemsInput struct {
+ EnvironmentID string `path:"id" doc:"Environment ID"`
+ DebugAllGood bool `query:"debugAllGood" default:"false" doc:"Debug mode: force an empty action item list"`
+}
+
+type GetDashboardActionItemsOutput struct {
+ Body base.ApiResponse[dashboardtypes.ActionItems]
+}
+
+func RegisterDashboard(api huma.API, dashboardService *services.DashboardService) {
+ h := &DashboardHandler{dashboardService: dashboardService}
+
+ huma.Register(api, huma.Operation{
+ OperationID: "get-dashboard-action-items",
+ Method: http.MethodGet,
+ Path: "/environments/{id}/dashboard/action-items",
+ Summary: "Get dashboard action items",
+ Description: "Returns only dashboard action items that currently need attention",
+ Tags: []string{"Dashboard"},
+ Security: []map[string][]string{
+ {"BearerAuth": {}},
+ {"ApiKeyAuth": {}},
+ },
+ }, h.GetActionItems)
+}
+
+func (h *DashboardHandler) GetActionItems(ctx context.Context, input *GetDashboardActionItemsInput) (*GetDashboardActionItemsOutput, error) {
+ if h.dashboardService == nil {
+ return nil, huma.Error500InternalServerError("service not available")
+ }
+
+ // EnvironmentID is consumed by env proxy/auth middleware for routing/validation.
+ _ = input.EnvironmentID
+
+ actionItems, err := h.dashboardService.GetActionItems(ctx, services.DashboardActionItemsOptions{
+ DebugAllGood: input.DebugAllGood,
+ })
+ if err != nil {
+ return nil, huma.Error500InternalServerError(err.Error())
+ }
+
+ if actionItems == nil {
+ actionItems = &dashboardtypes.ActionItems{Items: []dashboardtypes.ActionItem{}}
+ } else if actionItems.Items == nil {
+ actionItems.Items = []dashboardtypes.ActionItem{}
+ }
+
+ return &GetDashboardActionItemsOutput{
+ Body: base.ApiResponse[dashboardtypes.ActionItems]{
+ Success: true,
+ Data: *actionItems,
+ },
+ }, nil
+}
diff --git a/backend/internal/huma/huma.go b/backend/internal/huma/huma.go
index 78e48ff3e..3abdee52d 100644
--- a/backend/internal/huma/huma.go
+++ b/backend/internal/huma/huma.go
@@ -144,6 +144,7 @@ type Services struct {
GitRepository *services.GitRepositoryService
GitOpsSync *services.GitOpsSyncService
Vulnerability *services.VulnerabilityService
+ Dashboard *services.DashboardService
Config *config.Config
}
@@ -303,6 +304,7 @@ func registerHandlers(api huma.API, svc *Services) {
var gitRepositorySvc *services.GitRepositoryService
var gitOpsSyncSvc *services.GitOpsSyncService
var vulnerabilitySvc *services.VulnerabilityService
+ var dashboardSvc *services.DashboardService
var cfg *config.Config
if svc != nil {
@@ -336,6 +338,7 @@ func registerHandlers(api huma.API, svc *Services) {
gitRepositorySvc = svc.GitRepository
gitOpsSyncSvc = svc.GitOpsSync
vulnerabilitySvc = svc.Vulnerability
+ dashboardSvc = svc.Dashboard
cfg = svc.Config
}
handlers.RegisterHealth(api)
@@ -365,4 +368,5 @@ func registerHandlers(api huma.API, svc *Services) {
handlers.RegisterGitRepositories(api, gitRepositorySvc)
handlers.RegisterGitOpsSyncs(api, gitOpsSyncSvc)
handlers.RegisterVulnerability(api, vulnerabilitySvc)
+ handlers.RegisterDashboard(api, dashboardSvc)
}
diff --git a/backend/internal/services/dashboard_service.go b/backend/internal/services/dashboard_service.go
new file mode 100644
index 000000000..dd9b022b3
--- /dev/null
+++ b/backend/internal/services/dashboard_service.go
@@ -0,0 +1,218 @@
+package services
+
+import (
+ "context"
+ "fmt"
+ "time"
+
+ "github.com/getarcaneapp/arcane/backend/internal/database"
+ "github.com/getarcaneapp/arcane/backend/internal/models"
+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane"
+ dashboardtypes "github.com/getarcaneapp/arcane/types/dashboard"
+ "golang.org/x/sync/errgroup"
+)
+
+const defaultDashboardAPIKeyExpiryWindow = 14 * 24 * time.Hour
+
+type DashboardService struct {
+ db *database.DB
+ dockerService *DockerClientService
+ vulnerabilityService *VulnerabilityService
+}
+
+type DashboardActionItemsOptions struct {
+ DebugAllGood bool
+}
+
+func NewDashboardService(
+ db *database.DB,
+ dockerService *DockerClientService,
+ vulnerabilityService *VulnerabilityService,
+) *DashboardService {
+ return &DashboardService{
+ db: db,
+ dockerService: dockerService,
+ vulnerabilityService: vulnerabilityService,
+ }
+}
+
+func (s *DashboardService) GetActionItems(ctx context.Context, options DashboardActionItemsOptions) (*dashboardtypes.ActionItems, error) {
+ if options.DebugAllGood {
+ return &dashboardtypes.ActionItems{Items: []dashboardtypes.ActionItem{}}, nil
+ }
+
+ var (
+ stoppedContainers int
+ pendingImageUpdates int
+ actionableVulnerabilities int
+ expiringAPIKeys int
+ )
+
+ g, groupCtx := errgroup.WithContext(ctx)
+
+ g.Go(func() error {
+ count, err := s.getStoppedContainersCountInternal(groupCtx)
+ if err != nil {
+ return err
+ }
+ stoppedContainers = count
+ return nil
+ })
+
+ g.Go(func() error {
+ count, err := s.getPendingImageUpdatesCountInternal(groupCtx)
+ if err != nil {
+ return err
+ }
+ pendingImageUpdates = count
+ return nil
+ })
+
+ g.Go(func() error {
+ count, err := s.getActionableVulnerabilitiesCountInternal(groupCtx)
+ if err != nil {
+ return err
+ }
+ actionableVulnerabilities = count
+ return nil
+ })
+
+ g.Go(func() error {
+ count, err := s.getExpiringAPIKeysCountInternal(groupCtx)
+ if err != nil {
+ return err
+ }
+ expiringAPIKeys = count
+ return nil
+ })
+
+ if err := g.Wait(); err != nil {
+ return nil, err
+ }
+
+ actionItems := make([]dashboardtypes.ActionItem, 0, 4)
+
+ if stoppedContainers > 0 {
+ actionItems = append(actionItems, dashboardtypes.ActionItem{
+ Kind: dashboardtypes.ActionItemKindStoppedContainers,
+ Count: stoppedContainers,
+ Severity: dashboardtypes.ActionItemSeverityWarning,
+ })
+ }
+
+ if pendingImageUpdates > 0 {
+ actionItems = append(actionItems, dashboardtypes.ActionItem{
+ Kind: dashboardtypes.ActionItemKindImageUpdates,
+ Count: pendingImageUpdates,
+ Severity: dashboardtypes.ActionItemSeverityWarning,
+ })
+ }
+
+ if actionableVulnerabilities > 0 {
+ actionItems = append(actionItems, dashboardtypes.ActionItem{
+ Kind: dashboardtypes.ActionItemKindActionableVulnerabilities,
+ Count: actionableVulnerabilities,
+ Severity: dashboardtypes.ActionItemSeverityCritical,
+ })
+ }
+
+ if expiringAPIKeys > 0 {
+ actionItems = append(actionItems, dashboardtypes.ActionItem{
+ Kind: dashboardtypes.ActionItemKindExpiringKeys,
+ Count: expiringAPIKeys,
+ Severity: dashboardtypes.ActionItemSeverityWarning,
+ })
+ }
+
+ return &dashboardtypes.ActionItems{Items: actionItems}, nil
+}
+
+func (s *DashboardService) getStoppedContainersCountInternal(ctx context.Context) (int, error) {
+ if s.dockerService == nil {
+ return 0, nil
+ }
+
+ containers, _, _, _, err := s.dockerService.GetAllContainers(ctx)
+ if err != nil {
+ return 0, fmt.Errorf("failed to load container counts: %w", err)
+ }
+
+ stoppedCount := 0
+ for _, container := range containers {
+ if libarcane.IsInternalContainer(container.Labels) {
+ continue
+ }
+
+ if container.State != "running" {
+ stoppedCount++
+ }
+ }
+
+ return stoppedCount, nil
+}
+
+func (s *DashboardService) getPendingImageUpdatesCountInternal(ctx context.Context) (int, error) {
+ if s.db == nil || s.dockerService == nil {
+ return 0, nil
+ }
+
+ images, _, _, _, err := s.dockerService.GetAllImages(ctx)
+ if err != nil {
+ return 0, fmt.Errorf("failed to load images for update counts: %w", err)
+ }
+
+ if len(images) == 0 {
+ return 0, nil
+ }
+
+ imageIDs := make([]string, 0, len(images))
+ for _, img := range images {
+ imageIDs = append(imageIDs, img.ID)
+ }
+
+ var count int64
+ err = s.db.WithContext(ctx).
+ Model(&models.ImageUpdateRecord{}).
+ Where("id IN ? AND has_update = ?", imageIDs, true).
+ Count(&count).Error
+ if err != nil {
+ return 0, fmt.Errorf("failed to count pending image updates: %w", err)
+ }
+
+ return int(count), nil
+}
+
+func (s *DashboardService) getActionableVulnerabilitiesCountInternal(ctx context.Context) (int, error) {
+ if s.vulnerabilityService == nil {
+ return 0, nil
+ }
+
+ summary, err := s.vulnerabilityService.GetEnvironmentSummary(ctx)
+ if err != nil {
+ return 0, fmt.Errorf("failed to load vulnerability summary: %w", err)
+ }
+
+ if summary == nil || summary.Summary == nil {
+ return 0, nil
+ }
+
+ return summary.Summary.Critical + summary.Summary.High, nil
+}
+
+func (s *DashboardService) getExpiringAPIKeysCountInternal(ctx context.Context) (int, error) {
+ if s.db == nil {
+ return 0, nil
+ }
+
+ var count int64
+ err := s.db.WithContext(ctx).
+ Model(&models.ApiKey{}).
+ Where("expires_at IS NOT NULL").
+ Where("expires_at <= ?", time.Now().Add(defaultDashboardAPIKeyExpiryWindow)).
+ Count(&count).Error
+ if err != nil {
+ return 0, fmt.Errorf("failed to count expiring API keys: %w", err)
+ }
+
+ return int(count), nil
+}
diff --git a/backend/internal/services/dashboard_service_test.go b/backend/internal/services/dashboard_service_test.go
new file mode 100644
index 000000000..48856d85e
--- /dev/null
+++ b/backend/internal/services/dashboard_service_test.go
@@ -0,0 +1,98 @@
+package services
+
+import (
+ "context"
+ "testing"
+ "time"
+
+ "github.com/getarcaneapp/arcane/backend/internal/database"
+ "github.com/getarcaneapp/arcane/backend/internal/models"
+ dashboardtypes "github.com/getarcaneapp/arcane/types/dashboard"
+ glsqlite "github.com/glebarez/sqlite"
+ "github.com/stretchr/testify/require"
+ "gorm.io/gorm"
+)
+
+func setupDashboardServiceTestDB(t *testing.T) *database.DB {
+ t.Helper()
+
+ db, err := gorm.Open(glsqlite.Open(":memory:"), &gorm.Config{})
+ require.NoError(t, err)
+ require.NoError(t, db.AutoMigrate(&models.ApiKey{}))
+
+ return &database.DB{DB: db}
+}
+
+func createDashboardTestAPIKey(t *testing.T, db *database.DB, key models.ApiKey) {
+ t.Helper()
+ require.NoError(t, db.WithContext(context.Background()).Create(&key).Error)
+}
+
+func TestDashboardService_GetActionItems_IncludesExpiringAPIKeys(t *testing.T) {
+ db := setupDashboardServiceTestDB(t)
+ svc := NewDashboardService(db, nil, nil)
+
+ now := time.Now()
+ expiringSoon := now.Add(24 * time.Hour)
+ alreadyExpired := now.Add(-24 * time.Hour)
+ farFuture := now.Add(45 * 24 * time.Hour)
+
+ createDashboardTestAPIKey(t, db, models.ApiKey{
+ Name: "expiring-soon",
+ KeyHash: "hash-soon",
+ KeyPrefix: "arc_test_s",
+ UserID: "user-1",
+ ExpiresAt: &expiringSoon,
+ })
+ createDashboardTestAPIKey(t, db, models.ApiKey{
+ Name: "already-expired",
+ KeyHash: "hash-expired",
+ KeyPrefix: "arc_test_e",
+ UserID: "user-1",
+ ExpiresAt: &alreadyExpired,
+ })
+ createDashboardTestAPIKey(t, db, models.ApiKey{
+ Name: "future",
+ KeyHash: "hash-future",
+ KeyPrefix: "arc_test_f",
+ UserID: "user-1",
+ ExpiresAt: &farFuture,
+ })
+ createDashboardTestAPIKey(t, db, models.ApiKey{
+ Name: "never-expires",
+ KeyHash: "hash-never",
+ KeyPrefix: "arc_test_n",
+ UserID: "user-1",
+ })
+
+ actionItems, err := svc.GetActionItems(context.Background(), DashboardActionItemsOptions{})
+ require.NoError(t, err)
+ require.NotNil(t, actionItems)
+ require.Len(t, actionItems.Items, 1)
+
+ item := actionItems.Items[0]
+ require.Equal(t, dashboardtypes.ActionItemKindExpiringKeys, item.Kind)
+ require.Equal(t, 2, item.Count)
+ require.Equal(t, dashboardtypes.ActionItemSeverityWarning, item.Severity)
+}
+
+func TestDashboardService_GetActionItems_DebugAllGoodReturnsNoItems(t *testing.T) {
+ db := setupDashboardServiceTestDB(t)
+ svc := NewDashboardService(db, nil, nil)
+
+ expiresAt := time.Now().Add(2 * time.Hour)
+ createDashboardTestAPIKey(t, db, models.ApiKey{
+ Name: "expiring-soon",
+ KeyHash: "hash-soon",
+ KeyPrefix: "arc_test_d",
+ UserID: "user-1",
+ ExpiresAt: &expiresAt,
+ })
+
+ actionItems, err := svc.GetActionItems(context.Background(), DashboardActionItemsOptions{
+ DebugAllGood: true,
+ })
+ require.NoError(t, err)
+ require.NotNil(t, actionItems)
+ require.Empty(t, actionItems.Items)
+}
diff --git a/cli/internal/benchmark/baseline_benchmark_test.go b/cli/internal/benchmark/baseline_benchmark_test.go
index 21517f4ad..2a84a41f5 100644
--- a/cli/internal/benchmark/baseline_benchmark_test.go
+++ b/cli/internal/benchmark/baseline_benchmark_test.go
@@ -15,7 +15,7 @@ import (
func BenchmarkClientListMediumPayload(b *testing.B) {
payload := make(map[string]any, 0)
items := make([]map[string]any, 0, 200)
- for i := 0; i < 200; i++ {
+ for i := range 200 {
items = append(items, map[string]any{
"id": fmt.Sprintf("id-%d", i),
"name": fmt.Sprintf("name-%d", i),
diff --git a/cli/internal/client/client.go b/cli/internal/client/client.go
index 700636ea2..5229e3e0b 100644
--- a/cli/internal/client/client.go
+++ b/cli/internal/client/client.go
@@ -334,10 +334,7 @@ func (c *Client) resolveURL(path string) (string, error) {
}
func (c *Client) doRequest(ctx context.Context, method, fullURL string, bodyBytes []byte, allowRefresh bool) (*http.Response, error) {
- attempts := c.maxAttempts
- if attempts < 1 {
- attempts = 1
- }
+ attempts := max(c.maxAttempts, 1)
for attempt := 1; attempt <= attempts; attempt++ {
var bodyReader io.Reader
diff --git a/cli/internal/types/config.go b/cli/internal/types/config.go
index 092691d35..204d788db 100644
--- a/cli/internal/types/config.go
+++ b/cli/internal/types/config.go
@@ -2,6 +2,7 @@ package types
import (
"fmt"
+ "maps"
"strings"
)
@@ -133,15 +134,11 @@ func (c *Config) Clone() *Config {
out := *c
if c.ResourceLimits != nil {
out.ResourceLimits = make(map[string]int, len(c.ResourceLimits))
- for k, v := range c.ResourceLimits {
- out.ResourceLimits[k] = v
- }
+ maps.Copy(out.ResourceLimits, c.ResourceLimits)
}
if c.Pagination.Resources != nil {
out.Pagination.Resources = make(map[string]PaginationResourceConfig, len(c.Pagination.Resources))
- for k, v := range c.Pagination.Resources {
- out.Pagination.Resources[k] = v
- }
+ maps.Copy(out.Pagination.Resources, c.Pagination.Resources)
}
return &out
}
diff --git a/cli/internal/types/endpoints.go b/cli/internal/types/endpoints.go
index 6fd398597..caf2375bd 100644
--- a/cli/internal/types/endpoints.go
+++ b/cli/internal/types/endpoints.go
@@ -150,6 +150,9 @@ type ArcaneApiEndpoints struct {
DeploymentEndpoint string
HeartbeatEndpoint string
+ // Dashboard
+ DashboardActionItemsEndpoint string
+
// Assets
AppImagesFaviconEndpoint string
AppImagesLogoEndpoint string
@@ -310,6 +313,9 @@ var Endpoints = ArcaneApiEndpoints{ //nolint:gosec // static endpoint paths; aut
DeploymentEndpoint: "/api/environments/%s/deployment",
HeartbeatEndpoint: "/api/environments/%s/heartbeat",
+ // Dashboard
+ DashboardActionItemsEndpoint: "/api/environments/%s/dashboard/action-items",
+
// Assets
AppImagesFaviconEndpoint: "/api/app-images/favicon",
AppImagesLogoEndpoint: "/api/app-images/logo",
@@ -652,6 +658,11 @@ func (e ArcaneApiEndpoints) Heartbeat(envID string) string {
return fmt.Sprintf(e.HeartbeatEndpoint, envID)
}
+// Dashboard endpoints
+func (e ArcaneApiEndpoints) DashboardActionItems(envID string) string {
+ return fmt.Sprintf(e.DashboardActionItemsEndpoint, envID)
+}
+
// Version & Health endpoints
func (e ArcaneApiEndpoints) AppVersion() string { return e.AppVersionEndpoint }
func (e ArcaneApiEndpoints) Version() string { return e.VersionEndpoint }
diff --git a/cli/pkg/alerts/cmd.go b/cli/pkg/alerts/cmd.go
new file mode 100644
index 000000000..f76876be9
--- /dev/null
+++ b/cli/pkg/alerts/cmd.go
@@ -0,0 +1,101 @@
+package alerts
+
+import (
+ "fmt"
+ "net/url"
+ "strings"
+
+ "github.com/getarcaneapp/arcane/cli/internal/cmdutil"
+ "github.com/getarcaneapp/arcane/cli/internal/output"
+ "github.com/getarcaneapp/arcane/cli/internal/types"
+ "github.com/getarcaneapp/arcane/types/base"
+ dashboardtypes "github.com/getarcaneapp/arcane/types/dashboard"
+ "github.com/spf13/cobra"
+)
+
+var debugAllGood bool
+
+// AlertsCmd shows dashboard alerts/action items.
+var AlertsCmd = &cobra.Command{
+ Use: "alerts",
+ Aliases: []string{"alert", "actionitems"},
+ Short: "Show dashboard alerts",
+ SilenceUsage: true,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ c, err := cmdutil.ClientFromCommand(cmd)
+ if err != nil {
+ return err
+ }
+
+ path := types.Endpoints.DashboardActionItems(c.EnvID())
+ if debugAllGood {
+ parsed, err := url.Parse(path)
+ if err != nil {
+ return fmt.Errorf("failed to parse endpoint path: %w", err)
+ }
+ q := parsed.Query()
+ q.Set("debugAllGood", "true")
+ parsed.RawQuery = q.Encode()
+ path = parsed.String()
+ }
+
+ resp, err := c.Get(cmd.Context(), path)
+ if err != nil {
+ return fmt.Errorf("failed to get dashboard alerts: %w", err)
+ }
+ defer func() { _ = resp.Body.Close() }()
+
+ var result base.ApiResponse[dashboardtypes.ActionItems]
+ if err := cmdutil.DecodeJSON(resp, &result); err != nil {
+ return fmt.Errorf("failed to parse response: %w", err)
+ }
+
+ if cmdutil.JSONOutputEnabled(cmd) {
+ return cmdutil.PrintJSON(result.Data)
+ }
+
+ items := result.Data.Items
+ if len(items) == 0 {
+ output.Success("No alerts. Environment is good.")
+ return nil
+ }
+
+ output.Header("Dashboard Alerts")
+ headers := []string{"KIND", "COUNT", "SEVERITY"}
+ rows := make([][]string, 0, len(items))
+ for _, item := range items {
+ rows = append(rows, []string{
+ formatActionItemKind(item.Kind),
+ fmt.Sprintf("%d", item.Count),
+ strings.ToUpper(string(item.Severity)),
+ })
+ }
+ output.Table(headers, rows)
+ output.Info("Total: %d alert(s)", len(items))
+ return nil
+ },
+}
+
+func formatActionItemKind(kind dashboardtypes.ActionItemKind) string {
+ switch kind {
+ case dashboardtypes.ActionItemKindStoppedContainers:
+ return "Stopped Containers"
+ case dashboardtypes.ActionItemKindImageUpdates:
+ return "Image Updates"
+ case dashboardtypes.ActionItemKindActionableVulnerabilities:
+ return "Actionable Vulnerabilities"
+ case dashboardtypes.ActionItemKindExpiringKeys:
+ return "Expiring Keys"
+ default:
+ value := strings.TrimSpace(string(kind))
+ if value == "" {
+ return "-"
+ }
+ return strings.ReplaceAll(value, "_", " ")
+ }
+}
+
+func init() {
+ AlertsCmd.Flags().Bool("json", false, "Output in JSON format")
+ AlertsCmd.Flags().BoolVar(&debugAllGood, "debug-all-good", false, "Force no alerts (debug mode)")
+}
diff --git a/cli/pkg/config/cmd.go b/cli/pkg/config/cmd.go
index 0385775ed..7a26bd7ff 100644
--- a/cli/pkg/config/cmd.go
+++ b/cli/pkg/config/cmd.go
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"net/http"
+ "slices"
"sort"
"strconv"
"strings"
@@ -70,13 +71,7 @@ var configShowCmd = &cobra.Command{
if cfg.Pagination.Resources != nil {
extras := make([]string, 0)
for k, v := range cfg.Pagination.Resources {
- known := false
- for _, resource := range clitypes.KnownPaginatedResources {
- if resource == k {
- known = true
- break
- }
- }
+ known := slices.Contains(clitypes.KnownPaginatedResources, k)
if !known && v.Limit > 0 {
extras = append(extras, k)
}
@@ -312,13 +307,7 @@ func parseResourceLimitPair(pair string) (resource string, limit int, ok bool) {
if resource == "" {
return "", 0, false
}
- known := false
- for _, candidate := range clitypes.KnownPaginatedResources {
- if candidate == resource {
- known = true
- break
- }
- }
+ known := slices.Contains(clitypes.KnownPaginatedResources, resource)
if !known {
return "", 0, false
}
@@ -509,12 +498,7 @@ func applyResourceLimitByKey(cfg *clitypes.Config, key, resourceValue, limitValu
}
func isKnownPaginatedResource(resource string) bool {
- for _, candidate := range clitypes.KnownPaginatedResources {
- if candidate == resource {
- return true
- }
- }
- return false
+ return slices.Contains(clitypes.KnownPaginatedResources, resource)
}
func parseLimitValue(key, value string) (int, error) {
diff --git a/cli/pkg/root.go b/cli/pkg/root.go
index 2958e167e..55c1bb4d4 100644
--- a/cli/pkg/root.go
+++ b/cli/pkg/root.go
@@ -21,6 +21,7 @@
// # Command Groups
//
// - admin: Administration & platform management
+// - alerts: Show dashboard alerts
// - auth: Authentication operations
// - config: Manage CLI configuration
// - containers: Manage containers
@@ -46,6 +47,7 @@ import (
"github.com/getarcaneapp/arcane/cli/internal/runstate"
runtimectx "github.com/getarcaneapp/arcane/cli/internal/runtime"
"github.com/getarcaneapp/arcane/cli/pkg/admin"
+ "github.com/getarcaneapp/arcane/cli/pkg/alerts"
"github.com/getarcaneapp/arcane/cli/pkg/auth"
"github.com/getarcaneapp/arcane/cli/pkg/completion"
configClient "github.com/getarcaneapp/arcane/cli/pkg/config"
@@ -187,6 +189,7 @@ func init() {
rootCmd.AddCommand(generate.GenerateCmd)
rootCmd.AddCommand(version.VersionCmd)
rootCmd.AddCommand(auth.AuthCmd)
+ rootCmd.AddCommand(alerts.AlertsCmd)
rootCmd.AddCommand(containers.ContainersCmd)
rootCmd.AddCommand(images.ImagesCmd)
rootCmd.AddCommand(volumes.VolumesCmd)
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 14e8c4f51..bca6ae213 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -343,6 +343,17 @@
"_comment_dashboard": "=== DASHBOARD ===",
"dashboard_title": "Dashboard",
"dashboard_subtitle": "Overview of your Container Environment",
+ "dashboard_greeting_welcome_back": "Welcome back",
+ "dashboard_greeting_morning": "Good morning",
+ "dashboard_greeting_afternoon": "Good afternoon",
+ "dashboard_greeting_evening": "Good evening",
+ "dashboard_greeting_with_name": "{greeting}, {name}",
+ "dashboard_greeting_without_name": "{greeting}",
+ "dashboard_hero_summary": "Running {running}/{total} containers across {images} images.",
+ "dashboard_action_items_title": "Action Items",
+ "dashboard_overview_caption": "Live resource telemetry and Docker runtime snapshot.",
+ "dashboard_resource_tables_title": "Containers and Images",
+ "dashboard_no_actionable_events": "No actionable events found",
"dashboard_system_overview": "System Overview",
"dashboard_start_all_failed": "Failed to start all containers",
"dashboard_start_all_success": "All containers started successfully",
diff --git a/frontend/src/lib/components/dialogs/docker-info-dialog.svelte b/frontend/src/lib/components/dialogs/docker-info-dialog.svelte
index b6204a5d8..93a910f5c 100644
--- a/frontend/src/lib/components/dialogs/docker-info-dialog.svelte
+++ b/frontend/src/lib/components/dialogs/docker-info-dialog.svelte
@@ -44,13 +44,13 @@
{@render resourcesSection()}
</div>
- <div class="grid gap-6 lg:grid-cols-3">
+ <div class="grid gap-6 lg:grid-cols-2 xl:grid-cols-3">
{@render systemSection()}
{@render versionSection()}
{@render configurationSection()}
</div>
- <div class="grid gap-6 lg:grid-cols-3">
+ <div class="grid gap-6 lg:grid-cols-2 xl:grid-cols-3">
{@render networkSection()}
{@render securitySection()}
{@render pluginsSection()}
@@ -69,10 +69,10 @@
{m.docker_info_stats_section()}
</h3>
<div class="grid gap-3 sm:grid-cols-4">
- {@render statCard(m.common_running(), dockerInfo?.ContainersRunning ?? 0, 'emerald', true)}
- {@render statCard(m.docker_info_paused_label(), dockerInfo?.ContainersPaused ?? 0, 'amber', true)}
- {@render statCard(m.common_stopped(), dockerInfo?.ContainersStopped ?? 0, 'red', true)}
- {@render statCard(m.docker_info_images_label(), dockerInfo?.Images ?? 0, 'blue', true)}
+ {@render statCard(m.common_running(), dockerInfo?.ContainersRunning ?? 0, 'emerald')}
+ {@render statCard(m.docker_info_paused_label(), dockerInfo?.ContainersPaused ?? 0, 'amber')}
+ {@render statCard(m.common_stopped(), dockerInfo?.ContainersStopped ?? 0, 'red')}
+ {@render statCard(m.docker_info_images_label(), dockerInfo?.Images ?? 0, 'blue')}
</div>
</div>
{/snippet}
@@ -84,13 +84,13 @@
</h3>
<div class="space-y-1.5 rounded-lg border p-3">
{@render infoRow(m.common_name(), dockerInfo?.Name)}
- {@render infoRow(m.common_id(), dockerInfo?.ID, true, true)}
+ {@render infoRow(m.common_id(), dockerInfo?.ID, true)}
{@render infoRow(m.docker_info_os_label(), dockerInfo?.OperatingSystem)}
{@render infoRow(m.docker_info_os_type_label(), dockerInfo?.OSType)}
{@render infoRow(m.common_architecture(), dockerInfo?.Architecture)}
{@render infoRow(m.docker_info_kernel_version_label(), dockerInfo?.KernelVersion)}
{@render infoRow(m.docker_info_system_time(), formatTime(dockerInfo?.SystemTime), false)}
- {@render infoRow(m.docker_info_root_dir(), dockerInfo?.DockerRootDir, true, true)}
+ {@render infoRow(m.docker_info_root_dir(), dockerInfo?.DockerRootDir, true)}
</div>
</div>
{/snippet}
@@ -128,21 +128,21 @@
<div class="rounded-lg border p-3">
<div class="text-muted-foreground mb-1 text-[10px] tracking-tight uppercase">{m.common_cpus()}</div>
<div class="flex items-center gap-2">
- <Badge variant="secondary" class="text-sm font-bold">{dockerInfo?.NCPU ?? 0}</Badge>
+ <Badge variant="outline" class="text-sm font-bold">{dockerInfo?.NCPU ?? 0}</Badge>
<span class="text-muted-foreground text-[10px]">cores</span>
</div>
</div>
<div class="rounded-lg border p-3">
<div class="text-muted-foreground mb-1 text-[10px] tracking-tight uppercase">{m.docker_info_memory_label()}</div>
- <Badge variant="secondary" class="text-sm font-bold">{formattedMemory}</Badge>
+ <Badge variant="outline" class="text-sm font-bold">{formattedMemory}</Badge>
</div>
<div class="rounded-lg border p-3">
<div class="text-muted-foreground mb-1 text-[10px] tracking-tight uppercase">{m.docker_info_goroutines()}</div>
- <Badge variant="secondary" class="text-sm font-bold">{dockerInfo?.NGoroutines ?? 0}</Badge>
+ <Badge variant="outline" class="text-sm font-bold">{dockerInfo?.NGoroutines ?? 0}</Badge>
</div>
<div class="rounded-lg border p-3">
<div class="text-muted-foreground mb-1 text-[10px] tracking-tight uppercase">{m.docker_info_file_descriptors()}</div>
- <Badge variant="secondary" class="text-sm font-bold">{dockerInfo?.NFd ?? 0}</Badge>
+ <Badge variant="outline" class="text-sm font-bold">{dockerInfo?.NFd ?? 0}</Badge>
</div>
</div>
</div>
@@ -234,7 +234,7 @@
<div class="text-muted-foreground mb-1 text-[10px] tracking-tight uppercase">{m.docker_info_security_options()}</div>
<div class="flex flex-wrap gap-1">
{#each dockerInfo?.SecurityOptions ?? [] as opt}
- <Badge variant="secondary" class="px-1.5 py-0 text-[10px]">{opt}</Badge>
+ <Badge variant="outline" class="px-1.5 py-0 text-[10px]">{opt}</Badge>
{:else}
<span class="text-muted-foreground text-xs">-</span>
{/each}
@@ -254,12 +254,7 @@
</div>
{/snippet}
-{#snippet statCard(
- label: string,
- value: number,
- color: 'emerald' | 'amber' | 'red' | 'blue' | 'neutral',
- outline: boolean = false
-)}
+{#snippet statCard(label: string, value: number, color: 'emerald' | 'amber' | 'red' | 'blue' | 'neutral')}
{@const colors = {
emerald: {
bg: 'bg-emerald-500/5',
@@ -284,22 +279,16 @@
}}
<div class="rounded-lg border p-3 {colors[color].bg}">
<div class="text-muted-foreground mb-1 text-[10px] tracking-tight uppercase">{label}</div>
- {#if color === 'neutral'}
- <Badge variant="secondary" class="rounded-md text-xl font-bold tabular-nums">
- {value}
- </Badge>
- {:else}
- <Badge variant={outline ? 'outline' : undefined} class="{colors[color].badge} rounded-md text-base font-bold">
- {value}
- </Badge>
- {/if}
+ <Badge variant="outline" class="{colors[color].badge} rounded-md text-base font-bold tabular-nums">
+ {value}
+ </Badge>
</div>
{/snippet}
-{#snippet infoRow(label: string, value: string | undefined | null, mono: boolean = true, truncate: boolean = false)}
- <div class="flex items-center justify-between gap-4">
- <span class="text-muted-foreground shrink-0 text-[10px] tracking-tight uppercase">{label}</span>
- <span class="text-xs {mono ? 'font-mono' : ''} {truncate ? 'max-w-[180px] truncate' : ''}" title={value ?? ''}>
+{#snippet infoRow(label: string, value: string | undefined | null, mono: boolean = true)}
+ <div class="grid grid-cols-[minmax(112px,38%)_minmax(0,1fr)] items-start gap-x-4 gap-y-1">
+ <span class="text-muted-foreground text-[10px] tracking-tight uppercase">{label}</span>
+ <span class="text-right text-xs [overflow-wrap:anywhere] {mono ? 'font-mono' : ''}">
{value || '-'}
</span>
</div>
diff --git a/frontend/src/lib/query/query-keys.ts b/frontend/src/lib/query/query-keys.ts
index 30b9bc281..faea51192 100644
--- a/frontend/src/lib/query/query-keys.ts
+++ b/frontend/src/lib/query/query-keys.ts
@@ -74,6 +74,10 @@ export const queryKeys = {
versionInfo: (environmentId: string) => ['system', 'version-info', environmentId] as const,
dockerInfo: (environmentId: string) => ['system', 'docker-info', environmentId] as const
},
+ dashboard: {
+ actionItems: (environmentId: string, debugAllGood = false) =>
+ ['dashboard', 'action-items', environmentId, debugAllGood ? 'debug-all-good' : 'normal'] as const
+ },
containers: {
all: ['containers'] as const,
list: (environmentId: string, options: SearchPaginationSortRequest) =>
diff --git a/frontend/src/lib/services/dashboard-service.ts b/frontend/src/lib/services/dashboard-service.ts
new file mode 100644
index 000000000..84a353e89
--- /dev/null
+++ b/frontend/src/lib/services/dashboard-service.ts
@@ -0,0 +1,24 @@
+import BaseAPIService from './api-service';
+import { environmentStore } from '$lib/stores/environment.store.svelte';
+import type { DashboardActionItems } from '$lib/types/dashboard.type';
+
+interface GetDashboardActionItemsOptions {
+ debugAllGood?: boolean;
+}
+
+export class DashboardService extends BaseAPIService {
+ async getActionItems(): Promise<DashboardActionItems> {
+ const envId = await environmentStore.getCurrentEnvironmentId();
+ return this.getActionItemsForEnvironment(envId);
+ }
+
+ async getActionItemsForEnvironment(
+ environmentId: string,
+ options?: GetDashboardActionItemsOptions
+ ): Promise<DashboardActionItems> {
+ const params = options?.debugAllGood ? { debugAllGood: 'true' } : undefined;
+ return this.handleResponse(this.api.get(`/environments/${environmentId}/dashboard/action-items`, { params }));
+ }
+}
+
+export const dashboardService = new DashboardService();
diff --git a/frontend/src/lib/types/dashboard.type.ts b/frontend/src/lib/types/dashboard.type.ts
new file mode 100644
index 000000000..166788c97
--- /dev/null
+++ b/frontend/src/lib/types/dashboard.type.ts
@@ -0,0 +1,13 @@
+export type DashboardActionItemKind = 'stopped_containers' | 'image_updates' | 'actionable_vulnerabilities' | 'expiring_keys';
+
+export type DashboardActionItemSeverity = 'warning' | 'critical';
+
+export interface DashboardActionItem {
+ kind: DashboardActionItemKind;
+ count: number;
+ severity: DashboardActionItemSeverity;
+}
+
+export interface DashboardActionItems {
+ items: DashboardActionItem[];
+}
diff --git a/frontend/src/routes/(app)/dashboard/+page.svelte b/frontend/src/routes/(app)/dashboard/+page.svelte
index f0c41c98b..66e08235f 100644
--- a/frontend/src/routes/(app)/dashboard/+page.svelte
+++ b/frontend/src/routes/(app)/dashboard/+page.svelte
@@ -1,26 +1,42 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import PruneConfirmationDialog from '$lib/components/dialogs/prune-confirmation-dialog.svelte';
+ import DockerInfoDialog from '$lib/components/dialogs/docker-info-dialog.svelte';
+ import * as Card from '$lib/components/ui/card/index.js';
+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';
import { handleApiResultWithCallbacks } from '$lib/utils/api.util';
import { tryCatch } from '$lib/utils/try-catch';
import { openConfirmDialog } from '$lib/components/confirm-dialog';
import { onMount } from 'svelte';
import { environmentStore } from '$lib/stores/environment.store.svelte';
+ import userStore from '$lib/stores/user-store';
import { createStatsWebSocket } from '$lib/utils/ws';
import type { ReconnectingWebSocket } from '$lib/utils/ws';
- import MeterMetric from '$lib/components/meter-metric.svelte';
- import DiskMeter from '$lib/components/disk-meter.svelte';
- import GpuMeter from '$lib/components/gpu-meter.svelte';
+ import type { User } from '$lib/types/user.type';
import QuickActions from '$lib/components/quick-actions.svelte';
- import DockerOverview from '$lib/components/docker-overview.svelte';
import type { SystemStats } from '$lib/types/system-stats.type';
+ import DashboardActionCard from './dash-action-card.svelte';
+ import DashboardMetricTile from './dash-metric-tile.svelte';
import DashboardContainerTable from './dash-container-table.svelte';
import DashboardImageTable from './dash-image-table.svelte';
import { m } from '$lib/paraglide/messages';
import { invalidateAll } from '$app/navigation';
import { systemService } from '$lib/services/system-service';
import bytes from '$lib/utils/bytes';
- import { CpuIcon, MemoryStickIcon } from '$lib/icons';
+ import {
+ CpuIcon,
+ MemoryStickIcon,
+ StatsIcon,
+ UpdateIcon,
+ AlertTriangleIcon,
+ VolumesIcon,
+ ContainersIcon,
+ ImagesIcon,
+ GpuIcon,
+ InfoIcon,
+ ApiKeyIcon,
+ CheckIcon
+ } from '$lib/icons';
let { data } = $props();
let containers = $derived(data.containers);
@@ -28,9 +44,27 @@
let dockerInfo = $derived(data.dockerInfo);
let containerStatusCounts = $derived(data.containerStatusCounts);
let settings = $derived(data.settings);
+ let imageUsageCounts = $derived(
+ (
+ data as {
+ imageUsageCounts?: { imagesInuse?: number; imagesUnused?: number } | null;
+ }
+ ).imageUsageCounts
+ );
+ let dashboardActionItems = $derived(
+ (
+ data as {
+ dashboardActionItems?: { items?: Array<{ kind: string; count: number }> } | null;
+ }
+ ).dashboardActionItems
+ );
+ let debugAllGood = $derived((data as { debugAllGood?: boolean }).debugAllGood ?? false);
+ let initialUserFromData = $derived((data as { user?: User | null }).user ?? null);
+ let currentUser = $state<User | null>(null);
let systemStats = $state<SystemStats | null>(null);
let isPruneDialogOpen = $state(false);
+ let dockerInfoDialogOpen = $state(false);
type PruneType = 'containers' | 'images' | 'networks' | 'volumes' | 'buildCache';
@@ -48,67 +82,159 @@
let statsWSClient: ReconnectingWebSocket<SystemStats> | null = null;
let hasInitialStatsLoaded = $state(false);
- let historicalData = $state({
- cpu: [] as Array<{ date: Date; value: number }>,
- memory: [] as Array<{ date: Date; value: number }>,
- disk: [] as Array<{ date: Date; value: number }>,
- gpu: [] as Array<{ date: Date; value: number }>,
- containers: [] as Array<{ date: Date; value: number }>
- });
-
const stoppedContainers = $derived(containerStatusCounts.stoppedContainers);
const runningContainers = $derived(containerStatusCounts.runningContainers);
const totalContainers = $derived(containerStatusCounts.totalContainers);
const currentStats = $derived(systemStats);
- function addToHistoricalData(stats: SystemStats) {
- const now = new Date();
- const maxPoints = 20;
+ const dashboardAttentionCounts = $derived.by(() => {
+ const counts = {
+ stoppedContainers: 0,
+ imageUpdates: 0,
+ actionableVulnerabilities: 0,
+ expiringApiKeys: 0
+ };
- if (stats.cpuUsage !== undefined) {
- historicalData.cpu.push({ date: now, value: stats.cpuUsage });
- if (historicalData.cpu.length > maxPoints) {
- historicalData.cpu = historicalData.cpu.slice(-maxPoints);
+ for (const item of dashboardActionItems?.items ?? []) {
+ if (item.kind === 'stopped_containers') {
+ counts.stoppedContainers = item.count;
+ } else if (item.kind === 'image_updates') {
+ counts.imageUpdates = item.count;
+ } else if (item.kind === 'actionable_vulnerabilities') {
+ counts.actionableVulnerabilities = item.count;
+ } else if (item.kind === 'expiring_keys') {
+ counts.expiringApiKeys = item.count;
}
}
- if (stats.memoryUsage !== undefined && stats.memoryTotal !== undefined) {
- const memoryPercent = (stats.memoryUsage / stats.memoryTotal) * 100;
- historicalData.memory.push({ date: now, value: memoryPercent });
- if (historicalData.memory.length > maxPoints) {
- historicalData.memory = historicalData.memory.slice(-maxPoints);
- }
- }
+ return counts;
+ });
- if (stats.diskUsage !== undefined && stats.diskTotal !== undefined) {
- const diskPercent = (stats.diskUsage / stats.diskTotal) * 100;
- historicalData.disk.push({ date: now, value: diskPercent });
- if (historicalData.disk.length > maxPoints) {
- historicalData.disk = historicalData.disk.slice(-maxPoints);
- }
- }
+ const stoppedContainersAttentionCount = $derived(dashboardAttentionCounts.stoppedContainers);
+ const imageUpdatesAttentionCount = $derived(dashboardAttentionCounts.imageUpdates);
+ const actionableVulnerabilitiesAttentionCount = $derived(dashboardAttentionCounts.actionableVulnerabilities);
+ const expiringApiKeysAttentionCount = $derived(dashboardAttentionCounts.expiringApiKeys);
- if (stats.gpus && stats.gpus.length > 0) {
- // Track average GPU memory usage percentage across all GPUs
- // Filter out GPUs with zero total memory to avoid invalid calculations
- const validGpus = stats.gpus.filter((gpu) => gpu.memoryTotal > 0);
-
- if (validGpus.length > 0) {
- const totalGpuPercent = validGpus.reduce((sum, gpu) => {
- return sum + (gpu.memoryUsed / gpu.memoryTotal) * 100;
- }, 0);
- const avgGpuPercent = totalGpuPercent / validGpus.length;
- historicalData.gpu.push({ date: now, value: avgGpuPercent });
- if (historicalData.gpu.length > maxPoints) {
- historicalData.gpu = historicalData.gpu.slice(-maxPoints);
- }
- }
+ const imagesInUseCount = $derived(imageUsageCounts?.imagesInuse ?? 0);
+ const imagesUnusedCount = $derived(imageUsageCounts?.imagesUnused ?? 0);
+
+ const containerHealthPercent = $derived(totalContainers > 0 ? Math.round((runningContainers / totalContainers) * 100) : 100);
+ const diskUsagePercent = $derived.by(() => {
+ if (!currentStats?.diskTotal || currentStats.diskTotal <= 0 || currentStats.diskUsage === undefined) return null;
+ return (currentStats.diskUsage / currentStats.diskTotal) * 100;
+ });
+ const diskRisk = $derived.by(() => {
+ if (diskUsagePercent === null) return 'unknown';
+ if (diskUsagePercent >= 90) return 'critical';
+ if (diskUsagePercent >= 80) return 'high';
+ if (diskUsagePercent >= 65) return 'moderate';
+ return 'healthy';
+ });
+ const diskRiskLabel = $derived.by(() => {
+ if (diskRisk === 'critical') return m.vuln_severity_critical();
+ if (diskRisk === 'high') return m.vuln_severity_high();
+ if (diskRisk === 'moderate') return m.vuln_severity_medium();
+ if (diskRisk === 'healthy') return m.vuln_clean();
+ return m.common_unknown();
+ });
+ const diskRiskBadgeVariant = $derived.by(() => {
+ if (diskRisk === 'critical') return 'red';
+ if (diskRisk === 'high') return 'orange';
+ if (diskRisk === 'moderate') return 'amber';
+ if (diskRisk === 'healthy') return 'green';
+ return 'gray';
+ });
+ const hasDiskPressureAlert = $derived(!debugAllGood && (diskRisk === 'critical' || diskRisk === 'high'));
+ const showNeedsAttention = $derived(
+ !debugAllGood &&
+ (stoppedContainersAttentionCount > 0 ||
+ imageUpdatesAttentionCount > 0 ||
+ actionableVulnerabilitiesAttentionCount > 0 ||
+ expiringApiKeysAttentionCount > 0 ||
+ hasDiskPressureAlert)
+ );
+ const attentionItemsCount = $derived(
+ debugAllGood
+ ? 0
+ : (stoppedContainersAttentionCount > 0 ? 1 : 0) +
+ (imageUpdatesAttentionCount > 0 ? 1 : 0) +
+ (actionableVulnerabilitiesAttentionCount > 0 ? 1 : 0) +
+ (expiringApiKeysAttentionCount > 0 ? 1 : 0) +
+ (hasDiskPressureAlert ? 1 : 0)
+ );
+ const stoppedContainersBadgeText = $derived(`${stoppedContainersAttentionCount} ${m.common_stopped()}`);
+ const imageUpdatesBadgeText = $derived(`${imageUpdatesAttentionCount} ${m.common_pending()}`);
+ const actionableVulnerabilitiesBadgeText = $derived(`${m.vuln_severity_critical()} + ${m.vuln_severity_high()}`);
+ const expiringApiKeysBadgeText = $derived(`${expiringApiKeysAttentionCount} ${m.common_pending()}`);
+ const containerHealthLabel = $derived(`${runningContainers}/${totalContainers} ${m.common_running()}`);
+ const imageUsageLabel = $derived(`${imagesInUseCount} ${m.common_in_use()} · ${imagesUnusedCount} ${m.common_unused()}`);
+ const diskPressureValue = $derived(diskUsagePercent === null ? '--' : `${diskUsagePercent.toFixed(1)}%`);
+ const diskPressureDescription = $derived.by(() => {
+ if (currentStats?.diskUsage !== undefined && currentStats?.diskTotal) {
+ return `${bytes.format(currentStats.diskUsage, { unitSeparator: ' ' }) ?? '-'} / ${bytes.format(currentStats.diskTotal, { unitSeparator: ' ' }) ?? '-'}`;
}
+ return m.common_loading();
+ });
+
+ const cpuMetric = $derived.by(() => {
+ if (isLoading.loadingStats || !hasInitialStatsLoaded) return null;
+ return currentStats?.cpuUsage ?? null;
+ });
+ const memoryMetric = $derived.by(() => {
+ if (isLoading.loadingStats || !hasInitialStatsLoaded) return null;
+ if (currentStats?.memoryUsage === undefined || !currentStats.memoryTotal) return null;
+ return (currentStats.memoryUsage / currentStats.memoryTotal) * 100;
+ });
+ const diskMetric = $derived.by(() => {
+ if (isLoading.loadingStats || !hasInitialStatsLoaded) return null;
+ return diskUsagePercent;
+ });
+ const gpuMetric = $derived.by(() => {
+ if (isLoading.loadingStats || !hasInitialStatsLoaded) return null;
+ const gpus = currentStats?.gpus?.filter((gpu) => gpu.memoryTotal > 0) ?? [];
+ if (gpus.length === 0) return null;
+ const totalPercent = gpus.reduce((sum, gpu) => sum + (gpu.memoryUsed / gpu.memoryTotal) * 100, 0);
+ return totalPercent / gpus.length;
+ });
+
+ const cpuMetricLabel = $derived.by(() => `${currentStats?.cpuCount ?? 0} ${m.common_cpus()}`);
+ const memoryMetricLabel = $derived.by(() => {
+ if (currentStats?.memoryUsage === undefined || !currentStats.memoryTotal) return '--';
+ return `${bytes.format(currentStats.memoryUsage, { unitSeparator: ' ' }) ?? '-'} / ${bytes.format(currentStats.memoryTotal, { unitSeparator: ' ' }) ?? '-'}`;
+ });
+ const diskMetricLabel = $derived.by(() => {
+ if (currentStats?.diskUsage === undefined || !currentStats.diskTotal) return '--';
+ return `${bytes.format(currentStats.diskUsage, { unitSeparator: ' ' }) ?? '-'} / ${bytes.format(currentStats.diskTotal, { unitSeparator: ' ' }) ?? '-'}`;
+ });
+ const gpuMetricLabel = $derived.by(() => {
+ const count = currentStats?.gpuCount ?? 0;
+ return count > 0 ? `${count} ${count === 1 ? m.dashboard_meter_gpu_device() : m.dashboard_meter_gpu_devices()}` : '--';
+ });
+ const greetingBase = $derived.by(() => {
+ const hour = new Date().getHours();
+ if (hour >= 5 && hour < 12) return m.dashboard_greeting_morning();
+ if (hour >= 12 && hour < 18) return m.dashboard_greeting_afternoon();
+ if (hour >= 18 && hour < 23) return m.dashboard_greeting_evening();
+ return m.dashboard_greeting_welcome_back();
+ });
+ const greetingUserName = $derived.by(() => {
+ const name = currentUser?.displayName?.trim() || currentUser?.username?.trim() || '';
+ return name;
+ });
+ const dashboardHeroGreeting = $derived.by(() =>
+ greetingUserName
+ ? m.dashboard_greeting_with_name({ greeting: greetingBase, name: greetingUserName })
+ : m.dashboard_greeting_without_name({ greeting: greetingBase })
+ );
- historicalData.containers.push({ date: now, value: dockerInfo!.ContainersRunning });
- if (historicalData.containers.length > maxPoints) {
- historicalData.containers = historicalData.containers.slice(-maxPoints);
+ $effect(() => {
+ if (!currentUser && initialUserFromData) {
+ currentUser = initialUserFromData;
}
+ });
+
+ function formatPercent(value: number | null): string {
+ return value === null ? '--' : `${value.toFixed(1)}%`;
}
async function refreshData() {
@@ -119,6 +245,9 @@
onMount(() => {
let mounted = true;
+ const unsubscribeUser = userStore.subscribe((user) => {
+ currentUser = user ?? initialUserFromData;
+ });
(async () => {
await environmentStore.ready;
@@ -130,6 +259,7 @@
return () => {
mounted = false;
+ unsubscribeUser();
statsWSClient?.close();
statsWSClient = null;
};
@@ -138,13 +268,6 @@
function resetStats() {
systemStats = null;
hasInitialStatsLoaded = false;
- historicalData = {
- cpu: [],
- memory: [],
- disk: [],
- gpu: [],
- containers: []
- };
}
function setupStatsWS() {
@@ -167,7 +290,6 @@
},
onMessage: (data) => {
systemStats = data;
- addToHistoricalData(data);
hasInitialStatsLoaded = true;
isLoading.loadingStats = false;
},
@@ -272,111 +394,228 @@
}
</script>
-<div class="flex min-h-full flex-col space-y-6 pt-3 md:space-y-10 md:pt-5">
- <header class="flex items-center justify-between gap-4">
- <div class="flex min-w-0 flex-1 items-center gap-3 sm:gap-4">
- <div class="min-w-0">
- <h1 class="text-2xl font-bold tracking-tight sm:text-3xl">{m.dashboard_title()}</h1>
- <p class="text-muted-foreground mt-1 text-sm">{m.dashboard_subtitle()}</p>
+<div class="flex min-h-full flex-col gap-4 pt-3 md:gap-5 md:pt-4">
+ <header class="border-border/70 bg-card rounded-xl border p-4 shadow-sm sm:p-5">
+ <div class="relative flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between">
+ <div class="space-y-1.5">
+ <p class="text-muted-foreground text-[11px] font-semibold tracking-[0.14em] uppercase">{m.dashboard_title()}</p>
+ <h1 class="text-2xl font-bold tracking-tight sm:text-3xl">{dashboardHeroGreeting}</h1>
+ <p class="text-muted-foreground text-sm">
+ {m.dashboard_hero_summary({ running: runningContainers, total: totalContainers, images: images.pagination.totalItems })}
+ </p>
</div>
- </div>
- <QuickActions
- class="min-w-0 flex-1"
- compact
- user={data.user}
- {dockerInfo}
- {stoppedContainers}
- {runningContainers}
- loadingDockerInfo={isLoading.loadingDockerInfo}
- isLoading={{ starting: isLoading.starting, stopping: isLoading.stopping, pruning: isLoading.pruning }}
- onStartAll={handleStartAll}
- onStopAll={handleStopAll}
- onOpenPruneDialog={() => (isPruneDialogOpen = true)}
- onRefresh={refreshData}
- refreshing={isLoading.refreshing}
- />
+ <QuickActions
+ class="w-full justify-start lg:w-auto lg:justify-end"
+ compact
+ user={data.user}
+ {dockerInfo}
+ {stoppedContainers}
+ {runningContainers}
+ loadingDockerInfo={isLoading.loadingDockerInfo}
+ isLoading={{ starting: isLoading.starting, stopping: isLoading.stopping, pruning: isLoading.pruning }}
+ onStartAll={handleStartAll}
+ onStopAll={handleStopAll}
+ onOpenPruneDialog={() => (isPruneDialogOpen = true)}
+ onRefresh={refreshData}
+ refreshing={isLoading.refreshing}
+ />
+ </div>
</header>
- <section>
- <div class="mb-4 flex items-center justify-between gap-4">
- <h2 class="text-lg font-semibold tracking-tight">{m.dashboard_system_overview()}</h2>
- {#if currentStats?.hostname}
- <div class="text-muted-foreground flex items-center gap-2 text-sm">
- <span class="text-muted-foreground/70">Hostname:</span>
- <code class="bg-muted rounded px-2 py-0.5 font-mono text-xs">{currentStats.hostname}</code>
- </div>
- {/if}
- </div>
- <div class="space-y-3">
- <div
- class="grid grid-cols-2 gap-3 sm:grid-cols-2 {currentStats?.gpuCount && currentStats.gpuCount > 0
- ? 'lg:grid-cols-4'
- : 'lg:grid-cols-3'}"
- >
- <MeterMetric
- title={m.dashboard_meter_cpu()}
- icon={CpuIcon}
- description={m.dashboard_meter_cpu_desc()}
- currentValue={isLoading.loadingStats || !hasInitialStatsLoaded ? undefined : currentStats?.cpuUsage}
- unit="%"
- maxValue={100}
- formatValue={(v) => `${v.toFixed(1)}`}
- loading={isLoading.loadingStats || !hasInitialStatsLoaded}
- showAbsoluteValues={true}
- formatAbsoluteValue={() => `${currentStats?.cpuCount || 0} ${m.common_cpus()}`}
- />
-
- <MeterMetric
- title={m.dashboard_meter_memory()}
- icon={MemoryStickIcon}
- description={m.dashboard_meter_memory_desc()}
- currentValue={isLoading.loadingStats || !hasInitialStatsLoaded ? undefined : currentStats?.memoryUsage}
- unit="%"
- formatValue={(v) => {
- if (currentStats?.memoryTotal) {
- return ((v / currentStats.memoryTotal) * 100).toFixed(1);
- }
- return '0';
- }}
- maxValue={currentStats?.memoryTotal}
- showAbsoluteValues={true}
- formatAbsoluteValue={(v) => bytes.format(v, { unitSeparator: ' ' }) ?? '-'}
- formatUsageValue={(v) => bytes.format(v, { unitSeparator: ' ' }) ?? '-'}
- loading={isLoading.loadingStats || !hasInitialStatsLoaded}
- />
-
- <DiskMeter
- diskUsage={currentStats?.diskUsage}
- diskTotal={currentStats?.diskTotal}
- loading={isLoading.loadingStats || !hasInitialStatsLoaded}
- class="col-span-2 sm:col-span-1"
- />
-
- {#if currentStats?.gpuCount && currentStats.gpuCount > 0}
- <GpuMeter gpus={currentStats?.gpus} loading={isLoading.loadingStats || !hasInitialStatsLoaded} />
- {/if}
+ <section class="space-y-1.5">
+ {#if attentionItemsCount > 0}
+ <div class="flex flex-col gap-1">
+ <h2 class="text-lg font-semibold tracking-tight">{m.dashboard_action_items_title()}</h2>
</div>
+ <div class="grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">
+ {#if stoppedContainersAttentionCount > 0}
+ <DashboardActionCard
+ title={m.containers_title()}
+ icon={ContainersIcon}
+ badgeText={stoppedContainersBadgeText}
+ badgeVariant="red"
+ value={`${runningContainers}/${totalContainers}`}
+ description={m.common_running()}
+ ctaLabel={m.common_view_all()}
+ href="/containers"
+ />
+ {/if}
- <DockerOverview
- {dockerInfo}
- containersRunning={runningContainers}
- containersStopped={stoppedContainers}
- {totalContainers}
- totalImages={images.pagination.totalItems}
- loading={isLoading.loadingDockerInfo}
- />
- </div>
+ {#if imageUpdatesAttentionCount > 0}
+ <DashboardActionCard
+ title={m.images_updates()}
+ icon={UpdateIcon}
+ badgeText={imageUpdatesBadgeText}
+ badgeVariant="amber"
+ value={imageUpdatesAttentionCount}
+ description={m.image_update_tag_description()}
+ ctaLabel={m.common_view_all()}
+ href="/images"
+ />
+ {/if}
+
+ {#if actionableVulnerabilitiesAttentionCount > 0}
+ <DashboardActionCard
+ title={m.security_title()}
+ icon={AlertTriangleIcon}
+ badgeText={actionableVulnerabilitiesBadgeText}
+ badgeVariant="red"
+ value={actionableVulnerabilitiesAttentionCount}
+ description={m.security_subtitle()}
+ ctaLabel={m.common_view()}
+ href="/security"
+ />
+ {/if}
+
+ {#if hasDiskPressureAlert}
+ <DashboardActionCard
+ title={m.dashboard_meter_disk()}
+ icon={VolumesIcon}
+ badgeText={diskRiskLabel}
+ badgeVariant={diskRiskBadgeVariant}
+ value={diskPressureValue}
+ description={diskPressureDescription}
+ ctaLabel={m.common_view_all()}
+ href="/volumes"
+ />
+ {/if}
+
+ {#if expiringApiKeysAttentionCount > 0}
+ <DashboardActionCard
+ title={m.api_key_page_title()}
+ icon={ApiKeyIcon}
+ badgeText={expiringApiKeysBadgeText}
+ badgeVariant="orange"
+ value={expiringApiKeysAttentionCount}
+ description={m.api_key_expires_at_description()}
+ ctaLabel={m.common_view_all()}
+ href="/settings/api-keys"
+ />
+ {/if}
+ </div>
+ {:else}
+ <Card.Root variant="outlined" class="border-emerald-500/30 bg-emerald-500/5 shadow-sm">
+ <Card.Content class="space-y-2.5 p-4">
+ <div class="flex items-center gap-2 text-sm font-semibold text-emerald-700 dark:text-emerald-300">
+ <CheckIcon class="size-4" />
+ <span>{m.progress_deploy_service_healthy({ service: m.environments_title() })}</span>
+ </div>
+ <p class="text-muted-foreground text-xs leading-relaxed">{m.dashboard_no_actionable_events()}</p>
+ </Card.Content>
+ </Card.Root>
+ {/if}
</section>
+ <header>
+ <Card.Root class="overflow-hidden">
+ <Card.Header icon={StatsIcon} class="items-start">
+ <div class="flex w-full min-w-0 flex-col gap-2">
+ <h2 class="text-lg font-semibold tracking-tight">{m.common_overview()}</h2>
+ <p class="text-muted-foreground text-sm">{m.dashboard_overview_caption()}</p>
+ </div>
+ </Card.Header>
+ <Card.Content class="space-y-2.5 pt-0 pb-3">
+ <div
+ class={`grid grid-cols-2 gap-1 md:grid-cols-3 md:gap-1.5 ${gpuMetric !== null ? 'xl:grid-cols-4' : 'xl:grid-cols-3'}`}
+ >
+ <DashboardMetricTile
+ title={m.dashboard_meter_cpu()}
+ icon={CpuIcon}
+ value={formatPercent(cpuMetric)}
+ label={cpuMetricLabel}
+ meterValue={cpuMetric}
+ />
+
+ <DashboardMetricTile
+ title={m.dashboard_meter_memory()}
+ icon={MemoryStickIcon}
+ value={formatPercent(memoryMetric)}
+ label={memoryMetricLabel}
+ labelClass="truncate"
+ meterValue={memoryMetric}
+ />
+
+ <DashboardMetricTile
+ title={m.dashboard_meter_disk()}
+ icon={VolumesIcon}
+ value={formatPercent(diskMetric)}
+ label={diskMetricLabel}
+ labelClass="truncate"
+ meterValue={diskMetric}
+ />
+
+ {#if gpuMetric !== null}
+ <DashboardMetricTile
+ title={m.dashboard_meter_gpu()}
+ icon={GpuIcon}
+ value={formatPercent(gpuMetric)}
+ label={gpuMetricLabel}
+ meterValue={gpuMetric}
+ />
+ {/if}
+ </div>
+
+ <div class="mt-1 flex flex-col gap-2 border-t pt-3 md:flex-row md:items-center md:justify-between">
+ <div class="min-w-0 space-y-1">
+ <div class="text-sm font-medium">{m.docker_engine_title({ engine: dockerInfo?.Name ?? m.common_unknown() })}</div>
+ <div class="text-muted-foreground flex flex-wrap items-center gap-2 text-xs">
+ <span class="inline-flex items-center gap-1.5">
+ <ContainersIcon class="size-3" />
+ <span class="font-medium text-emerald-600">{runningContainers}</span>
+ <span class="text-muted-foreground/70">/</span>
+ <span>{totalContainers}</span>
+ </span>
+ <span class="text-muted-foreground/50">•</span>
+ <span class="inline-flex items-center gap-1.5">
+ <ImagesIcon class="size-3" />
+ <span>{images.pagination.totalItems}</span>
+ <span class="text-muted-foreground/70">{m.images_title()}</span>
+ </span>
+ <span class="text-muted-foreground/50">•</span>
+ <span>{imageUsageLabel}</span>
+ <span class="text-muted-foreground/50">•</span>
+ <span class="font-mono">{dockerInfo?.OperatingSystem ?? '-'} / {dockerInfo?.Architecture ?? '-'}</span>
+ </div>
+ </div>
+
+ {#if dockerInfo}
+ <ArcaneButton
+ action="base"
+ tone="ghost"
+ size="sm"
+ icon={InfoIcon}
+ showLabel={false}
+ customLabel={m.common_inspect()}
+ class="h-7 px-2.5 text-xs"
+ onclick={() => (dockerInfoDialogOpen = true)}
+ />
+ {/if}
+ </div>
+ </Card.Content>
+ </Card.Root>
+ </header>
+
<section class="flex min-h-0 flex-1 flex-col">
- <h2 class="mb-4 text-lg font-semibold tracking-tight">Resources</h2>
- <div class="grid min-h-0 flex-1 grid-cols-1 gap-6 lg:grid-cols-2">
+ <div class="mb-3 flex items-center justify-between gap-3">
+ <h2 class="text-lg font-semibold tracking-tight">{m.dashboard_resource_tables_title()}</h2>
+ <div class="hidden items-center gap-2 md:flex">
+ <ArcaneButton action="base" tone="ghost" size="sm" href="/containers">
+ {m.containers_title()}
+ </ArcaneButton>
+ <ArcaneButton action="base" tone="ghost" size="sm" href="/images">
+ {m.images_title()}
+ </ArcaneButton>
+ </div>
+ </div>
+ <div class="grid min-h-0 flex-1 grid-cols-1 gap-4 lg:grid-cols-2">
<DashboardContainerTable bind:containers isLoading={isLoading.loadingContainers} />
<DashboardImageTable bind:images isLoading={isLoading.loadingImages} />
</div>
</section>
+ <DockerInfoDialog bind:open={dockerInfoDialogOpen} {dockerInfo} />
+
<PruneConfirmationDialog
bind:open={isPruneDialogOpen}
isPruning={isLoading.pruning}
diff --git a/frontend/src/routes/(app)/dashboard/+page.ts b/frontend/src/routes/(app)/dashboard/+page.ts
index 7b602b47f..50bbec9ee 100644
--- a/frontend/src/routes/(app)/dashboard/+page.ts
+++ b/frontend/src/routes/(app)/dashboard/+page.ts
@@ -1,4 +1,5 @@
import { containerService } from '$lib/services/container-service';
+import { dashboardService } from '$lib/services/dashboard-service';
import { imageService } from '$lib/services/image-service';
import { settingsService } from '$lib/services/settings-service';
import { systemService } from '$lib/services/system-service';
@@ -7,9 +8,10 @@ import { queryKeys } from '$lib/query/query-keys';
import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';
import type { PageLoad } from './$types';
-export const load: PageLoad = async ({ parent }) => {
+export const load: PageLoad = async ({ parent, url }) => {
const { queryClient } = await parent();
const envId = await environmentStore.getCurrentEnvironmentId();
+ const debugAllGood = url.searchParams.get('debugAllGood') === 'true';
const containerRequestOptions: SearchPaginationSortRequest = {
pagination: {
@@ -47,7 +49,7 @@ export const load: PageLoad = async ({ parent }) => {
})
]);
- const [dockerInfoResult, settingsResult] = await Promise.allSettled([
+ const [dockerInfoResult, settingsResult, imageUsageCountsResult, dashboardActionItemsResult] = await Promise.allSettled([
queryClient.fetchQuery({
queryKey: queryKeys.system.dockerInfo(envId),
queryFn: () => systemService.getDockerInfoForEnvironment(envId)
@@ -55,17 +57,30 @@ export const load: PageLoad = async ({ parent }) => {
queryClient.fetchQuery({
queryKey: queryKeys.settings.byEnvironment(envId),
queryFn: () => settingsService.getSettingsForEnvironmentMerged(envId)
+ }),
+ queryClient.fetchQuery({
+ queryKey: queryKeys.images.usageCounts(envId),
+ queryFn: () => imageService.getImageUsageCountsForEnvironment(envId)
+ }),
+ queryClient.fetchQuery({
+ queryKey: queryKeys.dashboard.actionItems(envId, debugAllGood),
+ queryFn: () => dashboardService.getActionItemsForEnvironment(envId, { debugAllGood })
})
]);
const dockerInfo = dockerInfoResult.status === 'fulfilled' ? dockerInfoResult.value : null;
const settings = settingsResult.status === 'fulfilled' ? settingsResult.value : null;
+ const imageUsageCounts = imageUsageCountsResult.status === 'fulfilled' ? imageUsageCountsResult.value : null;
+ const dashboardActionItems = dashboardActionItemsResult.status === 'fulfilled' ? dashboardActionItemsResult.value : null;
return {
dockerInfo,
containers,
images,
settings,
+ imageUsageCounts,
+ dashboardActionItems,
+ debugAllGood,
containerRequestOptions,
imageRequestOptions,
containerStatusCounts
diff --git a/frontend/src/routes/(app)/dashboard/dash-action-card.svelte b/frontend/src/routes/(app)/dashboard/dash-action-card.svelte
new file mode 100644
index 000000000..cd6628e2b
--- /dev/null
+++ b/frontend/src/routes/(app)/dashboard/dash-action-card.svelte
@@ -0,0 +1,65 @@
+<script lang="ts">
+ import * as Card from '$lib/components/ui/card/index.js';
+ import StatusBadge from '$lib/components/badges/status-badge.svelte';
+ import { ArcaneButton } from '$lib/components/arcane-button/index.js';
+ import { ArrowRightIcon, type IconType } from '$lib/icons';
+
+ type StatusVariant =
+ | 'red'
+ | 'purple'
+ | 'green'
+ | 'blue'
+ | 'gray'
+ | 'amber'
+ | 'pink'
+ | 'indigo'
+ | 'cyan'
+ | 'lime'
+ | 'emerald'
+ | 'teal'
+ | 'sky'
+ | 'violet'
+ | 'fuchsia'
+ | 'rose'
+ | 'orange';
+
+ interface Props {
+ title: string;
+ value: string | number;
+ description: string;
+ icon: IconType;
+ badgeText: string;
+ badgeVariant?: StatusVariant;
+ ctaLabel: string;
+ href: string;
+ }
+
+ let { title, value, description, icon: Icon, badgeText, badgeVariant = 'red', ctaLabel, href }: Props = $props();
+</script>
+
+<Card.Root
+ variant="outlined"
+ class="border-border/70 bg-card/75 dark:border-surface/70 dark:bg-surface/25 shadow-sm supports-[backdrop-filter]:backdrop-blur-sm"
+>
+ <Card.Content class="space-y-2.5 p-4">
+ <div class="flex items-center justify-between gap-2">
+ <div class="text-foreground/80 flex items-center gap-2 text-sm font-medium">
+ <Icon class="size-4" />
+ {title}
+ </div>
+ <StatusBadge text={badgeText} variant={badgeVariant} size="sm" minWidth="none" />
+ </div>
+ <p class="text-2xl leading-none font-semibold tracking-tight">{value}</p>
+ <p class="text-muted-foreground/90 text-xs leading-relaxed">{description}</p>
+ <ArcaneButton
+ action="base"
+ tone="ghost"
+ size="sm"
+ {href}
+ class="h-auto w-auto justify-start gap-1.5 !border-0 bg-transparent px-0 py-0 text-sm font-semibold shadow-none hover:bg-transparent"
+ >
+ {ctaLabel}
+ <ArrowRightIcon class="size-4" />
+ </ArcaneButton>
+ </Card.Content>
+</Card.Root>
diff --git a/frontend/src/routes/(app)/dashboard/dash-metric-tile.svelte b/frontend/src/routes/(app)/dashboard/dash-metric-tile.svelte
new file mode 100644
index 000000000..6d5f88005
--- /dev/null
+++ b/frontend/src/routes/(app)/dashboard/dash-metric-tile.svelte
@@ -0,0 +1,62 @@
+<script lang="ts">
+ import type { ClassValue } from 'svelte/elements';
+ import { cn } from '$lib/utils.js';
+ import type { IconType } from '$lib/icons';
+
+ interface Props {
+ title: string;
+ value: string;
+ label: string;
+ icon: IconType;
+ meterValue?: number | null;
+ labelClass?: ClassValue;
+ }
+
+ let { title, value, label, icon: Icon, meterValue = null, labelClass }: Props = $props();
+
+ const meterPercent = $derived.by(() => {
+ if (meterValue === null) return 0;
+ return Math.max(0, Math.min(100, meterValue));
+ });
+
+ const meterWidth = $derived.by(() => {
+ return `width: ${meterPercent}%`;
+ });
+
+ const meterDotStyle = $derived.by(() => {
+ return `left: calc(${meterPercent}% - 4px)`;
+ });
+</script>
+
+<div class="min-w-0 px-2.5 py-2.5">
+ <div class="flex items-start justify-between gap-2">
+ <p class="text-foreground/70 flex items-center gap-1 text-[10px] font-semibold tracking-wide uppercase">
+ <Icon class="size-3.5" />
+ {title}
+ </p>
+ <p class="text-base font-semibold tracking-tight tabular-nums">{value}</p>
+ </div>
+ <p class={cn('text-muted-foreground/90 mt-0.5 text-[11px]', labelClass)}>{label}</p>
+
+ {#if meterValue !== null}
+ <div class="mt-2.5">
+ <div class="bg-muted/45 relative h-1.5 overflow-hidden rounded-full">
+ <div class="pointer-events-none absolute inset-0">
+ {#each [25, 50, 75] as tick}
+ <span class="bg-foreground/15 absolute top-0 h-full w-px opacity-60" style={`left: ${tick}%`}></span>
+ {/each}
+ </div>
+ <div
+ class="from-primary/65 via-primary absolute inset-y-0 left-0 rounded-full bg-gradient-to-r to-violet-500/85 transition-[width] duration-700 ease-out motion-reduce:transition-none"
+ style={meterWidth}
+ ></div>
+ {#if meterPercent > 0}
+ <div
+ class="bg-primary absolute top-1/2 size-2 -translate-y-1/2 rounded-full shadow-[0_0_0_2px_hsl(var(--background))] transition-[left] duration-700 ease-out motion-reduce:transition-none"
+ style={meterDotStyle}
+ ></div>
+ {/if}
+ </div>
+ </div>
+ {/if}
+</div>
diff --git a/types/dashboard/dashboard.go b/types/dashboard/dashboard.go
new file mode 100644
index 000000000..dea064ac7
--- /dev/null
+++ b/types/dashboard/dashboard.go
@@ -0,0 +1,41 @@
+package dashboard
+
+type ActionItemKind string
+
+const (
+ ActionItemKindStoppedContainers ActionItemKind = "stopped_containers"
+ ActionItemKindImageUpdates ActionItemKind = "image_updates"
+ ActionItemKindActionableVulnerabilities ActionItemKind = "actionable_vulnerabilities"
+ ActionItemKindExpiringKeys ActionItemKind = "expiring_keys"
+)
+
+type ActionItemSeverity string
+
+const (
+ ActionItemSeverityWarning ActionItemSeverity = "warning"
+ ActionItemSeverityCritical ActionItemSeverity = "critical"
+)
+
+type ActionItem struct {
+ // Kind identifies the type of dashboard action item.
+ //
+ // Required: true
+ Kind ActionItemKind `json:"kind"`
+
+ // Count is the number of impacted resources for this action item.
+ //
+ // Required: true
+ Count int `json:"count"`
+
+ // Severity indicates urgency for the action item.
+ //
+ // Required: true
+ Severity ActionItemSeverity `json:"severity"`
+}
+
+type ActionItems struct {
+ // Items is the list of action items requiring attention.
+ //
+ // Required: true
+ Items []ActionItem `json:"items"`
+}