Manage .env from the admin panel

Add an Environment tab to /admin that lists every variable in .env.example
and lets keys, OAuth settings, email settings and generated secrets be
changed without SSH. Secrets are write-only; infrastructure variables are
shown read-only.

The backend never writes .env or touches Docker. It validates an edit and
queues it in env-apply/run/request.json; env-apply/apply.py, run on the host
by a systemd path unit (env-apply/install.sh), rewrites .env atomically,
keeps .env.bak, and recreates only the services that read the change.

backend/services/env_registry.json is the single list of variables, shared
by the backend and the host script; a test keeps it in step with
.env.example. It replaces the drifted checklist in handle_admin.go. The job
capture token card moves to the new tab.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-12 14:02:28 +01:00
co-authored by Claude Opus 5.5
parent 26f312e307
commit 2786bce022
24 changed files with 2293 additions and 306 deletions
+78
View File
@@ -0,0 +1,78 @@
<!--
A credential shown exactly once: the value, a copy button, and the warning
that it cannot be read back. Used wherever the server mints a secret and
keeps only a hash of it, or no copy the browser can ask for again.
-->
<script setup>
import { ref, watch } from "vue";
import Button from "@/components/input/Button.vue";
const props = defineProps({
value: { type: String, required: true },
label: { type: String, default: "" },
});
const copied = ref(false);
const failed = ref(false);
// A regenerated value is a new thing to copy.
watch(
() => props.value,
() => {
copied.value = false;
failed.value = false;
},
);
async function copy() {
try {
await navigator.clipboard.writeText(props.value);
copied.value = true;
} catch {
// Clipboard access can be refused; the value is on screen to select.
failed.value = true;
}
}
</script>
<template>
<div class="secret-reveal">
<p class="secret-note">
<code v-if="label">{{ label }}</code>
Copy this now. It will not be shown again.
</p>
<code class="secret-value">{{ value }}</code>
<Button class="px-2" @click="copy">{{ copied ? "Copied" : "Copy" }}</Button>
<p v-if="failed" class="secret-note secret-failed">
Could not copy — select the value and copy it by hand.
</p>
</div>
</template>
<style scoped>
.secret-reveal {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid var(--color-tertiary);
background: var(--color-surface-tint);
}
.secret-note {
flex-basis: 100%;
margin: 0;
font-size: 0.85rem;
opacity: 0.85;
}
.secret-failed {
color: var(--color-error, #b91c1c);
}
.secret-value {
flex: 1;
min-width: 0;
font-size: 0.8rem;
word-break: break-all;
user-select: all;
}
</style>
+2
View File
@@ -18,6 +18,7 @@ import CreateBookmark from "./CreateBookmark.vue";
import CreatePlace from "./CreatePlace.vue";
import ManageUsers from "./ManageUsers.vue";
import ManageRadio from "./ManageRadio.vue";
import Environment from "./Environment.vue";
import Diagnostics from "./Diagnostics.vue";
const auth = useAuthStore();
@@ -32,6 +33,7 @@ const sections = [
{ id: "place", label: "Place / Thing To Do", component: CreatePlace },
{ id: "users", label: "Manage Users", component: ManageUsers },
{ id: "radio", label: "Manage Radio", component: ManageRadio },
{ id: "environment", label: "Environment", component: Environment },
{ id: "diagnostics", label: "Diagnostics", component: Diagnostics },
];
+122
View File
@@ -0,0 +1,122 @@
<script setup>
/**
* The job capture token card on the admin Environment tab.
*
* The token is the credential the job capture userscript
* (public/job-capture.user.js) sends. It is not a .env variable: the server
* keeps only a hash in backend/token/, so it can be shown exactly once, in
* the response to generating it, and replacing it needs no restart.
*/
import { ref, onMounted } from "vue";
import axios from "axios";
import Button from "@/components/input/Button.vue";
import SecretReveal from "@/components/admin/SecretReveal.vue";
import "./env.css";
// `newToken` holds a just-generated token and lives only in this component's
// memory: leaving the tab is the end of it.
const capture = ref(null);
const error = ref("");
const busy = ref(false);
const newToken = ref("");
async function fetchCaptureToken() {
try {
capture.value = (await axios.get("/api/admin/capture-token")).data;
error.value = "";
} catch (err) {
error.value =
err.response?.data?.error || "Failed to load the capture token state";
}
}
async function generate() {
// Generating replaces: an installed script stops working until it is
// given the new token, which is worth a pause when one already exists.
if (
capture.value?.set &&
!confirm(
"Replace the existing capture token? The installed userscript will stop working until you paste the new one into it.",
)
)
return;
busy.value = true;
try {
const res = await axios.post("/api/admin/capture-token");
newToken.value = res.data.token;
capture.value = { set: true, createdAt: res.data.createdAt };
error.value = "";
} catch (err) {
error.value = err.response?.data?.error || "Failed to generate a token";
} finally {
busy.value = false;
}
}
async function revoke() {
if (!confirm("Revoke the capture token? The userscript will stop working."))
return;
busy.value = true;
try {
capture.value = (await axios.delete("/api/admin/capture-token")).data;
newToken.value = "";
error.value = "";
} catch (err) {
error.value = err.response?.data?.error || "Failed to revoke the token";
} finally {
busy.value = false;
}
}
onMounted(fetchCaptureToken);
</script>
<template>
<section class="env-card">
<header class="env-card-head">
<h2>Job capture</h2>
<span v-if="capture" class="env-pill" :class="capture.set ? 'is-set' : 'is-unset'">
{{ capture.set ? "active" : "no token" }}
</span>
</header>
<div class="capture-body">
<p class="env-hint">
The credential for the
<a href="/job-capture.user.js" target="_blank" rel="noopener"
>job capture userscript</a
>. Generate one, then paste it into the script's
<em>Configure job capture</em> menu command. Only a hash is stored, so
it takes effect at once and cannot be recovered — generate again to
replace it.
</p>
<p v-if="error" class="env-error">{{ error }}</p>
<template v-if="capture">
<p v-if="capture.set" class="env-hint">
Generated {{ new Date(capture.createdAt).toLocaleString() }}.
</p>
<SecretReveal v-if="newToken" :value="newToken" />
<div class="capture-controls">
<Button class="px-2" :disabled="busy" @click="generate">
{{ capture.set ? "Regenerate" : "Generate token" }}
</Button>
<Button v-if="capture.set" class="px-2" :disabled="busy" @click="revoke">
Revoke
</Button>
</div>
</template>
</div>
</section>
</template>
<style scoped>
.capture-body {
display: flex;
flex-direction: column;
gap: 8px;
padding: 8px 10px;
}
.capture-controls {
display: flex;
gap: 12px;
}
</style>
+7 -212
View File
@@ -1,41 +1,22 @@
<script setup>
/**
* Admin panel: configuration checklist, the job capture token, and log tail.
* Admin panel: tail of the backend log.
*
* All of it comes from the backend as JSON (GET /api/admin/config,
* /api/admin/capture-token, /api/admin/logs). Nothing here is GraphQL — the
* data is process environment and filesystem, not the site's data model.
* GET /api/admin/logs returns JSON read from the filesystem, not GraphQL —
* it is not part of the site's data model. Configuration and the job capture
* token, which used to share this tab, are on the Environment tab.
*
* The capture token is the credential the job capture userscript
* (public/job-capture.user.js) sends. The server keeps only a hash, so the
* token can be shown exactly once, in the response to generating it.
*
* The log tail loads lazily (only when the Logs tab is selected first)
* because reading the file on every /admin visit would be waste; an admin
* who remounts the component via tab switches re-triggers onMounted, which
* is the desired "refresh on tab change" behaviour.
* An admin who remounts the component via tab switches re-triggers
* onMounted, which is the desired "refresh on tab change" behaviour.
*/
import { ref, onMounted, computed } from "vue";
import axios from "axios";
import Button from "@/components/input/Button.vue";
const vars = ref([]);
const configError = ref("");
const lines = ref([]);
const logsError = ref("");
const loadingLogs = ref(false);
async function fetchConfig() {
try {
const res = await axios.get("/api/admin/config");
vars.value = res.data.vars;
configError.value = "";
} catch (err) {
configError.value = err.response?.data?.error || "Failed to load config";
}
}
async function fetchLogs() {
loadingLogs.value = true;
try {
@@ -49,79 +30,6 @@ async function fetchLogs() {
}
}
// Job capture token. `newToken` holds a just-generated token and lives only in
// this component's memory: leaving the tab is the end of it.
const capture = ref(null);
const captureError = ref("");
const captureBusy = ref(false);
const newToken = ref("");
const copied = ref(false);
async function fetchCaptureToken() {
try {
capture.value = (await axios.get("/api/admin/capture-token")).data;
captureError.value = "";
} catch (err) {
captureError.value =
err.response?.data?.error || "Failed to load the capture token state";
}
}
async function generateCaptureToken() {
// Generating replaces: an installed script stops working until it is
// given the new token, which is worth a pause when one already exists.
if (
capture.value?.set &&
!confirm(
"Replace the existing capture token? The installed userscript will stop working until you paste the new one into it.",
)
)
return;
captureBusy.value = true;
try {
const res = await axios.post("/api/admin/capture-token");
newToken.value = res.data.token;
capture.value = { set: true, createdAt: res.data.createdAt };
copied.value = false;
captureError.value = "";
} catch (err) {
captureError.value =
err.response?.data?.error || "Failed to generate a token";
} finally {
captureBusy.value = false;
}
}
async function revokeCaptureToken() {
if (!confirm("Revoke the capture token? The userscript will stop working."))
return;
captureBusy.value = true;
try {
capture.value = (await axios.delete("/api/admin/capture-token")).data;
newToken.value = "";
captureError.value = "";
} catch (err) {
captureError.value =
err.response?.data?.error || "Failed to revoke the token";
} finally {
captureBusy.value = false;
}
}
async function copyToken() {
try {
await navigator.clipboard.writeText(newToken.value);
copied.value = true;
} catch {
// Clipboard access can be refused; the token is on screen to select.
captureError.value = "Could not copy — select the token and copy it by hand.";
}
}
const blank = computed(() =>
vars.value.filter((v) => !v.set),
);
// Traffic view: a filter over the log tail for "who is using my site" —
// lines with a client IP (the formatter appends it only for real visitors
// and error statuses). Skips the standard line numbers of JSON-array output.
@@ -131,82 +39,11 @@ const shownLines = computed(() => {
return lines.value.filter((l) => /\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(l.trim()) || l.includes("!!! SERVER ERROR") || l.includes(" !!"));
});
onMounted(() => {
fetchConfig();
fetchCaptureToken();
fetchLogs();
});
onMounted(fetchLogs);
</script>
<template>
<div class="diagnostics">
<h1>Configuration</h1>
<p v-if="blank.length === 0" class="ok">All known configuration set.</p>
<p v-else class="warn">
{{ blank.length }} unset. Blank vars with <em>required</em> break their
feature; optional ones degrade it.
</p>
<p v-if="configError" class="error">{{ configError }}</p>
<table v-if="vars.length">
<thead>
<tr>
<th>Variable</th>
<th>For</th>
<th>State</th>
</tr>
</thead>
<tbody>
<tr v-for="v in vars" :key="v.name">
<td><code>{{ v.name }}</code></td>
<td>{{ v.purpose }}</td>
<td>
<span v-if="!v.set" class="warn">unset</span>
<span v-else-if="v.secret">set (secret)</span>
<span v-else>{{ v.value }}</span>
</td>
</tr>
</tbody>
</table>
<h1>Job capture token</h1>
<p class="hint">
The credential for the
<a href="/job-capture.user.js" target="_blank" rel="noopener"
>job capture userscript</a
>. Generate one, then paste it into the script's
<em>Configure job capture</em> menu command. Only a hash is stored, so a
token is shown once and cannot be recovered — generate again to replace
it.
</p>
<p v-if="captureError" class="error">{{ captureError }}</p>
<template v-if="capture">
<p v-if="capture.set">
A token is active, generated
{{ new Date(capture.createdAt).toLocaleString() }}.
</p>
<p v-else class="warn">
No token — the capture script cannot reach the tracker.
</p>
<div v-if="newToken" class="token-box">
<p class="hint">Copy this now. It will not be shown again.</p>
<code class="token">{{ newToken }}</code>
<Button @click="copyToken">{{ copied ? "Copied" : "Copy" }}</Button>
</div>
<div class="token-controls">
<Button :disabled="captureBusy" @click="generateCaptureToken">
{{ capture.set ? "Regenerate" : "Generate token" }}
</Button>
<Button
v-if="capture.set"
:disabled="captureBusy"
@click="revokeCaptureToken"
>
Revoke
</Button>
</div>
</template>
<h1>Logs</h1>
<p class="hint">
Tail of the backend log (up to 500 lines): HTTP traffic and application
@@ -235,24 +72,6 @@ onMounted(() => {
gap: 8px;
}
table {
width: 100%;
border-collapse: collapse;
font-size: 0.85rem;
}
th,
td {
text-align: left;
padding: 4px 8px;
border-bottom: 1px solid var(--color-quaternary);
}
.ok {
color: var(--color-tertiary);
}
.warn {
color: var(--color-error, #b91c1c);
}
.error {
color: var(--color-error, #b91c1c);
}
@@ -261,30 +80,6 @@ td {
opacity: 0.75;
}
.token-box {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
padding: 8px;
border: 1px solid var(--color-quaternary);
}
.token-box .hint {
flex-basis: 100%;
margin: 0;
}
.token {
flex: 1;
min-width: 0;
font-size: 0.8rem;
word-break: break-all;
user-select: all;
}
.token-controls {
display: flex;
gap: 12px;
}
.log-controls {
display: flex;
justify-content: flex-end;
+552
View File
@@ -0,0 +1,552 @@
<script setup>
/**
* Admin Environment tab: every variable in .env, grouped, with the ones that
* are safe to change editable in place.
*
* Nothing here writes .env directly, and neither does the backend. Applying
* sends the staged edits to PUT /api/admin/env, which queues them for a
* script on the host (env-apply/apply.py) that rewrites the file and
* recreates the containers that read the changed variables. This component
* then polls GET /api/admin/env/status until the host reports back — through
* the backend's own restart, which is why failed polls are expected and
* ignored rather than shown.
*
* Secrets are write-only: the server sends "set" and at most the last four
* characters, never the value. A generated secret is the one exception, shown
* once from the response that created it.
*/
import { ref, reactive, computed, onMounted, onUnmounted } from "vue";
import axios from "axios";
import Button from "@/components/input/Button.vue";
import SecretReveal from "@/components/admin/SecretReveal.vue";
import CaptureToken from "./CaptureToken.vue";
import "./env.css";
const groups = ref([]);
const status = ref(null);
const error = ref("");
const loading = ref(true);
// Staged edits, none of which exist anywhere but this component until Apply.
// drafts: name -> text in the row's input
// generating: names to have the server mint a value for
// clearing: secrets to blank (a secret's empty input means "unchanged",
// so clearing one needs saying explicitly)
const drafts = reactive({});
const generating = reactive(new Set());
const clearing = reactive(new Set());
// Values the server generated in the last apply, shown once.
const revealed = ref({});
const applying = ref(false);
const outcome = ref(null); // { ok, text, output }
const awaitedId = ref("");
let pollTimer = null;
const allVars = computed(() => groups.value.flatMap((g) => g.vars));
function resetDrafts() {
for (const v of allVars.value) drafts[v.name] = v.secret ? "" : v.value || "";
generating.clear();
clearing.clear();
}
async function fetchEnv() {
try {
const res = await axios.get("/api/admin/env");
groups.value = res.data.groups;
status.value = res.data.status;
error.value = "";
resetDrafts();
} catch (err) {
error.value = err.response?.data?.error || "Failed to load the environment";
} finally {
loading.value = false;
}
}
// What a row would send: null when it is untouched.
function changeFor(v) {
if (!v.editable) return null;
if (generating.has(v.name)) return { name: v.name, type: "generate" };
if (clearing.has(v.name)) return { name: v.name, type: "clear" };
const draft = (drafts[v.name] ?? "").trim();
if (v.secret) return draft ? { name: v.name, type: "set", value: draft } : null;
if (draft === (v.value || "")) return null;
return { name: v.name, type: draft ? "set" : "clear", value: draft };
}
const changes = computed(() =>
allVars.value.map((v) => ({ v, change: changeFor(v) })).filter((c) => c.change),
);
// Mirrors EnvManager.ServicesFor: the backend is always recreated.
const affectedServices = computed(() => {
const services = new Set(["backend"]);
for (const { v } of changes.value)
for (const s of v.services || []) services.add(s);
return [...services].sort();
});
const pendingNames = computed(() => new Set(status.value?.pending || []));
function toggleGenerate(v) {
if (generating.has(v.name)) return generating.delete(v.name);
generating.add(v.name);
clearing.delete(v.name);
drafts[v.name] = "";
}
function toggleClear(v) {
if (clearing.has(v.name)) return clearing.delete(v.name);
clearing.add(v.name);
generating.delete(v.name);
drafts[v.name] = "";
}
// Typing a value withdraws a staged generate or clear for the same row.
function onInput(v) {
generating.delete(v.name);
clearing.delete(v.name);
}
function pillFor(v) {
if (changeFor(v)) return { text: "changed", cls: "is-changed" };
if (pendingNames.value.has(v.name)) return { text: "pending", cls: "is-changed" };
if (!v.set) return { text: "unset", cls: "is-unset" };
if (v.secret) return { text: v.hint ? `set ••••${v.hint}` : "set", cls: "is-set" };
return { text: "set", cls: "is-set" };
}
async function apply() {
const warnings = changes.value.filter((c) => c.v.warning).map((c) => `• ${c.v.warning}`);
const lines = [
`Apply ${changes.value.length} change(s)?`,
`This recreates: ${affectedServices.value.join(", ")}. The site's API is unavailable for a few seconds.`,
...warnings,
];
if (!confirm(lines.join("\n"))) return;
const body = { set: {}, generate: [] };
for (const { change } of changes.value) {
if (change.type === "generate") body.generate.push(change.name);
else body.set[change.name] = change.type === "clear" ? "" : change.value;
}
applying.value = true;
outcome.value = null;
try {
const res = await axios.put("/api/admin/env", body);
revealed.value = res.data.generated || {};
status.value = res.data.status;
awaitedId.value = res.data.status.id;
// Staged secrets have been sent; do not keep them in the inputs.
resetDrafts();
startPolling();
} catch (err) {
applying.value = false;
outcome.value = {
ok: false,
text: err.response?.data?.error || "Failed to queue the change",
};
}
}
function startPolling() {
stopPolling();
pollTimer = setInterval(poll, 2000);
}
function stopPolling() {
if (pollTimer) clearInterval(pollTimer);
pollTimer = null;
}
async function poll() {
let next;
try {
next = (await axios.get("/api/admin/env/status")).data;
} catch (err) {
// 401/403 after an apply means the change invalidated this session
// (rotating BACKEND_SECRET does). Anything else is the backend
// restarting, which is the apply working.
if ([401, 403].includes(err.response?.status)) {
stopPolling();
applying.value = false;
outcome.value = {
ok: true,
text: "Applied. Your session was signed with the old secret — log in again.",
};
}
return;
}
status.value = next;
if (next.id !== awaitedId.value) return;
if (next.state === "applied") {
stopPolling();
applying.value = false;
outcome.value = {
ok: true,
text: `Applied. Recreated ${(next.services || []).join(", ")}.`,
};
await fetchEnv();
} else if (next.state === "failed") {
stopPolling();
applying.value = false;
outcome.value = { ok: false, text: "The host could not apply the change.", output: next.output };
await fetchEnv();
}
}
async function cancelPending() {
try {
status.value = (await axios.delete("/api/admin/env/pending")).data;
stopPolling();
applying.value = false;
outcome.value = { ok: true, text: "Pending change withdrawn. Nothing was applied." };
} catch (err) {
outcome.value = {
ok: false,
text: err.response?.data?.error || "Failed to withdraw the change",
};
}
}
const progressText = computed(() => {
const s = status.value;
if (!s) return "";
if (s.state === "pending") return "Queued — waiting for the host to pick it up…";
if (s.state === "applying")
return `Recreating ${(s.services || []).join(", ")}…`;
return "";
});
onMounted(async () => {
await fetchEnv();
// A change queued before this tab was opened is still worth following.
if (["pending", "applying"].includes(status.value?.state)) {
awaitedId.value = status.value.id;
applying.value = true;
startPolling();
}
});
onUnmounted(stopPolling);
</script>
<template>
<div class="env">
<h1>Environment</h1>
<p class="env-hint">
The site's <code>.env</code>. Edits are staged here, then applied on the
server, which restarts only the services that read what changed. Secrets
can be replaced but never read back.
</p>
<p v-if="error" class="env-error">{{ error }}</p>
<p v-if="loading" class="env-hint">Loading…</p>
<div v-if="Object.keys(revealed).length" class="env-revealed">
<SecretReveal
v-for="(value, name) in revealed"
:key="name"
:label="name"
:value="value"
/>
</div>
<div v-if="applying" class="env-banner">
<p>{{ progressText || "Applying…" }}</p>
<template v-if="status?.state === 'pending' && !status.watcher">
<p class="env-hint">
Nothing on the host has picked this up. On the Pi, run
<code>./env-apply/install.sh</code> once to install the watcher. To
apply this change by hand, from the repo root:
</p>
<code class="env-command">python3 env-apply/apply.py</code>
<Button class="px-2" @click="cancelPending">Withdraw change</Button>
</template>
</div>
<div v-else-if="outcome" class="env-banner" :class="outcome.ok ? 'is-ok' : 'is-failed'">
<p>{{ outcome.text }}</p>
<pre v-if="outcome.output" class="env-output">{{ outcome.output }}</pre>
</div>
<section v-for="group in groups" :key="group.name" class="env-card">
<header class="env-card-head">
<h2>{{ group.name }}</h2>
<span class="env-hint">
{{ group.vars.filter((v) => v.set).length }}/{{ group.vars.length }} set
</span>
</header>
<div
v-for="v in group.vars"
:key="v.name"
class="env-row"
:class="{ 'is-locked': !v.editable, 'is-dirty': !!changeFor(v) }"
>
<div class="env-meta">
<div class="env-name">
<code>{{ v.name }}</code>
<span class="env-pill" :class="pillFor(v).cls">{{ pillFor(v).text }}</span>
</div>
<p class="env-hint">
{{ v.purpose }}
<a
v-if="v.docsUrl && v.editable"
:href="v.docsUrl"
target="_blank"
rel="noopener noreferrer"
class="env-docs"
>{{ v.secret ? "Get a key" : "Open" }} ↗</a
>
</p>
</div>
<div v-if="v.editable" class="env-control">
<select
v-if="v.kind === 'enum' || v.kind === 'bool'"
v-model="drafts[v.name]"
:disabled="applying"
>
<option value="">(unset)</option>
<option
v-for="option in v.kind === 'bool' ? ['true', 'false'] : v.options"
:key="option"
:value="option"
>
{{ option }}
</option>
</select>
<template v-else>
<input
v-model="drafts[v.name]"
:type="v.secret ? 'password' : 'text'"
:placeholder="
generating.has(v.name)
? 'A new value will be generated'
: clearing.has(v.name)
? 'Will be cleared'
: v.secret
? v.set
? 'Paste a replacement'
: 'Paste a value'
: ''
"
:disabled="applying"
autocomplete="off"
spellcheck="false"
@input="onInput(v)"
/>
<Button
v-if="v.kind === 'generated'"
class="px-2"
:class="{ 'is-on': generating.has(v.name) }"
:disabled="applying"
@click="toggleGenerate(v)"
>
{{ v.set ? "Regenerate" : "Generate" }}
</Button>
<Button
v-if="v.secret && v.set"
class="px-2"
:class="{ 'is-on': clearing.has(v.name) }"
:disabled="applying"
@click="toggleClear(v)"
>
Clear
</Button>
</template>
<p v-if="v.warning && changeFor(v)" class="env-warning">
{{ v.warning }}
</p>
</div>
<p v-else class="env-control env-locked" :title="v.lockedReason">
<span v-if="!v.secret && v.set" class="env-value">{{ v.value }}</span>
<span class="env-hint">🔒 {{ v.lockedReason }}</span>
</p>
</div>
</section>
<CaptureToken v-if="!loading" />
<footer v-if="changes.length && !applying" class="env-apply-bar">
<p>
<strong>{{ changes.length }}</strong>
{{ changes.length === 1 ? "change" : "changes" }} — recreates
{{ affectedServices.join(", ") }}
</p>
<div class="env-apply-actions">
<Button class="px-2" @click="resetDrafts">Discard</Button>
<Button class="px-2 env-apply" @click="apply">Apply</Button>
</div>
</footer>
</div>
</template>
<style scoped>
.env {
display: flex;
flex-direction: column;
gap: 10px;
}
.env-revealed {
display: flex;
flex-direction: column;
gap: 6px;
}
.env-banner {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 6px;
padding: 8px 10px;
border: 1px solid var(--color-primary);
background: var(--color-surface-tint);
}
.env-banner p {
margin: 0;
}
.env-banner.is-failed {
border-color: var(--color-error, #f87171);
}
.env-banner.is-failed > p {
color: var(--color-error, #f87171);
}
.env-command {
user-select: all;
font-size: 0.8rem;
}
.env-output {
width: 100%;
max-height: 200px;
overflow: auto;
margin: 0;
padding: 6px;
font-size: 0.75rem;
white-space: pre-wrap;
word-break: break-all;
color: var(--color-primary);
background: var(--color-surface-deep);
}
.env-row {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
gap: 4px 12px;
align-items: center;
padding: 6px 10px;
border-bottom: 1px solid var(--color-quaternary);
border-left: 2px solid transparent;
}
.env-row:last-child {
border-bottom: none;
}
.env-row.is-dirty {
border-left-color: var(--color-tertiary);
background: var(--color-surface-tint);
}
.env-row.is-locked .env-meta {
opacity: 0.6;
}
.env-name {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
}
.env-name code {
font-size: 0.8rem;
word-break: break-all;
}
.env-docs {
margin-left: 4px;
padding: 0 4px;
font-size: 0.75rem;
white-space: nowrap;
}
.env-control {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
margin: 0;
}
.env-control input,
.env-control select {
flex: 1;
min-width: 120px;
padding: 3px 6px;
font-size: 0.85rem;
color: var(--color-primary);
background: var(--color-surface);
border: 1px solid var(--color-quaternary);
}
.env-control input:focus,
.env-control select:focus {
border-color: var(--color-primary);
outline: none;
}
.env-control :deep(button.is-on) {
color: var(--color-tertiary);
border-color: var(--color-tertiary);
}
.env-control :deep(button:disabled),
.env-control input:disabled,
.env-control select:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.env-warning {
flex-basis: 100%;
margin: 0;
font-size: 0.8rem;
color: var(--color-tertiary);
}
.env-locked {
flex-direction: column;
align-items: flex-start;
gap: 0;
}
.env-value {
font-size: 0.85rem;
color: var(--color-primary);
word-break: break-all;
}
/* Stays in view while scrolling a long list of rows, so the count of staged
changes and the Apply button are never off-screen. */
.env-apply-bar {
position: sticky;
bottom: 8px;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 8px 10px;
border: 1px solid var(--color-tertiary);
background: var(--color-surface);
box-shadow: 0 0 12px var(--color-surface-deep);
}
.env-apply-bar p {
margin: 0;
}
.env-apply-actions {
display: flex;
gap: 8px;
}
.env-apply-actions :deep(.env-apply) {
color: var(--color-surface-deep);
background: var(--color-primary);
}
@media (max-width: 700px) {
.env-row {
grid-template-columns: 1fr;
}
}
</style>
+54
View File
@@ -0,0 +1,54 @@
/*
* Card, pill and message styles shared by the admin Environment tab
* (Environment.vue) and the cards it hosts (CaptureToken.vue). A plain
* stylesheet rather than a scoped block because scoped styles stop at a child
* component's root; the env- prefix is what keeps these from leaking.
*/
.env-card {
border: 1px solid var(--color-quaternary);
background: var(--color-surface-deep);
}
.env-card-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 4px 10px;
border-bottom: 1px solid var(--color-quaternary);
background: var(--color-surface-tint);
}
.env-card-head h2 {
margin: 0;
font-size: 1rem;
}
.env-pill {
flex: none;
padding: 0 8px;
border: 1px solid currentColor;
border-radius: 999px;
font-size: 0.7rem;
line-height: 1.5;
white-space: nowrap;
color: var(--color-muted);
}
.env-pill.is-set {
color: var(--color-secondary);
}
.env-pill.is-unset {
color: var(--color-muted);
opacity: 0.6;
}
.env-pill.is-changed {
color: var(--color-tertiary);
}
.env-hint {
margin: 0;
font-size: 0.85rem;
opacity: 0.75;
}
.env-error {
margin: 0;
color: var(--color-error, #f87171);
}