diff --git a/frontend/src/routes/admin/templates/+page.svelte b/frontend/src/routes/admin/templates/+page.svelte index ae678ed..414d68f 100644 --- a/frontend/src/routes/admin/templates/+page.svelte +++ b/frontend/src/routes/admin/templates/+page.svelte @@ -2,6 +2,7 @@ import CopyButton from '$lib/components/CopyButton.svelte'; import { onMount, onDestroy } from 'svelte'; import { toast } from '$lib/toast.svelte'; + import { auth } from '$lib/auth.svelte'; import { formatDate, timeAgo } from '$lib/utils/format'; import { listBuilds, @@ -13,6 +14,7 @@ type BuildLogEntry, type AdminTemplate } from '$lib/api/builds'; + import { listAdminTeams } from '$lib/api/team'; let activeTab = $state<'templates' | 'builds'>('templates'); @@ -35,6 +37,9 @@ let expandedBuildId = $state(null); let expandedSteps = $state>(new Set()); + // Team name lookup + let teamNames = $state>(new Map()); + // Delete template state let deleteTarget = $state(null); let deleting = $state(false); @@ -64,6 +69,28 @@ let baseCount = $derived(templates.filter((t) => t.type === 'base').length); let runningBuilds = $derived(builds.filter((b) => b.status === 'running').length); + async function fetchTeamNames() { + const names = new Map(); + let page = 1; + while (true) { + const result = await listAdminTeams(page); + if (!result.ok) break; + for (const team of result.data.teams) { + names.set(team.id, team.name); + } + if (page >= result.data.total_pages) break; + page++; + } + teamNames = names; + } + + const PLATFORM_TEAM_ID = 'team-0000000000000000000000000'; + + function canDeleteTemplate(tmpl: AdminTemplate): boolean { + if (tmpl.name === 'minimal') return false; + return tmpl.team_id === PLATFORM_TEAM_ID; + } + async function fetchTemplates() { templatesLoading = true; templatesError = null; @@ -238,6 +265,7 @@ } onMount(() => { + fetchTeamNames(); fetchTemplates(); fetchBuilds().then(startPolling); @@ -339,7 +367,7 @@
{#if activeTab === 'templates'} {#if templatesLoading} - {@render skeletonRows(5, ['Name', 'Type', 'Specs', 'Size', 'Created', ''])} + {@render skeletonRows(5, ['Name', 'Type', 'Owner', 'Specs', 'Size', 'Created', ''])} {:else if templatesError}
{templatesError} @@ -442,6 +470,7 @@ Name Type + Owner Specs Size Created @@ -473,6 +502,13 @@ {/if} + + {#if tmpl.team_id === PLATFORM_TEAM_ID} + Platform + {:else} + {teamNames.get(tmpl.team_id) ?? tmpl.team_id} + {/if} + {#if tmpl.vcpus && tmpl.memory_mb} @@ -495,7 +531,11 @@