Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: show correct counts for stat cards (#437)
Kyle Mendelleb2ed7319a93
diff --git a/backend/internal/api/container_handler.go b/backend/internal/api/container_handler.goindex 9f36c4023..d77d71092 100644--- a/backend/internal/api/container_handler.go+++ b/backend/internal/api/container_handler.go@@ -18,10 +18,11 @@ import (type ContainerHandler struct {containerService *services.ContainerServiceimageService *services.ImageService+ dockerService *services.DockerClientService}-func NewContainerHandler(group *gin.RouterGroup, containerService *services.ContainerService, imageService *services.ImageService, authMiddleware *middleware.AuthMiddleware) {- handler := &ContainerHandler{containerService: containerService, imageService: imageService}+func NewContainerHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, containerService *services.ContainerService, imageService *services.ImageService, authMiddleware *middleware.AuthMiddleware) {+ handler := &ContainerHandler{dockerService: dockerService, containerService: containerService, imageService: imageService}apiGroup := group.Group("/containers")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -37,6 +38,7 @@ func NewContainerHandler(group *gin.RouterGroup, containerService *services.ContapiGroup.GET("/:id/logs", handler.GetLogs)apiGroup.GET("/:id/logs/stream", handler.GetLogsStream)apiGroup.DELETE("/:id", handler.Delete)+}}@@ -260,6 +262,28 @@ func (h *ContainerHandler) Delete(c *gin.Context) {})}+func (h *ContainerHandler) GetContainerStatusCounts(c *gin.Context) {+ _, running, stopped, total, err := h.dockerService.GetAllContainers(c.Request.Context())+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{+ "success": false,+ "data": gin.H{"error": "Failed to get container counts: " + err.Error()},+ })+ return+ }++ out := dto.ContainerStatusLengthsDto{+ RunningContainers: running,+ StoppedContainers: stopped,+ TotalContainers: total,+ }++ c.JSON(http.StatusOK, gin.H{+ "success": true,+ "data": out,+ })+}+func (h *ContainerHandler) IsImageInUse(c *gin.Context) {imageID := c.Param("imageId")if imageID == "" {@@ -270,7 +294,7 @@ func (h *ContainerHandler) IsImageInUse(c *gin.Context) {return}- containers, err := h.containerService.ListContainers(c.Request.Context(), true)+ containers, _, _, _, err := h.dockerService.GetAllContainers(c.Request.Context())if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,diff --git a/backend/internal/api/environment_handler.go b/backend/internal/api/environment_handler.goindex 3ae1640e8..d89942d16 100644--- a/backend/internal/api/environment_handler.go+++ b/backend/internal/api/environment_handler.go@@ -71,6 +71,7 @@ func NewEnvironmentHandler(apiGroup.POST("/:id/test", handler.TestConnection)apiGroup.POST("/:id/heartbeat", handler.UpdateHeartbeat)+ apiGroup.GET("/:id/containers/counts", handler.GetContainerStatusCounts)apiGroup.POST("/:id/containers", handler.CreateContainer)apiGroup.GET("/:id/containers", handler.GetContainers)apiGroup.GET("/:id/containers/:containerId", handler.GetContainer)@@ -89,13 +90,14 @@ func NewEnvironmentHandler(apiGroup.DELETE("/:id/images/:imageId", handler.RemoveImage)apiGroup.POST("/:id/images/pull", handler.PullImage)apiGroup.POST("/:id/images/prune", handler.PruneImages)- apiGroup.GET("/:id/images/total-size", handler.GetTotalImageSize)+ apiGroup.GET("/:id/networks/counts", handler.GetNetworkUsageCounts)apiGroup.GET("/:id/networks", handler.GetNetworks)apiGroup.POST("/:id/networks", handler.CreateNetwork)apiGroup.GET("/:id/networks/:networkId", handler.GetNetwork)apiGroup.DELETE("/:id/networks/:networkId", handler.RemoveNetwork)+ apiGroup.GET("/:id/volumes/counts", handler.GetVolumeUsageCounts)apiGroup.GET("/:id/volumes", handler.GetVolumes)apiGroup.POST("/:id/volumes", handler.CreateVolume)apiGroup.GET("/:id/volumes/:volumeName", handler.GetVolume)@@ -103,14 +105,13 @@ func NewEnvironmentHandler(apiGroup.GET("/:id/volumes/:volumeName/usage", handler.GetVolumeUsage)apiGroup.POST("/:id/volumes/prune", handler.PruneVolumes)+ apiGroup.GET("/:id/stacks/counts", handler.GetStackStatusCounts)apiGroup.GET("/:id/stacks", handler.GetStacks)apiGroup.POST("/:id/stacks", handler.CreateStack)apiGroup.GET("/:id/stacks/:stackId", handler.GetStack)apiGroup.PUT("/:id/stacks/:stackId", handler.UpdateStack)apiGroup.DELETE("/:id/stacks/:stackId", handler.DeleteStack)- apiGroup.POST("/:id/stacks/:stackId/start", handler.StartStack)apiGroup.POST("/:id/stacks/:stackId/deploy", handler.DeployStack)- apiGroup.POST("/:id/stacks/:stackId/stop", handler.StopStack)apiGroup.POST("/:id/stacks/:stackId/restart", handler.RestartStack)apiGroup.GET("/:id/stacks/:stackId/services", handler.GetStackServices)apiGroup.POST("/:id/stacks/:stackId/pull", handler.PullStackImages)@@ -120,7 +121,6 @@ func NewEnvironmentHandler(apiGroup.GET("/:id/stacks/:stackId/logs/stream", handler.GetStackLogsStream)apiGroup.POST("/:id/stacks/convert", handler.ConvertDockerRun)- // Image update endpointsapiGroup.GET("/:id/image-updates/check", handler.CheckImageUpdate)apiGroup.GET("/:id/image-updates/check/:imageId", handler.CheckImageUpdateByID)apiGroup.POST("/:id/image-updates/check-batch", handler.CheckMultipleImages)@@ -129,7 +129,6 @@ func NewEnvironmentHandler(apiGroup.GET("/:id/image-updates/versions", handler.GetImageVersions)apiGroup.POST("/:id/image-updates/compare", handler.CompareVersions)- // Updater endpointsapiGroup.POST("/:id/updater/run", handler.UpdaterRun)apiGroup.GET("/:id/updater/status", handler.UpdaterStatus)apiGroup.GET("/:id/updater/history", handler.UpdaterHistory)@@ -302,6 +301,9 @@ func (h *EnvironmentHandler) handleContainerEndpoints(c *gin.Context, endpoint s}switch {+ case endpoint == "/containers/counts" && c.Request.Method == http.MethodGet:+ containerHandler.GetContainerStatusCounts(c)+ return truecase endpoint == "/containers" && c.Request.Method == http.MethodGet:containerHandler.List(c)return true@@ -349,12 +351,12 @@ func (h *EnvironmentHandler) handleImageEndpoints(c *gin.Context, endpoint strin}switch {+ case endpoint == "/images/counts" && c.Request.Method == http.MethodGet:+ imageHandler.GetImageUsageCounts(c)+ return truecase endpoint == "/images" && c.Request.Method == http.MethodGet:imageHandler.List(c)return true- case endpoint == "/images/total-size" && c.Request.Method == http.MethodGet:- imageHandler.GetTotalSize(c)- return truecase endpoint == "/images/pull" && c.Request.Method == http.MethodPost:imageHandler.Pull(c)return true@@ -377,6 +379,9 @@ func (h *EnvironmentHandler) handleNetworkEndpoints(c *gin.Context, endpoint str}switch {+ case endpoint == "/networks/counts" && c.Request.Method == http.MethodGet:+ networkHandler.GetNetworkUsageCounts(c)+ return truecase endpoint == "/networks" && c.Request.Method == http.MethodGet:networkHandler.List(c)return true@@ -399,6 +404,9 @@ func (h *EnvironmentHandler) handleVolumeEndpoints(c *gin.Context, endpoint stri}switch {+ case endpoint == "/volumes/counts" && c.Request.Method == http.MethodGet:+ volumeHandler.GetVolumeUsageCounts(c)+ return truecase endpoint == "/volumes" && c.Request.Method == http.MethodGet:volumeHandler.List(c)return true@@ -427,6 +435,9 @@ func (h *EnvironmentHandler) handleStackEndpoints(c *gin.Context, endpoint strin}switch {+ case endpoint == "/stacks/counts" && c.Request.Method == http.MethodGet:+ stackHandler.GetProjectStatusCounts(c)+ return truecase endpoint == "/stacks" && c.Request.Method == http.MethodGet:stackHandler.ListStacks(c)return true@@ -436,12 +447,6 @@ func (h *EnvironmentHandler) handleStackEndpoints(c *gin.Context, endpoint strincase strings.HasPrefix(endpoint, "/stacks/") && strings.HasSuffix(endpoint, "/deploy"):stackHandler.DeployStack(c)return true- case strings.HasPrefix(endpoint, "/stacks/") && strings.HasSuffix(endpoint, "/start"):- stackHandler.StartStack(c)- return true- case strings.HasPrefix(endpoint, "/stacks/") && strings.HasSuffix(endpoint, "/stop"):- stackHandler.StopStack(c)- return truecase strings.HasPrefix(endpoint, "/stacks/") && strings.HasSuffix(endpoint, "/restart"):stackHandler.RestartStack(c)return true@@ -808,6 +813,10 @@ func (h *EnvironmentHandler) GetImages(c *gin.Context) {h.routeRequest(c, "/images")}+func (h *EnvironmentHandler) GetNetworkUsageCounts(c *gin.Context) {+ h.routeRequest(c, "/networks/counts")+}+func (h *EnvironmentHandler) GetNetworks(c *gin.Context) {h.routeRequest(c, "/networks")}@@ -828,6 +837,10 @@ func (h *EnvironmentHandler) CreateVolume(c *gin.Context) {h.routeRequest(c, "/volumes")}+func (h *EnvironmentHandler) GetVolumeUsageCounts(c *gin.Context) {+ h.routeRequest(c, "/volumes/counts")+}+func (h *EnvironmentHandler) CreateStack(c *gin.Context) {h.routeRequest(c, "/stacks")}@@ -839,6 +852,10 @@ func (h *EnvironmentHandler) GetContainer(c *gin.Context) {h.routeRequest(c, "/containers/"+containerID)}+func (h *EnvironmentHandler) GetContainerStatusCounts(c *gin.Context) {+ h.routeRequest(c, "/containers/counts")+}+func (h *EnvironmentHandler) StartContainer(c *gin.Context) {containerID := c.Param("containerId")h.routeRequest(c, "/containers/"+containerID+"/start")@@ -897,8 +914,8 @@ func (h *EnvironmentHandler) GetImage(c *gin.Context) {h.routeRequest(c, "/images/"+imageID)}-func (h *EnvironmentHandler) GetTotalImageSize(c *gin.Context) {- h.routeRequest(c, "/images/total-size")+func (h *EnvironmentHandler) GetImageUsageCounts(c *gin.Context) {+ h.routeRequest(c, "/images/counts")}func (h *EnvironmentHandler) RemoveImage(c *gin.Context) {@@ -940,14 +957,13 @@ func (h *EnvironmentHandler) PruneVolumes(c *gin.Context) {h.routeRequest(c, "/volumes/prune")}-func (h *EnvironmentHandler) GetStack(c *gin.Context) {- stackId := c.Param("stackId")- h.routeRequest(c, "/stacks/"+stackId)+func (h *EnvironmentHandler) GetStackStatusCounts(c *gin.Context) {+ h.routeRequest(c, "/stacks/counts")}-func (h *EnvironmentHandler) StartStack(c *gin.Context) {+func (h *EnvironmentHandler) GetStack(c *gin.Context) {stackId := c.Param("stackId")- h.routeRequest(c, "/stacks/"+stackId+"/start")+ h.routeRequest(c, "/stacks/"+stackId)}func (h *EnvironmentHandler) UpdateStack(c *gin.Context) {@@ -960,11 +976,6 @@ func (h *EnvironmentHandler) DeleteStack(c *gin.Context) {h.routeRequest(c, "/stacks/"+stackId)}-func (h *EnvironmentHandler) StopStack(c *gin.Context) {- stackId := c.Param("stackId")- h.routeRequest(c, "/stacks/"+stackId+"/stop")-}-func (h *EnvironmentHandler) RestartStack(c *gin.Context) {stackId := c.Param("stackId")h.routeRequest(c, "/stacks/"+stackId+"/restart")diff --git a/backend/internal/api/image_handler.go b/backend/internal/api/image_handler.goindex 4898ea64d..6ea91efba 100644--- a/backend/internal/api/image_handler.go+++ b/backend/internal/api/image_handler.go@@ -1,11 +1,11 @@package apiimport (+ "errors""fmt""log/slog""net/http"- "github.com/docker/docker/api/types/image""github.com/gin-gonic/gin""github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/middleware"@@ -16,10 +16,11 @@ import (type ImageHandler struct {imageService *services.ImageServiceimageUpdateService *services.ImageUpdateService+ dockerService *services.DockerClientService}-func NewImageHandler(group *gin.RouterGroup, imageService *services.ImageService, imageUpdateService *services.ImageUpdateService, authMiddleware *middleware.AuthMiddleware) {- handler := &ImageHandler{imageService: imageService, imageUpdateService: imageUpdateService}+func NewImageHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, imageService *services.ImageService, imageUpdateService *services.ImageUpdateService, authMiddleware *middleware.AuthMiddleware) {+ handler := &ImageHandler{dockerService: dockerService, imageService: imageService, imageUpdateService: imageUpdateService}apiGroup := group.Group("/images")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -29,8 +30,6 @@ func NewImageHandler(group *gin.RouterGroup, imageService *services.ImageServiceapiGroup.DELETE("/:id", handler.Remove)apiGroup.POST("/pull", handler.Pull)apiGroup.POST("/prune", handler.Prune)- apiGroup.GET("/:id/history", handler.GetHistory)- apiGroup.GET("/total-size", handler.GetTotalSize)}}@@ -162,44 +161,46 @@ func (h *ImageHandler) Prune(c *gin.Context) {})}-func (h *ImageHandler) GetHistory(c *gin.Context) {- id := c.Param("id")+func (h *ImageHandler) GetImageUsageCounts(c *gin.Context) {+ ctx := c.Request.Context()++ var (+ inuse, unused, total int+ totalSize int64+ errs []error+ )- history, err := h.imageService.GetImageHistory(c.Request.Context(), id)+ _, iu, un, tot, err := h.dockerService.GetAllImages(ctx)if err != nil {- c.JSON(http.StatusInternalServerError, gin.H{- "success": false,- "data": dto.MessageDto{Message: err.Error()},- })- return+ errs = append(errs, fmt.Errorf("get images: %w", err))+ } else {+ inuse, unused, total = iu, un, tot}- out, mapErr := dto.MapSlice[image.HistoryResponseItem, dto.ImageHistoryItemDto](history)- if mapErr != nil {- c.JSON(http.StatusInternalServerError, gin.H{"success": false, "data": dto.MessageDto{Message: mapErr.Error()}})- return+ sz, err := h.imageService.GetTotalImageSize(ctx)+ if err != nil {+ errs = append(errs, fmt.Errorf("get total image size: %w", err))+ } else {+ totalSize = sz}- c.JSON(http.StatusOK, gin.H{- "success": true,- "data": out,- })-}--func (h *ImageHandler) GetTotalSize(c *gin.Context) {- ctx := c.Request.Context()-- total, err := h.imageService.GetTotalImageSize(ctx)- if err != nil {+ if len(errs) > 0 {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": dto.MessageDto{Message: errors.Join(errs...).Error()},})return}+ out := dto.ImageUsageCountsDto{+ Inuse: inuse,+ Unused: unused,+ Total: total,+ TotalSize: totalSize,+ }+c.JSON(http.StatusOK, gin.H{"success": true,- "data": dto.TotalImageSizeDto{TotalSize: total},+ "data": out,})}diff --git a/backend/internal/api/network_handler.go b/backend/internal/api/network_handler.goindex e2dac56b7..a81ea5285 100644--- a/backend/internal/api/network_handler.go+++ b/backend/internal/api/network_handler.go@@ -13,10 +13,11 @@ import (type NetworkHandler struct {networkService *services.NetworkService+ dockerService *services.DockerClientService}-func NewNetworkHandler(group *gin.RouterGroup, networkService *services.NetworkService, authMiddleware *middleware.AuthMiddleware) {- handler := &NetworkHandler{networkService: networkService}+func NewNetworkHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, networkService *services.NetworkService, authMiddleware *middleware.AuthMiddleware) {+ handler := &NetworkHandler{dockerService: dockerService, networkService: networkService}apiGroup := group.Group("/networks")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -25,8 +26,6 @@ func NewNetworkHandler(group *gin.RouterGroup, networkService *services.NetworkSapiGroup.GET("/:id", handler.GetByID)apiGroup.POST("", handler.Create)apiGroup.DELETE("/:id", handler.Remove)- apiGroup.POST("/:id/connect", handler.ConnectContainer)- apiGroup.POST("/:id/disconnect", handler.DisconnectContainer)apiGroup.POST("/prune", handler.Prune)}}@@ -150,73 +149,25 @@ func (h *NetworkHandler) Remove(c *gin.Context) {})}-func (h *NetworkHandler) ConnectContainer(c *gin.Context) {- networkID := c.Param("networkId")-- var req struct {- ContainerID string `json:"containerId" binding:"required"`- Config *network.EndpointSettings `json:"config"`- }-- if err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{- "success": false,- "data": dto.MessageDto{Message: err.Error()},- })- return- }-- currentUser, exists := middleware.GetCurrentUser(c)- if !exists || currentUser == nil {- c.JSON(http.StatusUnauthorized, gin.H{"success": false, "data": dto.MessageDto{Message: "User not authenticated"}})- return- }- if err := h.networkService.ConnectContainer(c.Request.Context(), networkID, req.ContainerID, req.Config, *currentUser); err != nil {+func (h *NetworkHandler) GetNetworkUsageCounts(c *gin.Context) {+ _, running, stopped, total, err := h.dockerService.GetAllNetworks(c.Request.Context())+ if err != nil {c.JSON(http.StatusInternalServerError, gin.H{"success": false,- "data": dto.MessageDto{Message: err.Error()},+ "data": gin.H{"error": "Failed to get container counts: " + err.Error()},})return}- c.JSON(http.StatusOK, gin.H{- "success": true,- "data": dto.MessageDto{Message: "Container connected to network successfully"},- })-}--func (h *NetworkHandler) DisconnectContainer(c *gin.Context) {- networkID := c.Param("networkId")-- var req struct {- ContainerID string `json:"containerId" binding:"required"`- Force bool `json:"force"`- }-- if err := c.ShouldBindJSON(&req); err != nil {- c.JSON(http.StatusBadRequest, gin.H{- "success": false,- "data": dto.MessageDto{Message: err.Error()},- })- return- }-- currentUser, exists := middleware.GetCurrentUser(c)- if !exists || currentUser == nil {- c.JSON(http.StatusUnauthorized, gin.H{"success": false, "data": dto.MessageDto{Message: "User not authenticated"}})- return- }- if err := h.networkService.DisconnectContainer(c.Request.Context(), networkID, req.ContainerID, req.Force, *currentUser); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{- "success": false,- "data": dto.MessageDto{Message: err.Error()},- })- return+ out := dto.NetworkUsageCounts{+ Inuse: running,+ Unused: stopped,+ Total: total,}c.JSON(http.StatusOK, gin.H{"success": true,- "data": dto.MessageDto{Message: "Container disconnected from network successfully"},+ "data": out,})}diff --git a/backend/internal/api/stack_handler.go b/backend/internal/api/stack_handler.goindex 6d9ddaeb2..037558c5b 100644--- a/backend/internal/api/stack_handler.go+++ b/backend/internal/api/stack_handler.go@@ -32,7 +32,6 @@ func NewStackHandler(group *gin.RouterGroup, stackService *services.StackServiceapiGroup.GET("/:id", handler.GetStack)apiGroup.PUT("/:id", handler.UpdateStack)apiGroup.POST("/:id/deploy", handler.DeployStack)- apiGroup.POST("/:id/stop", handler.StopStack)apiGroup.POST("/:id/restart", handler.RestartStack)apiGroup.GET("/:id/services", handler.GetStackServices)apiGroup.POST("/:id/pull", handler.PullImages)@@ -288,64 +287,6 @@ func (h *StackHandler) UpdateStack(c *gin.Context) {})}-func (h *StackHandler) StartStack(c *gin.Context) {- stackID := c.Param("stackId")- if stackID == "" {- stackID = c.Param("id")- }-- if stackID == "" {- c.JSON(http.StatusBadRequest, gin.H{- "success": false,- "error": "Stack ID is required",- })- return- }-- currentUser, exists := middleware.GetCurrentUser(c)- if !exists || currentUser == nil {- c.JSON(http.StatusUnauthorized, gin.H{"success": false, "error": "User not authenticated"})- return- }- if err := h.stackService.DeployStack(c.Request.Context(), stackID, *currentUser); err != nil {- c.JSON(http.StatusBadRequest, gin.H{- "success": false,- "error": err.Error(),- })- return- }-- c.JSON(http.StatusOK, gin.H{- "success": true,- "data": gin.H{"message": "Stack started successfully"},- })-}--func (h *StackHandler) StopStack(c *gin.Context) {- stackID := c.Param("stackId")- if stackID == "" {- stackID = c.Param("id")- }-- currentUser, exists := middleware.GetCurrentUser(c)- if !exists || currentUser == nil {- c.JSON(http.StatusUnauthorized, gin.H{"success": false, "error": "User not authenticated"})- return- }- if err := h.stackService.StopStack(c.Request.Context(), stackID, *currentUser); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{- "success": false,- "error": "Failed to stop stack",- })- return- }-- c.JSON(http.StatusOK, gin.H{- "success": true,- "data": gin.H{"message": "Stack stopped successfully"},- })-}-func (h *StackHandler) RestartStack(c *gin.Context) {stackID := c.Param("stackId")if stackID == "" {@@ -495,16 +436,10 @@ func (h *StackHandler) DeployStack(c *gin.Context) {stackID = c.Param("id")}- var req struct {- Profiles []string `json:"profiles"`- EnvOverrides map[string]string `json:"env_overrides"`- ForceRecreate bool `json:"force_recreate"`- }-- if err := c.ShouldBindJSON(&req); err != nil {+ if stackID == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": err.Error(),+ "error": "Stack ID is required",})return}@@ -515,7 +450,7 @@ func (h *StackHandler) DeployStack(c *gin.Context) {return}if err := h.stackService.DeployStack(c.Request.Context(), stackID, *currentUser); err != nil {- c.JSON(http.StatusInternalServerError, gin.H{+ c.JSON(http.StatusBadRequest, gin.H{"success": false,"error": err.Error(),})@@ -524,7 +459,7 @@ func (h *StackHandler) DeployStack(c *gin.Context) {c.JSON(http.StatusOK, gin.H{"success": true,- "data": gin.H{"message": "Stack deployed successfully"},+ "data": gin.H{"message": "Project deployed successfully"},})}@@ -670,3 +605,25 @@ func (h *StackHandler) parseStackLogLine(logLine string) gin.H {"service": service,}}++func (h *StackHandler) GetProjectStatusCounts(c *gin.Context) {+ _, running, stopped, total, err := h.stackService.GetProjectStatusCounts(c.Request.Context())+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{+ "success": false,+ "data": gin.H{"error": "Failed to get project counts: " + err.Error()},+ })+ return+ }++ out := dto.ProjectStatusCounts{+ RunningProjects: int(running),+ StoppedProjects: int(stopped),+ TotalProjects: int(total),+ }++ c.JSON(http.StatusOK, gin.H{+ "success": true,+ "data": out,+ })+}diff --git a/backend/internal/api/volume_handler.go b/backend/internal/api/volume_handler.goindex 7139b858c..00112bb64 100644--- a/backend/internal/api/volume_handler.go+++ b/backend/internal/api/volume_handler.go@@ -13,10 +13,11 @@ import (type VolumeHandler struct {volumeService *services.VolumeService+ dockerService *services.DockerClientService}-func NewVolumeHandler(group *gin.RouterGroup, volumeService *services.VolumeService, authMiddleware *middleware.AuthMiddleware) {- handler := &VolumeHandler{volumeService: volumeService}+func NewVolumeHandler(group *gin.RouterGroup, dockerService *services.DockerClientService, volumeService *services.VolumeService, authMiddleware *middleware.AuthMiddleware) {+ handler := &VolumeHandler{dockerService: dockerService, volumeService: volumeService}apiGroup := group.Group("/volumes")apiGroup.Use(authMiddleware.WithAdminNotRequired().Add())@@ -185,3 +186,25 @@ func (h *VolumeHandler) GetUsage(c *gin.Context) {},})}++func (h *VolumeHandler) GetVolumeUsageCounts(c *gin.Context) {+ _, running, stopped, total, err := h.dockerService.GetAllVolumes(c.Request.Context())+ if err != nil {+ c.JSON(http.StatusInternalServerError, gin.H{+ "success": false,+ "data": gin.H{"error": "Failed to get container counts: " + err.Error()},+ })+ return+ }++ out := dto.VolumeUsageCounts{+ Inuse: running,+ Unused: stopped,+ Total: total,+ }++ c.JSON(http.StatusOK, gin.H{+ "success": true,+ "data": out,+ })+}diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.goindex 3b50c6c91..fe2799984 100644--- a/backend/internal/bootstrap/router_bootstrap.go+++ b/backend/internal/bootstrap/router_bootstrap.go@@ -70,14 +70,14 @@ func setupRouter(cfg *config.Config, appServices *Services) *gin.Engine {api.NewHealthHandler(apiGroup)api.NewAuthHandler(apiGroup, appServices.User, appServices.Auth, appServices.Oidc, authMiddleware)- api.NewContainerHandler(apiGroup, appServices.Container, appServices.Image, authMiddleware)+ api.NewContainerHandler(apiGroup, appServices.Docker, appServices.Container, appServices.Image, authMiddleware)api.NewContainerRegistryHandler(apiGroup, appServices.ContainerRegistry, authMiddleware)api.NewConverterHandler(apiGroup, appServices.Converter, authMiddleware)api.NewEnvironmentHandler(apiGroup, appServices.Environment, appServices.Container, appServices.Image, appServices.ImageUpdate, appServices.Updater, appServices.Network, appServices.Volume, appServices.Stack, appServices.Settings, authMiddleware, cfg)api.NewEventHandler(apiGroup, appServices.Event, authMiddleware)- api.NewImageHandler(apiGroup, appServices.Image, appServices.ImageUpdate, authMiddleware)+ api.NewImageHandler(apiGroup, appServices.Docker, appServices.Image, appServices.ImageUpdate, authMiddleware)api.NewImageUpdateHandler(apiGroup, appServices.ImageUpdate, authMiddleware)- api.NewNetworkHandler(apiGroup, appServices.Network, authMiddleware)+ api.NewNetworkHandler(apiGroup, appServices.Docker, appServices.Network, authMiddleware)api.NewOidcHandler(apiGroup, appServices.Auth, appServices.Oidc, cfg)api.NewSettingsHandler(apiGroup, appServices.Settings, authMiddleware)api.NewStackHandler(apiGroup, appServices.Stack, authMiddleware)@@ -85,7 +85,7 @@ func setupRouter(cfg *config.Config, appServices *Services) *gin.Engine {api.NewTemplateHandler(apiGroup, appServices.Template, authMiddleware)api.NewUpdaterHandler(apiGroup, appServices.Updater, authMiddleware)api.NewUserHandler(apiGroup, appServices.User, authMiddleware)- api.NewVolumeHandler(apiGroup, appServices.Volume, authMiddleware)+ api.NewVolumeHandler(apiGroup, appServices.Docker, appServices.Volume, authMiddleware)if cfg.Environment != "production" {for _, registerFunc := range registerPlaywrightRoutes {diff --git a/backend/internal/dto/container_dto.go b/backend/internal/dto/container_dto.goindex 745056b57..876d49601 100644--- a/backend/internal/dto/container_dto.go+++ b/backend/internal/dto/container_dto.go@@ -26,6 +26,12 @@ type CreateContainerDto struct {CPUs float64 `json:"cpus,omitempty"`}+type ContainerStatusLengthsDto struct {+ RunningContainers int `json:"runningContainers"`+ StoppedContainers int `json:"stoppedContainers"`+ TotalContainers int `json:"totalContainers"`+}+type ContainerActionResult struct {Started []string `json:"started,omitempty"`Stopped []string `json:"stopped,omitempty"`diff --git a/backend/internal/dto/image_dto.go b/backend/internal/dto/image_dto.goindex bd56e16d9..ec09e4ff8 100644--- a/backend/internal/dto/image_dto.go+++ b/backend/internal/dto/image_dto.go@@ -29,6 +29,13 @@ type ImageUpdateInfoDto struct {UsedCredential bool `json:"usedCredential,omitempty"`}+type ImageUsageCountsDto struct {+ Inuse int `json:"imagesInuse"`+ Unused int `json:"imagesUnused"`+ Total int `json:"totalImages"`+ TotalSize int64 `json:"totalImageSize"`+}+type ImageSummaryDto struct {ID string `json:"id" sortable:"true"`RepoTags []string `json:"repoTags"`@@ -237,7 +244,3 @@ func NewImagePruneReportDto(src image.PruneReport) ImagePruneReportDto {type MessageDto struct {Message string `json:"message"`}--type TotalImageSizeDto struct {- TotalSize int64 `json:"totalSize"`-}diff --git a/backend/internal/dto/network_dto.go b/backend/internal/dto/network_dto.goindex 079e71699..f7108e00a 100644--- a/backend/internal/dto/network_dto.go+++ b/backend/internal/dto/network_dto.go@@ -16,6 +16,12 @@ type NetworkSummaryDto struct {Labels map[string]string `json:"labels"`}+type NetworkUsageCounts struct {+ Inuse int `json:"networksInuse"`+ Unused int `json:"networksUnused"`+ Total int `json:"totalNetworks"`+}+type NetworkInspectDto struct {ID string `json:"id"`Name string `json:"name"`diff --git a/backend/internal/dto/stack_dto.go b/backend/internal/dto/stack_dto.goindex 8eaa6ef33..223e2dd23 100644--- a/backend/internal/dto/stack_dto.go+++ b/backend/internal/dto/stack_dto.go@@ -58,3 +58,9 @@ type StackDetailsDto struct {UpdatedAt string `json:"updatedAt"`Services []any `json:"services,omitempty"`}++type ProjectStatusCounts struct {+ RunningProjects int `json:"runningProjects"`+ StoppedProjects int `json:"stoppedProjects"`+ TotalProjects int `json:"totalProjects"`+}diff --git a/backend/internal/dto/volume_dto.go b/backend/internal/dto/volume_dto.goindex abfc4c8d9..e14423eed 100644--- a/backend/internal/dto/volume_dto.go+++ b/backend/internal/dto/volume_dto.go@@ -28,6 +28,12 @@ func NewVolumeDto(v volume.Volume, inUse bool) VolumeDto {}}+type VolumeUsageCounts struct {+ Inuse int `json:"volumesInuse"`+ Unused int `json:"volumesUnused"`+ Total int `json:"totalVolumes"`+}+type VolumePruneReportDto struct {VolumesDeleted []string `json:"volumesDeleted"`SpaceReclaimed uint64 `json:"spaceReclaimed"`diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex 17b8f7531..792955ae9 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -57,21 +57,6 @@ func (s *ContainerService) PullContainerImage(ctx context.Context, containerID sreturn err}-func (s *ContainerService) ListContainers(ctx context.Context, includeAll bool) ([]container.Summary, error) {- dockerClient, err := s.dockerService.CreateConnection(ctx)- if err != nil {- return nil, fmt.Errorf("failed to connect to Docker: %w", err)- }- defer dockerClient.Close()-- containers, err := dockerClient.ContainerList(ctx, container.ListOptions{All: includeAll})- if err != nil {- return nil, fmt.Errorf("failed to list Docker containers: %w", err)- }-- return containers, nil-}-func (s *ContainerService) StartContainer(ctx context.Context, containerID string, user models.User) error {dockerClient, err := s.dockerService.CreateConnection(ctx)if err != nil {@@ -450,11 +435,19 @@ func (s *ContainerService) readAllLogs(logs io.ReadCloser, logsChan chan<- strin//nolint:gocognitfunc (s *ContainerService) ListContainersPaginated(ctx context.Context, req utils.SortedPaginationRequest, includeAll bool) ([]dto.ContainerSummaryDto, utils.PaginationResponse, error) {- dockerContainers, err := s.ListContainers(ctx, includeAll)+ dockerClient, err := s.dockerService.CreateConnection(ctx)+ if err != nil {+ return nil, utils.PaginationResponse{}, fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ dockerContainers, err := dockerClient.ContainerList(ctx, container.ListOptions{All: includeAll})if err != nil {return nil, utils.PaginationResponse{}, fmt.Errorf("failed to list Docker containers: %w", err)}+ grandTotal := len(dockerContainers)+// Map to DTOsresult := make([]dto.ContainerSummaryDto, 0, len(dockerContainers))for _, dc := range dockerContainers {@@ -509,10 +502,11 @@ func (s *ContainerService) ListContainersPaginated(ctx context.Context, req utiltotalPages := (totalItems + req.Pagination.Limit - 1) / req.Pagination.Limitpagination := utils.PaginationResponse{- TotalPages: int64(totalPages),- TotalItems: int64(totalItems),- CurrentPage: req.Pagination.Page,- ItemsPerPage: req.Pagination.Limit,+ TotalPages: int64(totalPages),+ TotalItems: int64(totalItems),+ CurrentPage: req.Pagination.Page,+ ItemsPerPage: req.Pagination.Limit,+ GrandTotalItems: int64(grandTotal),}return pageItems, pagination, nildiff --git a/backend/internal/services/docker_client_service.go b/backend/internal/services/docker_client_service.goindex 6873dde61..840ffb467 100644--- a/backend/internal/services/docker_client_service.go+++ b/backend/internal/services/docker_client_service.go@@ -4,8 +4,14 @@ import ("context""fmt"+ "github.com/docker/docker/api/types/container"+ "github.com/docker/docker/api/types/image"+ "github.com/docker/docker/api/types/mount"+ "github.com/docker/docker/api/types/network"+ "github.com/docker/docker/api/types/volume""github.com/docker/docker/client""github.com/ofkm/arcane-backend/internal/database"+ "github.com/ofkm/arcane-backend/internal/utils/docker")type DockerClientService struct {@@ -28,3 +34,119 @@ func (s *DockerClientService) CreateConnection(ctx context.Context) (*client.Clireturn cli, nil}++func (s *DockerClientService) GetAllContainers(ctx context.Context) ([]container.Summary, int, int, int, error) {+ dockerClient, err := s.CreateConnection(ctx)+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ containers, err := dockerClient.ContainerList(ctx, container.ListOptions{All: true})+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to list Docker containers: %w", err)+ }++ var running, stopped, total int+ for _, c := range containers {+ total+++ if c.State == "running" {+ running+++ } else {+ stopped+++ }+ }++ return containers, running, stopped, total, nil+}++func (s *DockerClientService) GetAllImages(ctx context.Context) ([]image.Summary, int, int, int, error) {+ dockerClient, err := s.CreateConnection(ctx)+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ images, err := dockerClient.ImageList(ctx, image.ListOptions{All: true})+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to list Docker containers: %w", err)+ }++ var inuse, unused, total int+ for _, i := range images {+ total+++ if i.Containers >= 1 {+ inuse+++ } else {+ unused+++ }+ }++ return images, inuse, unused, total, nil+}++func (s *DockerClientService) GetAllNetworks(ctx context.Context) ([]network.Summary, int, int, int, error) {+ dockerClient, err := s.CreateConnection(ctx)+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ networks, err := dockerClient.NetworkList(ctx, network.ListOptions{})+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to list Docker networks: %w", err)+ }++ var inuse, unused, total int+ for _, n := range networks {+ total+++ if !docker.IsDefaultNetwork(n.Name) {+ if len(n.Containers) > 0 {+ inuse+++ } else {+ unused+++ }+ }+ }++ return networks, inuse, unused, total, nil+}++func (s *DockerClientService) GetAllVolumes(ctx context.Context) ([]*volume.Volume, int, int, int, error) {+ dockerClient, err := s.CreateConnection(ctx)+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to connect to Docker: %w", err)+ }+ defer dockerClient.Close()++ containers, err := dockerClient.ContainerList(ctx, container.ListOptions{All: true})+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to list Docker containers: %w", err)+ }+ ref := make(map[string]int64, len(containers))+ for _, c := range containers {+ for _, m := range c.Mounts {+ if m.Type == mount.TypeVolume && m.Name != "" {+ ref[m.Name]+++ }+ }+ }++ volResp, err := dockerClient.VolumeList(ctx, volume.ListOptions{})+ if err != nil {+ return nil, 0, 0, 0, fmt.Errorf("failed to list Docker volumes: %w", err)+ }+ volumes := volResp.Volumes++ var inuse, unused, total int+ for _, v := range volumes {+ total+++ if ref[v.Name] > 0 {+ inuse+++ } else {+ unused+++ }+ }++ return volumes, inuse, unused, total, nil+}diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.goindex fdc187e66..31f4f0452 100644--- a/backend/internal/services/image_service.go+++ b/backend/internal/services/image_service.go@@ -458,18 +458,6 @@ func (s *ImageService) deleteAllImages(ctx context.Context) error {return nil}-func (s *ImageService) ListImagesWithUpdates(ctx context.Context) ([]*models.Image, error) {- err := s.SyncDockerImages(ctx)- if err != nil {- return nil, fmt.Errorf("failed to list and sync Docker images: %w", err)- }- var images []*models.Image- if err := s.db.WithContext(ctx).Preload("UpdateRecord").Find(&images).Error; err != nil {- return nil, fmt.Errorf("failed to get images with update data from DB: %w", err)- }- return images, nil-}-func (s *ImageService) DeleteImageByDockerID(ctx context.Context, dockerImageID string) error {if dockerImageID == "" {return fmt.Errorf("docker image ID cannot be empty")diff --git a/backend/internal/services/network_service.go b/backend/internal/services/network_service.goindex f28542b84..64b052feb 100644--- a/backend/internal/services/network_service.go+++ b/backend/internal/services/network_service.go@@ -13,6 +13,7 @@ import ("github.com/ofkm/arcane-backend/internal/dto""github.com/ofkm/arcane-backend/internal/models""github.com/ofkm/arcane-backend/internal/utils"+ "github.com/ofkm/arcane-backend/internal/utils/docker")type NetworkService struct {@@ -29,40 +30,6 @@ func NewNetworkService(db *database.DB, dockerService *DockerClientService, even}}-var defaultNetworkNames = map[string]bool{- "bridge": true,- "host": true,- "none": true,- "ingress": true,-}--func (s *NetworkService) ListNetworks(ctx context.Context) ([]network.Summary, error) {- dockerClient, err := s.dockerService.CreateConnection(ctx)- if err != nil {- return nil, fmt.Errorf("failed to connect to Docker: %w", err)- }- defer dockerClient.Close()-- networks, err := dockerClient.NetworkList(ctx, network.ListOptions{})- if err != nil {- return nil, fmt.Errorf("failed to list Docker networks: %w", err)- }-- // Convert types.NetworkResource to network.Summary- var summaries []network.Summary- for _, net := range networks {- summaries = append(summaries, network.Summary{- ID: net.ID,- Name: net.Name,- Driver: net.Driver,- Scope: net.Scope,- })- }-- return summaries, nil-}--// GetNetworkByID gets live network info from Dockerfunc (s *NetworkService) GetNetworkByID(ctx context.Context, id string) (*network.Inspect, error) {dockerClient, err := s.dockerService.CreateConnection(ctx)if err != nil {@@ -78,7 +45,6 @@ func (s *NetworkService) GetNetworkByID(ctx context.Context, id string) (*networreturn &networkInspect, nil}-// CreateNetwork creates a Docker networkfunc (s *NetworkService) CreateNetwork(ctx context.Context, name string, options network.CreateOptions, user models.User) (*network.CreateResponse, error) {dockerClient, err := s.dockerService.CreateConnection(ctx)if err != nil {@@ -91,7 +57,6 @@ func (s *NetworkService) CreateNetwork(ctx context.Context, name string, optionsreturn nil, fmt.Errorf("failed to create network: %w", err)}- // Log network creation eventmetadata := models.JSON{"action": "create","driver": options.Driver,@@ -104,7 +69,6 @@ func (s *NetworkService) CreateNetwork(ctx context.Context, name string, optionsreturn &response, nil}-// RemoveNetwork removes a Docker networkfunc (s *NetworkService) RemoveNetwork(ctx context.Context, id string, user models.User) error {dockerClient, err := s.dockerService.CreateConnection(ctx)if err != nil {@@ -112,7 +76,6 @@ func (s *NetworkService) RemoveNetwork(ctx context.Context, id string, user mode}defer dockerClient.Close()- // Get network details for logging before deletionnetworkDetails, inspectErr := dockerClient.NetworkInspect(ctx, id, network.InspectOptions{})var networkName stringif inspectErr == nil {@@ -125,7 +88,6 @@ func (s *NetworkService) RemoveNetwork(ctx context.Context, id string, user modereturn fmt.Errorf("failed to remove network: %w", err)}- // Log network deletion eventmetadata := models.JSON{"action": "delete","networkId": id,@@ -137,72 +99,6 @@ func (s *NetworkService) RemoveNetwork(ctx context.Context, id string, user modereturn nil}-// ConnectContainer connects a container to a network-func (s *NetworkService) ConnectContainer(ctx context.Context, networkID, containerID string, config *network.EndpointSettings, user models.User) error {- dockerClient, err := s.dockerService.CreateConnection(ctx)- if err != nil {- return fmt.Errorf("failed to connect to Docker: %w", err)- }- defer dockerClient.Close()-- if err := dockerClient.NetworkConnect(ctx, networkID, containerID, config); err != nil {- return fmt.Errorf("failed to connect container to network: %w", err)- }-- // Get network name for logging- networkDetails, _ := dockerClient.NetworkInspect(ctx, networkID, network.InspectOptions{})- networkName := networkDetails.Name- if networkName == "" {- networkName = networkID- }-- // Log network connect event- metadata := models.JSON{- "action": "connect_container",- "networkId": networkID,- "containerId": containerID,- }- if logErr := s.eventService.LogNetworkEvent(ctx, models.EventTypeNetworkCreate, networkID, networkName, user.ID, user.Username, "0", metadata); logErr != nil {- fmt.Printf("Could not log network connect action: %s\n", logErr)- }-- return nil-}--// DisconnectContainer disconnects a container from a network-func (s *NetworkService) DisconnectContainer(ctx context.Context, networkID, containerID string, force bool, user models.User) error {- dockerClient, err := s.dockerService.CreateConnection(ctx)- if err != nil {- return fmt.Errorf("failed to connect to Docker: %w", err)- }- defer dockerClient.Close()-- // Get network name for logging- networkDetails, _ := dockerClient.NetworkInspect(ctx, networkID, network.InspectOptions{})- networkName := networkDetails.Name- if networkName == "" {- networkName = networkID- }-- if err := dockerClient.NetworkDisconnect(ctx, networkID, containerID, force); err != nil {- return fmt.Errorf("failed to disconnect container from network: %w", err)- }-- // Log network disconnect event- metadata := models.JSON{- "action": "disconnect_container",- "networkId": networkID,- "containerId": containerID,- "force": force,- }- if logErr := s.eventService.LogNetworkEvent(ctx, models.EventTypeNetworkDelete, networkID, networkName, user.ID, user.Username, "0", metadata); logErr != nil {- fmt.Printf("Could not log network disconnect action: %s\n", logErr)- }-- return nil-}--// PruneNetworks removes unused Docker networksfunc (s *NetworkService) PruneNetworks(ctx context.Context) (*network.PruneReport, error) {dockerClient, err := s.dockerService.CreateConnection(ctx)if err != nil {@@ -217,7 +113,6 @@ func (s *NetworkService) PruneNetworks(ctx context.Context) (*network.PruneReporreturn nil, fmt.Errorf("failed to prune networks: %w", err)}- // Log network prune event using system user since this is typically a system operationmetadata := models.JSON{"action": "prune","networksDeleted": len(report.NetworksDeleted),@@ -229,9 +124,8 @@ func (s *NetworkService) PruneNetworks(ctx context.Context) (*network.PruneReporreturn &report, nil}-// GetNetworksByDriver filters networks by driver typefunc (s *NetworkService) GetNetworksByDriver(ctx context.Context, driver string) ([]network.Summary, error) {- networks, err := s.ListNetworks(ctx)+ networks, _, _, _, err := s.dockerService.GetAllNetworks(ctx)if err != nil {return nil, err}@@ -246,16 +140,15 @@ func (s *NetworkService) GetNetworksByDriver(ctx context.Context, driver string)return filtered, nil}-// GetDefaultNetworks returns Docker's default networks (bridge, host, none)func (s *NetworkService) GetDefaultNetworks(ctx context.Context) ([]network.Summary, error) {- networks, err := s.ListNetworks(ctx)+ networks, _, _, _, err := s.dockerService.GetAllNetworks(ctx)if err != nil {return nil, err}var defaults []network.Summaryfor _, net := range networks {- if defaultNetworkNames[net.Name] {+ if docker.IsDefaultNetwork(net.Name) {defaults = append(defaults, net)}}@@ -263,7 +156,7 @@ func (s *NetworkService) GetDefaultNetworks(ctx context.Context) ([]network.Summ}func (s *NetworkService) GetNetworksByScope(ctx context.Context, scope string) ([]network.Summary, error) {- networks, err := s.ListNetworks(ctx)+ networks, _, _, _, err := s.dockerService.GetAllNetworks(ctx)if err != nil {return nil, err}@@ -278,16 +171,15 @@ func (s *NetworkService) GetNetworksByScope(ctx context.Context, scope string) (return filtered, nil}-// GetUserDefinedNetworks returns non-default networksfunc (s *NetworkService) GetUserDefinedNetworks(ctx context.Context) ([]network.Summary, error) {- networks, err := s.ListNetworks(ctx)+ networks, _, _, _, err := s.dockerService.GetAllNetworks(ctx)if err != nil {return nil, err}var userDefined []network.Summaryfor _, net := range networks {- if !defaultNetworkNames[net.Name] {+ if !docker.IsDefaultNetwork(net.Name) {userDefined = append(userDefined, net)}}@@ -296,8 +188,7 @@ func (s *NetworkService) GetUserDefinedNetworks(ctx context.Context) ([]network.//nolint:gocognitfunc (s *NetworkService) ListNetworksPaginated(ctx context.Context, req utils.SortedPaginationRequest) ([]dto.NetworkSummaryDto, utils.PaginationResponse, error) {- // Fetch from Docker- nets, err := s.ListNetworks(ctx)+ nets, _, _, _, err := s.dockerService.GetAllNetworks(ctx)if err != nil {return nil, utils.PaginationResponse{}, fmt.Errorf("failed to list Docker networks: %w", err)}diff --git a/backend/internal/services/stack_service.go b/backend/internal/services/stack_service.goindex a75a8fee8..94d41c56c 100644--- a/backend/internal/services/stack_service.go+++ b/backend/internal/services/stack_service.go@@ -18,6 +18,7 @@ import ("github.com/ofkm/arcane-backend/internal/database""github.com/ofkm/arcane-backend/internal/models""github.com/ofkm/arcane-backend/internal/utils"+ "github.com/ofkm/arcane-backend/internal/utils/docker""gorm.io/gorm")@@ -107,8 +108,8 @@ func (s *StackService) DeployStack(ctx context.Context, stackID string, user modreturn fmt.Errorf("stack directory does not exist: %s", stack.Path)}- composeFileName := s.findComposeFileName(stack.Path)- if composeFileName == "" {+ composeFileFullPath := docker.LocateComposeFile(stack.Path)+ if composeFileFullPath == "" {return fmt.Errorf("no compose file found in stack directory: %s", stack.Path)}@@ -116,8 +117,7 @@ func (s *StackService) DeployStack(ctx context.Context, stackID string, user modreturn fmt.Errorf("failed to update stack status to deploying: %w", err)}- cmd := exec.CommandContext(ctx, "docker-compose", "-f", composeFileName, "up", "-d")- cmd.Dir = stack.Path+ cmd := exec.CommandContext(ctx, "docker-compose", "-f", composeFileFullPath, "up", "-d")cmd.Env = append(os.Environ(),fmt.Sprintf("COMPOSE_PROJECT_NAME=%s", stack.Name),)@@ -143,47 +143,6 @@ func (s *StackService) DeployStack(ctx context.Context, stackID string, user modreturn s.updateStackStatusAndCounts(ctx, stackID, models.StackStatusRunning)}-func (s *StackService) StopStack(ctx context.Context, stackID string, user models.User) error {- stack, err := s.GetStackByID(ctx, stackID)- if err != nil {- return err- }-- // Verify stack directory exists- if _, err := os.Stat(stack.Path); os.IsNotExist(err) {- return fmt.Errorf("stack directory does not exist: %s", stack.Path)- }-- // Update status to stopping first- if err := s.UpdateStackStatus(ctx, stackID, models.StackStatusStopping); err != nil {- return fmt.Errorf("failed to update stack status to stopping: %w", err)- }-- cmd := exec.CommandContext(ctx, "docker-compose", "stop")- cmd.Dir = stack.Path- cmd.Env = append(os.Environ(),- fmt.Sprintf("COMPOSE_PROJECT_NAME=%s", stack.Name),- )-- output, err := cmd.CombinedOutput()- if err != nil {- return fmt.Errorf("failed to stop stack: %w\nOutput: %s", err, string(output))- }-- // Log stack stop event- metadata := models.JSON{- "action": "stop",- "stackId": stackID,- "stackName": stack.Name,- }- if logErr := s.eventService.LogStackEvent(ctx, models.EventTypeStackStop, stackID, stack.Name, user.ID, user.Username, "0", metadata); logErr != nil {- fmt.Printf("Could not log stack stop action: %s\n", logErr)- }-- // Update status and counts after successful stop- return s.updateStackStatusAndCounts(ctx, stackID, models.StackStatusStopped)-}-func (s *StackService) DownStack(ctx context.Context, stackID string, user models.User) error {stack, err := s.GetStackByID(ctx, stackID)if err != nil {@@ -195,8 +154,8 @@ func (s *StackService) DownStack(ctx context.Context, stackID string, user modelreturn fmt.Errorf("stack directory does not exist: %s", stack.Path)}- composeFileName := s.findComposeFileName(stack.Path)- if composeFileName == "" {+ composeFileFullPath := docker.LocateComposeFile(stack.Path)+ if composeFileFullPath == "" {return fmt.Errorf("no compose file found in stack directory: %s", stack.Path)}@@ -205,8 +164,7 @@ func (s *StackService) DownStack(ctx context.Context, stackID string, user modelreturn fmt.Errorf("failed to update stack status to stopping: %w", err)}- cmd := exec.CommandContext(ctx, "docker-compose", "-f", composeFileName, "down")- cmd.Dir = stack.Path+ cmd := exec.CommandContext(ctx, "docker-compose", "-f", composeFileFullPath, "down")cmd.Env = append(os.Environ(),fmt.Sprintf("COMPOSE_PROJECT_NAME=%s", stack.Name),)@@ -258,7 +216,7 @@ func (s *StackService) GetStackServices(ctx context.Context, stackID string) ([]return services, nil}- composeFile := s.findComposeFile(stack.Path)+ composeFile := docker.LocateComposeFile(stack.Path)if composeFile == "" {return nil, fmt.Errorf("no compose file found for stack")}@@ -414,7 +372,7 @@ func (le lineEmitter) WriteJSON(m map[string]any) {}func (s *StackService) collectStackImages(ctx context.Context, stack *models.Stack) ([]string, error) {- composeFile := s.findComposeFile(stack.Path)+ composeFile := docker.LocateComposeFile(stack.Path)if composeFile == "" {return nil, fmt.Errorf("no compose file found for stack")}@@ -625,7 +583,7 @@ func (s *StackService) SyncAllStacksFromFilesystem(ctx context.Context) error {seenDirs[dirPath] = struct{}{}// Skip if no compose file- if s.findComposeFile(dirPath) == "" {+ if docker.LocateComposeFile(dirPath) == "" {continue}@@ -669,7 +627,7 @@ func (s *StackService) SyncAllStacksFromFilesystem(ctx context.Context) error {continue}- if s.findComposeFile(stack.Path) == "" {+ if docker.LocateComposeFile(stack.Path) == "" {if err := s.db.WithContext(ctx).Where("stack_id = ?", stack.ID).Delete(&models.ProjectCache{}).Error; err != nil {fmt.Printf("Warning: failed to delete cache for removed stack %s: %v\n", stack.ID, err)}@@ -706,7 +664,7 @@ func (s *StackService) syncStackWithFilesystem(ctx context.Context, stack *model}// Check if compose file still exists- if s.findComposeFile(stack.Path) == "" {+ if docker.LocateComposeFile(stack.Path) == "" {stack.Status = "unknown"stack.ServiceCount = 0stack.RunningCount = 0@@ -755,7 +713,7 @@ func (s *StackService) UpdateStackContent(ctx context.Context, stackID string, c}if composeContent != nil {- existingComposeFile := s.findComposeFile(stack.Path)+ existingComposeFile := docker.LocateComposeFile(stack.Path)var composePath stringif existingComposeFile != "" {@@ -789,7 +747,7 @@ func (s *StackService) GetStackContent(ctx context.Context, stackID string) (comreturn "", "", err}- composeFile := s.findComposeFile(stack.Path)+ composeFile := docker.LocateComposeFile(stack.Path)if composeFile != "" {if content, err := os.ReadFile(composeFile); err == nil {composeContent = string(content)@@ -902,7 +860,7 @@ func (s *StackService) getLiveStackStatus(ctx context.Context, stackDir, project}// Get service count from compose file to know the expected total- composeFile := s.findComposeFile(stackDir)+ composeFile := docker.LocateComposeFile(stackDir)if composeFile != "" {if expectedServices, err := s.parseServicesFromComposeFile(ctx, composeFile, projectName); err == nil {expectedTotal := len(expectedServices)@@ -1147,7 +1105,7 @@ func (s *StackService) saveStackFiles(stackPath, composeContent string, envContereturn fmt.Errorf("failed to create stack directory: %w", err)}- existingComposeFile := s.findComposeFile(stackPath)+ existingComposeFile := docker.LocateComposeFile(stackPath)var composePath stringif existingComposeFile != "" {@@ -1170,35 +1128,6 @@ func (s *StackService) saveStackFiles(stackPath, composeContent string, envContereturn nil}-// Centralize compose filename candidates once.-var composeFileCandidates = []string{- "compose.yaml",- "compose.yml",- "docker-compose.yaml",- "docker-compose.yml",-}--// findFirstExistingComposeFile returns (fullPath, filename) of the first compose file found.-func findFirstExistingComposeFile(stackDir string) (string, string) {- for _, filename := range composeFileCandidates {- fullPath := filepath.Join(stackDir, filename)- if info, err := os.Stat(fullPath); err == nil && !info.IsDir() {- return fullPath, filename- }- }- return "", ""-}--func (s *StackService) findComposeFile(stackDir string) string {- full, _ := findFirstExistingComposeFile(stackDir)- return full-}--func (s *StackService) findComposeFileName(stackDir string) string {- _, name := findFirstExistingComposeFile(stackDir)- return name-}-func (s *StackService) parseComposePS(output string) ([]StackServiceInfo, error) {if strings.TrimSpace(output) == "" {return []StackServiceInfo{}, nil@@ -1311,7 +1240,7 @@ func (s *StackService) importExternalStack(ctx context.Context, dirName, stackNa}path := filepath.Join(stacksDir, dirName)- if s.findComposeFile(path) == "" {+ if docker.LocateComposeFile(path) == "" {return nil, fmt.Errorf("no compose file found in %q", path)}@@ -1351,3 +1280,56 @@ func (s *StackService) importExternalStack(ctx context.Context, dirName, stackNareturn stack, nil}++func (s *StackService) GetProjectStatusCounts(ctx context.Context) (folderCount, runningStacks, stoppedStacks, totalStacks int, err error) {+ stacksDir, derr := s.getStacksDirectory(ctx)+ if derr != nil {+ return 0, 0, 0, 0, fmt.Errorf("could not determine stacks directory: %w", derr)+ }++ // Count only directories that contain a compose file+ if info, statErr := os.Stat(stacksDir); statErr == nil && info.IsDir() {+ entries, readErr := os.ReadDir(stacksDir)+ if readErr != nil {+ return 0, 0, 0, 0, fmt.Errorf("failed to read stacks directory %s: %w", stacksDir, readErr)+ }+ for _, e := range entries {+ if !e.IsDir() {+ continue+ }+ dirPath := filepath.Join(stacksDir, e.Name())+ if docker.LocateComposeFile(dirPath) != "" {+ folderCount+++ }+ }+ } else if os.IsNotExist(statErr) {+ // Directory missing: folderCount stays 0+ } else if statErr != nil {+ return 0, 0, 0, 0, fmt.Errorf("unable to access stacks directory %s: %w", stacksDir, statErr)+ }++ // DB counts+ var (+ running int64+ stopped int64+ total int64+ )+ if err := s.db.WithContext(ctx).Model(&models.Stack{}).Count(&total).Error; err != nil {+ return folderCount, 0, 0, 0, fmt.Errorf("failed to count total stacks: %w", err)+ }+ // running = running + partially_running+ if err := s.db.WithContext(ctx).+ Model(&models.Stack{}).+ Where("status IN ?", []models.StackStatus{models.StackStatusRunning, models.StackStatusPartiallyRunning}).+ Count(&running).Error; err != nil {+ return folderCount, 0, 0, int(total), fmt.Errorf("failed to count running stacks: %w", err)+ }+ if err := s.db.WithContext(ctx).+ Model(&models.Stack{}).+ Where("status = ?", models.StackStatusStopped).+ Count(&stopped).Error; err != nil {+ return folderCount, int(running), 0, int(total), fmt.Errorf("failed to count stopped stacks: %w", err)+ }++ return folderCount, int(running), int(stopped), int(total), nil+}diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.goindex bf2a25d45..88fda4b77 100644--- a/backend/internal/services/system_service.go+++ b/backend/internal/services/system_service.go@@ -137,7 +137,7 @@ func (s *SystemService) StartAllContainers(ctx context.Context) (*dto.ContainerASuccess: true,}- containers, err := s.containerService.ListContainers(ctx, true)+ containers, _, _, _, err := s.dockerService.GetAllContainers(ctx)if err != nil {result.Success = falseresult.Errors = append(result.Errors, fmt.Sprintf("Failed to list containers: %v", err))@@ -164,7 +164,7 @@ func (s *SystemService) StartAllStoppedContainers(ctx context.Context) (*dto.ConSuccess: true,}- containers, err := s.containerService.ListContainers(ctx, true)+ containers, _, _, _, err := s.dockerService.GetAllContainers(ctx)if err != nil {result.Success = falseresult.Errors = append(result.Errors, fmt.Sprintf("Failed to list containers: %v", err))@@ -191,7 +191,7 @@ func (s *SystemService) StopAllContainers(ctx context.Context) (*dto.ContainerAcSuccess: true,}- containers, err := s.containerService.ListContainers(ctx, false)+ containers, _, _, _, err := s.dockerService.GetAllContainers(ctx)if err != nil {result.Success = falseresult.Errors = append(result.Errors, fmt.Sprintf("Failed to list containers: %v", err))diff --git a/backend/internal/utils/docker/compose_util.go b/backend/internal/utils/docker/compose_util.gonew file mode 100644index 000000000..b47036f09--- /dev/null+++ b/backend/internal/utils/docker/compose_util.go@@ -0,0 +1,23 @@+package docker++import (+ "os"+ "path/filepath"+)++var ComposeFileCandidates = []string{+ "compose.yaml",+ "compose.yml",+ "docker-compose.yaml",+ "docker-compose.yml",+}++func LocateComposeFile(stackDir string) string {+ for _, filename := range ComposeFileCandidates {+ fullPath := filepath.Join(stackDir, filename)+ if info, err := os.Stat(fullPath); err == nil && !info.IsDir() {+ return fullPath+ }+ }+ return ""+}diff --git a/backend/internal/utils/docker/network_utils.go b/backend/internal/utils/docker/network_utils.gonew file mode 100644index 000000000..f7fd9dbc5--- /dev/null+++ b/backend/internal/utils/docker/network_utils.go@@ -0,0 +1,10 @@+package docker++func IsDefaultNetwork(name string) bool {+ switch name {+ case "bridge", "host", "none", "ingress":+ return true+ default:+ return false+ }+}diff --git a/backend/internal/utils/fs/fs_util.go b/backend/internal/utils/fs/fs_util.gonew file mode 100644index 000000000..830952113--- /dev/null+++ b/backend/internal/utils/fs/fs_util.go@@ -0,0 +1,21 @@+package fs++import (+ "fmt"+ "os"+)++func CountSubdirectories(path string) (int, error) {+ entries, err := os.ReadDir(path)+ if err != nil {+ return 0, fmt.Errorf("failed to read directory: %w", err)+ }++ count := 0+ for _, entry := range entries {+ if entry.IsDir() {+ count+++ }+ }+ return count, nil+}diff --git a/backend/internal/utils/page_util.go b/backend/internal/utils/page_util.goindex 7fecbbcbb..9be2e110e 100644--- a/backend/internal/utils/page_util.go+++ b/backend/internal/utils/page_util.go@@ -11,10 +11,11 @@ import ()type PaginationResponse struct {- TotalPages int64 `json:"totalPages"`- TotalItems int64 `json:"totalItems"`- CurrentPage int `json:"currentPage"`- ItemsPerPage int `json:"itemsPerPage"`+ TotalPages int64 `json:"totalPages"`+ TotalItems int64 `json:"totalItems"`+ CurrentPage int `json:"currentPage"`+ ItemsPerPage int `json:"itemsPerPage"`+ GrandTotalItems int64 `json:"grandTotalItems,omitempty"`}type SortedPaginationRequest struct {diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 5ee6dde92..77d97da27 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -173,7 +173,7 @@"networks_create_failed": "Failed to Create Network \"{name}\"","networks_refresh_failed": "Failed to Refresh Networks","networks_total": "Total Networks",- "networks_bridge": "Bridge Networks",+ "unused_networks": "Unused Networks","networks_host": "Host","networks_overlay": "Overlay","networks_macvlan": "Macvlan",diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelteindex 58a400578..9d6f0bc02 100644--- a/frontend/src/lib/components/action-buttons.svelte+++ b/frontend/src/lib/components/action-buttons.svelte@@ -207,7 +207,7 @@async function handleStart() {setLoading('start', true);await handleApiResultWithCallbacks({- result: await tryCatch(type === 'container' ? environmentAPI.startContainer(id) : environmentAPI.startProject(id)),+ result: await tryCatch(type === 'container' ? environmentAPI.startContainer(id) : environmentAPI.deployProject(id)),message: m.action_failed_generic({ action: m.common_start(), type }),setLoadingState: (value) => setLoading('start', value),onSuccess: async () => {@@ -221,7 +221,7 @@async function handleDeploy() {setLoading('start', true);await handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.startProject(id)),+ result: await tryCatch(environmentAPI.deployProject(id)),message: m.action_failed_generic({ action: m.common_start(), type }),setLoadingState: (value) => setLoading('start', value),onSuccess: async () => {diff --git a/frontend/src/lib/services/api/environment-api-service.ts b/frontend/src/lib/services/api/environment-api-service.tsindex 7037b2655..d7e9a5e76 100644--- a/frontend/src/lib/services/api/environment-api-service.ts+++ b/frontend/src/lib/services/api/environment-api-service.ts@@ -2,13 +2,13 @@ import BaseAPIService from './api-service';import { get } from 'svelte/store';import { environmentStore, LOCAL_DOCKER_ENVIRONMENT_ID } from '$lib/stores/environment.store';import type { ContainerCreateOptions, NetworkCreateOptions, VolumeCreateOptions, ContainerStats } from 'dockerode';-import type { Project } from '$lib/types/project.type';+import type { Project, ProjectStatusCounts } from '$lib/types/project.type';import type { SearchPaginationSortRequest, Paginated } from '$lib/types/pagination.type';import { browser } from '$app/environment';-import type { ContainerSummaryDto } from '$lib/types/container.type';-import type { ImageSummaryDto, ImageUpdateInfoDto } from '$lib/types/image.type';-import type { NetworkSummaryDto } from '$lib/types/network.type';-import type { VolumeSummaryDto, VolumeDetailDto, VolumeUsageDto } from '$lib/types/volume.type';+import type { ContainerStatusCounts, ContainerSummaryDto } from '$lib/types/container.type';+import type { ImageSummaryDto, ImageUpdateInfoDto, ImageUsageCounts } from '$lib/types/image.type';+import type { NetworkSummaryDto, NetworkUsageCounts } from '$lib/types/network.type';+import type { VolumeSummaryDto, VolumeDetailDto, VolumeUsageDto, VolumeUsageCounts } from '$lib/types/volume.type';import type { ImageUpdateSummary, ImageVersions, VersionComparison, CompareVersionRequest } from '$lib/types/image.type';import type { AutoUpdateCheck, AutoUpdateResult, AutoUpdateRecord, AutoUpdateStatus } from '$lib/types/auto-update.type';@@ -31,6 +31,13 @@ export class EnvironmentAPIService extends BaseAPIService {return res.data;}+ async getContainerStatusCounts(): Promise<ContainerStatusCounts> {+ const envId = await this.getCurrentEnvironmentId();++ const res = await this.api.get(`/environments/${envId}/containers/counts`);+ return res.data.data;+ }+async getContainer(containerId: string): Promise<any> {const envId = await this.getCurrentEnvironmentId();return this.handleResponse(this.api.get(`/environments/${envId}/containers/${containerId}`));@@ -83,16 +90,11 @@ export class EnvironmentAPIService extends BaseAPIService {return res.data;}- async getTotalImageSize(): Promise<number> {+ async getImageUsageCounts(): Promise<ImageUsageCounts> {const envId = await this.getCurrentEnvironmentId();- const res = await this.handleResponse<any>(this.api.get(`/environments/${envId}/images/total-size`));- // Support both shapes just in case- if (typeof res === 'number') return res;- if (res && typeof res === 'object') {- if ('totalSize' in res && typeof res.totalSize === 'number') return res.totalSize;- if ('data' in res && res.data && typeof res.data.totalSize === 'number') return res.data.totalSize;- }- return 0;++ const res = await this.api.get(`/environments/${envId}/images/counts`);+ return res.data.data;}async getImage(imageId: string): Promise<any> {@@ -121,26 +123,18 @@ export class EnvironmentAPIService extends BaseAPIService {return this.handleResponse(this.api.get(`/environments/${envId}/images/${imageId}/inspect`));}- async searchImages(term: string, limit?: number): Promise<any> {- const envId = await this.getCurrentEnvironmentId();- return this.handleResponse(this.api.get(`/environments/${envId}/images/search`, { params: { term, limit } }));- }-- async tagImage(imageId: string, repo: string, tag: string): Promise<any> {+ async getNetworks(options?: SearchPaginationSortRequest): Promise<Paginated<NetworkSummaryDto>> {const envId = await this.getCurrentEnvironmentId();- return this.handleResponse(this.api.post(`/environments/${envId}/images/${imageId}/tag`, { repo, tag }));- }- async getImageHistory(imageId: string): Promise<any> {- const envId = await this.getCurrentEnvironmentId();- return this.handleResponse(this.api.get(`/environments/${envId}/images/${imageId}/history`));+ const res = await this.api.get(`/environments/${envId}/networks`, { params: options });+ return res.data;}- async getNetworks(options?: SearchPaginationSortRequest): Promise<Paginated<NetworkSummaryDto>> {+ async getNetworkUsageCounts(): Promise<NetworkUsageCounts> {const envId = await this.getCurrentEnvironmentId();- const res = await this.api.get(`/environments/${envId}/networks`, { params: options });- return res.data;+ const res = await this.api.get(`/environments/${envId}/networks/counts`);+ return res.data.data;}async getNetwork(networkId: string): Promise<any> {@@ -175,6 +169,13 @@ export class EnvironmentAPIService extends BaseAPIService {return this.handleResponse(this.api.get(`/environments/${envId}/volumes/${volumeName}/usage`)) as Promise<VolumeUsageDto>;}+ async getVolumeUsageCounts(): Promise<VolumeUsageCounts> {+ const envId = await this.getCurrentEnvironmentId();++ const res = await this.api.get(`/environments/${envId}/volumes/counts`);+ return res.data.data;+ }+async createVolume(options: VolumeCreateOptions): Promise<any> {const envId = await this.getCurrentEnvironmentId();return this.handleResponse(this.api.post(`/environments/${envId}/volumes`, options));@@ -223,6 +224,13 @@ export class EnvironmentAPIService extends BaseAPIService {return res.data;}+ async getProjectStatusCounts(): Promise<ProjectStatusCounts> {+ const envId = await this.getCurrentEnvironmentId();++ const res = await this.api.get(`/environments/${envId}/stacks/counts`);+ return res.data.data;+ }+async getProject(projectName: string): Promise<Project> {const envId = await this.getCurrentEnvironmentId();const response = await this.handleResponse<{ stack?: Project; success?: boolean }>(@@ -236,7 +244,7 @@ export class EnvironmentAPIService extends BaseAPIService {return response as Project;}- async deployProject(projectName: string, composeContent: string, envContent?: string): Promise<Project> {+ async createProject(projectName: string, composeContent: string, envContent?: string): Promise<Project> {const envId = await this.getCurrentEnvironmentId();const payload = {name: projectName,@@ -255,9 +263,9 @@ export class EnvironmentAPIService extends BaseAPIService {return this.handleResponse(this.api.put(`/environments/${envId}/stacks/${projectName}`, payload));}- async startProject(projectId: string): Promise<Project> {+ async deployProject(projectId: string): Promise<Project> {const envId = await this.getCurrentEnvironmentId();- return this.handleResponse(this.api.post(`/environments/${envId}/stacks/${projectId}/start`));+ return this.handleResponse(this.api.post(`/environments/${envId}/stacks/${projectId}/deploy`));}async restartProject(projectId: string): Promise<Project> {diff --git a/frontend/src/lib/types/container.type.ts b/frontend/src/lib/types/container.type.tsindex 4f0c1c960..dac2c819f 100644--- a/frontend/src/lib/types/container.type.ts+++ b/frontend/src/lib/types/container.type.ts@@ -10,6 +10,12 @@ export interface BaseContainer {status: string;}+export interface ContainerStatusCounts {+ runningContainers: number;+ stoppedContainers: number;+ totalContainers: number;+}+export interface PortDto {ip?: string;privatePort: number;diff --git a/frontend/src/lib/types/image.type.ts b/frontend/src/lib/types/image.type.tsindex 9a8ed6920..090d0db58 100644--- a/frontend/src/lib/types/image.type.ts+++ b/frontend/src/lib/types/image.type.ts@@ -14,6 +14,13 @@ export interface ImageUpdateInfoDto {usedCredential?: boolean;}+export interface ImageUsageCounts {+ imagesInuse: number;+ imagesUnused: number;+ totalImages: number;+ totalImageSize: number;+}+export interface ImageSummaryDto {id: string;repoTags: string[];diff --git a/frontend/src/lib/types/network.type.ts b/frontend/src/lib/types/network.type.tsindex ed1effaa3..b81594135 100644--- a/frontend/src/lib/types/network.type.ts+++ b/frontend/src/lib/types/network.type.ts@@ -11,6 +11,12 @@ export interface NetworkCreateOptions {checkDuplicate?: boolean;}+export interface NetworkUsageCounts {+ networksInuse: number;+ networksUnused: number;+ totalNetworks: number;+}+export interface IPAMConfig {driver?: string;config?: IPAMSubnet[];diff --git a/frontend/src/lib/types/pagination.type.ts b/frontend/src/lib/types/pagination.type.tsindex bae4f41b7..0aa646c65 100644--- a/frontend/src/lib/types/pagination.type.ts+++ b/frontend/src/lib/types/pagination.type.ts@@ -22,6 +22,7 @@ export type PaginationResponse = {totalItems: number;currentPage: number;itemsPerPage: number;+ grandTotalItems?: number;};export type Paginated<T> = {diff --git a/frontend/src/lib/types/project.type.ts b/frontend/src/lib/types/project.type.tsindex 596653bd3..45288cf81 100644--- a/frontend/src/lib/types/project.type.ts+++ b/frontend/src/lib/types/project.type.ts@@ -44,3 +44,9 @@ export interface Project {composeContent?: string;envContent?: string;}++export interface ProjectStatusCounts {+ runningProjects: number;+ stoppedProjects: number;+ totalProjects: number;+}diff --git a/frontend/src/lib/types/volume.type.ts b/frontend/src/lib/types/volume.type.tsindex 1f6460c00..31e6602fb 100644--- a/frontend/src/lib/types/volume.type.ts+++ b/frontend/src/lib/types/volume.type.ts@@ -18,3 +18,9 @@ export interface VolumeUsageDto {inUse: boolean;containers: string[];}++export interface VolumeUsageCounts {+ volumesInuse: number;+ volumesUnused: number;+ totalVolumes: number;+}diff --git a/frontend/src/routes/compose/+page.svelte b/frontend/src/routes/compose/+page.svelteindex 480f4e7be..94d833c53 100644--- a/frontend/src/routes/compose/+page.svelte+++ b/frontend/src/routes/compose/+page.svelte@@ -14,8 +14,7 @@let { data } = $props();- let projects = $state(data.projects);- let projectRequestOptions = $state(data.projectRequestOptions);+ let { projects, projectStatusCounts, projectRequestOptions } = $state(data);let selectedIds = $state<string[]>([]);let isLoading = $state({@@ -23,9 +22,9 @@refreshing: false});- const totalCompose = $derived(projects.pagination.totalItems);- const runningCompose = $derived(projects.data.filter((s) => s.status === 'running').length);- const stoppedCompose = $derived(projects.data.filter((s) => s.status === 'stopped').length);+ const totalCompose = $derived(projectStatusCounts.totalProjects);+ const runningCompose = $derived(projectStatusCounts.runningProjects);+ const stoppedCompose = $derived(projectStatusCounts.stoppedProjects);async function handleCheckForUpdates() {isLoading.updating = true;diff --git a/frontend/src/routes/compose/+page.ts b/frontend/src/routes/compose/+page.tsindex eb11394cc..cf014bdd0 100644--- a/frontend/src/routes/compose/+page.ts+++ b/frontend/src/routes/compose/+page.ts@@ -15,6 +15,7 @@ export const load: PageLoad = async () => {};const projects = await environmentAPI.getProjects(projectRequestOptions);+ const projectStatusCounts = await environmentAPI.getProjectStatusCounts();- return { projects, projectRequestOptions };+ return { projects, projectRequestOptions, projectStatusCounts };};diff --git a/frontend/src/routes/compose/compose-table.svelte b/frontend/src/routes/compose/compose-table.svelteindex 0a4af6127..871e103e1 100644--- a/frontend/src/routes/compose/compose-table.svelte+++ b/frontend/src/routes/compose/compose-table.svelte@@ -53,7 +53,7 @@try {if (action === 'start') {handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.startProject(id)),+ result: await tryCatch(environmentAPI.deployProject(id)),message: m.compose_start_failed(),setLoadingState: (value) => (isLoading.start = value),onSuccess: async () => {diff --git a/frontend/src/routes/compose/new/+page.svelte b/frontend/src/routes/compose/new/+page.svelteindex d9bbc17e5..d450540cc 100644--- a/frontend/src/routes/compose/new/+page.svelte+++ b/frontend/src/routes/compose/new/+page.svelte@@ -64,7 +64,7 @@const { name, composeContent, envContent } = validated;handleApiResultWithCallbacks({- result: await tryCatch(environmentAPI.deployProject(name, composeContent, envContent)),+ result: await tryCatch(environmentAPI.createProject(name, composeContent, envContent)),message: m.compose_create_failed(),setLoadingState: (value) => (saving = value),onSuccess: async (project) => {diff --git a/frontend/src/routes/containers/+page.svelte b/frontend/src/routes/containers/+page.svelteindex 20d64abd9..9ff81a11d 100644--- a/frontend/src/routes/containers/+page.svelte+++ b/frontend/src/routes/containers/+page.svelte@@ -12,8 +12,9 @@let { data } = $props();- let containers = $state(data.containers);- let requestOptions = $state(data.containerRequestOptions);+ let { containers, containerStatusCounts, containerRequestOptions } = $state(data);++ let requestOptions = $state(containerRequestOptions);let selectedIds = $state([]);let isCreateDialogOpen = $state(false);@@ -36,9 +37,6 @@});}- const runningContainers = $derived(containers.data.filter((s) => s.state === 'running').length);- const stoppedContainers = $derived(containers.data.filter((s) => s.state != 'running').length);-async function refreshContainers() {isLoading.refreshing = true;handleApiResultWithCallbacks({@@ -86,13 +84,13 @@<div class="grid grid-cols-1 gap-4 sm:grid-cols-3"><StatCardtitle={m.containers_total()}- value={containers.pagination.totalItems}+ value={containerStatusCounts.totalContainers}icon={BoxIcon}class="border-l-primary border-l-4 transition-shadow hover:shadow-lg"/><StatCardtitle={m.containers_running()}- value={runningContainers}+ value={containerStatusCounts.runningContainers}icon={BoxIcon}iconColor="text-green-500"bgColor="bg-green-500/10"@@ -100,7 +98,7 @@/><StatCardtitle={m.containers_stopped()}- value={stoppedContainers}+ value={containerStatusCounts.stoppedContainers}icon={BoxIcon}iconColor="text-amber-500"class="border-l-4 border-l-amber-500"diff --git a/frontend/src/routes/containers/+page.ts b/frontend/src/routes/containers/+page.tsindex 86e071bca..65a30be5c 100644--- a/frontend/src/routes/containers/+page.ts+++ b/frontend/src/routes/containers/+page.ts@@ -15,6 +15,7 @@ export const load: PageLoad = async () => {};const containers = await environmentAPI.getContainers(containerRequestOptions);+ const containerStatusCounts = await environmentAPI.getContainerStatusCounts();- return { containers, containerRequestOptions };+ return { containers, containerStatusCounts, containerRequestOptions };};diff --git a/frontend/src/routes/images/+page.svelte b/frontend/src/routes/images/+page.svelteindex 8eaa6542c..14267e168 100644--- a/frontend/src/routes/images/+page.svelte+++ b/frontend/src/routes/images/+page.svelte@@ -17,8 +17,7 @@let { data } = $props();- let images = $state(data.images);- let requestOptions = $state(data.imageRequestOptions);+ let { images, imageUsageCounts, imageRequestOptions: requestOptions } = $state(data);let selectedIds = $state<string[]>([]);let isLoading = $state({@@ -111,14 +110,14 @@<div class="grid grid-cols-1 gap-4 sm:grid-cols-2"><StatCardtitle={m.images_total()}- value={images.pagination.totalItems}+ value={imageUsageCounts.totalImages}icon={HardDriveIcon}iconColor="text-blue-500"class="border-l-4 border-l-blue-500"/><StatCardtitle={m.images_total_size()}- value={String(bytes.format(data.totalSize))}+ value={String(bytes.format(imageUsageCounts.totalImageSize))}icon={PackageIcon}iconColor="text-amber-500"class="border-l-4 border-l-amber-500"diff --git a/frontend/src/routes/images/+page.ts b/frontend/src/routes/images/+page.tsindex a0adbd390..d93a144fc 100644--- a/frontend/src/routes/images/+page.ts+++ b/frontend/src/routes/images/+page.ts@@ -13,10 +13,9 @@ export const load: PageLoad = async () => {direction: 'desc' as const}};-- const totalSize = await environmentAPI.getTotalImageSize();const images = await environmentAPI.getImages(imageRequestOptions);const settings = await settingsAPI.getSettings();+ const imageUsageCounts = await environmentAPI.getImageUsageCounts();- return { totalSize, images, imageRequestOptions, settings };+ return { images, imageRequestOptions, settings, imageUsageCounts };};diff --git a/frontend/src/routes/networks/+page.svelte b/frontend/src/routes/networks/+page.svelteindex 326be1d8d..68b5bc0db 100644--- a/frontend/src/routes/networks/+page.svelte+++ b/frontend/src/routes/networks/+page.svelte@@ -14,8 +14,7 @@let { data } = $props();- let networks = $state(data.networks);- let requestOptions = $state(data.networkRequestOptions);+ let { networks, networkUsageCounts, networkRequestOptions: requestOptions } = $state(data);let selectedIds = $state<string[]>([]);let isCreateDialogOpen = $state(false);@@ -24,8 +23,8 @@refresh: false});- const totalNetworks = $derived(networks.data.length);- const bridgeNetworks = $derived(networks.data.filter((n) => n.driver === 'bridge').length);+ const totalNetworks = $derived(networkUsageCounts.totalNetworks);+ const unusedNetworks = $derived(networkUsageCounts.networksUnused);async function refreshNetworks() {isLoading.refresh = true;@@ -82,11 +81,11 @@class="border-l-4 border-l-blue-500"/><StatCard- title={m.networks_bridge()}- value={bridgeNetworks}+ title={m.unused_networks()}+ value={unusedNetworks}icon={EthernetPortIcon}- iconColor="text-green-500"- class="border-l-4 border-l-green-500"+ iconColor="text-amber-500"+ class="border-l-4 border-l-amber-500"/></div>diff --git a/frontend/src/routes/networks/+page.ts b/frontend/src/routes/networks/+page.tsindex 83474d372..224e0ed8e 100644--- a/frontend/src/routes/networks/+page.ts+++ b/frontend/src/routes/networks/+page.ts@@ -15,6 +15,7 @@ export const load: PageLoad = async () => {};const networks = await environmentAPI.getNetworks(networkRequestOptions);+ const networkUsageCounts = await environmentAPI.getNetworkUsageCounts();- return { networks, networkRequestOptions };+ return { networks, networkRequestOptions, networkUsageCounts };};diff --git a/frontend/src/routes/volumes/+page.svelte b/frontend/src/routes/volumes/+page.svelteindex 79f0e69ab..b9dcf362f 100644--- a/frontend/src/routes/volumes/+page.svelte+++ b/frontend/src/routes/volumes/+page.svelte@@ -15,8 +15,8 @@let { data } = $props();- let volumes = $state(data.volumes);- let requestOptions = $state(data.volumeRequestOptions);+ let { volumes, volumeUsageCounts, volumeRequestOptions: requestOptions } = $state(data);+let selectedIds = $state<string[]>([]);let isCreateDialogOpen = $state(false);@@ -26,9 +26,9 @@removingSelected: false});- const totalVolumes = $derived(volumes.data.length);- const usedVolumes = $derived(volumes.data.filter((v) => v.inUse).length);- const unusedVolumes = $derived(volumes.data.filter((v) => !v.inUse).length);+ const totalVolumes = $derived(volumeUsageCounts.totalVolumes);+ const usedVolumes = $derived(volumeUsageCounts.volumesInuse);+ const unusedVolumes = $derived(volumeUsageCounts.volumesUnused);async function handleCreateVolumeSubmit(options: VolumeCreateOptions) {isLoading.creating = true;diff --git a/frontend/src/routes/volumes/+page.ts b/frontend/src/routes/volumes/+page.tsindex 0b8df2acb..bb17f81ca 100644--- a/frontend/src/routes/volumes/+page.ts+++ b/frontend/src/routes/volumes/+page.ts@@ -15,6 +15,7 @@ export const load: PageLoad = async () => {};const volumes = await environmentAPI.getVolumes(volumeRequestOptions);+ const volumeUsageCounts = await environmentAPI.getVolumeUsageCounts();- return { volumes, volumeRequestOptions };+ return { volumes, volumeRequestOptions, volumeUsageCounts };};diff --git a/tests/spec/network.spec.ts b/tests/spec/network.spec.tsindex a79e02ac8..00f766b2b 100644--- a/tests/spec/network.spec.ts+++ b/tests/spec/network.spec.ts@@ -38,10 +38,9 @@ test.describe('Networks Page', () => {await page.goto('/networks');const total = realNetworks.length;- const bridgeCount = realNetworks.filter((n) => n.driver === 'bridge').length;await expect(page.locator('p:has-text("Total Networks") + p')).toHaveText(String(total));- await expect(page.locator('p:has-text("Bridge Networks") + p')).toHaveText(String(bridgeCount));+ await expect(page.locator('p:has-text("Unused Networks") + p')).toBeVisible();});test('Table displays when networks exist, else empty state', async ({ page }) => {