Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: show ports in project service overview panel
Kyle Mendell72298c431c23
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.goindex 45bf12bdf..eb21ab827 100644--- a/backend/internal/services/project_service.go+++ b/backend/internal/services/project_service.go@@ -47,13 +47,14 @@ func NewProjectService(db *database.DB, settingsService *SettingsService, eventS// Helperstype ProjectServiceInfo struct {- Name string `json:"name"`- Image string `json:"image"`- Status string `json:"status"`- ContainerID string `json:"container_id"`- ContainerName string `json:"container_name"`- Ports []string `json:"ports"`- Health *string `json:"health,omitempty"`+ Name string `json:"name"`+ Image string `json:"image"`+ Status string `json:"status"`+ ContainerID string `json:"container_id"`+ ContainerName string `json:"container_name"`+ Ports []string `json:"ports"`+ Health *string `json:"health,omitempty"`+ ServiceConfig *composetypes.ServiceConfig `json:"service_config,omitempty"`}func normalizeComposeProjectName(name string) string {@@ -160,12 +161,23 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strinhave := map[string]bool{}var services []ProjectServiceInfo+ // Create a map for quick lookup of service config+ serviceConfigs := make(map[string]composetypes.ServiceConfig)+ for _, svc := range project.Services {+ serviceConfigs[svc.Name] = svc+ }+for _, c := range containers {var health *stringif c.Health != "" {health = &c.Health}+ var svcConfig *composetypes.ServiceConfig+ if cfg, ok := serviceConfigs[c.Service]; ok {+ svcConfig = &cfg+ }+services = append(services, ProjectServiceInfo{Name: c.Service,Image: c.Image,@@ -174,17 +186,20 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strinContainerName: c.Name,Ports: formatPorts(c.Publishers),Health: health,+ ServiceConfig: svcConfig,})have[c.Service] = true}for _, svc := range project.Services {if !have[svc.Name] {+ svcCopy := svcservices = append(services, ProjectServiceInfo{- Name: svc.Name,- Image: svc.Image,- Status: "stopped",- Ports: []string{},+ Name: svc.Name,+ Image: svc.Image,+ Status: "stopped",+ Ports: []string{},+ ServiceConfig: &svcCopy,})}}@@ -285,6 +300,7 @@ func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID stringContainerName: svc.ContainerName,Ports: svc.Ports,Health: svc.Health,+ ServiceConfig: svc.ServiceConfig,}}resp.RuntimeServices = runtimeServices@@ -1164,6 +1180,7 @@ func (s *ProjectService) mapProjectToDto(ctx context.Context, p models.Project,ContainerName: s.ContainerName,Ports: s.Ports,Health: s.Health,+ ServiceConfig: s.ServiceConfig,}}resp.RuntimeServices = runtimeServicesdiff --git a/frontend/src/lib/types/project.type.ts b/frontend/src/lib/types/project.type.tsindex deebd7d9d..32855ed6c 100644--- a/frontend/src/lib/types/project.type.ts+++ b/frontend/src/lib/types/project.type.ts@@ -59,6 +59,7 @@ export interface RuntimeService {containerName?: string;ports?: string[];health?: string;+ serviceConfig?: ProjectService;}export interface Project {diff --git a/frontend/src/routes/(app)/projects/components/ServicesGrid.svelte b/frontend/src/routes/(app)/projects/components/ServicesGrid.svelteindex bbba7387c..46ab15606 100644--- a/frontend/src/routes/(app)/projects/components/ServicesGrid.svelte+++ b/frontend/src/routes/(app)/projects/components/ServicesGrid.svelte@@ -3,6 +3,7 @@import LayersIcon from '@lucide/svelte/icons/layers';import HeartPulseIcon from '@lucide/svelte/icons/heart-pulse';import StatusBadge from '$lib/components/badges/status-badge.svelte';+ import { PortBadge } from '$lib/components/badges';import { getStatusVariant } from '$lib/utils/status.utils';import { capitalizeFirstLetter } from '$lib/utils/string.utils';import { m } from '$lib/paraglide/messages';@@ -23,8 +24,38 @@if (normalized === 'unhealthy') return 'text-red-500';return 'text-amber-500';}++ function parseStringPorts(ports: string[]): any[] {+ return ports.map((p) => {+ const [numsPart, proto] = p.split('/');+ const nums = numsPart.split(':');+ if (nums.length === 2) {+ return {+ publicPort: parseInt(nums[0]),+ privatePort: parseInt(nums[1]),+ type: proto || 'tcp'+ };+ }+ return {+ privatePort: parseInt(nums[0]),+ type: proto || 'tcp'+ };+ });+ }</script>+{#snippet portsDisplay(service: RuntimeService)}+ {#if service.serviceConfig?.ports && service.serviceConfig.ports.length > 0}+ <div class="mt-3">+ <PortBadge ports={service.serviceConfig.ports as any} />+ </div>+ {:else if service.ports && service.ports.length > 0}+ <div class="mt-3">+ <PortBadge ports={parseStringPorts(service.ports)} />+ </div>+ {/if}+{/snippet}+{#snippet serviceCard(service: RuntimeService)}{@const status = service.status || 'unknown'}{@const containerUrl = projectId@@ -61,11 +92,7 @@</div>{/if}</div>- {#if service.ports && service.ports.length > 0}- <div class="text-muted-foreground mt-2 text-xs">- {m.common_ports()}: {service.ports.join(', ')}- </div>- {/if}+ {@render portsDisplay(service)}</div></div></Card.Content>@@ -86,6 +113,7 @@<p class="text-muted-foreground mt-2 text-xs">{m.compose_service_not_created()}</p>+ {@render portsDisplay(service)}</div></div></Card.Content>diff --git a/types/project/project.go b/types/project/project.goindex 3a046f291..7135cb81b 100644--- a/types/project/project.go+++ b/types/project/project.go@@ -108,6 +108,11 @@ type RuntimeService struct {//// Required: falseHealth *string `json:"health,omitempty"`++ // ServiceConfig is the configuration of the service from the compose file.+ //+ // Required: false+ ServiceConfig *composetypes.ServiceConfig `json:"serviceConfig,omitempty"`}// CreateReponse is the response when a project is created.