Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: truncate long images names on dashboard table
Kyle Mendell87556c94e9f3
diff --git a/src/lib/utils/string.utils.ts b/src/lib/utils/string.utils.tsindex a1ea71ec2..a7d605829 100644--- a/src/lib/utils/string.utils.ts+++ b/src/lib/utils/string.utils.ts@@ -1,8 +1,17 @@-export function shortId(id: string): string {- return id?.substring(0, 12) || '';+export function capitalizeFirstLetter(string: string): string {+ if (!string) return '';+ return string.charAt(0).toUpperCase() + string.slice(1);}-export const capitalizeFirstLetter = (text: string) => {- if (!text) return '';- return text.charAt(0).toUpperCase() + text.slice(1);-};+export function shortId(id: string | undefined, length = 12): string {+ if (!id) return 'N/A';+ return id.substring(0, length);+}++export function truncateString(str: string | undefined, maxLength: number): string {+ if (!str) return '';+ if (str.length <= maxLength) {+ return str;+ }+ return str.substring(0, maxLength - 3) + '...';+}diff --git a/src/routes/+page.svelte b/src/routes/+page.svelteindex 12352cff8..9fb2a16ad 100644--- a/src/routes/+page.svelte+++ b/src/routes/+page.svelte@@ -6,7 +6,7 @@import { AlertCircle, Box, HardDrive, Cpu, MemoryStick, ArrowRight, PlayCircle, StopCircle, Trash2, Settings, RefreshCw, Loader2 } from '@lucide/svelte';import * as Alert from '$lib/components/ui/alert/index.js';import { Progress } from '$lib/components/ui/progress/index.js';- import { capitalizeFirstLetter } from '$lib/utils/string.utils';+ import { capitalizeFirstLetter, truncateString } from '$lib/utils/string.utils';import { formatBytes } from '$lib/utils';import StatusBadge from '$lib/components/badges/status-badge.svelte';import { invalidateAll } from '$app/navigation';@@ -329,7 +329,7 @@{#snippet rows({ item })}{@const stateVariant = statusVariantMap[item.state.toLowerCase()]}<Table.Cell><a class="font-medium hover:underline" href="/containers/{item.id}/">{item.name}</a></Table.Cell>- <Table.Cell>{item.image}</Table.Cell>+ <Table.Cell title={item.image}>{truncateString(item.image, 40)}</Table.Cell><Table.Cell><StatusBadge variant={stateVariant} text={capitalizeFirstLetter(item.state)} /></Table.Cell><Table.Cell>{item.status}</Table.Cell>{/snippet}