[web] Domi UI: the web UI on @domi/ui v1.0.4, vendored (CPAL-1.0), with the Built on Domi credit (PR #14, squashed)
@domi/ui v1.0.4 vendored unchanged in packages/domi-ui by domi-design's tools/vendor.mjs and used as workspace:*, so the Nix build fetches nothing from Gitea (web.nix sources the folder; fetchPnpmDeps hash from the NixOS runner). Its fonts, roles (data-domi-room="ianitor", the same hex) and controls replace Ianitor's copies: Button through Ianitor's adapter (desktop sizes kept), every text field a TextField with its seal, Checkbox, Select, Segmented. Ianitor's 22 role names renamed to --domi-*. <DomiCredit /> on every screen and in About, with the CPAL section 15 note beside the source link; the README names the vendored package. Disabled buttons are natively disabled.
This commit was merged in pull request #14.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
// the install (the accepted 4th click). Until Custos can approve, approval is the server
|
||||
// command control names (docs/pki.md).
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { TextField } from "@domi/ui";
|
||||
import { Banner, Button, Dialog, Icon, Segmented, Status } from "@ianitor/ui";
|
||||
import HostMenu from "../components/HostMenu.svelte";
|
||||
import IntermediateBanner from "../components/IntermediateBanner.svelte";
|
||||
@@ -184,12 +185,9 @@
|
||||
<Dialog title="New device certificate" kind="panel" onclose={closeForm}>
|
||||
{#if !request}
|
||||
<form id="device-form" onsubmit={issue} class="form">
|
||||
<div class="domi-field">
|
||||
<label class="domi-field-label" for="device-name">Device name</label>
|
||||
<input id="device-name" class="domi-input" bind:value={name} autocomplete="off" aria-invalid={nameErr ? "true" : undefined} aria-describedby="device-name-h" />
|
||||
{#if nameErr}<p class="domi-error"><Icon name="ring" />{nameErr}</p>{/if}
|
||||
<p class="ia-hint" id="device-name-h">Shown in this list and inside the certificate.</p>
|
||||
</div>
|
||||
<TextField id="device-name" label="Device name" bind:value={name} autocomplete="off" action="send"
|
||||
actionLabel="Request the certificate" clearOnSend={false} error={nameErr ?? undefined}
|
||||
hint="Shown in this list and inside the certificate." />
|
||||
<Segmented legend="What is it" name="kind" bind:value={kind} options={[{ value: "phone", label: "Phone or tablet" }, { value: "computer", label: "Computer" }, { value: "app", label: "Domi app" }]} />
|
||||
<p class="ia-hint">{#if capped}Valid until {until}, when the Domi intermediate certificate ends (renew it to issue for a full year).{:else}Valid for {lifetime} days, until {until}.{/if} It lets this device into hosts that ask for a Domi device certificate.</p>
|
||||
</form>
|
||||
@@ -245,8 +243,8 @@
|
||||
|
||||
<style>
|
||||
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
|
||||
.devices { list-style: none; margin: 0; padding: 0; border: 1px solid var(--hairline); border-radius: var(--radius-lg); }
|
||||
.devices li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; min-height: 56px; padding: 6px 10px 6px 16px; border-top: 1px solid var(--hairline); }
|
||||
.devices { list-style: none; margin: 0; padding: 0; border: 1px solid var(--domi-line); border-radius: var(--radius-lg); }
|
||||
.devices li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; min-height: 56px; padding: 6px 10px 6px 16px; border-top: 1px solid var(--domi-line); }
|
||||
.devices li:first-child { border-top: 0; }
|
||||
.dname { font-weight: 600; flex: 1 1 140px; }
|
||||
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex-basis: 100%; }
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
</script>
|
||||
|
||||
<h1 class="ia-display">{host ? `History of ${host}` : "History"}</h1>
|
||||
{#if host}<div><button type="button" class="domi-btn link" onclick={() => navigate("/history")}>Show all changes</button></div>{/if}
|
||||
{#if host}<div><button type="button" class="ia-link" onclick={() => navigate("/history")}>Show all changes</button></div>{/if}
|
||||
{#if problem}<Banner tone="notice" live="status">{#snippet title()}{problem}{/snippet}</Banner>{/if}
|
||||
|
||||
<div class="cols">
|
||||
@@ -168,11 +168,11 @@
|
||||
.cols { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
|
||||
.list { flex: 1 1 360px; max-width: 520px; display: flex; flex-direction: column; gap: 8px; }
|
||||
.entries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
|
||||
.entry { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; color: var(--text); text-align: left; cursor: pointer; }
|
||||
.entry:hover { background: var(--surface); }
|
||||
.entry[aria-current="true"] { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
|
||||
.entry { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; background: none; color: var(--domi-fg); text-align: left; cursor: pointer; }
|
||||
.entry:hover { background: var(--domi-panel); }
|
||||
.entry[aria-current="true"] { background: var(--domi-hover); border-color: color-mix(in srgb, var(--domi-accent) 55%, transparent); }
|
||||
.sum { font-weight: 600; }
|
||||
.detail { flex: 2 1 360px; background: var(--colonnade); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.detail { flex: 2 1 360px; background: var(--domi-chrome); border: 1px solid var(--domi-line); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.detail ul { margin: 0; padding-left: 1.1rem; }
|
||||
.buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
|
||||
</style>
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
Routes live in the {o.repo.name} repository, one file per host.
|
||||
{#if o.repo.last_push_at}Last pushed to Gitea {atTime(o.repo.last_push_at, app.now)}.{/if}
|
||||
{#if o.repo.unpushed}{o.repo.unpushed} changes not yet pushed.{/if}
|
||||
<button type="button" class="domi-btn link" onclick={() => navigate("/history")}>See history</button>
|
||||
<button type="button" class="ia-link" onclick={() => navigate("/history")}>See history</button>
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<script lang="ts">
|
||||
// Handoff §13.6: signing the intermediate by hand on the offline computer (the temporary step
|
||||
// until Custos can sign, docs/pki.md). The root key never comes to this server.
|
||||
import { TextField } from "@domi/ui";
|
||||
import { Banner, Button, Icon } from "@ianitor/ui";
|
||||
import { ApiError, post, put, sentence } from "../lib/api";
|
||||
import { app, navigate, refresh } from "../lib/app.svelte";
|
||||
@@ -120,24 +121,22 @@
|
||||
<p class="ia-label">Step 3</p>
|
||||
<h2 class="ia-h3">Upload the signed certificate</h2>
|
||||
{#if paste}
|
||||
<div class="domi-field">
|
||||
<label class="domi-field-label" for="cert-paste">Signed certificate</label>
|
||||
<textarea id="cert-paste" class="domi-input" rows="8" bind:value={pem} aria-invalid={err ? "true" : undefined}></textarea>
|
||||
</div>
|
||||
<TextField id="cert-paste" label="Signed certificate" multiline rows={8} enterSends="never" spellcheck={false} bind:value={pem}
|
||||
action="send" actionLabel="Use the pasted certificate" clearOnSend={false} onsend={() => { void use(); }} />
|
||||
{:else}
|
||||
<div class="domi-field">
|
||||
<label class="domi-field-label" for="cert-file">Signed certificate (.crt)</label>
|
||||
<input id="cert-file" class="domi-input" type="file" accept=".crt,.pem" onchange={file} aria-invalid={err ? "true" : undefined} />
|
||||
<div><button type="button" class="domi-btn link" onclick={() => (paste = true)}>Paste it instead</button></div>
|
||||
<div class="ia-field">
|
||||
<label class="ia-field-label" for="cert-file">Signed certificate (.crt)</label>
|
||||
<input id="cert-file" class="ia-input" type="file" accept=".crt,.pem" onchange={file} aria-invalid={err ? "true" : undefined} />
|
||||
<div><button type="button" class="ia-link" onclick={() => (paste = true)}>Paste it instead</button></div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if err}<p class="domi-error" role="alert"><Icon name="ring" />{err}</p>{/if}
|
||||
{#if err}<p class="ia-error" role="alert"><Icon name="ring" />{err}</p>{/if}
|
||||
<div><Button variant="primary" onclick={use} {pending} disabled={!pem.includes("BEGIN CERTIFICATE")}>Use this certificate</Button></div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.row { display: flex; gap: 8px; flex-wrap: wrap; }
|
||||
.step { border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.fp { word-break: break-all; color: var(--accent-strong); }
|
||||
.step { border: 1px solid var(--domi-line); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.fp { word-break: break-all; color: var(--domi-accent-strong); }
|
||||
</style>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
// Handoff §8.3: Settings with General, API (⚙ → API → New token = 3 clicks, Copy token the
|
||||
// accepted 4th), Share links and About.
|
||||
import { onMount } from "svelte";
|
||||
import { DomiCredit, DomiError, TextField } from "@domi/ui";
|
||||
import { Banner, Button, Dialog, Segmented } from "@ianitor/ui";
|
||||
import { ApiError, call, del, get, newKey, patch, post, sentence } from "../lib/api";
|
||||
import { app, navigate, toast } from "../lib/app.svelte";
|
||||
import { longDate, shortDate, whenInline } from "../lib/format";
|
||||
import { CREDIT } from "../lib/credit";
|
||||
import type { CreatedToken, ShareLink, TokenRow } from "../lib/types";
|
||||
|
||||
let { tab }: { tab: string } = $props();
|
||||
@@ -93,23 +93,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Renames the new token now (its field's seal) or when the dialog closes. False when the name was refused.
|
||||
async function rename(): Promise<boolean> {
|
||||
if (!made || !tokenName.trim() || tokenName.trim() === made.name) return true;
|
||||
nameErr = null;
|
||||
try {
|
||||
await patch(`/tokens/${encodeURIComponent(made.id)}`, { name: tokenName.trim() });
|
||||
made.name = tokenName.trim();
|
||||
toast("Renamed.");
|
||||
} catch (e) {
|
||||
if (e instanceof ApiError && e.code === "token.name") {
|
||||
nameErr = e.body.message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function closeToken(force = false) {
|
||||
if (!made) return;
|
||||
if (!tokenCopied && !force) {
|
||||
askClose = true;
|
||||
return;
|
||||
}
|
||||
if (tokenName.trim() && tokenName !== made.name) {
|
||||
try {
|
||||
await patch(`/tokens/${encodeURIComponent(made.id)}`, { name: tokenName.trim() });
|
||||
toast("Renamed.");
|
||||
} catch (e) {
|
||||
if (e instanceof ApiError && e.code === "token.name") {
|
||||
nameErr = e.body.message;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(await rename())) return;
|
||||
// The token leaves memory with the dialog.
|
||||
made = null;
|
||||
tokenName = "";
|
||||
@@ -170,7 +177,7 @@
|
||||
<p>{settings?.watch_seconds ?? app.overview?.site?.watch_seconds ?? 60} seconds</p>
|
||||
<p class="ia-label">Signed in</p>
|
||||
<p>{viewer ? (viewer.via === "authelia" ? `${viewer.name} through Authelia` : `API token "${viewer.name}"`) : "Through Authelia"}</p>
|
||||
{#if app.overview?.site?.auth_logout_url}<p><a class="domi-btn link" href={app.overview.site.auth_logout_url}>Sign out</a></p>{/if}
|
||||
{#if app.overview?.site?.auth_logout_url}<p><a class="ia-link" href={app.overview.site.auth_logout_url}>Sign out</a></p>{/if}
|
||||
{:else if tab === "api"}
|
||||
<div class="row">
|
||||
<h2 class="ia-h3">API tokens</h2>
|
||||
@@ -236,9 +243,10 @@
|
||||
{:else}
|
||||
<p>Ianitor Domi 0.1.0</p>
|
||||
<p>CPAL-1.0 (Common Public Attribution License 1.0). Ianitor 0.2.0 and earlier stay MPL-2.0.</p>
|
||||
<p><a class="domi-btn link" href={CREDIT.url} rel="noreferrer">{CREDIT.phrase}</a> · {CREDIT.notice}</p>
|
||||
<div class="about-credit"><DomiCredit /></div>
|
||||
<p>Built, tested and signed by Fabrica Domi</p>
|
||||
<p><a class="domi-btn link" href="https://gitea.marek-novak.cz/mnovak/Ianitor" rel="noreferrer">Source on Gitea</a></p>
|
||||
<p>Using Ianitor over a network counts as distribution under CPAL-1.0 (§15), so its source, with any changes, stays
|
||||
available: <a class="ia-link" href="https://gitea.marek-novak.cz/mnovak/Ianitor" rel="noreferrer">Source on Gitea</a></p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -248,12 +256,9 @@
|
||||
<p class="ia-text2">Ianitor cannot show it again; if it is lost, make a new one and revoke this one.</p>
|
||||
<input class="ia-secret" readonly value={made.token} aria-label="New API token" onfocus={(e) => (e.currentTarget as HTMLInputElement).select()} />
|
||||
<div class="grid">
|
||||
<div class="domi-field">
|
||||
<label class="domi-field-label" for="token-name">Name</label>
|
||||
<input id="token-name" class="domi-input" bind:value={tokenName} aria-invalid={nameErr ? "true" : undefined} />
|
||||
{#if nameErr}<p class="domi-error">{nameErr}</p>{/if}
|
||||
<p class="ia-hint">Rename it now or later, so you know what uses it.</p>
|
||||
</div>
|
||||
<TextField id="token-name" label="Name" bind:value={tokenName} autocomplete="off" action="save" actionLabel="Rename the token"
|
||||
onsend={async () => { if (!(await rename())) throw new DomiError(nameErr ?? "That name was not accepted."); }}
|
||||
error={nameErr ?? undefined} hint="Rename it now or later, so you know what uses it." />
|
||||
<Button variant={tokenCopied ? "quiet" : "primary"} icon="copy" onclick={copyToken} data-autofocus>{tokenCopied ? "Copy again" : "Copy token"}</Button>
|
||||
</div>
|
||||
{#if tokenCopied}<p role="status">Copied. Paste it into Custos now. Ianitor cannot show it again.</p>{/if}
|
||||
@@ -267,16 +272,17 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.about-credit :global(.domi-credit) { justify-content: flex-start; }
|
||||
.tabs { display: flex; gap: 4px; overflow-x: auto; }
|
||||
.tabs [role="tab"] { min-height: 44px; padding: 0 1rem; border-radius: var(--radius-sm); border: 0; background: none; color: var(--text-2); font-weight: 600; cursor: pointer; }
|
||||
.tabs [role="tab"][aria-selected="true"] { background: var(--surface-2); color: var(--text); }
|
||||
.tabs [role="tab"] { min-height: 44px; padding: 0 1rem; border-radius: var(--radius-sm); border: 0; background: none; color: var(--domi-fg-2); font-weight: 600; cursor: pointer; }
|
||||
.tabs [role="tab"][aria-selected="true"] { background: var(--domi-hover); color: var(--domi-fg); }
|
||||
.panel { display: flex; flex-direction: column; gap: 10px; }
|
||||
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
|
||||
.rows { list-style: none; margin: 0; padding: 0; }
|
||||
.rows li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 44px; padding: 8px 0; border-top: 1px solid var(--hairline); }
|
||||
.rows li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 44px; padding: 8px 0; border-top: 1px solid var(--domi-line); }
|
||||
.grow { flex: 1 1 200px; min-width: 0; }
|
||||
.tname { font-weight: 600; }
|
||||
.struck { text-decoration: line-through; color: var(--muted); }
|
||||
.struck { text-decoration: line-through; color: var(--domi-muted); }
|
||||
.grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
|
||||
@media (max-width: 719.98px) { .grid { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user