Files
shared/media-webui/src/lib/components/StatusDialog.svelte
T
Gabriel20xxandClaude Sonnet 5 acde180086 Fold MediaEngine (media-backend, media-webui) into this repo
Per owner decision: MediaEngine (the Media product family's Go backend
and SvelteKit frontend, previously its own repo referenced by 7 thin
service repos via git submodule) is folded directly into shared/ as
media-backend/ and media-webui/, rather than staying separate.

media-backend/go.mod's replace directive now points at ../backend (a
true sibling within this repo) instead of a vendored ../shared/backend
copy, since there's no more nested vendoring - it's the real thing.

Also moved MediaEngine's own CI (media-backend-lint.yml,
media-backend-tests.yml) and dev tooling scripts (scripts/media/*,
audit/lint/enforce scripts for the media-backend+media-webui content),
fixing their path assumptions for the new layout, and dropped
scripts/media/sync-shared.mjs (confirmed dead code, and now doubly
obsolete since there's no more vendored shared/ subfolder for it to
check). Added media:* script aliases to package.json for the moved
tooling, namespaced to avoid colliding with this repo's own scripts.

Also fixed sync-consumers.ps1's workspace-root resolution to walk up
until it finds a directory containing both Original/ and Forks/,
instead of assuming shared/ is always a direct child of the workspace
root - it broke when shared/ moved from Web/shared to Web/Central/shared
earlier in this same restructuring. Removed the now-obsolete
Original/MediaEngine entry from its consumer list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-31 22:06:29 +02:00

103 lines
3.6 KiB
Svelte

<script lang="ts">
import { AlertCircle, AlertTriangle, CheckCircle2, CircleHelp, LoaderCircle, RefreshCw, X } from '@lucide/svelte'
import Button from '$lib/components/ui/button.svelte'
import type { StatusProbe, StatusSnapshot } from '$lib/status'
let {
open = $bindable(false),
status,
onRefresh,
}: {
open?: boolean
status: StatusSnapshot
onRefresh: () => Promise<void>
} = $props()
const levelLabel = {
checking: 'Checking',
healthy: 'Healthy',
degraded: 'Degraded',
offline: 'Offline',
}
const levelClass = {
checking: 'text-muted-fg',
healthy: 'text-success',
degraded: 'text-warning',
offline: 'text-danger',
}
function probeLabel(probe: StatusProbe | null) {
if (!probe) return 'Not checked'
if (probe.ok) return 'OK'
if (probe.error) return probe.error
return probe.httpStatus ? `HTTP ${probe.httpStatus}` : 'Unavailable'
}
</script>
{#if open}
<div
class="fixed inset-0 z-50 grid place-items-center bg-black/70 px-4"
role="presentation"
onclick={(event) => event.target === event.currentTarget && (open = false)}
>
<div
class="w-full max-w-lg rounded-xl border border-border bg-bg p-6 text-fg shadow-2xl"
role="dialog"
aria-modal="true"
aria-labelledby="status-dialog-title"
>
<div class="mb-5 flex items-start justify-between gap-3">
<div>
<h2 id="status-dialog-title" class="text-xl font-semibold">Service status</h2>
<p class="mt-1 text-sm text-muted-fg">Live liveness and database readiness checks.</p>
</div>
<Button variant="ghost" size="icon" aria-label="Close" onclick={() => (open = false)}>
<X class="size-4" />
</Button>
</div>
<div class="mb-5 flex items-center gap-3 rounded-lg border border-border bg-surface p-3" aria-live="polite">
{#if status.loading && status.level === 'checking'}
<LoaderCircle class="size-5 animate-spin text-muted-fg" />
{:else if status.level === 'healthy'}
<CheckCircle2 class="size-5 text-success" />
{:else if status.level === 'degraded'}
<AlertTriangle class="size-5 text-warning" />
{:else if status.level === 'offline'}
<AlertCircle class="size-5 text-danger" />
{:else}
<CircleHelp class="size-5 text-muted-fg" />
{/if}
<span class={`font-medium ${levelClass[status.level]}`}>{levelLabel[status.level]}</span>
{#if status.checkedAt}
<span class="ml-auto text-xs text-muted-fg">{new Date(status.checkedAt).toLocaleTimeString()}</span>
{/if}
</div>
<div class="space-y-2 text-sm">
{#each [{ label: 'Liveness', probe: status.health }, { label: 'Readiness / database', probe: status.readiness }] as item (item.label)}
<div class="flex items-center justify-between gap-4 rounded-md border border-border px-3 py-2">
<span>{item.label}</span>
<span class={item.probe?.ok ? 'text-success' : 'text-danger'}>{probeLabel(item.probe)}</span>
</div>
{/each}
</div>
{#if status.health?.service || status.readiness?.service}
<p class="mt-4 text-xs text-muted-fg">
Service: {status.health?.service || status.readiness?.service}
</p>
{/if}
<div class="mt-6 flex justify-end gap-2">
<Button variant="outline" disabled={status.loading} onclick={() => void onRefresh()}>
<RefreshCw class={status.loading ? 'animate-spin' : ''} />
Refresh
</Button>
<Button variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
</div>
</div>
</div>
{/if}