Redesign UI with new token system, primitives, and motion
Restraint-first design language: neutral gray surfaces + one blue accent (cyan/amber/red reserved for state), 8pt spacing, softer radii, one ambient + one raised shadow, standardized motion tokens. Alfa Slab One demoted to BrandMark only; Inter carries all page copy. New primitives (Button, Card, Badge, Stat, SectionHeader, Skeleton, EmptyState, Tabs, Breadcrumbs, StatusPip, Field, Input, Select, Textarea) plus motion utilities (tweenNumber, viewTransition) and a global toast system. All eight route surfaces rewritten on top: Fleet gains an overview hero, Server detail restructures into tabs, Deployments gets a collapsible drift summary + per-server pipeline visual, and the scripts/configs/plugins/betas flows adopt the new form primitives. Sticky translucent nav with backdrop blur, view-transition cross-fades between routes, staggered card entrance on Fleet, breathing status pip halo, tabular-numeric player counts. Gmail-style g-key nav shortcuts. Mobile stacks below 720px; prefers-reduced-motion neutralizes durations. Legacy tokens preserved as aliases so any un-migrated code still renders.
This commit is contained in:
+157
-46
@@ -1,9 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { onNavigate, goto } from '$app/navigation';
|
||||
import { startPipelineStream } from '$ui/stores/pipeline.js';
|
||||
import { startServerStream } from '$ui/stores/servers.js';
|
||||
import { page } from '$app/stores';
|
||||
import BrandMark from '$ui/components/BrandMark.svelte';
|
||||
import Toaster from '$ui/components/Toaster.svelte';
|
||||
import { enableViewTransitions } from '$ui/motion/viewTransition.js';
|
||||
// Side-effect import — puts @fontsource CSS on Vite's module graph so
|
||||
// the referenced woff/woff2 files get emitted into the build.
|
||||
import '$ui/styles/fonts.js';
|
||||
@@ -14,27 +17,83 @@
|
||||
onMount(() => {
|
||||
startPipelineStream();
|
||||
startServerStream();
|
||||
|
||||
// Two-key nav shortcuts (Gmail-style): `g f` fleet, `g d` deployments,
|
||||
// `g b` betas, `g s` scripts. Ignored while typing in inputs.
|
||||
const shortcuts: Record<string, string> = {
|
||||
f: '/', d: '/deployments', b: '/betas',
|
||||
s: '/scripts', c: '/configs', p: '/plugins'
|
||||
};
|
||||
let armed = false;
|
||||
let armTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
const target = e.target as HTMLElement;
|
||||
if (target && (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable)) return;
|
||||
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
||||
|
||||
if (!armed && e.key === 'g') {
|
||||
armed = true;
|
||||
if (armTimer) clearTimeout(armTimer);
|
||||
armTimer = setTimeout(() => { armed = false; }, 1000);
|
||||
return;
|
||||
}
|
||||
if (armed) {
|
||||
armed = false;
|
||||
if (armTimer) { clearTimeout(armTimer); armTimer = null; }
|
||||
const dest = shortcuts[e.key];
|
||||
if (dest) {
|
||||
e.preventDefault();
|
||||
goto(dest);
|
||||
}
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', onKey);
|
||||
return () => {
|
||||
window.removeEventListener('keydown', onKey);
|
||||
if (armTimer) clearTimeout(armTimer);
|
||||
};
|
||||
});
|
||||
|
||||
// Route changes cross-fade via the browser's View Transitions API.
|
||||
// Non-Chromium browsers fall through to plain navigation.
|
||||
onNavigate(enableViewTransitions);
|
||||
|
||||
const tabs = [
|
||||
{ href: '/', label: 'Fleet', match: (p: string) => p === '/' },
|
||||
{ href: '/scripts', label: 'Scripts', match: (p: string) => p.startsWith('/scripts') },
|
||||
{ href: '/configs', label: 'Configs', match: (p: string) => p.startsWith('/configs') },
|
||||
{ href: '/plugins', label: 'Plugins', match: (p: string) => p.startsWith('/plugins') },
|
||||
{ href: '/deployments', label: 'Deployments', match: (p: string) => p.startsWith('/deployments') },
|
||||
{ href: '/betas', label: 'Betas', match: (p: string) => p.startsWith('/betas') }
|
||||
];
|
||||
</script>
|
||||
|
||||
<div class="shell">
|
||||
<nav>
|
||||
<nav aria-label="Primary">
|
||||
<a class="brand-link" href="/" aria-label="Electric Cherry home">
|
||||
<BrandMark size="md" />
|
||||
<BrandMark size="sm" />
|
||||
</a>
|
||||
<div class="tabs">
|
||||
<a href="/" class:on={$page.url.pathname === '/'}>Fleet</a>
|
||||
<a href="/scripts" class:on={$page.url.pathname.startsWith('/scripts')}>Scripts</a>
|
||||
<a href="/configs" class:on={$page.url.pathname.startsWith('/configs')}>Configs</a>
|
||||
<a href="/plugins" class:on={$page.url.pathname.startsWith('/plugins')}>Plugins</a>
|
||||
<a href="/deployments" class:on={$page.url.pathname.startsWith('/deployments')}>Deployments</a>
|
||||
<a href="/betas" class:on={$page.url.pathname.startsWith('/betas')}>Betas</a>
|
||||
<div class="tabs" role="tablist">
|
||||
{#each tabs as t (t.href)}
|
||||
{@const on = t.match($page.url.pathname)}
|
||||
<a
|
||||
href={t.href}
|
||||
class:on
|
||||
role="tab"
|
||||
aria-selected={on}
|
||||
aria-current={on ? 'page' : undefined}
|
||||
>
|
||||
<span class="lbl">{t.label}</span>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="strut" aria-hidden="true"></div>
|
||||
</nav>
|
||||
<main>
|
||||
{@render children()}
|
||||
</main>
|
||||
<Toaster />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -42,76 +101,128 @@
|
||||
|
||||
:global(html, body) {
|
||||
margin: 0;
|
||||
background: var(--bg-page);
|
||||
color: var(--ink-100);
|
||||
background: var(--surface-sunken);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-base);
|
||||
line-height: var(--leading-body);
|
||||
min-height: 100vh;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
:global(*) { box-sizing: border-box; }
|
||||
:global(a) { color: var(--accent-hi); }
|
||||
:global(a) { color: var(--accent-primary-hover); }
|
||||
:global(::selection) {
|
||||
background: var(--accent);
|
||||
color: var(--cream);
|
||||
background: var(--accent-primary);
|
||||
color: var(--text-on-accent);
|
||||
}
|
||||
:global(:focus-visible) {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Ambient background — a faint radial gradient hints at depth without
|
||||
any lines. Fixed to the viewport so scrolling stays quiet. */
|
||||
:global(body::before) {
|
||||
content: '';
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background:
|
||||
radial-gradient(1200px 700px at 20% -10%, rgba(46, 134, 209, 0.10), transparent 60%),
|
||||
radial-gradient(900px 600px at 90% 100%, rgba(124, 192, 245, 0.05), transparent 60%);
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.shell { min-height: 100vh; }
|
||||
|
||||
nav {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
padding: var(--pad-nav-y) var(--pad-nav-x);
|
||||
align-items: center;
|
||||
background:
|
||||
linear-gradient(180deg, rgba(46, 134, 209, 0.18) 0%, transparent 100%),
|
||||
var(--bg-nav);
|
||||
border-bottom: 1px solid var(--border);
|
||||
box-shadow: 0 1px 0 0 rgba(46, 134, 209, 0.25);
|
||||
gap: var(--space-6);
|
||||
height: 60px;
|
||||
padding: 0 var(--space-8);
|
||||
background: color-mix(in oklab, var(--surface) 75%, transparent);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
@supports (backdrop-filter: blur(4px)) {
|
||||
nav {
|
||||
backdrop-filter: blur(20px) saturate(1.4);
|
||||
-webkit-backdrop-filter: blur(20px) saturate(1.4);
|
||||
background: color-mix(in oklab, var(--surface) 62%, transparent);
|
||||
}
|
||||
}
|
||||
|
||||
.brand-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.brand-link:focus-visible { box-shadow: var(--focus-ring); }
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-left: 20px;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
margin-left: var(--space-4);
|
||||
}
|
||||
.tabs a {
|
||||
color: var(--ink-300);
|
||||
text-decoration: none;
|
||||
padding: 10px 18px;
|
||||
border-radius: var(--r-sm);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: 500;
|
||||
letter-spacing: var(--tracking-nav);
|
||||
position: relative;
|
||||
transition: color 0.15s;
|
||||
color: var(--text-tertiary);
|
||||
text-decoration: none;
|
||||
padding: 8px 14px;
|
||||
border-radius: var(--radius-pill);
|
||||
font-size: var(--text-sm);
|
||||
font-weight: var(--weight-medium);
|
||||
letter-spacing: var(--tracking-normal);
|
||||
transition:
|
||||
color var(--dur-fast) var(--ease-standard),
|
||||
background-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.tabs a:hover { color: var(--ink-100); }
|
||||
.tabs a:hover { color: var(--text-primary); }
|
||||
.tabs a:focus-visible { box-shadow: var(--focus-ring); }
|
||||
.tabs a.on {
|
||||
color: var(--cream);
|
||||
}
|
||||
.tabs a.on::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
bottom: -2px;
|
||||
height: 2px;
|
||||
background: var(--accent);
|
||||
box-shadow: var(--accent-glow);
|
||||
border-radius: 2px;
|
||||
color: var(--text-primary);
|
||||
background: var(--surface-raised);
|
||||
/* Shared-element transition — pill slides smoothly between tabs
|
||||
when navigating. Chromium only; falls back to instant swap. */
|
||||
view-transition-name: nav-active;
|
||||
}
|
||||
|
||||
.strut { margin-left: auto; }
|
||||
|
||||
main {
|
||||
padding: 40px 32px 64px;
|
||||
max-width: 1400px;
|
||||
padding: var(--space-10) var(--space-10) var(--space-24);
|
||||
max-width: 1440px;
|
||||
margin: 0 auto;
|
||||
view-transition-name: main;
|
||||
}
|
||||
|
||||
/* Mobile — collapse nav to a bottom-anchored, thumb-reachable bar.
|
||||
(Fully realized in Phase 8; this is the graceful base.) */
|
||||
@media (max-width: 720px) {
|
||||
nav {
|
||||
gap: var(--space-3);
|
||||
padding: 0 var(--space-4);
|
||||
overflow-x: auto;
|
||||
}
|
||||
.tabs { margin-left: var(--space-2); }
|
||||
main { padding: var(--space-6) var(--space-4) var(--space-16); }
|
||||
}
|
||||
|
||||
/* View-transition tuning — cross-fade routes, ease the shared nav pill. */
|
||||
:global(::view-transition-old(root)),
|
||||
:global(::view-transition-new(root)) {
|
||||
animation-duration: var(--dur-base);
|
||||
animation-timing-function: var(--ease-standard);
|
||||
}
|
||||
:global(::view-transition-old(main)),
|
||||
:global(::view-transition-new(main)) {
|
||||
animation-duration: var(--dur-base);
|
||||
animation-timing-function: var(--ease-standard);
|
||||
}
|
||||
</style>
|
||||
|
||||
+144
-54
@@ -1,9 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { fly } from 'svelte/transition';
|
||||
import { cubicOut } from 'svelte/easing';
|
||||
import ServerCard from '$ui/components/ServerCard.svelte';
|
||||
import DeployServerDialog from '$ui/components/DeployServerDialog.svelte';
|
||||
import { statusByServer } from '$ui/stores/servers.js';
|
||||
import { deployments } from '$ui/stores/pipeline.js';
|
||||
import type { RosterPlayer, Health } from '$ui/stores/servers.js';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import Stat from '$ui/components/primitives/Stat.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
|
||||
interface HeldRow { target: string; betaId: number; }
|
||||
interface ServerRow {
|
||||
@@ -40,7 +48,6 @@
|
||||
refresh();
|
||||
});
|
||||
|
||||
// Live server view — merge SSE data over the initial GET
|
||||
function liveFor(name: string, fallback: ServerRow) {
|
||||
const live = $statusByServer.get(name);
|
||||
if (!live) {
|
||||
@@ -72,27 +79,92 @@
|
||||
gameEndedAt: live.gameEndedAt
|
||||
};
|
||||
}
|
||||
|
||||
// Aggregate fleet metrics — pulled from the same SSE store cards use, so
|
||||
// the hero and grid stay perfectly consistent.
|
||||
let liveViews = $derived(servers.map((s) => liveFor(s.name, s)));
|
||||
let totalPlayers = $derived(
|
||||
liveViews.reduce((sum, v) => sum + (v.players ?? 0), 0)
|
||||
);
|
||||
let activeCount = $derived(
|
||||
liveViews.filter((v) => v.health === 'online').length
|
||||
);
|
||||
let totalCount = $derived(servers.length);
|
||||
let inFlightDeployments = $derived(
|
||||
Array.from($deployments.values()).filter((d) => {
|
||||
for (const s of d.servers.values()) if (s.state === 'pending') return true;
|
||||
return false;
|
||||
}).length
|
||||
);
|
||||
let activeRatio = $derived(totalCount > 0 ? activeCount / totalCount : 0);
|
||||
</script>
|
||||
|
||||
<section class="left">
|
||||
<header class="hdr">
|
||||
<div class="title-block">
|
||||
<h1>Fleet</h1>
|
||||
<span class="count">{servers.length} server{servers.length === 1 ? '' : 's'}</span>
|
||||
</div>
|
||||
<div class="hdr-actions">
|
||||
<button class="deploy" onclick={() => (deployOpen = true)}>Deploy new server</button>
|
||||
</div>
|
||||
</header>
|
||||
<section class="page">
|
||||
<!-- Fleet Overview — the first thing the eye lands on: three big numbers
|
||||
that tell the operator the state of the world in under half a second. -->
|
||||
<div class="hero">
|
||||
<Card padding="lg" elevation="flat">
|
||||
<div class="hero-grid">
|
||||
<div class="hero-cell">
|
||||
<Stat
|
||||
label="Players online"
|
||||
value={totalPlayers}
|
||||
size="xl"
|
||||
tone={totalPlayers > 0 ? 'online' : 'primary'}
|
||||
tween
|
||||
/>
|
||||
</div>
|
||||
<div class="hero-cell">
|
||||
<Stat
|
||||
label="Active servers"
|
||||
value={`${activeCount}/${totalCount}`}
|
||||
size="xl"
|
||||
tone="primary"
|
||||
tween={false}
|
||||
/>
|
||||
<div class="ratio-bar" aria-hidden="true">
|
||||
<div class="ratio-fill" style="width: {activeRatio * 100}%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-cell">
|
||||
<a class="deploy-link" href="/deployments">
|
||||
<Stat
|
||||
label="Deployments in flight"
|
||||
value={inFlightDeployments}
|
||||
size="xl"
|
||||
tone={inFlightDeployments > 0 ? 'accent' : 'primary'}
|
||||
tween
|
||||
/>
|
||||
<span class="link-hint">View →</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<SectionHeader
|
||||
title="Fleet"
|
||||
subtitle={totalCount === 1 ? '1 server' : `${totalCount} servers`}
|
||||
>
|
||||
{#snippet actions()}
|
||||
<Button variant="primary" size="md" onclick={() => (deployOpen = true)}>
|
||||
Deploy new server
|
||||
</Button>
|
||||
{/snippet}
|
||||
</SectionHeader>
|
||||
|
||||
<DeployServerDialog bind:open={deployOpen} />
|
||||
|
||||
{#if servers.length === 0}
|
||||
<p class="empty">no servers registered yet — check SERVERS_ROOT</p>
|
||||
<EmptyState
|
||||
title="No servers registered yet"
|
||||
description="Point SERVERS_ROOT at your fleet directory and refresh to hydrate the dashboard."
|
||||
/>
|
||||
{:else}
|
||||
<div class="cards">
|
||||
{#each servers as s (s.name)}
|
||||
{#each servers as s, i (s.name)}
|
||||
{@const live = liveFor(s.name, s)}
|
||||
<div in:fly={{ y: 12, duration: 320, delay: Math.min(i * 40, 320), easing: cubicOut }}>
|
||||
<ServerCard
|
||||
name={s.name}
|
||||
players={live.players}
|
||||
@@ -108,60 +180,78 @@
|
||||
gameStartedAt={live.gameStartedAt}
|
||||
gameEndedAt={live.gameEndedAt}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.hdr {
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-10);
|
||||
}
|
||||
|
||||
.hero-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: var(--space-8);
|
||||
}
|
||||
.hero-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ratio-bar {
|
||||
height: 3px;
|
||||
width: 100%;
|
||||
max-width: 220px;
|
||||
background: var(--surface-overlay);
|
||||
border-radius: var(--radius-pill);
|
||||
overflow: hidden;
|
||||
}
|
||||
.ratio-fill {
|
||||
height: 100%;
|
||||
background: var(--accent-primary);
|
||||
transition: width var(--dur-slow) var(--ease-standard);
|
||||
}
|
||||
|
||||
.deploy-link {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
align-items: flex-end;
|
||||
margin-bottom: 28px;
|
||||
padding-bottom: 18px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: var(--space-3);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
border-radius: var(--radius-md);
|
||||
transition: opacity var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.title-block { display: flex; align-items: baseline; gap: 18px; }
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-3xl);
|
||||
color: var(--cream);
|
||||
letter-spacing: var(--tracking-display);
|
||||
line-height: var(--leading-tight);
|
||||
}
|
||||
.count {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--ink-500);
|
||||
letter-spacing: 0.5px;
|
||||
.deploy-link:hover { opacity: 0.85; }
|
||||
.deploy-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
.link-hint {
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
letter-spacing: var(--tracking-wide);
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
gap: var(--gap-cards);
|
||||
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
|
||||
gap: var(--space-4);
|
||||
grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
|
||||
}
|
||||
.empty {
|
||||
color: var(--ink-500);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-base);
|
||||
padding: 48px;
|
||||
text-align: center;
|
||||
border: 1px dashed var(--border);
|
||||
border-radius: var(--r-md);
|
||||
.cards > div { display: flex; flex-direction: column; }
|
||||
.cards > div > :global(*) { flex: 1; }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.hero-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--space-5);
|
||||
}
|
||||
}
|
||||
.hdr-actions { display: flex; gap: 10px; }
|
||||
.deploy {
|
||||
background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
|
||||
border: 1px solid var(--blue-400);
|
||||
color: var(--cream);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 10px 18px;
|
||||
font-family: var(--font-body);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.15s;
|
||||
@media (max-width: 640px) {
|
||||
.cards { grid-template-columns: 1fr; }
|
||||
}
|
||||
.deploy:hover { box-shadow: var(--accent-glow); }
|
||||
</style>
|
||||
|
||||
+282
-255
@@ -1,6 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
import Field from '$ui/components/primitives/Field.svelte';
|
||||
|
||||
type ArtifactKind = 'script' | 'config' | 'plugin' | 'baseline';
|
||||
interface BetaListRow {
|
||||
@@ -11,62 +17,31 @@
|
||||
opened_at: string;
|
||||
closed_at: string | null;
|
||||
scripts: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
target_rel_path: string;
|
||||
kind: ArtifactKind;
|
||||
id: number; name: string; target_rel_path: string; kind: ArtifactKind;
|
||||
version: { id: number; version: number; sha256: string } | null;
|
||||
}>;
|
||||
servers: Array<{ server: string; stage: string; error: string | null }>;
|
||||
}
|
||||
|
||||
interface ScriptListRow {
|
||||
id: number;
|
||||
name: string;
|
||||
target_rel_path: string;
|
||||
scope_type: 'game' | 'map' | null;
|
||||
scope_value: string | null;
|
||||
current_version_id: number | null;
|
||||
kind: ArtifactKind;
|
||||
id: number; name: string; target_rel_path: string;
|
||||
scope_type: 'game' | 'map' | null; scope_value: string | null;
|
||||
current_version_id: number | null; kind: ArtifactKind;
|
||||
latestVersion: {
|
||||
id: number;
|
||||
version: number;
|
||||
sha256: string;
|
||||
id: number; version: number; sha256: string;
|
||||
state: 'untested' | 'tested' | 'test-failed';
|
||||
} | null;
|
||||
runningBetaId: number | null;
|
||||
}
|
||||
interface Version {
|
||||
id: number;
|
||||
version: number;
|
||||
sha256: string;
|
||||
size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed';
|
||||
}
|
||||
interface ServerRow { name: string; game: string | null; map: string | null }
|
||||
|
||||
interface ScriptDetail {
|
||||
script: ScriptListRow;
|
||||
versions: Version[];
|
||||
matchedServers: string[];
|
||||
}
|
||||
|
||||
// One row in the multi-script picker.
|
||||
interface Pick {
|
||||
key: number; // stable key for keyed each block
|
||||
scriptId: number | null;
|
||||
versionId: number | null;
|
||||
}
|
||||
interface Version { id: number; version: number; sha256: string; size: number; state: 'untested' | 'tested' | 'test-failed'; }
|
||||
interface ServerRow { name: string; game: string | null; map: string | null; }
|
||||
interface ScriptDetail { script: ScriptListRow; versions: Version[]; matchedServers: string[]; }
|
||||
interface Pick { key: number; scriptId: number | null; versionId: number | null; }
|
||||
|
||||
let betas = $state<BetaListRow[]>([]);
|
||||
let loading = $state(true);
|
||||
|
||||
let scripts = $state<ScriptListRow[]>([]);
|
||||
let fleetServers = $state<ServerRow[]>([]);
|
||||
// Cache script detail (versions + matched servers) per picked scriptId so
|
||||
// switching versions doesn't refetch.
|
||||
let detailById = $state<Record<number, ScriptDetail>>({});
|
||||
|
||||
let nextKey = 0;
|
||||
let picks = $state<Pick[]>([{ key: nextKey++, scriptId: null, versionId: null }]);
|
||||
let pickedServers = $state<Set<string>>(new Set());
|
||||
@@ -109,25 +84,15 @@
|
||||
if (poll) clearInterval(poll);
|
||||
});
|
||||
|
||||
// Scripts eligible for a new beta: has an unpromoted version and isn't in
|
||||
// a running beta already.
|
||||
const eligibleScripts = $derived(
|
||||
scripts.filter(
|
||||
(s) =>
|
||||
s.runningBetaId === null &&
|
||||
s.latestVersion !== null &&
|
||||
s.latestVersion.id !== s.current_version_id
|
||||
(s) => s.runningBetaId === null && s.latestVersion !== null && s.latestVersion.id !== s.current_version_id
|
||||
)
|
||||
);
|
||||
|
||||
// Scripts eligible for a specific picker row: eligible AND not already
|
||||
// chosen in a different row. Keeps the dropdown from letting you double-
|
||||
// add the same script.
|
||||
function eligibleForRow(rowIdx: number): ScriptListRow[] {
|
||||
const takenIds = new Set(
|
||||
picks
|
||||
.map((p, i) => (i === rowIdx ? null : p.scriptId))
|
||||
.filter((id): id is number => id !== null)
|
||||
picks.map((p, i) => (i === rowIdx ? null : p.scriptId)).filter((id): id is number => id !== null)
|
||||
);
|
||||
return eligibleScripts.filter((s) => !takenIds.has(s.id));
|
||||
}
|
||||
@@ -140,16 +105,14 @@
|
||||
if (pick.scriptId === null) return;
|
||||
if (!detailById[pick.scriptId]) {
|
||||
const res = await fetch(`/api/scripts/${pick.scriptId}`);
|
||||
if (!res.ok) { flash = 'failed to load script detail'; return; }
|
||||
if (!res.ok) { flash = 'Failed to load script detail'; return; }
|
||||
const body = (await res.json()) as ScriptDetail;
|
||||
detailById = { ...detailById, [pick.scriptId]: body };
|
||||
}
|
||||
// Default: latest non-current version.
|
||||
const detail = detailById[pick.scriptId];
|
||||
const eligibleVersions = detail.versions.filter((v) => v.id !== detail.script.current_version_id);
|
||||
pick.versionId = eligibleVersions[0]?.id ?? null;
|
||||
picks = [...picks];
|
||||
// Reset server selection to the recomputed candidate set.
|
||||
pickedServers = new Set(candidateServers);
|
||||
}
|
||||
|
||||
@@ -166,32 +129,23 @@
|
||||
else next.add(name);
|
||||
pickedServers = next;
|
||||
}
|
||||
|
||||
function versionsForRow(row: Pick): Version[] {
|
||||
if (row.scriptId === null) return [];
|
||||
const detail = detailById[row.scriptId];
|
||||
if (!detail) return [];
|
||||
return detail.versions.filter((v) => v.id !== detail.script.current_version_id);
|
||||
}
|
||||
|
||||
// Servers each pick would land on if promoted alone. Scoped scripts →
|
||||
// matched servers; unscoped scripts → whole fleet.
|
||||
function candidatesFor(row: Pick): string[] | null {
|
||||
if (row.scriptId === null) return null;
|
||||
const detail = detailById[row.scriptId];
|
||||
if (!detail) return null;
|
||||
return detail.script.scope_type
|
||||
? detail.matchedServers
|
||||
: fleetServers.map((s) => s.name);
|
||||
return detail.script.scope_type ? detail.matchedServers : fleetServers.map((s) => s.name);
|
||||
}
|
||||
|
||||
// Intersection of every picked script's candidate set. A beta with two
|
||||
// scripts must run on servers that are in-scope for BOTH.
|
||||
const candidateServers = $derived.by(() => {
|
||||
const perPick: string[][] = [];
|
||||
for (const p of picks) {
|
||||
const c = candidatesFor(p);
|
||||
if (c === null) continue; // row not yet picked — don't constrain
|
||||
if (c === null) continue;
|
||||
perPick.push(c);
|
||||
}
|
||||
if (perPick.length === 0) return [] as string[];
|
||||
@@ -199,8 +153,6 @@
|
||||
return first.filter((name) => rest.every((set) => set.includes(name)));
|
||||
});
|
||||
|
||||
// Ready to submit when every row has a script + version and at least one
|
||||
// server is picked from the intersection.
|
||||
const canSubmit = $derived(
|
||||
!openingBeta &&
|
||||
picks.length > 0 &&
|
||||
@@ -225,11 +177,7 @@
|
||||
waitForMatch
|
||||
})
|
||||
});
|
||||
const body = (await res.json()) as {
|
||||
ok: boolean;
|
||||
error?: string;
|
||||
result?: { betaId: number };
|
||||
};
|
||||
const body = (await res.json()) as { ok: boolean; error?: string; result?: { betaId: number } };
|
||||
if (!res.ok || !body.ok) {
|
||||
flash = body.error ?? `HTTP ${res.status}`;
|
||||
return;
|
||||
@@ -255,214 +203,293 @@
|
||||
for (const s of b.scripts) byKind[s.kind] = (byKind[s.kind] ?? 0) + 1;
|
||||
return Object.entries(byKind).map(([k, n]) => `${n} ${k}${n === 1 ? '' : 's'}`).join(', ');
|
||||
}
|
||||
function betaStateVariant(s: string): 'online' | 'warning' | 'info' | 'neutral' {
|
||||
return s === 'ready-promote' ? 'online' :
|
||||
s === 'running' ? 'warning' :
|
||||
s === 'promoted' ? 'info' :
|
||||
'neutral';
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1>Betas</h1>
|
||||
<div class="page">
|
||||
<SectionHeader
|
||||
title="Betas"
|
||||
subtitle="Test unpromoted versions on selected servers before rolling them out."
|
||||
/>
|
||||
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
{:else}
|
||||
<section class="panel">
|
||||
<h2>Open a beta</h2>
|
||||
{#if eligibleScripts.length === 0}
|
||||
<p class="empty">no artifacts with untested versions — upload a new version from a scripts / configs / plugins page</p>
|
||||
{:else}
|
||||
<form onsubmit={openNewBeta} class="new-beta-form">
|
||||
<div class="picks">
|
||||
{#each picks as row, idx (row.key)}
|
||||
<div class="pick-row">
|
||||
<select
|
||||
bind:value={row.scriptId}
|
||||
onchange={() => onPickScript(idx)}
|
||||
>
|
||||
<option value={null}>— pick an artifact —</option>
|
||||
{#each eligibleForRow(idx) as s (s.id)}
|
||||
<option value={s.id}>[{s.kind}] {s.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<select bind:value={row.versionId} disabled={row.scriptId === null}>
|
||||
{#if row.scriptId === null}
|
||||
<option value={null}>—</option>
|
||||
{:else}
|
||||
{#each versionsForRow(row) as v (v.id)}
|
||||
<option value={v.id}>v{v.version} · {v.sha256.slice(0, 8)} · {v.state}</option>
|
||||
{/each}
|
||||
{/if}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="row-x"
|
||||
onclick={() => removeRow(idx)}
|
||||
disabled={picks.length === 1}
|
||||
title={picks.length === 1 ? 'need at least one script' : 'remove this script'}
|
||||
>×</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<button type="button" class="add-row" onclick={addRow}>+ add artifact</button>
|
||||
|
||||
<label>
|
||||
<span class="k">test servers</span>
|
||||
<div class="server-picker">
|
||||
{#if candidateServers.length === 0}
|
||||
<span class="empty">no server satisfies all selected scopes — pick different scripts</span>
|
||||
{:else}
|
||||
{#each candidateServers as name (name)}
|
||||
<label class="chk">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={pickedServers.has(name)}
|
||||
onchange={() => toggleServer(name)}
|
||||
/>
|
||||
{name}
|
||||
</label>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<div class="opts">
|
||||
<label class="chk">
|
||||
<input type="checkbox" bind:checked={waitForHealth} />
|
||||
wait for server start healthy
|
||||
</label>
|
||||
<label class="chk">
|
||||
<input type="checkbox" bind:checked={waitForMatch} />
|
||||
wait for server match
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="primary" disabled={!canSubmit}>
|
||||
{openingBeta ? 'opening…' : 'open beta'}
|
||||
</button>
|
||||
</form>
|
||||
{#if flash}<p class="flash">{flash}</p>{/if}
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
{#if betas.length === 0}
|
||||
<p class="empty">no betas yet — open one above</p>
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else}
|
||||
{#each grouped as g (g.state)}
|
||||
{#if g.rows.length > 0}
|
||||
<section class="panel">
|
||||
<h2>{g.state.replace('-', ' ')} · {g.rows.length}</h2>
|
||||
<div class="rows">
|
||||
{#each g.rows as b (b.id)}
|
||||
<a class="row" href="/betas/{b.id}">
|
||||
<span class="id">#{b.id}</span>
|
||||
<span class="script">{summarizeScripts(b)}</span>
|
||||
<span class="tag state-{b.state}">{b.state}</span>
|
||||
<span class="servers mono">{b.servers.length} server{b.servers.length === 1 ? '' : 's'}</span>
|
||||
</a>
|
||||
{/each}
|
||||
<Card padding="lg">
|
||||
<h2 class="panel-title">Open a beta</h2>
|
||||
|
||||
{#if eligibleScripts.length === 0}
|
||||
<EmptyState
|
||||
title="No artifacts with untested versions"
|
||||
description="Upload a new version from scripts / configs / plugins to open a beta."
|
||||
/>
|
||||
{:else}
|
||||
<form onsubmit={openNewBeta} class="beta-form">
|
||||
<Field label="Artifacts">
|
||||
<div class="picks">
|
||||
{#each picks as row, idx (row.key)}
|
||||
<div class="pick-row">
|
||||
<div class="pick-select">
|
||||
<select
|
||||
class="native-select"
|
||||
bind:value={row.scriptId}
|
||||
onchange={() => onPickScript(idx)}
|
||||
>
|
||||
<option value={null}>— Pick an artifact —</option>
|
||||
{#each eligibleForRow(idx) as s (s.id)}
|
||||
<option value={s.id}>[{s.kind}] {s.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<span class="chev">▾</span>
|
||||
</div>
|
||||
<div class="pick-select">
|
||||
<select
|
||||
class="native-select"
|
||||
bind:value={row.versionId}
|
||||
disabled={row.scriptId === null}
|
||||
>
|
||||
{#if row.scriptId === null}
|
||||
<option value={null}>—</option>
|
||||
{:else}
|
||||
{#each versionsForRow(row) as v (v.id)}
|
||||
<option value={v.id}>v{v.version} · {v.sha256.slice(0, 8)} · {v.state}</option>
|
||||
{/each}
|
||||
{/if}
|
||||
</select>
|
||||
<span class="chev">▾</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="row-x"
|
||||
onclick={() => removeRow(idx)}
|
||||
disabled={picks.length === 1}
|
||||
title={picks.length === 1 ? 'Need at least one script' : 'Remove this script'}
|
||||
aria-label="Remove artifact"
|
||||
>×</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<button type="button" class="add-row" onclick={addRow}>+ Add artifact</button>
|
||||
</Field>
|
||||
|
||||
<Field label="Test servers" hint="Intersection of scopes across all picked artifacts.">
|
||||
<div class="server-picker">
|
||||
{#if candidateServers.length === 0}
|
||||
<span class="picker-empty">No server satisfies all selected scopes — pick different scripts.</span>
|
||||
{:else}
|
||||
{#each candidateServers as name (name)}
|
||||
<label class="chk">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={pickedServers.has(name)}
|
||||
onchange={() => toggleServer(name)}
|
||||
/>
|
||||
<span>{name}</span>
|
||||
</label>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</Field>
|
||||
|
||||
<Field label="Options">
|
||||
<div class="opts">
|
||||
<label class="chk">
|
||||
<input type="checkbox" bind:checked={waitForHealth} />
|
||||
<span>Wait for server start healthy</span>
|
||||
</label>
|
||||
<label class="chk">
|
||||
<input type="checkbox" bind:checked={waitForMatch} />
|
||||
<span>Wait for server match</span>
|
||||
</label>
|
||||
</div>
|
||||
</Field>
|
||||
|
||||
<div class="form-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={!canSubmit}
|
||||
loading={openingBeta}
|
||||
>
|
||||
Open beta
|
||||
</Button>
|
||||
{#if flash}<span class="flash">{flash}</span>{/if}
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
{/if}
|
||||
{/each}
|
||||
</Card>
|
||||
|
||||
{#if betas.length === 0}
|
||||
<EmptyState title="No betas yet" description="Open one above once you have unpromoted versions." />
|
||||
{:else}
|
||||
{#each grouped as g (g.state)}
|
||||
{#if g.rows.length > 0}
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2 class="capitalize">{g.state.replace('-', ' ')}</h2>
|
||||
<Badge variant="neutral" size="sm">{g.rows.length}</Badge>
|
||||
</div>
|
||||
<div class="beta-rows">
|
||||
{#each g.rows as b (b.id)}
|
||||
<a class="beta-row" href="/betas/{b.id}">
|
||||
<span class="beta-id">#{b.id}</span>
|
||||
<span class="beta-script">{summarizeScripts(b)}</span>
|
||||
<Badge variant={betaStateVariant(b.state)} size="sm" uppercase>{b.state}</Badge>
|
||||
<span class="beta-servers">{b.servers.length} server{b.servers.length === 1 ? '' : 's'}</span>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
h1 { color: var(--cream); font-family: var(--font-display); font-size: var(--text-3xl); letter-spacing: var(--tracking-display); margin: 0 0 28px; }
|
||||
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-base); margin: 0; }
|
||||
.panel { background: var(--bg-nav); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--pad-panel); margin-bottom: 20px; }
|
||||
h2 { margin: 0 0 14px; font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-300); }
|
||||
.page { display: flex; flex-direction: column; gap: var(--space-6); }
|
||||
.loading { text-align: center; padding: var(--space-12); color: var(--text-tertiary); }
|
||||
|
||||
.new-beta-form { display: flex; flex-direction: column; gap: 14px; }
|
||||
.new-beta-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); }
|
||||
.new-beta-form .k { color: var(--ink-500); text-transform: uppercase; letter-spacing: 1px; }
|
||||
|
||||
.picks { display: flex; flex-direction: column; gap: 8px; }
|
||||
.pick-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; }
|
||||
.pick-row select {
|
||||
background: var(--bg-page);
|
||||
color: var(--ink-100);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 10px 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-mono);
|
||||
}
|
||||
.row-x {
|
||||
background: var(--bg-card);
|
||||
color: var(--ink-500);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 0 14px;
|
||||
.panel-title {
|
||||
margin: 0 0 var(--space-4);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
cursor: pointer;
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.row-x:hover:not(:disabled) { color: var(--danger-500); border-color: rgba(255, 48, 80, 0.4); }
|
||||
.row-x:disabled { opacity: 0.4; cursor: default; }
|
||||
.add-row {
|
||||
align-self: flex-start;
|
||||
background: transparent;
|
||||
color: var(--ink-300);
|
||||
border: 1px dashed var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 8px 14px;
|
||||
|
||||
.beta-form { display: flex; flex-direction: column; gap: var(--space-5); }
|
||||
|
||||
.picks { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.pick-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr auto;
|
||||
gap: var(--space-2);
|
||||
align-items: center;
|
||||
}
|
||||
.pick-select { position: relative; }
|
||||
.native-select {
|
||||
appearance: none;
|
||||
width: 100%;
|
||||
padding: 9px 32px 9px 12px;
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
transition: border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.add-row:hover { color: var(--cream); border-color: var(--accent); }
|
||||
.native-select:hover { border-color: var(--border-strong); }
|
||||
.native-select:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(46, 134, 209, 0.15); }
|
||||
.native-select:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.chev {
|
||||
position: absolute;
|
||||
right: var(--space-3);
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--text-tertiary);
|
||||
pointer-events: none;
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
.row-x {
|
||||
background: transparent;
|
||||
color: var(--text-tertiary);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 0 14px;
|
||||
height: 38px;
|
||||
font-size: var(--text-lg);
|
||||
cursor: pointer;
|
||||
transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.row-x:hover:not(:disabled) { color: var(--state-danger); border-color: rgba(255, 86, 112, 0.4); }
|
||||
.row-x:disabled { opacity: 0.3; cursor: default; }
|
||||
|
||||
.add-row {
|
||||
align-self: flex-start;
|
||||
background: transparent;
|
||||
color: var(--text-secondary);
|
||||
border: 1px dashed var(--border-strong);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 8px 14px;
|
||||
margin-top: var(--space-2);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.add-row:hover { color: var(--text-primary); border-color: var(--accent-primary); }
|
||||
|
||||
.server-picker {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding: 12px;
|
||||
background: var(--bg-page);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3);
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.picker-empty {
|
||||
color: var(--text-tertiary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
.chk {
|
||||
color: var(--ink-100);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-mono);
|
||||
display: flex;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.opts { display: flex; gap: 24px; }
|
||||
.primary {
|
||||
background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
|
||||
border: 1px solid var(--blue-400);
|
||||
color: var(--cream);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 12px 20px;
|
||||
gap: var(--space-2);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-body);
|
||||
font-weight: 600;
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
align-self: flex-start;
|
||||
user-select: none;
|
||||
}
|
||||
.primary:disabled { opacity: 0.4; cursor: default; }
|
||||
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin: 12px 0 0; }
|
||||
.chk input { accent-color: var(--accent-primary); cursor: pointer; }
|
||||
|
||||
.rows { display: flex; flex-direction: column; gap: 6px; }
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 60px 1fr 130px 120px;
|
||||
gap: 14px;
|
||||
padding: 12px 16px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
color: var(--ink-100);
|
||||
text-decoration: none;
|
||||
font-size: var(--text-mono);
|
||||
align-items: center;
|
||||
.opts { display: flex; flex-wrap: wrap; gap: var(--space-6); }
|
||||
|
||||
.form-actions { display: flex; align-items: center; gap: var(--space-4); }
|
||||
.flash { color: var(--state-danger); font-family: var(--font-mono); font-size: var(--text-xs); }
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.section-head { display: flex; align-items: center; gap: var(--space-3); }
|
||||
.section-head h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.capitalize { text-transform: capitalize; }
|
||||
|
||||
.beta-rows { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.beta-row {
|
||||
display: grid;
|
||||
grid-template-columns: 56px 1fr auto auto;
|
||||
gap: var(--space-4);
|
||||
align-items: center;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
text-decoration: none;
|
||||
color: var(--text-primary);
|
||||
transition: background-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.beta-row:hover { background: var(--surface-raised); }
|
||||
.beta-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
.beta-id { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-tertiary); }
|
||||
.beta-script { font-size: var(--text-sm); color: var(--text-primary); font-weight: var(--weight-medium); }
|
||||
.beta-servers { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-tertiary); }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.beta-row { grid-template-columns: 1fr; gap: var(--space-2); }
|
||||
}
|
||||
.row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
.id { color: var(--ink-500); font-family: var(--font-mono); }
|
||||
.script { color: var(--cream); font-weight: 600; font-family: var(--font-body); }
|
||||
.servers { color: var(--ink-500); }
|
||||
.tag { padding: 3px 10px; border-radius: var(--r-sm); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 1px; border: 1px solid transparent; text-align: center; }
|
||||
.state-running { background: rgba(255, 176, 32, 0.15); border-color: rgba(255, 176, 32, 0.4); color: var(--amber-500); }
|
||||
.state-ready-promote { background: rgba(124, 212, 255, 0.15); border-color: rgba(124, 212, 255, 0.4); color: var(--spark-500); }
|
||||
.state-promoted { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.28); color: var(--cream); }
|
||||
.state-rolled-back { background: var(--bg-nav); border-color: var(--border); color: var(--ink-500); }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
</style>
|
||||
|
||||
+262
-174
@@ -1,37 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import Breadcrumbs from '$ui/components/primitives/Breadcrumbs.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
|
||||
interface BetaRow {
|
||||
id: number;
|
||||
script_id: number;
|
||||
script_version_id: number;
|
||||
trigger_kind: string;
|
||||
wait_for_health: number;
|
||||
wait_for_match: number;
|
||||
id: number; script_id: number; script_version_id: number;
|
||||
trigger_kind: string; wait_for_health: number; wait_for_match: number;
|
||||
state: 'running' | 'ready-promote' | 'promoted' | 'rolled-back';
|
||||
opened_at: string;
|
||||
closed_at: string | null;
|
||||
notes: string | null;
|
||||
opened_at: string; closed_at: string | null; notes: string | null;
|
||||
}
|
||||
interface BetaServerRow {
|
||||
beta_id: number;
|
||||
server: string;
|
||||
had_original: number;
|
||||
prior_version_id: number | null;
|
||||
stage: string;
|
||||
error: string | null;
|
||||
deployed_at: string | null;
|
||||
restarted_at: string | null;
|
||||
healthy_at: string | null;
|
||||
match_seen_at: string | null;
|
||||
beta_id: number; server: string;
|
||||
had_original: number; prior_version_id: number | null;
|
||||
stage: string; error: string | null;
|
||||
deployed_at: string | null; restarted_at: string | null;
|
||||
healthy_at: string | null; match_seen_at: string | null;
|
||||
updated_at: string;
|
||||
}
|
||||
interface BetaScript {
|
||||
id: number;
|
||||
name: string;
|
||||
target_rel_path: string;
|
||||
id: number; name: string; target_rel_path: string;
|
||||
kind: 'script' | 'config' | 'plugin' | 'baseline';
|
||||
version: { id: number; version: number; sha256: string } | null;
|
||||
}
|
||||
@@ -48,11 +40,7 @@
|
||||
async function load(): Promise<void> {
|
||||
const res = await fetch(`/api/betas/${id}`);
|
||||
if (!res.ok) { loading = false; return; }
|
||||
const body = (await res.json()) as {
|
||||
beta: BetaRow;
|
||||
scripts: BetaScript[];
|
||||
servers: BetaServerRow[];
|
||||
};
|
||||
const body = (await res.json()) as { beta: BetaRow; scripts: BetaScript[]; servers: BetaServerRow[]; };
|
||||
beta = body.beta;
|
||||
scripts = body.scripts;
|
||||
servers = body.servers;
|
||||
@@ -67,12 +55,11 @@
|
||||
onDestroy(() => { if (poll) clearInterval(poll); });
|
||||
|
||||
async function promote(): Promise<void> {
|
||||
acting = 'promote';
|
||||
flash = null;
|
||||
acting = 'promote'; flash = null;
|
||||
try {
|
||||
const res = await fetch(`/api/betas/${id}/promote`, { method: 'POST' });
|
||||
const body = (await res.json()) as { ok: boolean; error?: string };
|
||||
if (!body.ok) { flash = body.error ?? 'promote failed'; return; }
|
||||
if (!body.ok) { flash = body.error ?? 'Promote failed'; return; }
|
||||
await load();
|
||||
} finally { acting = null; }
|
||||
}
|
||||
@@ -82,18 +69,16 @@
|
||||
? `Reject beta #${id}? This restores original files on every beta server and marks the version as test-failed.`
|
||||
: `Rollback beta #${id}? This restores original files on every beta server.`;
|
||||
if (!confirm(prompt)) return;
|
||||
acting = 'rollback';
|
||||
flash = null;
|
||||
acting = 'rollback'; flash = null;
|
||||
try {
|
||||
const res = await fetch(`/api/betas/${id}/rollback`, { method: 'POST' });
|
||||
const body = (await res.json()) as { ok: boolean; error?: string };
|
||||
if (!body.ok) { flash = body.error ?? 'rollback failed'; return; }
|
||||
if (!body.ok) { flash = body.error ?? 'Rollback failed'; return; }
|
||||
await load();
|
||||
} finally { acting = null; }
|
||||
}
|
||||
async function retry(server: string): Promise<void> {
|
||||
acting = `retry:${server}`;
|
||||
flash = null;
|
||||
acting = `retry:${server}`; flash = null;
|
||||
try {
|
||||
const res = await fetch(`/api/betas/${id}/retry`, {
|
||||
method: 'POST',
|
||||
@@ -101,168 +86,271 @@
|
||||
body: JSON.stringify({ server })
|
||||
});
|
||||
const body = (await res.json()) as { ok: boolean; error?: string };
|
||||
if (!body.ok) { flash = body.error ?? 'retry failed'; return; }
|
||||
if (!body.ok) { flash = body.error ?? 'Retry failed'; return; }
|
||||
await load();
|
||||
} finally { acting = null; }
|
||||
}
|
||||
|
||||
function betaStateVariant(s: string): 'online' | 'warning' | 'info' | 'neutral' {
|
||||
return s === 'ready-promote' ? 'online' :
|
||||
s === 'running' ? 'warning' :
|
||||
s === 'promoted' ? 'info' :
|
||||
'neutral';
|
||||
}
|
||||
function stageVariant(s: string): 'online' | 'warning' | 'danger' | 'neutral' {
|
||||
return s === 'ready' ? 'online' :
|
||||
s === 'failed' ? 'danger' :
|
||||
s === 'awaiting-empty' || s === 'restarting' || s === 'awaiting-health' || s === 'awaiting-match' || s === 'deploying'
|
||||
? 'warning' :
|
||||
'neutral';
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
<div class="loading">Loading…</div>
|
||||
{:else if !beta}
|
||||
<p class="empty">beta not found</p>
|
||||
<EmptyState title="Beta not found" description="This beta may have been archived." />
|
||||
{:else}
|
||||
<a class="back" href="/betas">← all betas</a>
|
||||
<div class="head-row">
|
||||
<h1>Beta #{beta.id}</h1>
|
||||
<span class="tag state-{beta.state}">{beta.state}</span>
|
||||
</div>
|
||||
{@const b = beta}
|
||||
<div class="page">
|
||||
<SectionHeader title="Beta #{b.id}">
|
||||
{#snippet crumbs()}
|
||||
<Breadcrumbs items={[{ label: 'Betas', href: '/betas' }, { label: `#${b.id}` }]} />
|
||||
{/snippet}
|
||||
{#snippet actions()}
|
||||
<Badge variant={betaStateVariant(b.state)} size="md" uppercase>{b.state}</Badge>
|
||||
{/snippet}
|
||||
</SectionHeader>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Artifacts · {scripts.length}</h2>
|
||||
{#if scripts.length === 0}
|
||||
<p class="empty">no artifacts bundled in this beta</p>
|
||||
{:else}
|
||||
<div class="script-list">
|
||||
{#each scripts as s (s.id)}
|
||||
<div class="script-row">
|
||||
<span class="s-kind mono">[{s.kind}]</span>
|
||||
<a class="s-name" href="/scripts/{s.id}">{s.name}</a>
|
||||
<span class="s-target mono">{s.target_rel_path}</span>
|
||||
<span class="s-ver mono">v{s.version?.version ?? '?'}</span>
|
||||
<span class="s-sha mono">{s.version?.sha256.slice(0, 8) ?? ''}</span>
|
||||
<!-- Artifacts -->
|
||||
<Card padding="lg">
|
||||
<div class="panel-head">
|
||||
<h2>Artifacts</h2>
|
||||
<Badge variant="neutral" size="sm">{scripts.length}</Badge>
|
||||
</div>
|
||||
{#if scripts.length === 0}
|
||||
<EmptyState title="No artifacts bundled" description="This beta has no scripts, configs, or plugins." />
|
||||
{:else}
|
||||
<div class="script-list">
|
||||
{#each scripts as s (s.id)}
|
||||
<div class="script-row">
|
||||
<Badge variant="neutral" size="sm" uppercase>{s.kind}</Badge>
|
||||
<a class="s-name" href="/scripts/{s.id}">{s.name}</a>
|
||||
<span class="s-target">{s.target_rel_path}</span>
|
||||
<span class="s-ver">v{s.version?.version ?? '?'}</span>
|
||||
<span class="s-sha">{s.version?.sha256.slice(0, 8) ?? ''}</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</Card>
|
||||
|
||||
<!-- Options -->
|
||||
<Card padding="lg">
|
||||
<div class="panel-head"><h2>Options</h2></div>
|
||||
<div class="opts">
|
||||
<div class="opt">
|
||||
<span class="opt-k">Wait for health</span>
|
||||
<span class="opt-v">{b.wait_for_health ? 'Yes' : 'No'}</span>
|
||||
</div>
|
||||
<div class="opt">
|
||||
<span class="opt-k">Wait for match</span>
|
||||
<span class="opt-v">{b.wait_for_match ? 'Yes' : 'No'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<!-- Server progress -->
|
||||
<Card padding="lg">
|
||||
<div class="panel-head">
|
||||
<h2>Server progress</h2>
|
||||
<Badge variant="neutral" size="sm">{servers.length}</Badge>
|
||||
</div>
|
||||
<div class="srv-list">
|
||||
{#each servers as bs (bs.server)}
|
||||
<div class="srv-row">
|
||||
<a class="srv-name" href="/servers/{bs.server}">{bs.server}</a>
|
||||
<Badge variant={stageVariant(bs.stage)} size="sm" uppercase>{bs.stage}</Badge>
|
||||
<div class="ticks" aria-label="pipeline progress">
|
||||
<span class:on={bs.deployed_at}>Deploy</span>
|
||||
<span class:on={bs.stage !== 'awaiting-empty' && bs.stage !== 'deploying'}>Empty</span>
|
||||
<span class:on={bs.restarted_at}>Restart</span>
|
||||
<span class:on={bs.healthy_at}>Healthy</span>
|
||||
{#if b.wait_for_match}
|
||||
<span class:on={bs.match_seen_at}>Match</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if bs.error}
|
||||
<span class="err">{bs.error}</span>
|
||||
{/if}
|
||||
{#if bs.stage === 'failed'}
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
onclick={() => retry(bs.server)}
|
||||
disabled={acting === `retry:${bs.server}`}
|
||||
loading={acting === `retry:${bs.server}`}
|
||||
>
|
||||
Retry
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
</Card>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Options</h2>
|
||||
<div class="opts mono">
|
||||
<span>wait for health: <strong>{beta.wait_for_health ? 'yes' : 'no'}</strong></span>
|
||||
<span>wait for match: <strong>{beta.wait_for_match ? 'yes' : 'no'}</strong></span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Server progress</h2>
|
||||
<div class="rows">
|
||||
{#each servers as bs (bs.server)}
|
||||
<div class="srv-row srv-{bs.stage}">
|
||||
<span class="srv-name mono">{bs.server}</span>
|
||||
<span class="tag stage-{bs.stage}">{bs.stage}</span>
|
||||
<div class="ticks mono">
|
||||
<span class:on={bs.deployed_at}>deploy</span>
|
||||
<span class:on={bs.stage !== 'awaiting-empty' && bs.stage !== 'deploying'}>empty</span>
|
||||
<span class:on={bs.restarted_at}>restart</span>
|
||||
<span class:on={bs.healthy_at}>healthy</span>
|
||||
{#if beta.wait_for_match}
|
||||
<span class:on={bs.match_seen_at}>match</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if bs.error}
|
||||
<span class="err mono">{bs.error}</span>
|
||||
{/if}
|
||||
{#if bs.stage === 'failed'}
|
||||
<button class="mini" onclick={() => retry(bs.server)} disabled={acting === `retry:${bs.server}`}>
|
||||
{acting === `retry:${bs.server}` ? 'retrying…' : 'retry'}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Actions</h2>
|
||||
<div class="action-row">
|
||||
<button
|
||||
class="primary"
|
||||
onclick={promote}
|
||||
disabled={beta.state !== 'ready-promote' || acting !== null}
|
||||
title={beta.state !== 'ready-promote' ? 'all servers must reach ready first' : ''}
|
||||
>
|
||||
{acting === 'promote' ? 'promoting…' : 'promote'}
|
||||
</button>
|
||||
<button
|
||||
class="danger"
|
||||
onclick={rollback}
|
||||
disabled={beta.state === 'promoted' || beta.state === 'rolled-back' || acting !== null}
|
||||
>
|
||||
{#if acting === 'rollback'}
|
||||
{beta.state === 'ready-promote' ? 'rejecting…' : 'rolling back…'}
|
||||
{:else if beta.state === 'ready-promote'}
|
||||
reject
|
||||
{:else}
|
||||
rollback
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{#if flash}<p class="flash">{flash}</p>{/if}
|
||||
<!-- Actions -->
|
||||
<Card padding="lg">
|
||||
<div class="panel-head"><h2>Actions</h2></div>
|
||||
<div class="action-row">
|
||||
<Button
|
||||
variant="primary"
|
||||
onclick={promote}
|
||||
disabled={b.state !== 'ready-promote' || acting !== null}
|
||||
loading={acting === 'promote'}
|
||||
title={b.state !== 'ready-promote' ? 'All servers must reach ready first' : ''}
|
||||
>
|
||||
Promote
|
||||
</Button>
|
||||
<Button
|
||||
variant="danger"
|
||||
onclick={rollback}
|
||||
disabled={b.state === 'promoted' || b.state === 'rolled-back' || acting !== null}
|
||||
loading={acting === 'rollback'}
|
||||
>
|
||||
{b.state === 'ready-promote' ? 'Reject' : 'Rollback'}
|
||||
</Button>
|
||||
</div>
|
||||
{#if flash}<div class="flash">{flash}</div>{/if}
|
||||
</Card>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.back { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono-sm); text-decoration: none; }
|
||||
.back:hover { color: var(--ink-100); }
|
||||
.head-row { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; }
|
||||
h1 { color: var(--cream); font-family: var(--font-display); font-size: var(--text-2xl); letter-spacing: 1.5px; margin: 0; }
|
||||
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono); }
|
||||
.page { display: flex; flex-direction: column; gap: var(--space-6); }
|
||||
.loading { text-align: center; padding: var(--space-16); color: var(--text-tertiary); }
|
||||
|
||||
.script-list { display: flex; flex-direction: column; gap: 6px; }
|
||||
.panel-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
.panel-head h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Artifacts */
|
||||
.script-list { display: flex; flex-direction: column; gap: var(--space-1); }
|
||||
.script-row {
|
||||
display: grid;
|
||||
grid-template-columns: 220px 1fr 80px 100px;
|
||||
gap: 14px;
|
||||
padding: 10px 14px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
grid-template-columns: auto minmax(160px, 220px) 1fr 80px 100px;
|
||||
gap: var(--space-3);
|
||||
align-items: center;
|
||||
font-size: var(--text-mono);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
.s-name { color: var(--spark-500); text-decoration: none; font-weight: 600; font-family: var(--font-body); }
|
||||
.s-name:hover { text-decoration: underline; }
|
||||
.s-target { color: var(--ink-300); word-break: break-all; }
|
||||
.s-ver, .s-sha { color: var(--ink-500); }
|
||||
.s-name { color: var(--text-primary); text-decoration: none; font-weight: var(--weight-semibold); }
|
||||
.s-name:hover { color: var(--accent-primary-hover); text-decoration: underline; }
|
||||
.s-target { color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-xs); word-break: break-all; }
|
||||
.s-ver, .s-sha { color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--text-xs); }
|
||||
|
||||
.panel { background: var(--bg-nav); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--pad-panel); margin-bottom: 20px; }
|
||||
h2 { margin: 0 0 14px; font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-300); }
|
||||
/* Options */
|
||||
.opts { display: flex; gap: var(--space-6); flex-wrap: wrap; }
|
||||
.opt {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
min-width: 200px;
|
||||
}
|
||||
.opt-k {
|
||||
font-size: var(--text-xs);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: var(--tracking-label);
|
||||
color: var(--text-tertiary);
|
||||
font-weight: var(--weight-semibold);
|
||||
}
|
||||
.opt-v { font-size: var(--text-md); color: var(--text-primary); font-weight: var(--weight-semibold); }
|
||||
|
||||
.tag { padding: 3px 10px; border-radius: var(--r-sm); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 1px; border: 1px solid transparent; }
|
||||
.state-running { background: rgba(255, 176, 32, 0.15); border-color: rgba(255, 176, 32, 0.4); color: var(--amber-500); }
|
||||
.state-ready-promote { background: rgba(124, 212, 255, 0.15); border-color: rgba(124, 212, 255, 0.4); color: var(--spark-500); }
|
||||
.state-promoted { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.28); color: var(--cream); }
|
||||
.state-rolled-back { background: var(--bg-card); border-color: var(--border); color: var(--ink-500); }
|
||||
/* Server progress */
|
||||
.srv-list { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.srv-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(160px, 220px) auto 1fr auto auto;
|
||||
gap: var(--space-3);
|
||||
align-items: center;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.srv-name { color: var(--text-primary); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium); }
|
||||
.srv-name:hover { color: var(--accent-primary-hover); }
|
||||
|
||||
.opts { display: flex; flex-direction: column; gap: 6px; color: var(--ink-100); font-size: var(--text-mono); }
|
||||
.opts strong { color: var(--cream); }
|
||||
|
||||
.rows { display: flex; flex-direction: column; gap: 8px; }
|
||||
.srv-row { display: grid; grid-template-columns: 220px 130px 1fr auto auto; gap: 14px; padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-sm); align-items: center; }
|
||||
.srv-ready { border-left: 3px solid var(--spark-500); }
|
||||
.srv-failed { border-left: 3px solid var(--danger-500); }
|
||||
.srv-awaiting-empty, .srv-restarting, .srv-awaiting-health, .srv-awaiting-match, .srv-deploying { border-left: 3px solid var(--amber-500); }
|
||||
|
||||
.srv-name { color: var(--cream); font-size: var(--text-md); }
|
||||
.stage-deploying, .stage-awaiting-empty, .stage-restarting, .stage-awaiting-health, .stage-awaiting-match { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.3); color: var(--amber-500); }
|
||||
.stage-ready { background: rgba(124, 212, 255, 0.15); border-color: rgba(124, 212, 255, 0.4); color: var(--spark-500); }
|
||||
.stage-failed { background: rgba(255, 48, 80, 0.15); border-color: rgba(255, 48, 80, 0.4); color: var(--danger-500); }
|
||||
.ticks { display: flex; gap: 14px; font-size: var(--text-mono-sm); color: var(--ink-500); }
|
||||
/* Pipeline ticks */
|
||||
.ticks {
|
||||
display: flex;
|
||||
gap: var(--space-4);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
.ticks span { position: relative; padding-left: 14px; }
|
||||
.ticks span::before { content: '○'; position: absolute; left: 0; color: var(--ink-500); }
|
||||
.ticks span.on { color: var(--cream); }
|
||||
.ticks span.on::before { content: '●'; color: var(--spark-500); }
|
||||
.err { color: var(--danger-500); font-size: var(--text-mono-sm); word-break: break-word; }
|
||||
.mini { background: var(--bg-nav); color: var(--cream); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px 12px; font-family: var(--font-body); font-size: var(--text-xs); cursor: pointer; }
|
||||
.ticks span::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid var(--text-quaternary);
|
||||
background: transparent;
|
||||
transition: background-color var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard);
|
||||
}
|
||||
.ticks span.on { color: var(--text-primary); }
|
||||
.ticks span.on::before {
|
||||
background: var(--state-online);
|
||||
border-color: var(--state-online);
|
||||
box-shadow: 0 0 5px rgba(124, 212, 255, 0.45);
|
||||
}
|
||||
.err {
|
||||
color: var(--state-danger);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.action-row { display: flex; gap: 12px; }
|
||||
.primary { background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); border: 1px solid var(--blue-400); color: var(--cream); border-radius: var(--r-sm); padding: 12px 20px; font-family: var(--font-body); font-weight: 600; cursor: pointer; }
|
||||
.primary:disabled { opacity: 0.4; cursor: default; }
|
||||
.danger { background: var(--bg-nav); border: 1px solid rgba(255, 48, 80, 0.4); color: var(--danger-500); border-radius: var(--r-sm); padding: 12px 20px; font-family: var(--font-body); cursor: pointer; }
|
||||
.danger:disabled { opacity: 0.4; cursor: default; }
|
||||
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
/* Actions */
|
||||
.action-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
|
||||
.flash {
|
||||
margin-top: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: rgba(255, 86, 112, 0.06);
|
||||
border: 1px solid rgba(255, 86, 112, 0.28);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--state-danger);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.script-row, .srv-row {
|
||||
grid-template-columns: 1fr;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
+252
-241
@@ -1,35 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
import Field from '$ui/components/primitives/Field.svelte';
|
||||
import Input from '$ui/components/primitives/Input.svelte';
|
||||
import Select from '$ui/components/primitives/Select.svelte';
|
||||
import Textarea from '$ui/components/primitives/Textarea.svelte';
|
||||
|
||||
type ArtifactKind = 'script' | 'config' | 'plugin' | 'baseline';
|
||||
|
||||
interface ArtifactRow {
|
||||
id: number;
|
||||
name: string;
|
||||
target_rel_path: string;
|
||||
scope_type: 'game' | 'map' | null;
|
||||
scope_value: string | null;
|
||||
current_version_id: number | null;
|
||||
kind: ArtifactKind;
|
||||
id: number; name: string; target_rel_path: string;
|
||||
scope_type: 'game' | 'map' | null; scope_value: string | null;
|
||||
current_version_id: number | null; kind: ArtifactKind;
|
||||
latestVersion: {
|
||||
id: number;
|
||||
version: number;
|
||||
sha256: string;
|
||||
size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed';
|
||||
uploaded_at: string;
|
||||
id: number; version: number; sha256: string; size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed'; uploaded_at: string;
|
||||
} | null;
|
||||
versionCount: number;
|
||||
servers: string[];
|
||||
runningBetaId: number | null;
|
||||
}
|
||||
interface ScopeOptions { games: string[]; mapsByGame: Record<string, string[]>; }
|
||||
|
||||
interface ScopeOptions {
|
||||
games: string[];
|
||||
mapsByGame: Record<string, string[]>;
|
||||
}
|
||||
|
||||
// Two lists: baselines (kind='baseline') and overlays (kind='config').
|
||||
let baselines = $state<ArtifactRow[]>([]);
|
||||
let overlays = $state<ArtifactRow[]>([]);
|
||||
let loading = $state(true);
|
||||
@@ -38,7 +33,6 @@
|
||||
let scopeOptions = $state<ScopeOptions>({ games: [], mapsByGame: {} });
|
||||
let successBanner = $state<{ name: string; artifactId: number; version: number; kind: string } | null>(null);
|
||||
|
||||
// Overlay form state
|
||||
let overlayName = $state('');
|
||||
let overlayScopeType = $state<'game' | 'map'>('game');
|
||||
let overlayScopeGame = $state('');
|
||||
@@ -46,7 +40,6 @@
|
||||
let overlayText = $state('');
|
||||
let overlayNotes = $state('');
|
||||
|
||||
// Baseline form state
|
||||
let baselineName = $state('');
|
||||
let baselineScopeGame = $state('');
|
||||
let baselineFile = $state<File | null>(null);
|
||||
@@ -65,9 +58,8 @@
|
||||
fetch('/api/scope-options')
|
||||
]);
|
||||
if (!baselineRes.ok || !overlayRes.ok) {
|
||||
flash = `configs API returned ${baselineRes.status}/${overlayRes.status}. If this is a dev environment, restart the server so the DB migration runs.`;
|
||||
baselines = [];
|
||||
overlays = [];
|
||||
flash = `Configs API returned ${baselineRes.status}/${overlayRes.status}. If dev, restart to run DB migrations.`;
|
||||
baselines = []; overlays = [];
|
||||
} else {
|
||||
baselines = ((await baselineRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? [];
|
||||
overlays = ((await overlayRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? [];
|
||||
@@ -76,25 +68,23 @@
|
||||
scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? { games: [], mapsByGame: {} };
|
||||
}
|
||||
} catch (err) {
|
||||
flash = `failed to load configs: ${(err as Error).message}`;
|
||||
flash = `Failed to load configs: ${(err as Error).message}`;
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
|
||||
async function createOverlay(e: Event): Promise<void> {
|
||||
e.preventDefault();
|
||||
if (uploading) return;
|
||||
if (!overlayName.trim()) { flash = 'name is required'; return; }
|
||||
if (!overlayScopeValue) { flash = `pick a ${overlayScopeType}`; return; }
|
||||
if (!overlayName.trim()) { flash = 'Name is required'; return; }
|
||||
if (!overlayScopeValue) { flash = `Pick a ${overlayScopeType}`; return; }
|
||||
if (!/^\s*set\s+\S+\s+/m.test(overlayText)) {
|
||||
flash = 'overlay must contain at least one `set KEY VALUE` line';
|
||||
flash = 'Overlay must contain at least one `set KEY VALUE` line';
|
||||
return;
|
||||
}
|
||||
uploading = true;
|
||||
flash = null;
|
||||
uploading = true; flash = null;
|
||||
const form = new FormData();
|
||||
form.append('name', overlayName.trim());
|
||||
form.append('kind', 'config');
|
||||
@@ -126,11 +116,10 @@
|
||||
e.preventDefault();
|
||||
if (uploading) return;
|
||||
if (!baselineName.trim() || !baselineFile || !baselineScopeGame) {
|
||||
flash = 'name, game, and cfg file are required';
|
||||
flash = 'Name, game, and cfg file are required';
|
||||
return;
|
||||
}
|
||||
uploading = true;
|
||||
flash = null;
|
||||
uploading = true; flash = null;
|
||||
const form = new FormData();
|
||||
form.append('name', baselineName.trim());
|
||||
form.append('kind', 'baseline');
|
||||
@@ -154,233 +143,255 @@
|
||||
|
||||
function scopeLabel(a: ArtifactRow): string {
|
||||
if (!a.scope_type) return 'unscoped';
|
||||
return `${a.scope_type}=${a.scope_value ?? '?'}`;
|
||||
return `${a.scope_type} · ${a.scope_value ?? '?'}`;
|
||||
}
|
||||
|
||||
function stateTag(a: ArtifactRow): { label: string; cls: string } | null {
|
||||
function stateVariantFor(a: ArtifactRow): 'online' | 'warning' | 'danger' | 'neutral' | null {
|
||||
if (!a.latestVersion) return null;
|
||||
if (a.current_version_id === null) return { label: 'untested', cls: 'state-untested' };
|
||||
if (a.current_version_id === null) return 'neutral';
|
||||
if (a.latestVersion.id !== a.current_version_id) {
|
||||
return { label: `v${a.latestVersion.version} ${a.latestVersion.state}`, cls: `state-${a.latestVersion.state}` };
|
||||
if (a.latestVersion.state === 'untested') return 'neutral';
|
||||
if (a.latestVersion.state === 'tested') return 'online';
|
||||
if (a.latestVersion.state === 'test-failed') return 'danger';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function stateLabel(a: ArtifactRow): string {
|
||||
if (!a.latestVersion) return '';
|
||||
if (a.current_version_id === null) return 'untested';
|
||||
if (a.latestVersion.id !== a.current_version_id) {
|
||||
return `v${a.latestVersion.version} ${a.latestVersion.state.replace('-', ' ')}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
let gameOptions = $derived([
|
||||
{ value: '', label: '— Pick a game —', disabled: true },
|
||||
...scopeOptions.games.map((g) => ({ value: g, label: g }))
|
||||
]);
|
||||
let mapOptions = $derived([
|
||||
{ value: '', label: '— Pick a map —', disabled: true },
|
||||
...(scopeOptions.mapsByGame[overlayScopeGame] ?? []).map((m) => ({ value: m, label: m }))
|
||||
]);
|
||||
let scopeTypeOptions = [
|
||||
{ value: 'game', label: 'Game' },
|
||||
{ value: 'map', label: 'Map' }
|
||||
];
|
||||
</script>
|
||||
|
||||
<h1>Configs</h1>
|
||||
<div class="page">
|
||||
<SectionHeader
|
||||
title="Configs"
|
||||
subtitle="One baseline per game, plus scoped overlays that patch it."
|
||||
/>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Upload a baseline (one per game)</h2>
|
||||
{#if successBanner}
|
||||
<div class="banner banner-info">
|
||||
<div class="banner">
|
||||
<strong>v{successBanner.version} of "{successBanner.name}" ({successBanner.kind}) uploaded — untested.</strong>
|
||||
<span>Open a beta on <a href="/betas">the betas page</a> to test it before it can be promoted.</span>
|
||||
<span>Open a beta on <a href="/betas">the betas page</a> to test it before promotion.</span>
|
||||
</div>
|
||||
{/if}
|
||||
<form onsubmit={createBaseline} class="upload-form">
|
||||
<label>
|
||||
<span class="k">name</span>
|
||||
<input type="text" bind:value={baselineName} placeholder="t5 baseline" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">game</span>
|
||||
<select bind:value={baselineScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">notes (optional)</span>
|
||||
<input type="text" bind:value={baselineNotes} placeholder="dedicated_sp.cfg baseline" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">cfg file (dedicated_sp.cfg)</span>
|
||||
<input type="file" accept=".cfg,text/plain" onchange={pickBaselineFile} disabled={uploading} />
|
||||
</label>
|
||||
<button type="submit" class="primary" disabled={uploading || !baselineFile || !baselineName || !baselineScopeGame}>
|
||||
{uploading ? 'uploading…' : 'upload baseline'}
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Create a config overlay</h2>
|
||||
<form onsubmit={createOverlay} class="upload-form">
|
||||
<label>
|
||||
<span class="k">name</span>
|
||||
<input type="text" bind:value={overlayName} placeholder="disable AFK" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">scope</span>
|
||||
<div class="scope-row">
|
||||
<select bind:value={overlayScopeType} disabled={uploading}>
|
||||
<option value="game">game</option>
|
||||
<option value="map">map</option>
|
||||
</select>
|
||||
{#if overlayScopeType === 'game'}
|
||||
<select bind:value={overlayScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<select bind:value={overlayScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<select bind:value={overlayScopeMap} disabled={uploading || !overlayScopeGame}>
|
||||
<option value="">— pick a map —</option>
|
||||
{#each (scopeOptions.mapsByGame[overlayScopeGame] ?? []) as m (m)}
|
||||
<option value={m}>{m}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{/if}
|
||||
<!-- Baseline upload -->
|
||||
<Card padding="lg">
|
||||
<h2 class="panel-title">Upload a baseline <span class="dim">(one per game)</span></h2>
|
||||
<form onsubmit={createBaseline} class="upload-form">
|
||||
<Field label="Name">
|
||||
<Input bind:value={baselineName} placeholder="t5 baseline" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Game">
|
||||
<Select bind:value={baselineScopeGame} options={gameOptions} disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Notes" hint="Optional. Describe what this baseline covers.">
|
||||
<Input bind:value={baselineNotes} placeholder="dedicated_sp.cfg baseline" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Cfg file (dedicated_sp.cfg)">
|
||||
<Input type="file" accept=".cfg,text/plain" onchange={pickBaselineFile} disabled={uploading} />
|
||||
</Field>
|
||||
<div class="form-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={uploading || !baselineFile || !baselineName || !baselineScopeGame}
|
||||
loading={uploading}
|
||||
>
|
||||
Upload baseline
|
||||
</Button>
|
||||
</div>
|
||||
</label>
|
||||
<label class="full">
|
||||
<span class="k">overlay lines</span>
|
||||
<textarea
|
||||
bind:value={overlayText}
|
||||
rows="4"
|
||||
placeholder={'set g_inactivity "0"'}
|
||||
disabled={uploading}
|
||||
></textarea>
|
||||
<span class="hint">one or more `set KEY "VALUE"` lines. Replaces baseline lines with the same KEY.</span>
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">notes (optional)</span>
|
||||
<input type="text" bind:value={overlayNotes} placeholder="why this change" disabled={uploading} />
|
||||
</label>
|
||||
<button type="submit" class="primary" disabled={uploading || !overlayName || !overlayText || !overlayScopeValue}>
|
||||
{uploading ? 'uploading…' : 'create overlay'}
|
||||
</button>
|
||||
</form>
|
||||
{#if flash}<p class="flash">{flash}</p>{/if}
|
||||
</section>
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Baselines · {baselines.length}</h2>
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
{:else if baselines.length === 0}
|
||||
<p class="empty">no baseline yet — upload one above</p>
|
||||
{:else}
|
||||
<div class="artifacts">
|
||||
{#each baselines as a (a.id)}
|
||||
<a class="artifact-row" href="/configs/{a.id}">
|
||||
<div class="row-top">
|
||||
<span class="artifact-name">{a.name}</span>
|
||||
<span class="scope tag scope-{a.scope_type ?? 'none'}">{scopeLabel(a)}</span>
|
||||
{#if stateTag(a)}
|
||||
{@const t = stateTag(a)!}
|
||||
<span class="tag {t.cls}">{t.label}</span>
|
||||
{/if}
|
||||
{#if a.runningBetaId}
|
||||
<span class="tag beta">beta {a.runningBetaId} running</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta mono">
|
||||
<span>{a.target_rel_path}</span>
|
||||
<span>v{a.latestVersion?.version ?? '—'} · {a.versionCount} version{a.versionCount === 1 ? '' : 's'}</span>
|
||||
<span>{a.servers.length ? `${a.servers.length} matching server${a.servers.length === 1 ? '' : 's'}` : ''}</span>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
<!-- Overlay creation -->
|
||||
<Card padding="lg">
|
||||
<h2 class="panel-title">Create a config overlay</h2>
|
||||
<form onsubmit={createOverlay} class="upload-form">
|
||||
<Field label="Name">
|
||||
<Input bind:value={overlayName} placeholder="disable AFK" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Scope">
|
||||
<div class="scope-row">
|
||||
<Select bind:value={overlayScopeType} options={scopeTypeOptions} disabled={uploading} />
|
||||
<Select bind:value={overlayScopeGame} options={gameOptions} disabled={uploading} />
|
||||
{#if overlayScopeType === 'map'}
|
||||
<Select bind:value={overlayScopeMap} options={mapOptions} disabled={uploading || !overlayScopeGame} />
|
||||
{/if}
|
||||
</div>
|
||||
</Field>
|
||||
<div class="full">
|
||||
<Field label="Overlay lines" hint="One or more `set KEY "VALUE"` lines. Replaces baseline lines with the same KEY.">
|
||||
<Textarea
|
||||
bind:value={overlayText}
|
||||
rows={4}
|
||||
mono
|
||||
placeholder={'set g_inactivity "0"'}
|
||||
disabled={uploading}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
<Field label="Notes" hint="Optional. Explain the reason for this overlay.">
|
||||
<Input bind:value={overlayNotes} placeholder="why this change" disabled={uploading} />
|
||||
</Field>
|
||||
<div class="form-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={uploading || !overlayName || !overlayText || !overlayScopeValue}
|
||||
loading={uploading}
|
||||
>
|
||||
Create overlay
|
||||
</Button>
|
||||
{#if flash}<span class="flash">{flash}</span>{/if}
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
<section class="panel">
|
||||
<h2>Overlays · {overlays.length}</h2>
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
{:else if overlays.length === 0}
|
||||
<p class="empty">no overlays yet — create one above</p>
|
||||
{:else}
|
||||
<div class="artifacts">
|
||||
{#each overlays as a (a.id)}
|
||||
<a class="artifact-row" href="/configs/{a.id}">
|
||||
<div class="row-top">
|
||||
<span class="artifact-name">{a.name}</span>
|
||||
<span class="scope tag scope-{a.scope_type ?? 'none'}">{scopeLabel(a)}</span>
|
||||
{#if stateTag(a)}
|
||||
{@const t = stateTag(a)!}
|
||||
<span class="tag {t.cls}">{t.label}</span>
|
||||
{/if}
|
||||
{#if a.runningBetaId}
|
||||
<span class="tag beta">beta {a.runningBetaId} running</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta mono">
|
||||
<span>v{a.latestVersion?.version ?? '—'} · {a.versionCount} version{a.versionCount === 1 ? '' : 's'}</span>
|
||||
<span>{a.servers.length ? `${a.servers.length} matching server${a.servers.length === 1 ? '' : 's'}` : ''}</span>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
<!-- Baselines list -->
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Baselines</h2>
|
||||
<Badge variant="neutral" size="sm">{baselines.length}</Badge>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else if baselines.length === 0}
|
||||
<EmptyState title="No baseline yet" description="Upload a per-game baseline above." />
|
||||
{:else}
|
||||
<div class="rows">
|
||||
{#each baselines as a (a.id)}
|
||||
{@render artifactRow(a)}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<!-- Overlays list -->
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Overlays</h2>
|
||||
<Badge variant="neutral" size="sm">{overlays.length}</Badge>
|
||||
</div>
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else if overlays.length === 0}
|
||||
<EmptyState title="No overlays yet" description="Create a scoped overlay above." />
|
||||
{:else}
|
||||
<div class="rows">
|
||||
{#each overlays as a (a.id)}
|
||||
{@render artifactRow(a)}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{#snippet artifactRow(a: ArtifactRow)}
|
||||
<a class="row" href="/configs/{a.id}">
|
||||
<div class="row-top">
|
||||
<span class="name">{a.name}</span>
|
||||
<Badge
|
||||
variant={a.scope_type === 'game' ? 'info' : a.scope_type === 'map' ? 'warning' : 'neutral'}
|
||||
size="sm"
|
||||
>
|
||||
{scopeLabel(a)}
|
||||
</Badge>
|
||||
{#if stateVariantFor(a)}
|
||||
{@const v = stateVariantFor(a)!}
|
||||
<Badge variant={v} size="sm">{stateLabel(a)}</Badge>
|
||||
{/if}
|
||||
{#if a.runningBetaId}
|
||||
<Badge variant="warning" size="sm">β{a.runningBetaId} running</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta">
|
||||
<span class="path">{a.target_rel_path}</span>
|
||||
<span>v{a.latestVersion?.version ?? '—'} · {a.versionCount} version{a.versionCount === 1 ? '' : 's'}</span>
|
||||
{#if a.servers.length}
|
||||
<span>{a.servers.length} matching server{a.servers.length === 1 ? '' : 's'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</a>
|
||||
{/snippet}
|
||||
|
||||
<style>
|
||||
h1 { color: var(--cream); font-family: var(--font-display); font-size: var(--text-3xl); letter-spacing: var(--tracking-display); line-height: var(--leading-tight); margin: 0 0 28px; }
|
||||
.panel { background: var(--bg-nav); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--pad-panel); margin-bottom: 20px; }
|
||||
h2 { margin: 0 0 14px; font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-300); }
|
||||
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono); margin: 0; }
|
||||
.upload-form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
|
||||
.upload-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); }
|
||||
.upload-form label.full { grid-column: 1 / -1; }
|
||||
.upload-form label .k { color: var(--ink-500); text-transform: uppercase; letter-spacing: 1px; }
|
||||
.upload-form .hint { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono-sm); }
|
||||
.upload-form input[type=text], .upload-form select, .upload-form input[type=file], .upload-form textarea {
|
||||
background: var(--bg-page);
|
||||
color: var(--ink-100);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 10px 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-mono);
|
||||
.page { display: flex; flex-direction: column; gap: var(--space-6); }
|
||||
.loading { text-align: center; padding: var(--space-12); color: var(--text-tertiary); }
|
||||
|
||||
.banner {
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: rgba(124, 212, 255, 0.06);
|
||||
border: 1px solid rgba(124, 212, 255, 0.22);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
.upload-form textarea { min-height: 100px; resize: vertical; }
|
||||
.upload-form input[type=text]:focus, .upload-form select:focus, .upload-form textarea:focus {
|
||||
outline: none; border-color: var(--accent); box-shadow: var(--accent-glow);
|
||||
}
|
||||
.scope-row { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.scope-row select:nth-of-type(1) { flex: 0 0 120px; }
|
||||
.scope-row select:nth-of-type(2), .scope-row select:nth-of-type(3) { flex: 1; }
|
||||
.primary {
|
||||
grid-column: 1 / -1;
|
||||
background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
|
||||
border: 1px solid var(--blue-400);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 12px 18px;
|
||||
color: var(--cream);
|
||||
.banner a { color: var(--state-online); text-decoration: underline; }
|
||||
|
||||
.panel-title {
|
||||
margin: 0 0 var(--space-4);
|
||||
font-family: var(--font-body);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.primary:disabled { opacity: 0.4; cursor: default; }
|
||||
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
|
||||
.artifacts { display: flex; flex-direction: column; gap: 8px; }
|
||||
.artifact-row { display: flex; flex-direction: column; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px 16px; text-decoration: none; color: var(--ink-100); }
|
||||
.artifact-row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
.row-top { display: flex; gap: 12px; align-items: center; }
|
||||
.artifact-name { color: var(--cream); font-weight: 600; font-size: var(--text-md); }
|
||||
.row-meta { display: flex; gap: 24px; color: var(--ink-500); font-size: var(--text-mono-sm); }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
.tag { font-family: var(--font-mono); font-size: var(--text-xs); padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid transparent; }
|
||||
.scope-none { background: var(--bg-nav); border-color: var(--border); color: var(--ink-500); }
|
||||
.scope-game { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
|
||||
.scope-map { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.35); color: var(--amber-500); }
|
||||
.beta { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.3); color: var(--amber-500); }
|
||||
.state-untested { background: var(--bg-nav); border-color: var(--border); color: var(--ink-300); }
|
||||
.state-tested { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
|
||||
.state-test-failed { background: rgba(255, 92, 92, 0.10); border-color: rgba(255, 92, 92, 0.4); color: var(--danger-500); }
|
||||
.banner { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 12px; font-size: var(--text-mono); }
|
||||
.banner-info { background: rgba(124, 212, 255, 0.08); border: 1px solid rgba(124, 212, 255, 0.28); color: var(--ink-100); }
|
||||
.banner-info a { color: var(--spark-500); text-decoration: underline; }
|
||||
.panel-title .dim {
|
||||
color: var(--text-tertiary);
|
||||
font-weight: var(--weight-regular);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
.upload-form { display: grid; gap: var(--space-4); grid-template-columns: 1fr 1fr; }
|
||||
.upload-form .full { grid-column: 1 / -1; }
|
||||
.scope-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
|
||||
.scope-row :global(.wrap) { flex: 1 1 140px; min-width: 140px; }
|
||||
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-4); }
|
||||
.flash { color: var(--state-danger); font-family: var(--font-mono); font-size: var(--text-xs); }
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.section-head { display: flex; align-items: center; gap: var(--space-3); }
|
||||
.section-head h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.rows { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.row {
|
||||
display: flex; flex-direction: column; gap: var(--space-2);
|
||||
padding: var(--space-4) var(--space-5);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.row:hover { background: var(--surface-raised); border-color: var(--border-strong); }
|
||||
.row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
.row-top { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
|
||||
.name { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); letter-spacing: var(--tracking-tight); }
|
||||
.row-meta { display: flex; gap: var(--space-5); color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--text-xs); flex-wrap: wrap; }
|
||||
.path { color: var(--text-secondary); }
|
||||
|
||||
@media (max-width: 720px) { .upload-form { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
|
||||
+467
-223
@@ -1,5 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
|
||||
interface ServerRow {
|
||||
server: string;
|
||||
@@ -32,7 +37,6 @@
|
||||
prior_version: number | null;
|
||||
scripts: DepScript[];
|
||||
}
|
||||
|
||||
interface DriftFile {
|
||||
relPath: string;
|
||||
size: number;
|
||||
@@ -50,13 +54,15 @@
|
||||
let running = $state(false);
|
||||
let rollingBack = $state<string | null>(null);
|
||||
let flash = $state<string | null>(null);
|
||||
// Drift panel opens automatically when there's a problem; collapses when clean.
|
||||
let driftOpen = $state(false);
|
||||
let driftFilter = $state('');
|
||||
|
||||
async function loadDeployments(): Promise<void> {
|
||||
const res = await fetch('/api/deployments');
|
||||
const body = (await res.json()) as { deployments: Deployment[] };
|
||||
deployments = body.deployments;
|
||||
}
|
||||
|
||||
async function scanDrift(): Promise<void> {
|
||||
scanning = true;
|
||||
try {
|
||||
@@ -76,14 +82,22 @@
|
||||
return { untracked: u, missing: m };
|
||||
});
|
||||
|
||||
// Auto-open on first scan if there's drift; leave user's toggle alone after.
|
||||
let firstScan = $state(true);
|
||||
$effect(() => {
|
||||
if (drift && firstScan) {
|
||||
firstScan = false;
|
||||
if (drift.totalDrift > 0) driftOpen = true;
|
||||
}
|
||||
});
|
||||
|
||||
async function runDrift(): Promise<void> {
|
||||
if (!drift || drift.totalDrift === 0) return;
|
||||
const parts: string[] = [];
|
||||
if (driftCounts.untracked > 0) parts.push(`delete ${driftCounts.untracked} untracked file(s)`);
|
||||
if (driftCounts.missing > 0) parts.push(`restore ${driftCounts.missing} missing artifact(s)`);
|
||||
if (!confirm(`Reconcile drift on ${drift.servers.length} server(s)? Will ${parts.join(' and ')}.`)) return;
|
||||
running = true;
|
||||
flash = null;
|
||||
running = true; flash = null;
|
||||
try {
|
||||
const res = await fetch('/api/drift', {
|
||||
method: 'POST',
|
||||
@@ -91,14 +105,8 @@
|
||||
body: JSON.stringify({})
|
||||
});
|
||||
const body = (await res.json()) as {
|
||||
ok: boolean;
|
||||
error?: string;
|
||||
result?: {
|
||||
deploymentId: string | null;
|
||||
totalRemoved: number;
|
||||
totalRestored?: number;
|
||||
totalServers: number;
|
||||
};
|
||||
ok: boolean; error?: string;
|
||||
result?: { deploymentId: string | null; totalRemoved: number; totalRestored?: number; totalServers: number };
|
||||
};
|
||||
if (!body.ok) { flash = body.error ?? 'drift run failed'; return; }
|
||||
const removed = body.result?.totalRemoved ?? 0;
|
||||
@@ -126,11 +134,6 @@
|
||||
function isActive(d: Deployment): boolean {
|
||||
return d.servers.some((s) => s.restart_state === 'pending' || s.restart_state === 'failed');
|
||||
}
|
||||
|
||||
function chipClass(state: string): string {
|
||||
return `chip chip-${state}`;
|
||||
}
|
||||
|
||||
function ago(iso: string): string {
|
||||
const d = Date.now() - new Date(iso).getTime();
|
||||
if (d < 60_000) return 'just now';
|
||||
@@ -138,6 +141,13 @@
|
||||
if (d < 86_400_000) return `${Math.floor(d / 3_600_000)}h ago`;
|
||||
return `${Math.floor(d / 86_400_000)}d ago`;
|
||||
}
|
||||
function stateBadgeVariant(s: string): 'online' | 'danger' | 'warning' | 'info' | 'neutral' {
|
||||
return s === 'done' ? 'online' :
|
||||
s === 'failed' ? 'danger' :
|
||||
s === 'pending' ? 'warning' :
|
||||
s === 'held' ? 'info' :
|
||||
'neutral';
|
||||
}
|
||||
|
||||
let active = $derived(deployments.filter(isActive));
|
||||
let history = $derived(deployments.filter((d) => !isActive(d)));
|
||||
@@ -150,7 +160,6 @@
|
||||
}
|
||||
return `${d.scripts.length} scripts`;
|
||||
}
|
||||
// Legacy fallback: pre-multi-script rows still use the top-level cols.
|
||||
if (d.script_name) return `${d.script_name} v${d.script_version ?? '?'}`;
|
||||
return '';
|
||||
}
|
||||
@@ -159,261 +168,496 @@
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
const summary = scriptSummary(d) || 'this promote';
|
||||
const msg = `Rollback ${summary} on ${d.servers.length} server(s)?`;
|
||||
if (!confirm(msg)) return;
|
||||
if (!confirm(`Rollback ${summary} on ${d.servers.length} server(s)?`)) return;
|
||||
rollingBack = d.id;
|
||||
flash = null;
|
||||
try {
|
||||
const res = await fetch(`/api/deployments/${d.id}/rollback`, { method: 'POST' });
|
||||
const body = (await res.json()) as { ok: boolean; error?: string };
|
||||
if (!body.ok) { flash = body.error ?? 'rollback failed'; return; }
|
||||
flash = `rollback deployment opened`;
|
||||
flash = 'Rollback deployment opened';
|
||||
await loadDeployments();
|
||||
} finally {
|
||||
rollingBack = null;
|
||||
}
|
||||
}
|
||||
|
||||
// History grouped by day for a nice timeline read.
|
||||
let historyByDay = $derived.by(() => {
|
||||
const groups = new Map<string, Deployment[]>();
|
||||
for (const d of history) {
|
||||
const key = new Date(d.started_at).toDateString();
|
||||
if (!groups.has(key)) groups.set(key, []);
|
||||
groups.get(key)!.push(d);
|
||||
}
|
||||
return Array.from(groups.entries());
|
||||
});
|
||||
|
||||
// Drift filtering — spare the operator's eyes on huge fleets.
|
||||
let filteredDriftServers = $derived(
|
||||
drift?.servers.filter((s) =>
|
||||
!driftFilter || s.server.toLowerCase().includes(driftFilter.toLowerCase())
|
||||
) ?? []
|
||||
);
|
||||
</script>
|
||||
|
||||
<h1>Deployments</h1>
|
||||
<div class="page">
|
||||
<SectionHeader
|
||||
title="Deployments"
|
||||
subtitle="Fleet-wide script deploys, drift reconciliation, and rollbacks."
|
||||
/>
|
||||
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
{:else}
|
||||
<section class="drift-panel">
|
||||
<div class="drift-head">
|
||||
<h2>Drift{drift ? ` · ${driftCounts.untracked} untracked, ${driftCounts.missing} missing` : ''}</h2>
|
||||
<div class="drift-actions">
|
||||
<button onclick={scanDrift} disabled={scanning || running}>{scanning ? 'scanning…' : 'rescan'}</button>
|
||||
<button class="primary" onclick={runDrift} disabled={running || scanning || !drift || drift.totalDrift === 0}>
|
||||
{running ? 'reconciling…' : 'reconcile drift'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{#if drift === null}
|
||||
<p class="empty">scan hasn't run yet</p>
|
||||
{:else if drift.totalDrift === 0}
|
||||
<p class="empty">inventory matches disk — no drift</p>
|
||||
{:else}
|
||||
{#each drift.servers as s (s.server)}
|
||||
<div class="drift-server">
|
||||
<div class="drift-server-head mono">{s.server} · {s.files.length} entr{s.files.length === 1 ? 'y' : 'ies'}</div>
|
||||
<div class="drift-files">
|
||||
{#each s.files as f (f.driftKind + ':' + f.kind + ':' + f.relPath)}
|
||||
<span
|
||||
class="drift-file mono {f.driftKind}"
|
||||
title="[{f.kind}] {f.driftKind} · {f.size}B · {f.sha256.slice(0, 12)}"
|
||||
>[{f.driftKind === 'missing' ? '+' : '−'} {f.kind}] {f.relPath}</span>
|
||||
{/each}
|
||||
</div>
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else}
|
||||
<!-- Drift summary — collapsed by default when there's no problem. -->
|
||||
<Card padding="lg">
|
||||
<button
|
||||
type="button"
|
||||
class="drift-summary"
|
||||
aria-expanded={driftOpen}
|
||||
onclick={() => (driftOpen = !driftOpen)}
|
||||
>
|
||||
<div class="drift-summary-l">
|
||||
<span class="chev" class:open={driftOpen} aria-hidden="true">›</span>
|
||||
<span class="drift-title">Drift</span>
|
||||
{#if drift === null}
|
||||
<Badge variant="neutral" size="sm">Not scanned</Badge>
|
||||
{:else if drift.totalDrift === 0}
|
||||
<Badge variant="online" size="sm">In sync</Badge>
|
||||
{:else}
|
||||
{#if driftCounts.untracked > 0}
|
||||
<Badge variant="danger" size="sm">{driftCounts.untracked} untracked</Badge>
|
||||
{/if}
|
||||
{#if driftCounts.missing > 0}
|
||||
<Badge variant="warning" size="sm">{driftCounts.missing} missing</Badge>
|
||||
{/if}
|
||||
<span class="drift-servers">
|
||||
across {drift.servers.length} server{drift.servers.length === 1 ? '' : 's'}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
{#if flash}<p class="flash">{flash}</p>{/if}
|
||||
</section>
|
||||
<div class="drift-summary-r" onclick={(e) => e.stopPropagation()} role="none">
|
||||
<Button variant="ghost" size="sm" onclick={scanDrift} disabled={scanning || running} loading={scanning}>
|
||||
Rescan
|
||||
</Button>
|
||||
<Button
|
||||
variant="danger"
|
||||
size="sm"
|
||||
onclick={runDrift}
|
||||
disabled={running || scanning || !drift || drift.totalDrift === 0}
|
||||
loading={running}
|
||||
>
|
||||
Reconcile
|
||||
</Button>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<section>
|
||||
<h2>Active</h2>
|
||||
{#if active.length === 0}
|
||||
<p class="empty">nothing active</p>
|
||||
{:else}
|
||||
{#each active as d (d.id)}
|
||||
{@render deployRow(d)}
|
||||
{/each}
|
||||
{/if}
|
||||
</section>
|
||||
{#if driftOpen}
|
||||
<div class="drift-body">
|
||||
{#if drift && drift.totalDrift > 0}
|
||||
<input
|
||||
class="drift-filter"
|
||||
type="search"
|
||||
placeholder="Filter by server name…"
|
||||
bind:value={driftFilter}
|
||||
/>
|
||||
{#each filteredDriftServers as s (s.server)}
|
||||
<div class="drift-server">
|
||||
<div class="drift-server-head">
|
||||
<span class="server-name">{s.server}</span>
|
||||
<span class="server-count">{s.files.length} entr{s.files.length === 1 ? 'y' : 'ies'}</span>
|
||||
</div>
|
||||
<div class="drift-files">
|
||||
{#each s.files as f (f.driftKind + ':' + f.kind + ':' + f.relPath)}
|
||||
<Badge
|
||||
variant={f.driftKind === 'untracked' ? 'danger' : 'warning'}
|
||||
size="sm"
|
||||
mono
|
||||
title="[{f.kind}] {f.driftKind} · {f.size}B · {f.sha256.slice(0, 12)}"
|
||||
>
|
||||
[{f.driftKind === 'missing' ? '+' : '−'} {f.kind}] {f.relPath}
|
||||
</Badge>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{:else if drift?.totalDrift === 0}
|
||||
<EmptyState title="Inventory matches disk" description="Nothing to reconcile." />
|
||||
{:else}
|
||||
<EmptyState title="Scan hasn't run yet" description="Click Rescan to look for drift." />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<section>
|
||||
<h2>History (7 days)</h2>
|
||||
{#if history.length === 0}
|
||||
<p class="empty">no completed deployments in the retention window</p>
|
||||
{:else}
|
||||
{#each history as d (d.id)}
|
||||
{@render deployRow(d)}
|
||||
{/each}
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
{#if flash}
|
||||
<div class="flash">{flash}</div>
|
||||
{/if}
|
||||
</Card>
|
||||
|
||||
<!-- Active pipelines -->
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Active</h2>
|
||||
<Badge variant="neutral" size="sm">{active.length}</Badge>
|
||||
</div>
|
||||
{#if active.length === 0}
|
||||
<EmptyState
|
||||
title="Nothing in flight"
|
||||
description="Push scripts or open a beta to see deployments here."
|
||||
/>
|
||||
{:else}
|
||||
<div class="deploy-list">
|
||||
{#each active as d (d.id)}
|
||||
{@render deployRow(d)}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
<!-- History timeline -->
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>History</h2>
|
||||
<Badge variant="neutral" size="sm">{history.length}</Badge>
|
||||
</div>
|
||||
{#if history.length === 0}
|
||||
<EmptyState
|
||||
title="No completed deployments in the retention window"
|
||||
description="Retention is 7 days by default."
|
||||
/>
|
||||
{:else}
|
||||
{#each historyByDay as [day, rows] (day)}
|
||||
<div class="day-group">
|
||||
<div class="day-label">{day}</div>
|
||||
<div class="deploy-list">
|
||||
{#each rows as d (d.id)}
|
||||
{@render deployRow(d)}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#snippet deployRow(d: Deployment)}
|
||||
<a class="row" href="/deployments/{d.id}">
|
||||
<div class="head">
|
||||
<div class="head-l">
|
||||
<a class="deploy-row" href="/deployments/{d.id}">
|
||||
<div class="row-head">
|
||||
<div class="row-head-l">
|
||||
<span class="action">{d.action}</span>
|
||||
{#if d.action === 'promote' || d.action === 'rollback'}
|
||||
<span class="target mono">{scriptSummary(d)}</span>
|
||||
<span class="target">{scriptSummary(d)}</span>
|
||||
{/if}
|
||||
{#if d.rolled_back_by}
|
||||
<span class="tag rb">rolled back</span>
|
||||
<Badge variant="neutral" size="sm">Rolled back</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="head-r">
|
||||
<div class="row-head-r">
|
||||
{#if d.action === 'promote' && !d.rolled_back_by}
|
||||
<button class="rb-btn" onclick={(e) => rollbackPromote(d, e)} disabled={rollingBack === d.id}>
|
||||
{rollingBack === d.id ? 'rolling back…' : 'rollback'}
|
||||
</button>
|
||||
<Button
|
||||
variant="danger"
|
||||
size="sm"
|
||||
onclick={(e) => rollbackPromote(d, e)}
|
||||
disabled={rollingBack === d.id}
|
||||
loading={rollingBack === d.id}
|
||||
>
|
||||
Rollback
|
||||
</Button>
|
||||
{/if}
|
||||
<span class="when">{ago(d.started_at)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chips">
|
||||
<!-- Mini pipeline visual: one dot per server, colored by state. -->
|
||||
<div class="pipeline" aria-label="Server progress">
|
||||
{#each d.servers as s (s.server)}
|
||||
<span class={chipClass(s.restart_state)} title={s.error ?? ''}>
|
||||
{s.server}{s.players !== null && s.players > 0 ? ` (${s.players}p)` : ''}
|
||||
<span
|
||||
class="node n-{s.restart_state}"
|
||||
title="{s.server}: {s.restart_state}{s.error ? ' — ' + s.error : ''}"
|
||||
>
|
||||
<span class="dot"></span>
|
||||
<span class="node-label">{s.server}{s.players !== null && s.players > 0 ? ` (${s.players}p)` : ''}</span>
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="id">{d.id}</div>
|
||||
<div class="row-foot">
|
||||
<span class="id">{d.id}</span>
|
||||
<div class="counts">
|
||||
{#each ['done','pending','failed','held','manual'] as state}
|
||||
{@const n = d.servers.filter((s) => s.restart_state === state).length}
|
||||
{#if n > 0}
|
||||
<Badge variant={stateBadgeVariant(state)} size="sm">{n} {state}</Badge>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{/snippet}
|
||||
|
||||
<style>
|
||||
h1 {
|
||||
color: var(--cream);
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-3xl);
|
||||
letter-spacing: var(--tracking-display);
|
||||
line-height: var(--leading-tight);
|
||||
margin: 0 0 28px;
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-8);
|
||||
}
|
||||
h2 {
|
||||
margin: var(--gap-section) 0 16px;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1.5px;
|
||||
color: var(--ink-300);
|
||||
}
|
||||
.row {
|
||||
display: block;
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-md);
|
||||
padding: 18px 20px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--ink-100);
|
||||
text-decoration: none;
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
.row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
.head { display: flex; justify-content: space-between; margin-bottom: 10px; align-items: center; gap: 12px; }
|
||||
.head-l { display: flex; gap: 10px; align-items: baseline; }
|
||||
.head-r { display: flex; gap: 10px; align-items: center; }
|
||||
.action { font-family: var(--font-mono); font-size: var(--text-md); color: var(--cream); }
|
||||
.target { color: var(--spark-500); font-size: var(--text-mono); }
|
||||
.when { color: var(--ink-500); font-size: var(--text-mono); font-family: var(--font-mono); }
|
||||
.tag { padding: 2px 8px; border-radius: var(--r-sm); font-family: var(--font-mono); font-size: var(--text-xs); border: 1px solid transparent; }
|
||||
.tag.rb { background: var(--bg-card); border-color: var(--border); color: var(--ink-500); }
|
||||
.rb-btn {
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid rgba(255, 48, 80, 0.4);
|
||||
color: var(--danger-500);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 6px 12px;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-xs);
|
||||
cursor: pointer;
|
||||
}
|
||||
.rb-btn:hover:not(:disabled) { border-color: var(--danger-500); }
|
||||
.rb-btn:disabled { opacity: 0.5; cursor: default; }
|
||||
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
|
||||
.chip {
|
||||
padding: 3px 9px;
|
||||
border-radius: var(--r-sm);
|
||||
font-size: var(--text-mono-sm);
|
||||
font-family: var(--font-mono);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.chip-done {
|
||||
background: rgba(124, 212, 255, 0.10);
|
||||
border-color: rgba(124, 212, 255, 0.3);
|
||||
color: var(--spark-500);
|
||||
}
|
||||
.chip-failed {
|
||||
background: rgba(255, 48, 80, 0.1);
|
||||
border-color: rgba(255, 48, 80, 0.3);
|
||||
color: var(--danger-500);
|
||||
}
|
||||
.chip-pending {
|
||||
background: rgba(255, 176, 32, 0.1);
|
||||
border-color: rgba(255, 176, 32, 0.3);
|
||||
color: var(--amber-500);
|
||||
}
|
||||
.chip-held {
|
||||
background: rgba(124, 192, 245, 0.10);
|
||||
border-color: rgba(124, 192, 245, 0.28);
|
||||
color: var(--cream);
|
||||
}
|
||||
.chip-manual {
|
||||
background: var(--bg-nav);
|
||||
border-color: var(--border);
|
||||
color: var(--ink-500);
|
||||
}
|
||||
.id {
|
||||
color: var(--ink-700);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-mono-sm);
|
||||
}
|
||||
.empty {
|
||||
color: var(--ink-500);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-base);
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: var(--space-16);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.drift-panel {
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-md);
|
||||
padding: var(--pad-panel);
|
||||
margin-bottom: var(--gap-section);
|
||||
/* Drift summary bar */
|
||||
.drift-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
text-align: left;
|
||||
font: inherit;
|
||||
}
|
||||
.drift-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
|
||||
.drift-head h2 { margin: 0; }
|
||||
.drift-actions { display: flex; gap: 8px; }
|
||||
.drift-actions button {
|
||||
background: var(--bg-card);
|
||||
color: var(--ink-100);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 8px 16px;
|
||||
.drift-summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-md); }
|
||||
.drift-summary-l {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
min-width: 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.drift-summary-r {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.drift-title {
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.drift-servers {
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
.chev {
|
||||
color: var(--text-tertiary);
|
||||
font-size: var(--text-lg);
|
||||
line-height: 1;
|
||||
transition: transform var(--dur-base) var(--ease-standard);
|
||||
display: inline-block;
|
||||
}
|
||||
.chev.open { transform: rotate(90deg); }
|
||||
|
||||
.drift-body {
|
||||
margin-top: var(--space-5);
|
||||
padding-top: var(--space-5);
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
}
|
||||
.drift-filter {
|
||||
width: 100%;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
margin-bottom: var(--space-4);
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
transition: border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.drift-actions button:hover:not(:disabled) { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
.drift-actions button.primary {
|
||||
background: linear-gradient(180deg, var(--danger-500), #a01e39);
|
||||
border-color: rgba(255, 48, 80, 0.6);
|
||||
color: var(--cream);
|
||||
font-weight: 600;
|
||||
.drift-filter:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
.drift-actions button:disabled { opacity: 0.4; cursor: default; }
|
||||
.drift-server {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 10px 14px;
|
||||
margin: 8px 0;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
margin: var(--space-2) 0;
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.drift-server-head { color: var(--cream); font-size: var(--text-mono); margin-bottom: 6px; }
|
||||
.drift-files { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.drift-file {
|
||||
.drift-server-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
margin-bottom: var(--space-2);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
.server-name { color: var(--text-primary); }
|
||||
.server-count { color: var(--text-tertiary); font-size: var(--text-xs); }
|
||||
.drift-files {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.flash {
|
||||
margin-top: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: rgba(124, 212, 255, 0.06);
|
||||
border: 1px solid rgba(124, 212, 255, 0.22);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--state-online);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/* Sections */
|
||||
.section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.section-head h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
letter-spacing: var(--tracking-tight);
|
||||
}
|
||||
|
||||
.day-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
margin-top: var(--space-4);
|
||||
}
|
||||
.day-label {
|
||||
font-size: var(--text-xs);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: var(--tracking-label);
|
||||
color: var(--text-tertiary);
|
||||
font-weight: var(--weight-semibold);
|
||||
}
|
||||
|
||||
.deploy-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
/* Deployment rows */
|
||||
.deploy-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-4) var(--space-5);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
transition:
|
||||
background-color var(--dur-fast) var(--ease-standard),
|
||||
border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.deploy-row:hover {
|
||||
background: var(--surface-raised);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
.deploy-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
|
||||
.row-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.row-head-l {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
}
|
||||
.row-head-r {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.action {
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.target {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.when {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
/* Pipeline visual */
|
||||
.pipeline {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
flex-wrap: wrap;
|
||||
padding: var(--space-2) 0;
|
||||
}
|
||||
.node {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding: 3px 8px;
|
||||
border-radius: var(--r-sm);
|
||||
font-size: var(--text-mono-sm);
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--radius-pill);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-secondary);
|
||||
background: var(--surface-sunken);
|
||||
}
|
||||
.drift-file.untracked {
|
||||
background: rgba(255, 48, 80, 0.08);
|
||||
border-color: rgba(255, 48, 80, 0.25);
|
||||
color: var(--danger-500);
|
||||
.node .dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-quaternary);
|
||||
}
|
||||
.drift-file.missing {
|
||||
background: rgba(255, 176, 32, 0.08);
|
||||
border-color: rgba(255, 176, 32, 0.3);
|
||||
color: var(--amber-500);
|
||||
.n-done .dot { background: var(--state-online); }
|
||||
.n-pending .dot { background: var(--state-warning); }
|
||||
.n-failed .dot { background: var(--state-danger); }
|
||||
.n-held .dot { background: var(--blue-300); }
|
||||
.n-manual .dot { background: var(--text-tertiary); }
|
||||
.node-label { color: var(--text-secondary); }
|
||||
|
||||
.row-foot {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
padding-top: var(--space-2);
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
}
|
||||
.id {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-quaternary);
|
||||
}
|
||||
.counts {
|
||||
display: flex;
|
||||
gap: var(--space-1);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.row-head, .row-foot { flex-direction: column; align-items: flex-start; }
|
||||
.drift-summary { flex-direction: column; align-items: flex-start; }
|
||||
.drift-summary-r { width: 100%; justify-content: flex-end; }
|
||||
}
|
||||
.flash { color: var(--spark-400); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
</style>
|
||||
|
||||
@@ -2,35 +2,28 @@
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import DiffViewer from '$ui/components/DiffViewer.svelte';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import Breadcrumbs from '$ui/components/primitives/Breadcrumbs.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
|
||||
interface FileRow {
|
||||
id: number;
|
||||
server: string;
|
||||
verb: string;
|
||||
rel_path: string;
|
||||
sha256_before: string | null;
|
||||
sha256_after: string | null;
|
||||
size_before: number | null;
|
||||
size_after: number | null;
|
||||
id: number; server: string; verb: string; rel_path: string;
|
||||
sha256_before: string | null; sha256_after: string | null;
|
||||
size_before: number | null; size_after: number | null;
|
||||
}
|
||||
interface ServerRow {
|
||||
deployment_id: string;
|
||||
server: string;
|
||||
files_changed: number;
|
||||
restart_state: string;
|
||||
players: number | null;
|
||||
checked_at: string | null;
|
||||
restarted_at: string | null;
|
||||
attempts: number;
|
||||
error: string | null;
|
||||
deployment_id: string; server: string; files_changed: number;
|
||||
restart_state: string; players: number | null;
|
||||
checked_at: string | null; restarted_at: string | null;
|
||||
attempts: number; error: string | null;
|
||||
}
|
||||
interface Detail {
|
||||
deployment: {
|
||||
id: string;
|
||||
action: string;
|
||||
started_at: string;
|
||||
finished_at: string | null;
|
||||
triggered_by: string | null;
|
||||
id: string; action: string; started_at: string;
|
||||
finished_at: string | null; triggered_by: string | null;
|
||||
};
|
||||
servers: ServerRow[];
|
||||
files: FileRow[];
|
||||
@@ -60,8 +53,7 @@
|
||||
openFile = { id: f.id, ...body };
|
||||
}
|
||||
|
||||
// Group files by server for the layout
|
||||
let byServer = $derived(() => {
|
||||
let byServer = $derived.by(() => {
|
||||
if (!detail) return new Map<string, FileRow[]>();
|
||||
const m = new Map<string, FileRow[]>();
|
||||
for (const f of detail.files) {
|
||||
@@ -70,203 +62,295 @@
|
||||
}
|
||||
return m;
|
||||
});
|
||||
|
||||
function stateVariant(s: string): 'online' | 'danger' | 'warning' | 'info' | 'neutral' {
|
||||
return s === 'done' ? 'online' :
|
||||
s === 'failed' ? 'danger' :
|
||||
s === 'pending' ? 'warning' :
|
||||
s === 'held' ? 'info' :
|
||||
'neutral';
|
||||
}
|
||||
function verbVariant(v: string): 'online' | 'info' | 'danger' | 'warning' | 'neutral' {
|
||||
return v === 'added' ? 'online' :
|
||||
v === 'updated' ? 'info' :
|
||||
v === 'removed' ? 'danger' :
|
||||
v === 'held' ? 'warning' :
|
||||
'neutral';
|
||||
}
|
||||
function fmt(iso: string | null): string {
|
||||
if (!iso) return '—';
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleString(undefined, {
|
||||
month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if detail}
|
||||
<h1>{detail.deployment.action}</h1>
|
||||
<p class="meta">
|
||||
started {detail.deployment.started_at}
|
||||
{#if detail.deployment.finished_at} · finished {detail.deployment.finished_at}{/if}
|
||||
· <code>{detail.deployment.id}</code>
|
||||
</p>
|
||||
{@const action = detail.deployment.action}
|
||||
<div class="page">
|
||||
<SectionHeader title={action} subtitle={detail.deployment.id}>
|
||||
{#snippet crumbs()}
|
||||
<Breadcrumbs items={[
|
||||
{ label: 'Deployments', href: '/deployments' },
|
||||
{ label: action }
|
||||
]} />
|
||||
{/snippet}
|
||||
</SectionHeader>
|
||||
|
||||
<h2>Servers</h2>
|
||||
<div class="server-grid">
|
||||
{#each detail.servers as s (s.server)}
|
||||
<div class="srv srv-{s.restart_state}">
|
||||
<div class="name">{s.server}</div>
|
||||
<div class="line">state: {s.restart_state}</div>
|
||||
{#if s.players !== null}<div class="line">players: {s.players}</div>{/if}
|
||||
{#if s.error}<div class="line err">{s.error}</div>{/if}
|
||||
{#if s.restarted_at}<div class="line dim">restarted {s.restarted_at}</div>{/if}
|
||||
<div class="line dim">attempts: {s.attempts}</div>
|
||||
<Card padding="lg">
|
||||
<div class="meta-grid">
|
||||
<div class="kv"><span class="k">Started</span><span class="v mono">{fmt(detail.deployment.started_at)}</span></div>
|
||||
<div class="kv"><span class="k">Finished</span><span class="v mono">{fmt(detail.deployment.finished_at)}</span></div>
|
||||
<div class="kv"><span class="k">Triggered by</span><span class="v mono">{detail.deployment.triggered_by ?? '—'}</span></div>
|
||||
<div class="kv"><span class="k">Servers</span><span class="v mono">{detail.servers.length}</span></div>
|
||||
</div>
|
||||
{/each}
|
||||
</Card>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Servers</h2>
|
||||
<Badge variant="neutral" size="sm">{detail.servers.length}</Badge>
|
||||
</div>
|
||||
<div class="server-list">
|
||||
{#each detail.servers as s (s.server)}
|
||||
<div class="srv-row">
|
||||
<div class="srv-l">
|
||||
<a class="srv-name" href="/servers/{s.server}">{s.server}</a>
|
||||
{#if s.error}
|
||||
<span class="err">{s.error}</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="srv-r">
|
||||
<Badge variant={stateVariant(s.restart_state)} size="sm" uppercase>{s.restart_state}</Badge>
|
||||
{#if s.players !== null && s.players > 0}
|
||||
<span class="players">{s.players}p</span>
|
||||
{/if}
|
||||
<span class="attempts">{s.attempts} attempt{s.attempts === 1 ? '' : 's'}</span>
|
||||
{#if s.restarted_at}
|
||||
<span class="when">restarted {fmt(s.restarted_at)}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>Files</h2>
|
||||
<Badge variant="neutral" size="sm">{detail.files.length}</Badge>
|
||||
</div>
|
||||
{#if detail.files.length === 0}
|
||||
<EmptyState title="No file changes recorded" description="This deployment didn't touch any tracked artifacts." />
|
||||
{:else}
|
||||
{#each [...byServer.entries()] as [srv, files] (srv)}
|
||||
<div class="file-group">
|
||||
<h3>{srv}</h3>
|
||||
<div class="file-rows">
|
||||
{#each files as f (f.id)}
|
||||
<button class="file-row" onclick={() => loadDiff(f)}>
|
||||
<Badge variant={verbVariant(f.verb)} size="sm" uppercase>{f.verb}</Badge>
|
||||
<span class="path">{f.rel_path}</span>
|
||||
<span class="sizes">
|
||||
{#if f.size_before !== null}{f.size_before} B{/if}
|
||||
{#if f.size_before !== null && f.size_after !== null} → {/if}
|
||||
{#if f.size_after !== null}{f.size_after} B{/if}
|
||||
</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
{#if openFile}
|
||||
<div
|
||||
class="diff-scrim"
|
||||
onclick={() => (openFile = null)}
|
||||
onkeydown={(e) => { if (e.key === 'Escape') openFile = null; }}
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
aria-label="Close diff"
|
||||
>
|
||||
<div class="diff-modal" onclick={(e) => e.stopPropagation()} role="none">
|
||||
<div class="diff-head">
|
||||
<span class="diff-title">{openFile.relPath}</span>
|
||||
<Button variant="ghost" size="sm" onclick={() => (openFile = null)}>Close</Button>
|
||||
</div>
|
||||
<DiffViewer
|
||||
before={openFile.before}
|
||||
after={openFile.after}
|
||||
verb={openFile.verb}
|
||||
relPath={openFile.relPath}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<h2>Files</h2>
|
||||
{#each [...byServer().entries()] as [srv, files] (srv)}
|
||||
<div class="file-group">
|
||||
<h3>{srv}</h3>
|
||||
{#each files as f (f.id)}
|
||||
<button class="file-row" onclick={() => loadDiff(f)}>
|
||||
<span class="verb verb-{f.verb}">{f.verb}</span>
|
||||
<code>{f.rel_path}</code>
|
||||
<span class="sizes">
|
||||
{#if f.size_before !== null}{f.size_before}b{/if}
|
||||
{#if f.size_before !== null && f.size_after !== null} → {/if}
|
||||
{#if f.size_after !== null}{f.size_after}b{/if}
|
||||
</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
{#if openFile}
|
||||
<div class="diff-scrim" onclick={() => (openFile = null)} onkeydown={(e) => { if (e.key === 'Escape') openFile = null; }} role="button" tabindex="-1">
|
||||
<div class="diff-modal" onclick={(e) => e.stopPropagation()} role="none">
|
||||
<button class="close" onclick={() => (openFile = null)}>close</button>
|
||||
<DiffViewer before={openFile.before} after={openFile.after} verb={openFile.verb} relPath={openFile.relPath} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<p class="empty">loading…</p>
|
||||
<div class="loading">Loading…</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
h1 {
|
||||
color: var(--cream);
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-2xl);
|
||||
letter-spacing: 1.5px;
|
||||
line-height: var(--leading-tight);
|
||||
margin: 0 0 8px;
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-8);
|
||||
}
|
||||
h2 {
|
||||
margin: var(--gap-section) 0 14px;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1.5px;
|
||||
color: var(--ink-300);
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: var(--space-16);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
h3 {
|
||||
margin: 18px 0 8px;
|
||||
font-size: var(--text-md);
|
||||
color: var(--cream);
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
.meta {
|
||||
color: var(--ink-500);
|
||||
font-size: var(--text-mono);
|
||||
margin: 0 0 28px;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
.server-grid {
|
||||
|
||||
.meta-grid {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.srv {
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 16px;
|
||||
.kv {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: var(--surface-sunken);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.srv-done { border-color: rgba(124, 212, 255, 0.35); }
|
||||
.srv-failed { border-color: rgba(255, 48, 80, 0.35); }
|
||||
.srv-pending { border-color: rgba(255, 176, 32, 0.35); }
|
||||
.srv-held { border-color: rgba(124, 192, 245, 0.3); }
|
||||
.srv-manual { border-color: var(--ink-500); }
|
||||
.name {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
color: var(--cream);
|
||||
.kv .k {
|
||||
font-size: var(--text-xs);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: var(--tracking-label);
|
||||
color: var(--text-tertiary);
|
||||
font-weight: var(--weight-semibold);
|
||||
}
|
||||
.kv .v { font-size: var(--text-sm); color: var(--text-primary); }
|
||||
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.section-head h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.line { font-size: var(--text-mono); color: var(--ink-300); font-family: var(--font-mono); line-height: var(--leading-mono); }
|
||||
.line.dim { color: var(--ink-500); }
|
||||
.line.err { color: var(--danger-500); }
|
||||
.file-group { margin-bottom: 20px; }
|
||||
|
||||
.server-list { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.srv-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.srv-l { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; }
|
||||
.srv-r { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
|
||||
.srv-name {
|
||||
font-family: var(--font-body);
|
||||
font-weight: var(--weight-semibold);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
}
|
||||
.srv-name:hover { color: var(--accent-primary-hover); }
|
||||
.err { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--state-danger); }
|
||||
.players { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--state-online); }
|
||||
.attempts, .when {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
}
|
||||
|
||||
.file-group {
|
||||
margin-top: var(--space-4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.file-group h3 {
|
||||
margin: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-secondary);
|
||||
font-weight: var(--weight-medium);
|
||||
}
|
||||
.file-rows { display: flex; flex-direction: column; gap: 2px; }
|
||||
.file-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
gap: var(--space-3);
|
||||
width: 100%;
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 8px 12px;
|
||||
margin: 4px 0;
|
||||
color: var(--ink-100);
|
||||
text-align: left;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
background: transparent;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
transition: border-color 0.15s;
|
||||
transition: background-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.file-row:hover { border-color: var(--accent); }
|
||||
.verb {
|
||||
padding: 3px 9px;
|
||||
border-radius: var(--r-sm);
|
||||
font-size: var(--text-xs);
|
||||
.file-row:hover { background: var(--surface-raised); }
|
||||
.file-row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
.path {
|
||||
font-family: var(--font-mono);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.8px;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.verb-added {
|
||||
background: rgba(124, 212, 255, 0.10);
|
||||
border-color: rgba(124, 212, 255, 0.3);
|
||||
color: var(--spark-500);
|
||||
}
|
||||
.verb-updated {
|
||||
background: rgba(124, 192, 245, 0.10);
|
||||
border-color: rgba(124, 192, 245, 0.28);
|
||||
color: var(--cream);
|
||||
}
|
||||
.verb-removed {
|
||||
background: rgba(255, 48, 80, 0.1);
|
||||
border-color: rgba(255, 48, 80, 0.3);
|
||||
color: var(--danger-500);
|
||||
}
|
||||
.verb-held {
|
||||
background: rgba(255, 176, 32, 0.1);
|
||||
border-color: rgba(255, 176, 32, 0.3);
|
||||
color: var(--amber-500);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-primary);
|
||||
word-break: break-all;
|
||||
}
|
||||
.sizes {
|
||||
margin-left: auto;
|
||||
color: var(--ink-500);
|
||||
font-size: var(--text-mono-sm);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--text-tertiary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
code { font-family: var(--font-mono); color: var(--ink-100); font-size: var(--text-mono); }
|
||||
.empty {
|
||||
color: var(--ink-500);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-base);
|
||||
}
|
||||
|
||||
/* Diff modal */
|
||||
.diff-scrim {
|
||||
position: fixed; inset: 0;
|
||||
background: rgba(6, 11, 22, 0.85);
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
z-index: 100;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
backdrop-filter: blur(4px);
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
}
|
||||
.diff-modal {
|
||||
max-width: 1000px;
|
||||
width: 92%;
|
||||
width: min(1000px, 92vw);
|
||||
max-height: 92vh;
|
||||
overflow: auto;
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-md);
|
||||
padding: var(--pad-panel);
|
||||
box-shadow: var(--shadow-panel);
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--space-6);
|
||||
box-shadow: var(--shadow-raised);
|
||||
}
|
||||
.close {
|
||||
float: right;
|
||||
background: var(--bg-card);
|
||||
color: var(--ink-100);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 6px 14px;
|
||||
font-family: var(--font-body);
|
||||
.diff-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-4);
|
||||
padding-bottom: var(--space-3);
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
.diff-title {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-sm);
|
||||
cursor: pointer;
|
||||
color: var(--text-primary);
|
||||
word-break: break-all;
|
||||
}
|
||||
.close:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
</style>
|
||||
|
||||
+168
-151
@@ -1,8 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
import Field from '$ui/components/primitives/Field.svelte';
|
||||
import Input from '$ui/components/primitives/Input.svelte';
|
||||
import Select from '$ui/components/primitives/Select.svelte';
|
||||
|
||||
type ArtifactKind = 'script' | 'config' | 'plugin' | 'baseline';
|
||||
|
||||
interface ArtifactRow {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -12,22 +19,14 @@
|
||||
current_version_id: number | null;
|
||||
kind: ArtifactKind;
|
||||
latestVersion: {
|
||||
id: number;
|
||||
version: number;
|
||||
sha256: string;
|
||||
size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed';
|
||||
uploaded_at: string;
|
||||
id: number; version: number; sha256: string; size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed'; uploaded_at: string;
|
||||
} | null;
|
||||
versionCount: number;
|
||||
servers: string[];
|
||||
runningBetaId: number | null;
|
||||
}
|
||||
|
||||
interface ScopeOptions {
|
||||
games: string[];
|
||||
mapsByGame: Record<string, string[]>;
|
||||
}
|
||||
interface ScopeOptions { games: string[]; mapsByGame: Record<string, string[]>; }
|
||||
|
||||
let plugins = $state<ArtifactRow[]>([]);
|
||||
let loading = $state(true);
|
||||
@@ -56,7 +55,7 @@
|
||||
fetch('/api/scope-options')
|
||||
]);
|
||||
if (!pluginRes.ok) {
|
||||
flash = `plugins API returned ${pluginRes.status}. If this is a dev environment, restart the server so the DB migration runs.`;
|
||||
flash = `Plugins API returned ${pluginRes.status}. If this is a dev environment, restart the server so the DB migration runs.`;
|
||||
plugins = [];
|
||||
} else {
|
||||
plugins = ((await pluginRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? [];
|
||||
@@ -65,12 +64,11 @@
|
||||
scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? { games: [], mapsByGame: {} };
|
||||
}
|
||||
} catch (err) {
|
||||
flash = `failed to load plugins: ${(err as Error).message}`;
|
||||
flash = `Failed to load plugins: ${(err as Error).message}`;
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
|
||||
function pickFile(e: Event): void {
|
||||
@@ -82,9 +80,8 @@
|
||||
async function createPlugin(e: Event): Promise<void> {
|
||||
e.preventDefault();
|
||||
if (uploading || !newFile || !newName.trim()) return;
|
||||
if (newScopeType !== 'none' && !scopeValue) { flash = `pick a ${newScopeType}`; return; }
|
||||
uploading = true;
|
||||
flash = null;
|
||||
if (newScopeType !== 'none' && !scopeValue) { flash = `Pick a ${newScopeType}`; return; }
|
||||
uploading = true; flash = null;
|
||||
const form = new FormData();
|
||||
form.append('name', newName.trim());
|
||||
form.append('kind', 'plugin');
|
||||
@@ -108,153 +105,173 @@
|
||||
|
||||
function scopeLabel(a: ArtifactRow): string {
|
||||
if (!a.scope_type) return 'unscoped';
|
||||
return `${a.scope_type}=${a.scope_value ?? '?'}`;
|
||||
return `${a.scope_type} · ${a.scope_value ?? '?'}`;
|
||||
}
|
||||
|
||||
function stateTag(a: ArtifactRow): { label: string; cls: string } | null {
|
||||
function stateVariantFor(a: ArtifactRow): 'online' | 'warning' | 'danger' | 'neutral' | null {
|
||||
if (!a.latestVersion) return null;
|
||||
if (a.current_version_id === null) return { label: 'untested', cls: 'state-untested' };
|
||||
if (a.current_version_id === null) return 'neutral';
|
||||
if (a.latestVersion.id !== a.current_version_id) {
|
||||
return { label: `v${a.latestVersion.version} ${a.latestVersion.state}`, cls: `state-${a.latestVersion.state}` };
|
||||
if (a.latestVersion.state === 'untested') return 'neutral';
|
||||
if (a.latestVersion.state === 'tested') return 'online';
|
||||
if (a.latestVersion.state === 'test-failed') return 'danger';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function stateLabel(a: ArtifactRow): string {
|
||||
if (!a.latestVersion) return '';
|
||||
if (a.current_version_id === null) return 'untested';
|
||||
if (a.latestVersion.id !== a.current_version_id) {
|
||||
return `v${a.latestVersion.version} ${a.latestVersion.state.replace('-', ' ')}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
let gameOptions = $derived([
|
||||
{ value: '', label: '— Pick a game —', disabled: true },
|
||||
...scopeOptions.games.map((g) => ({ value: g, label: g }))
|
||||
]);
|
||||
let mapOptions = $derived([
|
||||
{ value: '', label: '— Pick a map —', disabled: true },
|
||||
...(scopeOptions.mapsByGame[newScopeGame] ?? []).map((m) => ({ value: m, label: m }))
|
||||
]);
|
||||
let scopeTypeOptions = [
|
||||
{ value: 'none', label: 'Unscoped' },
|
||||
{ value: 'game', label: 'Game' },
|
||||
{ value: 'map', label: 'Map' }
|
||||
];
|
||||
</script>
|
||||
|
||||
<h1>Plugins</h1>
|
||||
<div class="page">
|
||||
<SectionHeader title="Plugins" subtitle="Native game plugins deployed alongside scripts." />
|
||||
|
||||
<section class="panel">
|
||||
<h2>Upload a plugin</h2>
|
||||
{#if successBanner}
|
||||
<div class="banner banner-info">
|
||||
<strong>v{successBanner.version} of "{successBanner.name}" uploaded — untested.</strong>
|
||||
<span>Open a beta on <a href="/betas">the betas page</a> to test it before it can be promoted.</span>
|
||||
</div>
|
||||
{/if}
|
||||
<form onsubmit={createPlugin} class="upload-form">
|
||||
<label>
|
||||
<span class="k">name</span>
|
||||
<input type="text" bind:value={newName} placeholder="my plugin" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">scope</span>
|
||||
<div class="scope-row">
|
||||
<select bind:value={newScopeType} disabled={uploading}>
|
||||
<option value="none">unscoped</option>
|
||||
<option value="game">game</option>
|
||||
<option value="map">map</option>
|
||||
</select>
|
||||
{#if newScopeType === 'game'}
|
||||
<select bind:value={newScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else if newScopeType === 'map'}
|
||||
<select bind:value={newScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<select bind:value={newScopeMap} disabled={uploading || !newScopeGame}>
|
||||
<option value="">— pick a map —</option>
|
||||
{#each (scopeOptions.mapsByGame[newScopeGame] ?? []) as m (m)}
|
||||
<option value={m}>{m}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{/if}
|
||||
<Card padding="lg">
|
||||
<h2 class="panel-title">Upload a plugin</h2>
|
||||
{#if successBanner}
|
||||
<div class="banner">
|
||||
<strong>v{successBanner.version} of "{successBanner.name}" uploaded — untested.</strong>
|
||||
<span>Open a beta on <a href="/betas">the betas page</a> to test it before promotion.</span>
|
||||
</div>
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">notes (optional)</span>
|
||||
<input type="text" bind:value={newNotes} placeholder="what changed" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">plugin file (.dll)</span>
|
||||
<input type="file" accept=".dll" onchange={pickFile} disabled={uploading} />
|
||||
</label>
|
||||
<button type="submit" class="primary" disabled={uploading || !newFile || !newName}>
|
||||
{uploading ? 'uploading…' : 'upload plugin'}
|
||||
</button>
|
||||
</form>
|
||||
{#if flash}<p class="flash">{flash}</p>{/if}
|
||||
</section>
|
||||
{/if}
|
||||
<form onsubmit={createPlugin} class="upload-form">
|
||||
<Field label="Name">
|
||||
<Input bind:value={newName} placeholder="my plugin" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Notes" hint="Optional. What changed in this version.">
|
||||
<Input bind:value={newNotes} placeholder="what changed" disabled={uploading} />
|
||||
</Field>
|
||||
<Field label="Scope" hint="Where this plugin deploys.">
|
||||
<div class="scope-row">
|
||||
<Select bind:value={newScopeType} options={scopeTypeOptions} disabled={uploading} />
|
||||
{#if newScopeType === 'game' || newScopeType === 'map'}
|
||||
<Select bind:value={newScopeGame} options={gameOptions} disabled={uploading} />
|
||||
{/if}
|
||||
{#if newScopeType === 'map'}
|
||||
<Select bind:value={newScopeMap} options={mapOptions} disabled={uploading || !newScopeGame} />
|
||||
{/if}
|
||||
</div>
|
||||
</Field>
|
||||
<Field label="Plugin file (.dll)">
|
||||
<Input type="file" accept=".dll" onchange={pickFile} disabled={uploading} />
|
||||
</Field>
|
||||
<div class="form-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={uploading || !newFile || !newName}
|
||||
loading={uploading}
|
||||
>
|
||||
Upload plugin
|
||||
</Button>
|
||||
{#if flash}<span class="flash">{flash}</span>{/if}
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
<section class="panel">
|
||||
<h2>All plugins</h2>
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
{:else if plugins.length === 0}
|
||||
<p class="empty">no plugins yet — upload one above</p>
|
||||
{:else}
|
||||
<div class="artifacts">
|
||||
{#each plugins as a (a.id)}
|
||||
<a class="artifact-row" href="/plugins/{a.id}">
|
||||
<div class="row-top">
|
||||
<span class="artifact-name">{a.name}</span>
|
||||
<span class="scope tag scope-{a.scope_type ?? 'none'}">{scopeLabel(a)}</span>
|
||||
{#if stateTag(a)}
|
||||
{@const t = stateTag(a)!}
|
||||
<span class="tag {t.cls}">{t.label}</span>
|
||||
{/if}
|
||||
{#if a.runningBetaId}
|
||||
<span class="tag beta">beta {a.runningBetaId} running</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta mono">
|
||||
<span>{a.target_rel_path}</span>
|
||||
<span>v{a.latestVersion?.version ?? '—'} · {a.versionCount} version{a.versionCount === 1 ? '' : 's'}</span>
|
||||
<span>{a.servers.length ? `${a.servers.length} matching server${a.servers.length === 1 ? '' : 's'}` : ''}</span>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>All plugins</h2>
|
||||
<Badge variant="neutral" size="sm">{plugins.length}</Badge>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else if plugins.length === 0}
|
||||
<EmptyState title="No plugins yet" description="Upload one above to get started." />
|
||||
{:else}
|
||||
<div class="rows">
|
||||
{#each plugins as a (a.id)}
|
||||
<a class="row" href="/plugins/{a.id}">
|
||||
<div class="row-top">
|
||||
<span class="name">{a.name}</span>
|
||||
<Badge
|
||||
variant={a.scope_type === 'game' ? 'info' : a.scope_type === 'map' ? 'warning' : 'neutral'}
|
||||
size="sm"
|
||||
>
|
||||
{scopeLabel(a)}
|
||||
</Badge>
|
||||
{#if stateVariantFor(a)}
|
||||
{@const v = stateVariantFor(a)!}
|
||||
<Badge variant={v} size="sm">{stateLabel(a)}</Badge>
|
||||
{/if}
|
||||
{#if a.runningBetaId}
|
||||
<Badge variant="warning" size="sm">β{a.runningBetaId} running</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta">
|
||||
<span class="path">{a.target_rel_path}</span>
|
||||
<span>v{a.latestVersion?.version ?? '—'} · {a.versionCount} version{a.versionCount === 1 ? '' : 's'}</span>
|
||||
{#if a.servers.length}
|
||||
<span>{a.servers.length} matching server{a.servers.length === 1 ? '' : 's'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
h1 { color: var(--cream); font-family: var(--font-display); font-size: var(--text-3xl); letter-spacing: var(--tracking-display); line-height: var(--leading-tight); margin: 0 0 28px; }
|
||||
.panel { background: var(--bg-nav); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--pad-panel); margin-bottom: 20px; }
|
||||
h2 { margin: 0 0 14px; font-family: var(--font-body); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-300); }
|
||||
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono); margin: 0; }
|
||||
.upload-form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
|
||||
.upload-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); }
|
||||
.upload-form label .k { color: var(--ink-500); text-transform: uppercase; letter-spacing: 1px; }
|
||||
.upload-form input[type=text], .upload-form select, .upload-form input[type=file] {
|
||||
background: var(--bg-page); color: var(--ink-100); border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--font-mono); font-size: var(--text-mono);
|
||||
.page { display: flex; flex-direction: column; gap: var(--space-6); }
|
||||
.loading { text-align: center; padding: var(--space-12); color: var(--text-tertiary); }
|
||||
|
||||
.panel-title { margin: 0 0 var(--space-4); font-family: var(--font-body); font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); }
|
||||
.banner {
|
||||
display: flex; flex-direction: column; gap: 4px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
margin-bottom: var(--space-4);
|
||||
background: rgba(124, 212, 255, 0.06);
|
||||
border: 1px solid rgba(124, 212, 255, 0.22);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
.upload-form input[type=text]:focus, .upload-form select:focus {
|
||||
outline: none; border-color: var(--accent); box-shadow: var(--accent-glow);
|
||||
.banner a { color: var(--state-online); text-decoration: underline; }
|
||||
|
||||
.upload-form { display: grid; gap: var(--space-4); grid-template-columns: 1fr 1fr; }
|
||||
.scope-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
|
||||
.scope-row :global(.wrap) { flex: 1 1 140px; min-width: 140px; }
|
||||
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-4); }
|
||||
.flash { color: var(--state-danger); font-family: var(--font-mono); font-size: var(--text-xs); }
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.section-head { display: flex; align-items: center; gap: var(--space-3); }
|
||||
.section-head h2 { margin: 0; font-family: var(--font-body); font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); }
|
||||
|
||||
.rows { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.row {
|
||||
display: flex; flex-direction: column; gap: var(--space-2);
|
||||
padding: var(--space-4) var(--space-5);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary); text-decoration: none;
|
||||
transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.scope-row { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.scope-row select:nth-of-type(1) { flex: 0 0 120px; }
|
||||
.scope-row select:nth-of-type(2), .scope-row select:nth-of-type(3) { flex: 1; }
|
||||
.primary {
|
||||
grid-column: 1 / -1; background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
|
||||
border: 1px solid var(--blue-400); border-radius: var(--r-sm); padding: 12px 18px;
|
||||
color: var(--cream); font-family: var(--font-body); font-weight: 600; cursor: pointer;
|
||||
}
|
||||
.primary:disabled { opacity: 0.4; cursor: default; }
|
||||
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
|
||||
.artifacts { display: flex; flex-direction: column; gap: 8px; }
|
||||
.artifact-row { display: flex; flex-direction: column; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px 16px; text-decoration: none; color: var(--ink-100); }
|
||||
.artifact-row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
.row-top { display: flex; gap: 12px; align-items: center; }
|
||||
.artifact-name { color: var(--cream); font-weight: 600; font-size: var(--text-md); }
|
||||
.row-meta { display: flex; gap: 24px; color: var(--ink-500); font-size: var(--text-mono-sm); }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
.tag { font-family: var(--font-mono); font-size: var(--text-xs); padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid transparent; }
|
||||
.scope-none { background: var(--bg-nav); border-color: var(--border); color: var(--ink-500); }
|
||||
.scope-game { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
|
||||
.scope-map { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.35); color: var(--amber-500); }
|
||||
.beta { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.3); color: var(--amber-500); }
|
||||
.state-untested { background: var(--bg-nav); border-color: var(--border); color: var(--ink-300); }
|
||||
.state-tested { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
|
||||
.state-test-failed { background: rgba(255, 92, 92, 0.10); border-color: rgba(255, 92, 92, 0.4); color: var(--danger-500); }
|
||||
.banner { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 12px; font-size: var(--text-mono); }
|
||||
.banner-info { background: rgba(124, 212, 255, 0.08); border: 1px solid rgba(124, 212, 255, 0.28); color: var(--ink-100); }
|
||||
.banner-info a { color: var(--spark-500); text-decoration: underline; }
|
||||
.row:hover { background: var(--surface-raised); border-color: var(--border-strong); }
|
||||
.row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
.row-top { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
|
||||
.name { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary); letter-spacing: var(--tracking-tight); }
|
||||
.row-meta { display: flex; gap: var(--space-5); color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--text-xs); flex-wrap: wrap; }
|
||||
.path { color: var(--text-secondary); }
|
||||
|
||||
@media (max-width: 720px) { .upload-form { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
|
||||
+256
-263
@@ -1,5 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import Card from '$ui/components/primitives/Card.svelte';
|
||||
import Badge from '$ui/components/primitives/Badge.svelte';
|
||||
import Button from '$ui/components/primitives/Button.svelte';
|
||||
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
|
||||
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
|
||||
import Field from '$ui/components/primitives/Field.svelte';
|
||||
import Input from '$ui/components/primitives/Input.svelte';
|
||||
import Select from '$ui/components/primitives/Select.svelte';
|
||||
|
||||
interface ScriptRow {
|
||||
id: number;
|
||||
@@ -10,22 +18,14 @@
|
||||
current_version_id: number | null;
|
||||
kind: 'script' | 'config' | 'plugin' | 'baseline';
|
||||
latestVersion: {
|
||||
id: number;
|
||||
version: number;
|
||||
sha256: string;
|
||||
size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed';
|
||||
uploaded_at: string;
|
||||
id: number; version: number; sha256: string; size: number;
|
||||
state: 'untested' | 'tested' | 'test-failed'; uploaded_at: string;
|
||||
} | null;
|
||||
versionCount: number;
|
||||
servers: string[];
|
||||
runningBetaId: number | null;
|
||||
}
|
||||
|
||||
interface ScopeOptions {
|
||||
games: string[];
|
||||
mapsByGame: Record<string, string[]>;
|
||||
}
|
||||
interface ScopeOptions { games: string[]; mapsByGame: Record<string, string[]>; }
|
||||
|
||||
let scripts = $state<ScriptRow[]>([]);
|
||||
let loading = $state(true);
|
||||
@@ -34,7 +34,6 @@
|
||||
let scopeOptions = $state<ScopeOptions>({ games: [], mapsByGame: {} });
|
||||
let successBanner = $state<{ name: string; scriptId: number; version: number } | null>(null);
|
||||
|
||||
// Form state for creating a new script.
|
||||
let newName = $state('');
|
||||
let newScopeType = $state<'none' | 'game' | 'map'>('none');
|
||||
let newScopeGame = $state('');
|
||||
@@ -42,37 +41,20 @@
|
||||
let newFile = $state<File | null>(null);
|
||||
let newNotes = $state('');
|
||||
|
||||
// The scope value we send to the API — computed from the two selects so
|
||||
// scope=map ships the map (game is just a filter narrowing the map list).
|
||||
const scopeValue = $derived.by(() => {
|
||||
if (newScopeType === 'game') return newScopeGame;
|
||||
if (newScopeType === 'map') return newScopeMap;
|
||||
return '';
|
||||
});
|
||||
|
||||
// Live preview: which servers would this script land on? Empty when the
|
||||
// scope matches nothing OR when scope=none (unscoped scripts only push to
|
||||
// explicitly-chosen beta targets, so there's no promotion audience yet).
|
||||
let serverCache = $state<Array<{ name: string; game: string | null; map: string | null }>>([]);
|
||||
const matchingServers = $derived.by(() => {
|
||||
if (newScopeType === 'none') return null;
|
||||
if (!scopeValue) return null;
|
||||
// scope-options carries fleet distincts, but not the (server → game/map)
|
||||
// mapping. We derive the count by checking every server in `scripts`
|
||||
// list responses — instead, use the /api/servers list. For simplicity
|
||||
// we call a scoped preview against the API on the fly. Cheaper: reuse
|
||||
// scope options — but we don't have server names. Fetch servers once.
|
||||
return matchingServersFromCache();
|
||||
});
|
||||
|
||||
let serverCache = $state<Array<{ name: string; game: string | null; map: string | null }>>([]);
|
||||
function matchingServersFromCache(): string[] {
|
||||
return serverCache
|
||||
.filter((s) => {
|
||||
const field = newScopeType === 'game' ? s.game : s.map;
|
||||
return field === scopeValue;
|
||||
})
|
||||
.filter((s) => (newScopeType === 'game' ? s.game : s.map) === scopeValue)
|
||||
.map((s) => s.name);
|
||||
}
|
||||
});
|
||||
|
||||
async function load(): Promise<void> {
|
||||
const [scriptsRes, scopeRes, serversRes] = await Promise.all([
|
||||
@@ -87,27 +69,22 @@
|
||||
serverCache = sBody.servers;
|
||||
loading = false;
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
|
||||
function pickFile(e: Event): void {
|
||||
const t = e.target as HTMLInputElement;
|
||||
newFile = t.files?.[0] ?? null;
|
||||
// Every T5 script lands in a flat sp/ directory, so target rel path is
|
||||
// just the filename — no need to ask the user.
|
||||
if (!newName && newFile) newName = newFile.name.replace(/\.[^.]+$/, '');
|
||||
}
|
||||
|
||||
async function createScript(e: Event): Promise<void> {
|
||||
e.preventDefault();
|
||||
if (uploading || !newFile || !newName.trim()) return;
|
||||
// Guard: scope was set but no value picked yet.
|
||||
if (newScopeType !== 'none' && !scopeValue) {
|
||||
flash = `pick a ${newScopeType}`;
|
||||
flash = `Pick a ${newScopeType}`;
|
||||
return;
|
||||
}
|
||||
uploading = true;
|
||||
flash = null;
|
||||
uploading = true; flash = null;
|
||||
const form = new FormData();
|
||||
form.append('name', newName.trim());
|
||||
form.append('scopeType', newScopeType);
|
||||
@@ -117,8 +94,7 @@
|
||||
try {
|
||||
const res = await fetch('/api/scripts', { method: 'POST', body: form });
|
||||
const body = (await res.json()) as {
|
||||
ok: boolean;
|
||||
error?: string;
|
||||
ok: boolean; error?: string;
|
||||
script?: { id: number; name: string };
|
||||
versionId?: number;
|
||||
};
|
||||
@@ -129,12 +105,9 @@
|
||||
successBanner = body.script
|
||||
? { name: body.script.name, scriptId: body.script.id, version: 1 }
|
||||
: null;
|
||||
newName = '';
|
||||
newScopeType = 'none';
|
||||
newScopeGame = '';
|
||||
newScopeMap = '';
|
||||
newNotes = '';
|
||||
newFile = null;
|
||||
newName = ''; newScopeType = 'none';
|
||||
newScopeGame = ''; newScopeMap = '';
|
||||
newNotes = ''; newFile = null;
|
||||
await load();
|
||||
} finally {
|
||||
uploading = false;
|
||||
@@ -143,251 +116,271 @@
|
||||
|
||||
function scopeLabel(s: ScriptRow): string {
|
||||
if (!s.scope_type) return 'unscoped';
|
||||
return `${s.scope_type}=${s.scope_value ?? '?'}`;
|
||||
return `${s.scope_type} · ${s.scope_value ?? '?'}`;
|
||||
}
|
||||
|
||||
// Configs/baselines and plugins have their own detail routes; scripts fall
|
||||
// through to /scripts/{id}. The "all scripts" list is still an everything
|
||||
// view, but each row deep-links to the right family.
|
||||
function detailHref(s: ScriptRow): string {
|
||||
if (s.kind === 'config' || s.kind === 'baseline') return `/configs/${s.id}`;
|
||||
if (s.kind === 'plugin') return `/plugins/${s.id}`;
|
||||
return `/scripts/${s.id}`;
|
||||
}
|
||||
|
||||
// What state tag to show on a script row. Distinguishes "never promoted"
|
||||
// (whole script is untested) from "promoted but has a newer untested
|
||||
// version" (existing production is fine, but there's unreleased work).
|
||||
function scriptStateTag(s: ScriptRow): { label: string; cls: string } | null {
|
||||
function stateVariantFor(s: ScriptRow): 'online' | 'warning' | 'danger' | 'neutral' | null {
|
||||
if (!s.latestVersion) return null;
|
||||
if (s.current_version_id === null) return { label: 'untested', cls: 'state-untested' };
|
||||
if (s.current_version_id === null) return 'neutral';
|
||||
if (s.latestVersion.id !== s.current_version_id) {
|
||||
if (s.latestVersion.state === 'untested') return { label: `v${s.latestVersion.version} untested`, cls: 'state-untested' };
|
||||
if (s.latestVersion.state === 'tested') return { label: `v${s.latestVersion.version} tested`, cls: 'state-tested' };
|
||||
if (s.latestVersion.state === 'test-failed') return { label: `v${s.latestVersion.version} test-failed`, cls: 'state-test-failed' };
|
||||
if (s.latestVersion.state === 'untested') return 'neutral';
|
||||
if (s.latestVersion.state === 'tested') return 'online';
|
||||
if (s.latestVersion.state === 'test-failed') return 'danger';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function stateLabel(s: ScriptRow): string {
|
||||
if (!s.latestVersion) return '';
|
||||
if (s.current_version_id === null) return 'untested';
|
||||
if (s.latestVersion.id !== s.current_version_id) {
|
||||
return `v${s.latestVersion.version} ${s.latestVersion.state.replace('-', ' ')}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
let gameOptions = $derived([
|
||||
{ value: '', label: '— Pick a game —', disabled: true },
|
||||
...scopeOptions.games.map((g) => ({ value: g, label: g }))
|
||||
]);
|
||||
let mapOptions = $derived([
|
||||
{ value: '', label: '— Pick a map —', disabled: true },
|
||||
...(scopeOptions.mapsByGame[newScopeGame] ?? []).map((m) => ({ value: m, label: m }))
|
||||
]);
|
||||
let scopeTypeOptions = [
|
||||
{ value: 'none', label: 'Unscoped' },
|
||||
{ value: 'game', label: 'Game' },
|
||||
{ value: 'map', label: 'Map' }
|
||||
];
|
||||
</script>
|
||||
|
||||
<h1>Scripts</h1>
|
||||
<div class="page">
|
||||
<SectionHeader title="Scripts" subtitle="Upload a script, then open a beta to test it before promotion." />
|
||||
|
||||
<section class="panel">
|
||||
<h2>Upload a script</h2>
|
||||
{#if successBanner}
|
||||
<div class="banner banner-info">
|
||||
<strong>v{successBanner.version} uploaded — untested.</strong>
|
||||
<span>Open a beta on <a href="/scripts/{successBanner.scriptId}">{successBanner.name}</a> to test it before it can be promoted.</span>
|
||||
</div>
|
||||
{/if}
|
||||
<form onsubmit={createScript} class="upload-form">
|
||||
<label>
|
||||
<span class="k">name</span>
|
||||
<input type="text" bind:value={newName} placeholder="hud tweaks" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">scope</span>
|
||||
<div class="scope-row">
|
||||
<select bind:value={newScopeType} disabled={uploading}>
|
||||
<option value="none">unscoped</option>
|
||||
<option value="game">game</option>
|
||||
<option value="map">map</option>
|
||||
</select>
|
||||
{#if newScopeType === 'game'}
|
||||
<select bind:value={newScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else if newScopeType === 'map'}
|
||||
<select bind:value={newScopeGame} disabled={uploading}>
|
||||
<option value="">— pick a game —</option>
|
||||
{#each scopeOptions.games as g (g)}
|
||||
<option value={g}>{g}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<select bind:value={newScopeMap} disabled={uploading || !newScopeGame}>
|
||||
<option value="">— pick a map —</option>
|
||||
{#each (scopeOptions.mapsByGame[newScopeGame] ?? []) as m (m)}
|
||||
<option value={m}>{m}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{/if}
|
||||
<!-- Upload form -->
|
||||
<Card padding="lg">
|
||||
<h2 class="panel-title">Upload a script</h2>
|
||||
|
||||
{#if successBanner}
|
||||
<div class="banner">
|
||||
<strong>v{successBanner.version} uploaded — untested.</strong>
|
||||
<span>
|
||||
Open a beta on <a href="/scripts/{successBanner.scriptId}">{successBanner.name}</a>
|
||||
to test it before it can be promoted.
|
||||
</span>
|
||||
</div>
|
||||
{#if newScopeType !== 'none' && scopeValue}
|
||||
{@const matches = matchingServers ?? []}
|
||||
{#if matches.length === 0}
|
||||
<p class="preview warn">⚠ no matching servers in the fleet — the promoted script will land nowhere</p>
|
||||
{:else}
|
||||
<p class="preview ok">{matches.length} matching server{matches.length === 1 ? '' : 's'}: {matches.join(', ')}</p>
|
||||
{/if}
|
||||
{/if}
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">notes (optional)</span>
|
||||
<input type="text" bind:value={newNotes} placeholder="what changed" disabled={uploading} />
|
||||
</label>
|
||||
<label>
|
||||
<span class="k">file</span>
|
||||
<input type="file" onchange={pickFile} disabled={uploading} />
|
||||
</label>
|
||||
<button type="submit" class="primary" disabled={uploading || !newFile || !newName}>
|
||||
{uploading ? 'uploading…' : 'upload script'}
|
||||
</button>
|
||||
</form>
|
||||
{#if flash}<p class="flash">{flash}</p>{/if}
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<section class="panel">
|
||||
<h2>All scripts</h2>
|
||||
{#if loading}
|
||||
<p class="empty">loading…</p>
|
||||
{:else if scripts.length === 0}
|
||||
<p class="empty">no scripts yet — upload one above</p>
|
||||
{:else}
|
||||
<div class="scripts">
|
||||
{#each scripts as s (s.id)}
|
||||
<a class="script-row" href={detailHref(s)}>
|
||||
<div class="row-top">
|
||||
<span class="script-name">{s.name}</span>
|
||||
<span class="scope tag scope-{s.scope_type ?? 'none'}">{scopeLabel(s)}</span>
|
||||
{#if scriptStateTag(s)}
|
||||
{@const t = scriptStateTag(s)!}
|
||||
<span class="tag {t.cls}">{t.label}</span>
|
||||
{/if}
|
||||
{#if s.runningBetaId}
|
||||
<span class="tag beta">beta {s.runningBetaId} running</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta mono">
|
||||
<span>{s.target_rel_path}</span>
|
||||
<span>v{s.latestVersion?.version ?? '—'} · {s.versionCount} version{s.versionCount === 1 ? '' : 's'}</span>
|
||||
<span>{s.servers.length ? `${s.servers.length} matching server${s.servers.length === 1 ? '' : 's'}` : ''}</span>
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
<form onsubmit={createScript} class="upload-form">
|
||||
<Field label="Name">
|
||||
<Input bind:value={newName} placeholder="hud tweaks" disabled={uploading} />
|
||||
</Field>
|
||||
|
||||
<Field label="Notes" hint="Optional. What changed in this version.">
|
||||
<Input bind:value={newNotes} placeholder="what changed" disabled={uploading} />
|
||||
</Field>
|
||||
|
||||
<Field label="Scope" hint="Where this script deploys. Unscoped ships wherever a beta targets it.">
|
||||
<div class="scope-row">
|
||||
<Select bind:value={newScopeType} options={scopeTypeOptions} disabled={uploading} />
|
||||
{#if newScopeType === 'game' || newScopeType === 'map'}
|
||||
<Select bind:value={newScopeGame} options={gameOptions} disabled={uploading} />
|
||||
{/if}
|
||||
{#if newScopeType === 'map'}
|
||||
<Select bind:value={newScopeMap} options={mapOptions} disabled={uploading || !newScopeGame} />
|
||||
{/if}
|
||||
</div>
|
||||
{#if newScopeType !== 'none' && scopeValue}
|
||||
{@const matches = matchingServers ?? []}
|
||||
{#if matches.length === 0}
|
||||
<div class="preview warn">No matching servers — the promoted script will land nowhere.</div>
|
||||
{:else}
|
||||
<div class="preview ok">
|
||||
{matches.length} matching server{matches.length === 1 ? '' : 's'}: {matches.join(', ')}
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</Field>
|
||||
|
||||
<Field label="File">
|
||||
<Input type="file" onchange={pickFile} disabled={uploading} />
|
||||
</Field>
|
||||
|
||||
<div class="form-actions">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={uploading || !newFile || !newName}
|
||||
loading={uploading}
|
||||
>
|
||||
Upload script
|
||||
</Button>
|
||||
{#if flash}<span class="flash">{flash}</span>{/if}
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
<!-- Script list -->
|
||||
<section class="section">
|
||||
<div class="section-head">
|
||||
<h2>All scripts</h2>
|
||||
<Badge variant="neutral" size="sm">{scripts.length}</Badge>
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
{#if loading}
|
||||
<div class="loading">Loading…</div>
|
||||
{:else if scripts.length === 0}
|
||||
<EmptyState title="No scripts yet" description="Upload one above to get started." />
|
||||
{:else}
|
||||
<div class="rows">
|
||||
{#each scripts as s (s.id)}
|
||||
<a class="row" href={detailHref(s)}>
|
||||
<div class="row-top">
|
||||
<span class="name">{s.name}</span>
|
||||
<Badge
|
||||
variant={s.scope_type === 'game' ? 'info' :
|
||||
s.scope_type === 'map' ? 'warning' : 'neutral'}
|
||||
size="sm"
|
||||
>
|
||||
{scopeLabel(s)}
|
||||
</Badge>
|
||||
{#if stateVariantFor(s)}
|
||||
{@const v = stateVariantFor(s)!}
|
||||
<Badge variant={v} size="sm">{stateLabel(s)}</Badge>
|
||||
{/if}
|
||||
{#if s.runningBetaId}
|
||||
<Badge variant="warning" size="sm">β{s.runningBetaId} running</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="row-meta">
|
||||
<span class="path">{s.target_rel_path}</span>
|
||||
<span>v{s.latestVersion?.version ?? '—'} · {s.versionCount} version{s.versionCount === 1 ? '' : 's'}</span>
|
||||
{#if s.servers.length}
|
||||
<span>{s.servers.length} matching server{s.servers.length === 1 ? '' : 's'}</span>
|
||||
{/if}
|
||||
</div>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
h1 {
|
||||
color: var(--cream);
|
||||
font-family: var(--font-display);
|
||||
font-size: var(--text-3xl);
|
||||
letter-spacing: var(--tracking-display);
|
||||
line-height: var(--leading-tight);
|
||||
margin: 0 0 28px;
|
||||
}
|
||||
.panel {
|
||||
background: var(--bg-nav);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-md);
|
||||
padding: var(--pad-panel);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
h2 {
|
||||
margin: 0 0 14px;
|
||||
.page { display: flex; flex-direction: column; gap: var(--space-6); }
|
||||
.loading { text-align: center; padding: var(--space-12); color: var(--text-tertiary); }
|
||||
|
||||
.panel-title {
|
||||
margin: 0 0 var(--space-4);
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-xs);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1.5px;
|
||||
color: var(--ink-300);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono); margin: 0; }
|
||||
|
||||
.upload-form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
|
||||
.upload-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); }
|
||||
.upload-form label .k { color: var(--ink-500); text-transform: uppercase; letter-spacing: 1px; }
|
||||
.upload-form input[type=text], .upload-form select, .upload-form input[type=file] {
|
||||
background: var(--bg-page);
|
||||
color: var(--ink-100);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 10px 12px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-mono);
|
||||
}
|
||||
.upload-form input[type=text]:focus, .upload-form select:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
box-shadow: var(--accent-glow);
|
||||
}
|
||||
.scope-row { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.scope-row select:nth-of-type(1) { flex: 0 0 120px; }
|
||||
.primary {
|
||||
grid-column: 1 / -1;
|
||||
background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
|
||||
border: 1px solid var(--blue-400);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 12px 18px;
|
||||
color: var(--cream);
|
||||
font-family: var(--font-body);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.primary:disabled { opacity: 0.4; cursor: default; }
|
||||
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
|
||||
|
||||
.scripts { display: flex; flex-direction: column; gap: 8px; }
|
||||
.script-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 14px 16px;
|
||||
text-decoration: none;
|
||||
color: var(--ink-100);
|
||||
}
|
||||
.script-row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
|
||||
.row-top { display: flex; gap: 12px; align-items: center; }
|
||||
.script-name { color: var(--cream); font-weight: 600; font-size: var(--text-md); }
|
||||
.row-meta { display: flex; gap: 24px; color: var(--ink-500); font-size: var(--text-mono-sm); }
|
||||
.mono { font-family: var(--font-mono); }
|
||||
.tag {
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
padding: 3px 9px;
|
||||
border-radius: var(--r-sm);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.scope-none { background: var(--bg-nav); border-color: var(--border); color: var(--ink-500); }
|
||||
.scope-game { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
|
||||
.scope-map { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.35); color: var(--amber-500); }
|
||||
.beta { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.3); color: var(--amber-500); }
|
||||
.state-untested { background: var(--bg-nav); border-color: var(--border); color: var(--ink-300); }
|
||||
.state-tested { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
|
||||
.state-test-failed { background: rgba(255, 92, 92, 0.10); border-color: rgba(255, 92, 92, 0.4); color: var(--danger-500); }
|
||||
|
||||
.banner {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
border-radius: var(--r-sm);
|
||||
padding: 12px 14px;
|
||||
margin-bottom: 12px;
|
||||
font-size: var(--text-mono);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
margin-bottom: var(--space-4);
|
||||
background: rgba(124, 212, 255, 0.06);
|
||||
border: 1px solid rgba(124, 212, 255, 0.22);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-sm);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.banner-info {
|
||||
background: rgba(124, 212, 255, 0.08);
|
||||
border: 1px solid rgba(124, 212, 255, 0.28);
|
||||
color: var(--ink-100);
|
||||
}
|
||||
.banner-info a { color: var(--spark-500); text-decoration: underline; }
|
||||
.banner a { color: var(--state-online); text-decoration: underline; }
|
||||
|
||||
.upload-form {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
.scope-row {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.scope-row :global(.wrap) { flex: 1 1 140px; min-width: 140px; }
|
||||
.preview {
|
||||
grid-column: 1 / -1;
|
||||
margin: 4px 0 0;
|
||||
margin-top: var(--space-2);
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: var(--text-xs);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-mono-sm);
|
||||
}
|
||||
.preview.ok { color: var(--ink-300); }
|
||||
.preview.warn { color: var(--amber-500); }
|
||||
.preview.ok { background: var(--surface-sunken); color: var(--text-secondary); }
|
||||
.preview.warn { background: rgba(255, 176, 32, 0.06); color: var(--state-warning); border: 1px solid rgba(255, 176, 32, 0.28); }
|
||||
|
||||
.scope-row select:nth-of-type(2), .scope-row select:nth-of-type(3) { flex: 1; }
|
||||
.form-actions {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
.flash {
|
||||
color: var(--state-danger);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
}
|
||||
|
||||
.section { display: flex; flex-direction: column; gap: var(--space-3); }
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.section-head h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-body);
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.rows { display: flex; flex-direction: column; gap: var(--space-2); }
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-4) var(--space-5);
|
||||
background: color-mix(in oklab, var(--surface) 88%, transparent);
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
transition:
|
||||
background-color var(--dur-fast) var(--ease-standard),
|
||||
border-color var(--dur-fast) var(--ease-standard);
|
||||
}
|
||||
.row:hover { background: var(--surface-raised); border-color: var(--border-strong); }
|
||||
.row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
|
||||
.row-top {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.name {
|
||||
font-size: var(--text-md);
|
||||
font-weight: var(--weight-semibold);
|
||||
color: var(--text-primary);
|
||||
letter-spacing: var(--tracking-tight);
|
||||
}
|
||||
.row-meta {
|
||||
display: flex;
|
||||
gap: var(--space-5);
|
||||
color: var(--text-tertiary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.path { color: var(--text-secondary); }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.upload-form { grid-template-columns: 1fr; }
|
||||
}
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user