Merge branch 'view-ui'
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ca0f148b78
29 files changed
+623
-55
No files matched your search
@@ -1,5 +1,5 @@
|
||||
// Jarl web UI: router, layout and login.
|
||||
import { h, mount, toast, errorBox, plural } from "./ui.js";
|
||||
import { h, mount, toast, errorBox, plural, lastList } from "./ui.js";
|
||||
import { wordmark, logo } from "./brand.js";
|
||||
import { api, get, state, loadDraft, onChange, setUnauthorizedHandler, setImmediate, setCodePrompt } from "./api.js";
|
||||
import * as totp from "./totp.js";
|
||||
@@ -50,7 +50,7 @@ const navItems = [
|
||||
];
|
||||
|
||||
const app = document.getElementById("app");
|
||||
let mainEl, navEl, barEl, current = { key: "" };
|
||||
let mainEl, navEl, barEl, current = { key: "" }, routeGen = 0;
|
||||
|
||||
function parseHash() {
|
||||
const raw = location.hash.replace(/^#\/?/, "");
|
||||
@@ -153,8 +153,7 @@ function layout() {
|
||||
const header = h("header", { class: "top" },
|
||||
h("a", { class: "brand", href: "#/", title: "Dashboard" },
|
||||
logo(30),
|
||||
wordmark({ rule: false, height: 19, cls: "brand-name" }),
|
||||
h("span", { class: "brand-version" }, me.version)),
|
||||
wordmark({ rule: false, height: 19, cls: "brand-name" })),
|
||||
navEl,
|
||||
h("div", { class: "spacer" }),
|
||||
modeEl = h("span"),
|
||||
@@ -162,7 +161,7 @@ function layout() {
|
||||
h("a", { href: "#/account", class: "user", title: (me.permissions || []).join("\n") }, me.user.username),
|
||||
me.admin ? h("a", { href: "#/users" }, "Users") : null,
|
||||
h("button", { class: "small", onclick: logout }, "Log out"));
|
||||
mount(app, header, barEl, mainEl);
|
||||
mount(app, h("div", { class: "shell" }, header, barEl, mainEl, footer(me.build)));
|
||||
modeHolder = modeEl;
|
||||
renderNav();
|
||||
renderBar();
|
||||
@@ -170,6 +169,16 @@ function layout() {
|
||||
|
||||
let modeHolder;
|
||||
|
||||
// footer names the Jarl build: the release, or the commit for other
|
||||
// builds, linked to it in the repository.
|
||||
function footer(b) {
|
||||
if (!b) return null;
|
||||
const what = b.tag ? "release " + b.tag
|
||||
: b.commit ? "commit " + b.commit + (b.modified ? ", with uncommitted changes" : "") : "version " + b.version;
|
||||
return h("footer", { class: "site" }, "Powered by ",
|
||||
h("a", { href: b.url, target: "_blank", rel: "noopener", title: "Jarl " + b.version + ", built from " + what }, "Jarl " + b.label));
|
||||
}
|
||||
|
||||
function renderNav() {
|
||||
mount(navEl, navItems.map(([key, href, label]) => h("a", { href, class: current.nav === key ? "active" : "" }, label)));
|
||||
}
|
||||
@@ -211,12 +220,21 @@ async function route() {
|
||||
const params = {};
|
||||
(r.params || []).forEach((p, i) => { params[p] = m[i + 1]; });
|
||||
current = { key: path, nav: r.nav, page: r.page, params, query };
|
||||
if (!r.params && r.nav) lastList[r.nav] = location.hash;
|
||||
renderNav();
|
||||
mount(mainEl, h("div", { class: "muted" }, "Loading…"));
|
||||
// Keep the old page until the new one is drawn (switching a zone's
|
||||
// tabs shouldn't blank the page); say "Loading…" only when it's slow.
|
||||
// (Only while the new page has drawn nothing yet: pages that draw
|
||||
// their frame first fill it in afterwards.)
|
||||
const gen = ++routeGen;
|
||||
const old = mainEl.firstChild;
|
||||
const slow = setTimeout(() => { if (gen === routeGen && mainEl.firstChild === old) mount(mainEl, h("div", { class: "muted" }, "Loading…")); }, 300);
|
||||
try {
|
||||
await r.page.render(mainEl, params, query);
|
||||
} catch (e) {
|
||||
mount(mainEl, h("h1", null, "Something went wrong"), errorBox(e));
|
||||
if (gen === routeGen) mount(mainEl, h("h1", null, "Something went wrong"), errorBox(e));
|
||||
} finally {
|
||||
clearTimeout(slow);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { h, mount, table, toast, confirmDialog, diffView, time, fmtTime, badge, plural } from "../ui.js";
|
||||
import { h, mount, table, toast, confirmDialog, diffView, time, fmtTime, badge, plural, backLink, lastList } from "../ui.js";
|
||||
import { api, get, useDraft } from "../api.js";
|
||||
|
||||
export async function render(el, params) {
|
||||
@@ -30,10 +30,10 @@ async function detail(el, id) {
|
||||
mount(el,
|
||||
h("div", { class: "page-head" },
|
||||
h("div", { class: "grow" },
|
||||
backLink("History", lastList.history || "#/history"),
|
||||
h("h1", null, "Changeset #" + c.id),
|
||||
h("div", { class: "muted" }, c.description || "(no description)")),
|
||||
h("div", { class: "actions" },
|
||||
h("a", { class: "button", href: "#/history" }, "All changes"),
|
||||
c.status === "applied" && c.undoable ? h("button", { onclick: () => revert(c) }, "Revert…") : null)),
|
||||
h("div", { class: "panel" }, h("dl", { class: "kv" },
|
||||
h("dt", null, "Status"), h("dd", null, badge(c.status, c.status === "applied" ? "ok" : "")),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { h, mount, table, field, input, select, textarea, toast, errorBox, confirmDialog, modal, lines, checkbox } from "../ui.js";
|
||||
import { h, mount, table, field, input, select, textarea, toast, errorBox, confirmDialog, modal, lines, checkbox, colorPicker, backLink, safeBack, viewHref } from "../ui.js";
|
||||
import { amlContext, suggestions } from "../aml.js";
|
||||
import { get, change, describeResult } from "../api.js";
|
||||
import { api, get, change, describeResult } from "../api.js";
|
||||
import { rerender } from "../app.js";
|
||||
import { optionsEditor } from "./options.js";
|
||||
|
||||
@@ -9,6 +9,9 @@ export async function render(el, params, query) {
|
||||
const viewless = zones.filter((z) => !z.view_id);
|
||||
const optsEl = h("div");
|
||||
const selected = query.get("view") ? views.find((v) => String(v.id) === query.get("view")) : null;
|
||||
// Opened from a view link on a zone or the zone list: offer the way back
|
||||
// (kept while picking other views here).
|
||||
const back = safeBack(query.get("back"));
|
||||
const move = async (i, d) => {
|
||||
const ids = views.map((v) => v.id);
|
||||
[ids[i], ids[i + d]] = [ids[i + d], ids[i]];
|
||||
@@ -20,14 +23,14 @@ export async function render(el, params, query) {
|
||||
};
|
||||
mount(el,
|
||||
h("div", { class: "page-head" },
|
||||
h("div", { class: "grow" }, h("h1", null, "Views"),
|
||||
h("div", { class: "grow" }, back ? backLink(backLabel(back, zones), back) : null, h("h1", null, "Views"),
|
||||
h("div", { class: "muted" }, "A client sees the first view it matches (by source address, destination address or TSIG key). Order matters.")),
|
||||
h("div", { class: "actions" }, h("button", { class: "primary", onclick: () => viewDialog(null, viewless) }, "New view"))),
|
||||
views.length === 0 ? h("div", { class: "msg info" },
|
||||
"No views: every client sees the same zones. Views let you serve different answers to different clients, for example an internal view with private records and recursion for your LAN, and an external view with only public records.") : null,
|
||||
h("div", { class: "panel" }, table([
|
||||
{ label: "#", render: (v, i) => String(i + 1) },
|
||||
{ label: "View", render: (v) => h("a", { href: "#/views?view=" + v.id }, h("strong", null, v.name)) },
|
||||
{ label: "View", render: (v) => h("a", { href: viewHref(v.id, back), class: v.color ? "vc-" + v.color : null }, h("strong", null, v.name)) },
|
||||
{ label: "Match clients", render: (v) => (v.match_clients || []).join("; ") || h("span", { class: "muted" }, "any"), tdClass: "data" },
|
||||
{ label: "Match destinations", render: (v) => (v.match_destinations || []).join("; ") || h("span", { class: "muted" }, "any"), tdClass: "data" },
|
||||
{ label: "Zones", render: (v) => h("a", { href: "#/zones?view=" + encodeURIComponent(v.name) }, String(v.zone_count)) },
|
||||
@@ -37,10 +40,24 @@ export async function render(el, params, query) {
|
||||
h("button", { class: "small", disabled: i === views.length - 1, title: "Move down", onclick: () => move(i, 1) }, "↓"), " ",
|
||||
h("button", { class: "small", onclick: () => viewDialog(v, viewless) }, "Edit"), " ",
|
||||
h("button", { class: "small danger", onclick: () => deleteView(v) }, "Delete")), tdClass: "actions-cell" },
|
||||
], views, { empty: "No views." })),
|
||||
], views, { empty: "No views.", rowClass: (v) => selected && v.id === selected.id ? "selected" : "" })),
|
||||
selected ? optsEl : (views.length ? h("p", { class: "muted" }, "Select a view to see its options.") : null));
|
||||
if (selected) await optionsEditor(optsEl, { scope: "view", scope_id: selected.id, catalogScope: "view", title: "Options of view " + selected.name,
|
||||
intro: "View options override the server options for clients in this view (for example recursion and allow-recursion)." });
|
||||
if (selected) {
|
||||
await optionsEditor(optsEl, { scope: "view", scope_id: selected.id, catalogScope: "view", title: "Options of view " + selected.name,
|
||||
intro: "View options override the server options for clients in this view (for example recursion and allow-recursion)." });
|
||||
// With a long list, scroll to the selected view's options.
|
||||
if (views.length > 3) optsEl.scrollIntoView({ block: "start" });
|
||||
}
|
||||
}
|
||||
|
||||
// backLabel names the page a back address leads to.
|
||||
function backLabel(back, zones) {
|
||||
const m = back.match(/^#\/zones\/(\d+)/);
|
||||
if (m) {
|
||||
const z = zones.find((z) => String(z.id) === m[1]);
|
||||
return z ? z.display_name + (z.view ? " (" + z.view + ")" : "") : "Zone";
|
||||
}
|
||||
return /^#\/zones(\?|$)/.test(back) ? "Zones" : "Back";
|
||||
}
|
||||
|
||||
async function viewDialog(v, viewless) {
|
||||
@@ -51,13 +68,15 @@ async function viewDialog(v, viewless) {
|
||||
const md = textarea(v ? (v.match_destinations || []).join("\n") : "", { class: "mono", rows: 2, placeholder: "(empty = any)" });
|
||||
const mro = select([["", "(default: no)"], ["true", "yes"], ["false", "no"]], v && v.match_recursive_only !== undefined && v.match_recursive_only !== null ? String(v.match_recursive_only) : "");
|
||||
const comment = input({ value: v ? v.comment : "" });
|
||||
const color = colorPicker(v ? v.color : "");
|
||||
const adopt = checkbox("Move the " + viewless.length + " zone(s) that are not in a view into this view", true);
|
||||
const body = h("div", null, h("div", { class: "form-grid" },
|
||||
field("Name", name),
|
||||
field("Match clients", h("div", null, mc, suggestions(mc, ctx)), "One element per line: addresses, prefixes, ACL names, key NAME, any/none/localhost/localnets; !negates. First match wins."),
|
||||
field("Match destinations", h("div", null, md, suggestions(md, ctx)), "Server addresses this view answers on (optional)."),
|
||||
field("Recursive only", mro, "If yes, only recursive queries match this view."),
|
||||
field("Comment", comment)),
|
||||
field("Comment", comment),
|
||||
field("Colour", color, "How the web UI shows this view, so zones of the same view are easy to spot. Only changes the web UI: it applies at once, with no deploy.")),
|
||||
!v && viewless.length ? h("div", { class: "msg warn" }, "Once views exist, named requires every zone to be inside a view. ", adopt) : null,
|
||||
err);
|
||||
await modal(v ? "Edit view " + v.name : "New view", body, [
|
||||
@@ -66,9 +85,16 @@ async function viewDialog(v, viewless) {
|
||||
const data = { name: name.value.trim(), match_clients: lines(mc.value), match_destinations: lines(md.value), comment: comment.value };
|
||||
data.match_recursive_only = mro.value === "" ? null : mro.value === "true";
|
||||
if (!v && viewless.length && adopt.input.checked) data.adopt_zones = true;
|
||||
const colorChanged = color.value !== ((v && v.color) || "");
|
||||
try {
|
||||
const r = v ? await change("PATCH", "/views/" + v.id, data) : await change("POST", "/views", data);
|
||||
toast(describeResult(r));
|
||||
let r = null;
|
||||
if (!v || configChanged(v, data)) r = v ? await change("PATCH", "/views/" + v.id, data) : await change("POST", "/views", data);
|
||||
const id = v ? v.id : (r.object && r.object.id) || ((r.added || [])[0] || {}).id;
|
||||
if (colorChanged && id) {
|
||||
// A view created in a draft only exists in that draft so far.
|
||||
await api("PUT", "/views/" + id + "/color", { body: { color: color.value }, stage: r && r.staged ? r.changeset_id : undefined });
|
||||
}
|
||||
toast(r ? describeResult(r) : "Colour saved");
|
||||
rerender();
|
||||
return true;
|
||||
} catch (e) { mount(err, errorBox(e)); return false; }
|
||||
@@ -76,6 +102,15 @@ async function viewDialog(v, viewless) {
|
||||
], { wide: true, sticky: true });
|
||||
}
|
||||
|
||||
// configChanged tells whether the dialog changed the view's configuration
|
||||
// (not just its colour), so a colour change alone stages nothing.
|
||||
function configChanged(v, data) {
|
||||
const same = (a, b) => JSON.stringify(a || []) === JSON.stringify(b || []);
|
||||
const mro = v.match_recursive_only === undefined ? null : v.match_recursive_only;
|
||||
return data.name !== v.name || !same(data.match_clients, v.match_clients) || !same(data.match_destinations, v.match_destinations) ||
|
||||
data.match_recursive_only !== mro || data.comment !== (v.comment || "");
|
||||
}
|
||||
|
||||
async function deleteView(v) {
|
||||
let cascade = false;
|
||||
if (v.zone_count > 0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { h, mount, table, field, input, select, textarea, toast, errorBox, display, badge, confirmDialog, modal, checkbox, time, diffView } from "../ui.js";
|
||||
import { h, mount, table, field, input, select, textarea, toast, errorBox, display, badge, confirmDialog, modal, checkbox, time, diffView, backLink, viewLink, lastList } from "../ui.js";
|
||||
import { api, get, change, describeResult, rrtypes, state, draftQuery } from "../api.js";
|
||||
import { rerender } from "../app.js";
|
||||
import { optionsEditor } from "./options.js";
|
||||
@@ -7,9 +7,12 @@ import { isReverseZone, reverseInfo, ptrOwner, addressOf } from "../names.js";
|
||||
import { dnssecTab } from "./dnssec.js";
|
||||
import { registrarTab } from "./registrar.js";
|
||||
|
||||
let renderSeq = 0;
|
||||
|
||||
export async function render(el, params, query) {
|
||||
const id = params.id;
|
||||
const zone = await get("/zones/" + id, draftQuery());
|
||||
const [zone, views] = await Promise.all([get("/zones/" + id, draftQuery()), get("/views")]);
|
||||
const view = views.find((v) => v.id === zone.view_id);
|
||||
const tab = params.tab || (zone.type === "primary" ? "records" : "settings");
|
||||
const tabs = [
|
||||
zone.type === "primary" ? ["records", "Records (" + zone.record_count + ")"] : null,
|
||||
@@ -21,21 +24,30 @@ export async function render(el, params, query) {
|
||||
zone.registrar && state.me && state.me.admin ? ["registrar", "Registrar"] : null,
|
||||
].filter(Boolean);
|
||||
const body = h("div");
|
||||
mount(el,
|
||||
h("div", { class: "page-head" },
|
||||
const head = h("div", { class: "page-head" },
|
||||
h("div", { class: "grow" },
|
||||
backLink("Zones", lastList.zones || "#/zones"),
|
||||
h("h1", { class: "mono" }, zone.display_name),
|
||||
h("div", { class: "muted" },
|
||||
badge(zone.type, "accent"), " ",
|
||||
zone.pending ? [pendingBadge(zone.pending), " "] : null,
|
||||
zone.view ? ["view ", h("a", { href: "#/views" }, zone.view), " · "] : null,
|
||||
zone.view ? ["view ", viewLink(view, zone.view, "#/zones/" + id + (params.tab ? "/" + params.tab : "")), " · "] : null,
|
||||
zone.type === "primary" ? "serial " + zone.soa.serial + " · " : null,
|
||||
zone.dnssec_policy ? [h("a", { href: "#/zones/" + id + "/dnssec" }, badge(zone.dnssec_policy === "insecure" ? "DNSSEC: turning off" : "DNSSEC", zone.dnssec_policy === "insecure" ? "warn" : "ok")), " "] : null,
|
||||
zone.zone_file ? h("span", { class: "mono small" }, zone.zone_file) : null)),
|
||||
h("div", { class: "actions" },
|
||||
h("button", { class: "danger", onclick: () => deleteZone(zone) }, "Delete zone"))),
|
||||
h("div", { class: "tabs" }, tabs.map(([k, label]) => h("a", { href: "#/zones/" + id + "/" + k, class: k === tab ? "active" : "" }, label))),
|
||||
body);
|
||||
h("button", { class: "danger", onclick: () => deleteZone(zone) }, "Delete zone")));
|
||||
const tabBar = h("div", { class: "tabs" }, tabs.map(([k, label]) => h("a", { href: "#/zones/" + id + "/" + k, class: k === tab ? "active" : "" }, label)));
|
||||
// The header and tabs show at once. Below them, switching tabs keeps the
|
||||
// previous tab's content (faded) until the new one is loaded, rather
|
||||
// than blanking the page; opening the zone shows "Loading…" there.
|
||||
const seq = ++renderSeq;
|
||||
const prev = el.querySelector(`:scope > .zone-body[data-zone="${id}"]`);
|
||||
const holder = prev || h("div", { class: "zone-body" }, h("div", { class: "muted" }, "Loading…"));
|
||||
holder.classList.add("stale");
|
||||
body.className = "zone-body";
|
||||
body.dataset.zone = id;
|
||||
mount(el, head, tabBar, holder);
|
||||
if (tab === "records") await recordsTab(body, zone, query);
|
||||
else if (tab === "settings") await settingsTab(body, zone);
|
||||
else if (tab === "options") await optionsEditor(body, { scope: "zone", scope_id: zone.id, catalogScope: "zone:" + zone.type, title: "Zone options" });
|
||||
@@ -43,6 +55,11 @@ export async function render(el, params, query) {
|
||||
else if (tab === "servers") await serversTab(body, zone);
|
||||
else if (tab === "dnssec") await dnssecTab(body, zone);
|
||||
else if (tab === "registrar") await registrarTab(body, zone);
|
||||
// A later click (another tab) has taken over the page.
|
||||
if (seq !== renderSeq || !holder.isConnected) return;
|
||||
holder.replaceWith(body);
|
||||
const first = body.querySelector("[data-autofocus]");
|
||||
if (first) first.focus();
|
||||
}
|
||||
|
||||
// ---- name servers: serials on the other servers, and the delegation
|
||||
@@ -166,7 +183,7 @@ async function recordsTab(el, zone, query) {
|
||||
const reverse = isReverseZone(zone.name);
|
||||
const rinfo = reverse ? reverseInfo(zone.name) : null;
|
||||
// Add form. In reverse zones records are named by address.
|
||||
const fName = input({ placeholder: reverse && rinfo ? rinfo.example : "@ or www", style: { width: reverse ? "220px" : "180px" }, class: "mono", autocomplete: "off", spellcheck: "false" });
|
||||
const fName = input({ placeholder: reverse && rinfo ? rinfo.example : "@ or www", style: { width: reverse ? "220px" : "180px" }, class: "mono", autocomplete: "off", spellcheck: "false", "data-autofocus": true });
|
||||
const fType = select(types.map((t) => [t.type, t.type + (t.common ? "" : "")]), reverse ? "PTR" : "A", { style: { width: "110px" } });
|
||||
const fTTL = input({ type: "number", placeholder: "default", min: 0, style: { width: "100px" } });
|
||||
const fData = input({ class: "mono", placeholder: typeInfo.A.example });
|
||||
@@ -388,7 +405,6 @@ async function recordsTab(el, zone, query) {
|
||||
(reverse ? "Names are the last part of the address within " + zone.display_name + "." : "Names are relative to " + zone.display_name + "; end a name with '.' to make it absolute."))),
|
||||
list));
|
||||
draw();
|
||||
fName.focus();
|
||||
}
|
||||
|
||||
// ---- settings
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { h, mount, table, modal, field, input, select, textarea, lines, toast, errorBox, display, badge } from "../ui.js";
|
||||
import { h, mount, table, modal, field, input, select, textarea, lines, toast, errorBox, display, badge, viewLink, lastList } from "../ui.js";
|
||||
import { get, change, changeMany, describeResult, can, draftQuery } from "../api.js";
|
||||
import { rerender } from "../app.js";
|
||||
import { checkDomain, reverseZoneFor } from "../names.js";
|
||||
@@ -8,13 +8,23 @@ export async function render(el, params, query) {
|
||||
const filter = input({ type: "search", placeholder: "Filter zones…", value: query.get("q") || "" });
|
||||
const viewSel = select([["", "All views"], ...views.map((v) => [v.name, v.name])], query.get("view") || "");
|
||||
const typeSel = select([["", "All types"], "primary", "secondary", "forward", "stub", "static-stub", "mirror", "hint", "redirect", "in-view"], query.get("type") || "");
|
||||
const viewsById = new Map(views.map((v) => [v.id, v]));
|
||||
const list = h("div");
|
||||
const draw = () => {
|
||||
const q = filter.value.trim().toLowerCase();
|
||||
// Keep the filters in the address, so going back to the list (or a
|
||||
// breadcrumb) restores them.
|
||||
const qs = new URLSearchParams();
|
||||
if (filter.value.trim()) qs.set("q", filter.value.trim());
|
||||
if (viewSel.value) qs.set("view", viewSel.value);
|
||||
if (typeSel.value) qs.set("type", typeSel.value);
|
||||
const hash = "#/zones" + (qs.toString() ? "?" + qs : "");
|
||||
if (location.hash !== hash && !query.get("new")) history.replaceState(null, "", hash);
|
||||
lastList.zones = hash;
|
||||
const rows = zones.filter((z) => (!q || z.name.includes(q)) && (!viewSel.value || z.view === viewSel.value) && (!typeSel.value || z.type === typeSel.value));
|
||||
mount(list, table([
|
||||
{ label: "Zone", render: (z) => [z.pending === "delete" ? h("span", null, z.display_name) : h("a", { href: "#/zones/" + z.id }, z.display_name), z.pending ? [" ", pendingBadge(z.pending)] : null], tdClass: "name" },
|
||||
views.length ? { label: "View", render: (z) => z.view || h("span", { class: "muted" }, "–") } : null,
|
||||
views.length ? { label: "View", render: (z) => viewLink(viewsById.get(z.view_id), z.view, hash) } : null,
|
||||
{ label: "Type", render: (z) => badge(z.type, z.type === "primary" ? "accent" : "") },
|
||||
{ label: "Records", render: (z) => z.type === "primary" ? String(z.record_count) : "", class: "right", tdClass: "right" },
|
||||
{ label: "Serial", render: (z) => z.type === "primary" ? String(z.soa.serial) : "", tdClass: "mono" },
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
--hunk: #e8eefb;
|
||||
--shadow: 0 1px 2px rgba(20, 30, 50, 0.08);
|
||||
--radius: 6px;
|
||||
--vc-green: #3d8160; --vc-teal: #2f7c80; --vc-purple: #7a5ba8; --vc-pink: #a8557f;
|
||||
--vc-orange: #a8652f; --vc-yellow: #8a7424; --vc-red: #b0534c; --vc-grey: #6b7280;
|
||||
--mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
|
||||
color-scheme: light;
|
||||
}
|
||||
@@ -50,6 +52,8 @@
|
||||
--del-text: #f7b2ac;
|
||||
--hunk: #23314a;
|
||||
--shadow: none;
|
||||
--vc-green: #8fcfa9; --vc-teal: #87cdd0; --vc-purple: #bca6e6; --vc-pink: #e6a6c6;
|
||||
--vc-orange: #ebbb8f; --vc-yellow: #e3d08e; --vc-red: #eba29c; --vc-grey: #aab2bf;
|
||||
color-scheme: dark;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +63,8 @@
|
||||
--warn: #e5b450; --warn-soft: #3a2f15; --err: #f08077; --err-soft: #3c1f1d; --info-soft: #232833;
|
||||
--code-bg: #242933; --add: #183a25; --add-text: #9fe3b5; --del: #43201e; --del-text: #f7b2ac; --hunk: #23314a;
|
||||
--shadow: none; color-scheme: dark;
|
||||
--vc-green: #8fcfa9; --vc-teal: #87cdd0; --vc-purple: #bca6e6; --vc-pink: #e6a6c6;
|
||||
--vc-orange: #ebbb8f; --vc-yellow: #e3d08e; --vc-red: #eba29c; --vc-grey: #aab2bf;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
@@ -91,7 +97,6 @@ header.top {
|
||||
header.top .brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
|
||||
header.top .brand .logo { display: block; transition: transform 0.15s; }
|
||||
header.top .brand .brand-name { display: block; color: var(--text); }
|
||||
header.top .brand .brand-version { color: var(--muted); font-size: 12px; align-self: flex-end; padding-bottom: 2px; }
|
||||
header.top .brand:hover { text-decoration: none; }
|
||||
header.top .brand:hover .brand-name { color: var(--accent); }
|
||||
header.top .brand:hover .logo { transform: scale(1.06); }
|
||||
@@ -397,3 +402,27 @@ button.chip:hover { background: var(--accent-soft); border-color: var(--accent);
|
||||
header.top .brand .logo { transition: none; }
|
||||
header.top .brand:hover .logo { transform: none; }
|
||||
}
|
||||
|
||||
/* a zone tab's previous content while the next tab loads */
|
||||
.zone-body.stale { opacity: 0.5; transition: opacity 0.15s 0.1s; pointer-events: none; }
|
||||
|
||||
/* the "← Zones" link above a page's heading */
|
||||
.back-link { font-size: 13px; margin-bottom: 2px; }
|
||||
|
||||
/* view colours (the default is the link colour) */
|
||||
.vc-green { color: var(--vc-green); } .vc-teal { color: var(--vc-teal); } .vc-purple { color: var(--vc-purple); }
|
||||
.vc-pink { color: var(--vc-pink); } .vc-orange { color: var(--vc-orange); } .vc-yellow { color: var(--vc-yellow); }
|
||||
.vc-red { color: var(--vc-red); } .vc-grey { color: var(--vc-grey); } .vc-default { color: var(--accent); }
|
||||
.swatches { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; }
|
||||
.swatch { width: 24px; height: 24px; min-width: 0; padding: 0; border-radius: 50%; background: currentColor; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
|
||||
.swatch:hover { background: currentColor; }
|
||||
.swatch.selected { box-shadow: 0 0 0 2px currentColor; }
|
||||
.swatch:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
|
||||
tr.selected td { background: var(--accent-soft); }
|
||||
|
||||
/* the page footer with the Jarl build */
|
||||
.shell { min-height: 100vh; display: flex; flex-direction: column; }
|
||||
.shell > main { flex: 1; width: 100%; }
|
||||
footer.site { padding: 12px 16px 16px; text-align: center; font-size: 12px; color: var(--muted); }
|
||||
footer.site a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
|
||||
footer.site a:hover { color: var(--accent); text-decoration-color: currentColor; }
|
||||
@@ -247,3 +247,50 @@ export function debounce(fn, ms = 250) {
|
||||
let t;
|
||||
return (...args) => { clearTimeout(t); t = setTimeout(() => fn(...args), ms); };
|
||||
}
|
||||
|
||||
// Where each list page was last left (with its filters), so a breadcrumb
|
||||
// back to it restores them. The router and list pages fill it in.
|
||||
export const lastList = {};
|
||||
|
||||
// backLink is the "← Zones" link above a page's heading, back to the
|
||||
// page it was opened from.
|
||||
export function backLink(label, href) {
|
||||
return h("nav", { class: "back-link", "aria-label": "Back" }, h("a", { href }, "← ", label));
|
||||
}
|
||||
|
||||
// safeBack returns a "back" address taken from the URL if it is one of
|
||||
// the UI's own (#/...), else null: it ends up in an href.
|
||||
export function safeBack(v) {
|
||||
return v && /^#\/[A-Za-z0-9\/?=&%._~+-]*$/.test(v) ? v : null;
|
||||
}
|
||||
|
||||
// The colours a view can be shown in (besides the default, the link
|
||||
// colour). Keep in step with model.ViewColors.
|
||||
export const viewColors = ["green", "teal", "purple", "pink", "orange", "yellow", "red", "grey"];
|
||||
|
||||
// viewLink links to a view's page, in the view's colour. v is a view
|
||||
// from /views; name is shown when the view is unknown. back is the
|
||||
// address the views page offers to go back to (the current page).
|
||||
export function viewLink(v, name, back) {
|
||||
if (!v) return name ? h("span", null, name) : h("span", { class: "muted" }, "–");
|
||||
return h("a", { href: viewHref(v.id, back), class: v.color ? "vc-" + v.color : null, title: "View " + v.name }, v.name);
|
||||
}
|
||||
|
||||
// viewHref is the address of a view on the views page.
|
||||
export function viewHref(id, back) {
|
||||
return "#/views?view=" + id + (back ? "&back=" + encodeURIComponent(back) : "");
|
||||
}
|
||||
|
||||
// colorPicker picks a view colour; its value is "" for the default.
|
||||
export function colorPicker(value) {
|
||||
const el = h("div", { class: "swatches", role: "radiogroup" });
|
||||
const draw = () => mount(el, ["", ...viewColors].map((c) => h("button", {
|
||||
type: "button", role: "radio", "aria-checked": String(c === el.value),
|
||||
class: "swatch" + (c ? " vc-" + c : " vc-default") + (c === el.value ? " selected" : ""),
|
||||
title: c || "default (link colour)", "aria-label": c || "default",
|
||||
onclick: () => { el.value = c; draw(); },
|
||||
})));
|
||||
el.value = value || "";
|
||||
draw();
|
||||
return el;
|
||||
}
|
||||
Reference in new issue
Block a user