Skip to content

Modern Docker Management, Designed for Everyone

feat: container port links and overview (#457)

Kyle Mendell154107da7e0d
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index d52d16b7a..ede8d53ef 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -578,10 +578,7 @@
"compose_nav_logs": "Logs",
"compose_overview_title": "Overview",
"compose_exposed_ports": "Exposed Ports",
- "compose_port_label": "Port {port}",
"compose_services_header": "Services ({count})",
- "compose_ports_label_one": "port",
- "compose_ports_label_many": "ports",
"compose_no_services_found": "No services found for this project",
"compose_service_not_created": "Not created",
"compose_configuration_title": "Configuration",
@@ -1052,5 +1049,6 @@
"security_settings_save_failed": "Failed to save security settings",
"common_skip": "Skip",
"language": "Language",
- "bridge": "Bridge"
+ "bridge": "Bridge",
+ "ports": "Ports"
}
diff --git a/frontend/src/lib/components/port-badges.svelte b/frontend/src/lib/components/port-badges.svelte
new file mode 100644
index 000000000..efef45c28
--- /dev/null
+++ b/frontend/src/lib/components/port-badges.svelte
@@ -0,0 +1,88 @@
+<script lang="ts">
+ import type { PortDto } from '$lib/types/container.type';
+ import { m } from '$lib/paraglide/messages';
+
+ let { ports = [] as PortDto[], baseServerUrl = '' } = $props<{
+ ports?: PortDto[];
+ baseServerUrl?: string;
+ }>();
+
+ type NormalizedPort = {
+ hostPort: string;
+ containerPort: string;
+ proto?: string;
+ ip?: string | null;
+ };
+
+ function getPublicPort(p: PortDto): string | null {
+ return (p as any).publicPort?.toString?.() ?? (p as any).hostPort?.toString?.() ?? (p as any).published?.toString?.() ?? null;
+ }
+
+ function getPrivatePort(p: PortDto): string {
+ return ((p as any).privatePort ?? (p as any).target ?? '?').toString();
+ }
+
+ function getProto(p: PortDto): string | undefined {
+ return (p as any).type ?? (p as any).protocol ?? undefined;
+ }
+
+ function normalize(p: PortDto): NormalizedPort | null {
+ const hostPort = getPublicPort(p);
+ if (!hostPort) return null;
+ return {
+ hostPort,
+ containerPort: getPrivatePort(p),
+ proto: getProto(p),
+ ip: (p as any).ip ?? null
+ };
+ }
+
+ function uniquePublished(list: PortDto[]): NormalizedPort[] {
+ const map = new Map<string, NormalizedPort>();
+ for (const p of list) {
+ const n = normalize(p);
+ if (!n) continue;
+ const key = `${n.hostPort}:${n.containerPort}/${n.proto ?? ''}`;
+ if (!map.has(key)) map.set(key, n);
+ }
+ return Array.from(map.values()).sort((a, b) => {
+ const hp = Number(a.hostPort) - Number(b.hostPort);
+ if (hp !== 0) return hp;
+ return Number(a.containerPort) - Number(b.containerPort);
+ });
+ }
+
+ function toHref(hostPort: string): string {
+ try {
+ const base = baseServerUrl || (typeof window !== 'undefined' ? window.location.origin : 'http://localhost');
+ const url = new URL(base.startsWith('http') ? base : `http://${base}`);
+ url.port = hostPort;
+ return url.toString();
+ } catch {
+ return '#';
+ }
+ }
+
+ const published = $derived(uniquePublished(ports));
+</script>
+
+{#if !published || published.length === 0}
+ <span class="text-muted-foreground text-xs">{m.containers_not_published()}</span>
+{:else}
+ <div class="flex flex-wrap gap-1.5">
+ {#each published as p, i (i)}
+ <a
+ class="ring-offset-background focus-visible:ring-ring bg-background/70 inline-flex items-center gap-1 rounded-lg border border-sky-700/20 px-2 py-1 text-[11px] shadow-sm transition-colors transition-shadow hover:border-sky-700/40 hover:bg-sky-500/10 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
+ href={toHref(p.hostPort)}
+ target="_blank"
+ rel="noopener noreferrer"
+ title={`${p.ip ?? '0.0.0.0'}:${p.hostPort} → ${p.containerPort}${p.proto ? `/${p.proto}` : ''}`}
+ >
+ <span class="font-medium tabular-nums">{p.hostPort}:{p.containerPort}</span>
+ {#if p.proto}
+ <span class="text-muted-foreground uppercase">{p.proto}</span>
+ {/if}
+ </a>
+ {/each}
+ </div>
+{/if}
diff --git a/frontend/src/routes/compose/[projectId]/+page.svelte b/frontend/src/routes/compose/[projectId]/+page.svelte
index 3f5a15e64..db67203e9 100644
--- a/frontend/src/routes/compose/[projectId]/+page.svelte
+++ b/frontend/src/routes/compose/[projectId]/+page.svelte
@@ -459,12 +459,6 @@
</div>
<div class="mt-1 flex items-center gap-2">
<StatusBadge {variant} text={capitalizeFirstLetter(status)} class="text-xs" />
- {#if service.ports && service.ports.length > 0}
- <span class="bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-xs">
- {service.ports.length}
- {service.ports.length > 1 ? m.compose_ports_label_many() : m.compose_ports_label_one()}
- </span>
- {/if}
</div>
</div>
</a>
diff --git a/frontend/src/routes/containers/+page.svelte b/frontend/src/routes/containers/+page.svelte
index 9ff81a11d..84d928a8c 100644
--- a/frontend/src/routes/containers/+page.svelte
+++ b/frontend/src/routes/containers/+page.svelte
@@ -24,6 +24,10 @@
refreshing: false
});
+ const baseServerUrl = $derived(
+ (data.settings as any)?.serverBaseUrl ?? (data.settings as any)?.baseServerUrl ?? (data.settings as any)?.baseUrl ?? ''
+ );
+
async function handleCheckForUpdates() {
isLoading.checking = true;
handleApiResultWithCallbacks({
@@ -105,7 +109,7 @@
/>
</div>
- <ContainerTable bind:containers bind:selectedIds bind:requestOptions />
+ <ContainerTable bind:containers bind:selectedIds bind:requestOptions {baseServerUrl} />
<CreateContainerSheet
bind:open={isCreateDialogOpen}
diff --git a/frontend/src/routes/containers/+page.ts b/frontend/src/routes/containers/+page.ts
index 65a30be5c..986169dbe 100644
--- a/frontend/src/routes/containers/+page.ts
+++ b/frontend/src/routes/containers/+page.ts
@@ -1,21 +1,18 @@
-import { environmentAPI } from '$lib/services/api';
+import { environmentAPI, settingsAPI } from '$lib/services/api';
import type { SearchPaginationSortRequest } from '$lib/types/pagination.type';
import type { PageLoad } from './$types';
export const load: PageLoad = async () => {
const containerRequestOptions: SearchPaginationSortRequest = {
- pagination: {
- page: 1,
- limit: 20
- },
- sort: {
- column: 'created',
- direction: 'desc' as const
- }
+ pagination: { page: 1, limit: 20 },
+ sort: { column: 'created', direction: 'desc' as const }
};
- const containers = await environmentAPI.getContainers(containerRequestOptions);
- const containerStatusCounts = await environmentAPI.getContainerStatusCounts();
+ const [containers, containerStatusCounts, settings] = await Promise.all([
+ environmentAPI.getContainers(containerRequestOptions),
+ environmentAPI.getContainerStatusCounts(),
+ settingsAPI.getSettings()
+ ]);
- return { containers, containerStatusCounts, containerRequestOptions };
+ return { containers, containerStatusCounts, containerRequestOptions, settings };
};
diff --git a/frontend/src/routes/containers/[containerId]/+page.svelte b/frontend/src/routes/containers/[containerId]/+page.svelte
index 0f3e67397..36a3c04fd 100644
--- a/frontend/src/routes/containers/[containerId]/+page.svelte
+++ b/frontend/src/routes/containers/[containerId]/+page.svelte
@@ -26,6 +26,7 @@
import Separator from '$lib/components/ui/separator/separator.svelte';
import type { ContainerDetailsDto, NetworkSettingsDto } from '$lib/types/container.type';
import { m } from '$lib/paraglide/messages';
+ import PortBadges from '$lib/components/port-badges.svelte';
interface NetworkConfig {
IPAddress?: string;
@@ -264,6 +265,10 @@
const d = parseDockerDate(input);
return d ? format(d, fmt) : 'N/A';
}
+
+ const baseServerUrl = $derived(
+ (data?.settings as any)?.serverBaseUrl ?? (data?.settings as any)?.baseServerUrl ?? (data?.settings as any)?.baseUrl ?? ''
+ );
</script>
<div class="bg-background min-h-screen">
@@ -705,25 +710,7 @@
{#if hasPorts}
<div>
<h3 class="mb-3 text-sm font-semibold tracking-tight">{m.containers_port_mappings()}</h3>
-
- <ul class="divide-border/60 divide-y">
- {#each container.ports as p, idx (idx)}
- <li class="px-4 py-2.5">
- <div class="flex min-w-0 items-center gap-3">
- <Badge variant="secondary">
- {p.privatePort}/{p.type}
- </Badge>
- {#if p.publicPort}
- <span class="truncate font-semibold">
- {p.ip || '0.0.0.0'}:{p.publicPort} → {p.privatePort}/{p.type}
- </span>
- {:else}
- <span class="text-muted-foreground font-semibold">{m.containers_not_published()}</span>
- {/if}
- </div>
- </li>
- {/each}
- </ul>
+ <PortBadges ports={container.ports ?? []} {baseServerUrl} />
</div>
{/if}
diff --git a/frontend/src/routes/containers/[containerId]/+page.ts b/frontend/src/routes/containers/[containerId]/+page.ts
index 5381a541f..02d9f1237 100644
--- a/frontend/src/routes/containers/[containerId]/+page.ts
+++ b/frontend/src/routes/containers/[containerId]/+page.ts
@@ -1,21 +1,25 @@
import type { PageLoad } from './$types';
-import { environmentAPI } from '$lib/services/api';
+import { environmentAPI, settingsAPI } from '$lib/services/api';
import { error } from '@sveltejs/kit';
export const load: PageLoad = async ({ params }) => {
const containerId = params.containerId;
try {
- const container = await environmentAPI.getContainer(containerId);
- const containerStats = await environmentAPI.getContainerStats(containerId);
+ const [container, containerStats, settings] = await Promise.all([
+ environmentAPI.getContainer(containerId),
+ environmentAPI.getContainerStats(containerId),
+ settingsAPI.getSettings()
+ ]);
if (!container) {
throw error(404, 'Container not found');
}
return {
- container: container,
- stats: containerStats
+ container,
+ stats: containerStats,
+ settings
};
} catch (err: any) {
console.error('Failed to load container:', err);
diff --git a/frontend/src/routes/containers/container-table.svelte b/frontend/src/routes/containers/container-table.svelte
index 35d11733d..977b3239d 100644
--- a/frontend/src/routes/containers/container-table.svelte
+++ b/frontend/src/routes/containers/container-table.svelte
@@ -23,15 +23,18 @@
import type { ContainerSummaryDto } from '$lib/types/container.type';
import type { ColumnSpec } from '$lib/components/arcane-table';
import { m } from '$lib/paraglide/messages';
+ import PortBadges from '$lib/components/port-badges.svelte';
let {
containers = $bindable(),
selectedIds = $bindable(),
- requestOptions = $bindable()
+ requestOptions = $bindable(),
+ baseServerUrl = $bindable()
}: {
containers: Paginated<ContainerSummaryDto>;
selectedIds: string[];
requestOptions: SearchPaginationSortRequest;
+ baseServerUrl: string;
} = $props();
let isLoading = $state({
@@ -128,10 +131,15 @@
{ accessorKey: 'image', title: m.common_image(), sortable: true },
{ accessorKey: 'state', title: m.common_state(), sortable: true, cell: StateCell },
{ accessorKey: 'status', title: m.common_status() },
+ { accessorKey: 'ports', title: m.ports(), cell: PortsCell },
{ accessorKey: 'created', title: m.common_created(), sortable: true, cell: CreatedCell }
] satisfies ColumnSpec<ContainerSummaryDto>[];
</script>
+{#snippet PortsCell({ item }: { item: ContainerSummaryDto })}
+ <PortBadges ports={item.ports ?? []} {baseServerUrl} />
+{/snippet}
+
{#snippet NameCell({ item }: { item: ContainerSummaryDto })}
<a class="font-medium hover:underline" href="/containers/{item.id}/">
{#if item.names && item.names.length > 0}