Panel: give the API Server a name, and a tab to set it in
The Web App can be pointed at more than one DriverVault, but a server it
adds is only ever identified by the URL that was typed into the connect
dialog. Nothing on the other end says what it is called, so the switcher
has no name to show that the operator did not invent locally.
So the server now carries one. SERVER_NAME joins the config, defaulting to
"DriverVault API Server" so /api/health always has something a client can
display rather than an empty string every caller has to special-case.
GET/PUT /api/admin/server-config follow the pb-config and webapp-config
shape exactly: superadmin only, applied at runtime and then persisted to
.env, with the same "applied but could not be saved" warning when the write
fails. There is no /test sibling, because a name is a label and not an
address - there is nothing to probe. The length cap counts runes rather
than bytes, so a 64-character Polish or Danish name is not cut off at the
halfway mark.
/api/health reports it, unauthenticated, which is the point of the whole
change: a client adding this server by URL can label it from the probe it
already makes, instead of needing a second and authenticated call before it
can draw the entry.
In the panel it is a new API Server tab, first in the superadmin group
since it is this server itself, ahead of the PocketBase and Web App tabs
that describe what it talks to. Strings in all three languages, and the
route table in the README and the API reference tab both grow the two new
endpoints.
Known gap, deliberately not closed here: the compose files do not pass
SERVER_NAME, so under Docker a rename from the panel writes the container's
.env and no volume keeps it - it reverts to the default the next time the
container is recreated. Wiring it as ${SERVER_NAME:-} would make the host
.env authoritative, at the cost of the other trap the previous commit
documented, where the environment silently overrides the panel on every
restart. That is a call about the deployment, not about this endpoint.
Verified by new tests over the handler: the rename applies at runtime,
lands in .env, reaches /api/health, is rejected without touching .env when
blank or over-long, and accepts a name of exactly the limit in multi-byte
runes. go build, go vet and go test ./... pass. Drove the built panel in a
browser against a stub backend - the tab renders, loads the current name,
saves, and reads correctly in Polish - and ran the rebuilt api-server.exe
and webapp.exe end to end, confirming the embedded bundle really contains
the new tab and that SERVER_NAME reaches /api/health through both the
server itself and the Web App's proxy.
Not verified: no Docker build, so the images still serve the old panel
until they are rebuilt and pushed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
9258532952
commit
215c027ada
@@ -6,6 +6,7 @@ import { me, token, restore, logout, isManager, isSuperadmin } from "./api";
|
||||
import LoginView from "./components/LoginView.vue";
|
||||
import StatusCard from "./components/StatusCard.vue";
|
||||
import PocketBaseCard from "./components/PocketBaseCard.vue";
|
||||
import ServerCard from "./components/ServerCard.vue";
|
||||
import WebAppCard from "./components/WebAppCard.vue";
|
||||
import PluginsCard from "./components/PluginsCard.vue";
|
||||
import UsersCard from "./components/UsersCard.vue";
|
||||
@@ -37,6 +38,7 @@ const sections = computed(() => {
|
||||
}
|
||||
if (isSuperadmin.value) {
|
||||
out.push(
|
||||
{ id: "server", label: t("sections.server") },
|
||||
{ id: "pocketbase", label: t("sections.pocketbase") },
|
||||
{ id: "webapp", label: t("sections.webapp") },
|
||||
{ id: "plugins", label: t("sections.plugins") },
|
||||
@@ -145,6 +147,8 @@ const superadminApi = [
|
||||
{ method: "GET", path: "/api/admin/pb-config", desc: "PocketBase connection + live probe" },
|
||||
{ method: "POST", path: "/api/admin/pb-config/test", desc: "Probe a candidate connection" },
|
||||
{ method: "PUT", path: "/api/admin/pb-config", desc: "Apply + persist a connection" },
|
||||
{ method: "GET", path: "/api/admin/server-config", desc: "This server's display name" },
|
||||
{ method: "PUT", path: "/api/admin/server-config", desc: "Rename this server (applied + persisted)" },
|
||||
{ method: "GET", path: "/api/admin/webapp-config", desc: "Web App URL + CORS origins, with a live probe" },
|
||||
{ method: "POST", path: "/api/admin/webapp-config/test", desc: "Probe a candidate Web App address" },
|
||||
{ method: "PUT", path: "/api/admin/webapp-config", desc: "Apply + persist Web App settings" },
|
||||
@@ -245,6 +249,7 @@ const superadminApi = [
|
||||
<StatusCard v-if="section === 'overview'" />
|
||||
<UsersCard v-else-if="section === 'users'" />
|
||||
<OrgsCard v-else-if="section === 'orgs'" />
|
||||
<ServerCard v-else-if="section === 'server'" />
|
||||
<PocketBaseCard v-else-if="section === 'pocketbase'" />
|
||||
<WebAppCard v-else-if="section === 'webapp'" />
|
||||
<PluginsCard v-else-if="section === 'plugins'" />
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from "vue";
|
||||
import { request } from "../api";
|
||||
import { t } from "../i18n";
|
||||
|
||||
// Superadmin-only: this server's display name. Like the PocketBase and Web App
|
||||
// cards, the change is applied at runtime AND persisted to the server's .env,
|
||||
// so it survives a restart. There is nothing to probe here — the name is a
|
||||
// label, not an address — so this card saves without a test button.
|
||||
const form = ref({ name: "" });
|
||||
const error = ref("");
|
||||
const notice = ref("");
|
||||
const busy = ref(false);
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const view = await request("/api/admin/server-config");
|
||||
form.value = { name: view.name };
|
||||
} catch (e) {
|
||||
error.value = e.message;
|
||||
}
|
||||
}
|
||||
onMounted(load);
|
||||
|
||||
async function save() {
|
||||
error.value = "";
|
||||
notice.value = "";
|
||||
busy.value = true;
|
||||
try {
|
||||
const out = await request("/api/admin/server-config", {
|
||||
method: "PUT",
|
||||
body: { name: form.value.name },
|
||||
});
|
||||
form.value = { name: out.config.name };
|
||||
notice.value = out.warning || t("server.savedNotice");
|
||||
} catch (e) {
|
||||
error.value = e.message;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="dh-card overflow-hidden">
|
||||
<div class="border-b border-subtle px-5 py-4">
|
||||
<div class="text-base font-bold tracking-[-0.02em] text-strong">{{ t("server.title") }}</div>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ t("server.subtitle") }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-4 px-5 py-4">
|
||||
<div>
|
||||
<label class="dh-label" for="server-name">{{ t("server.name") }}</label>
|
||||
<input
|
||||
id="server-name"
|
||||
v-model="form.name"
|
||||
class="dh-input"
|
||||
maxlength="64"
|
||||
placeholder="DriverVault API Server"
|
||||
@keyup.enter="save"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-muted">{{ t("server.nameHint") }}</p>
|
||||
</div>
|
||||
|
||||
<p v-if="notice" class="rounded-control bg-info-soft px-3 py-2 text-xs text-info">{{ notice }}</p>
|
||||
<p v-if="error" class="rounded-control bg-danger-soft px-3 py-2 text-xs text-danger">{{ error }}</p>
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<button class="dh-btn" :disabled="busy" @click="save">{{ t("server.saveApply") }}</button>
|
||||
<span class="flex-1"></span>
|
||||
<span class="eyebrow">{{ t("server.persistedEnv") }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -14,6 +14,7 @@
|
||||
"overview": "Oversigt",
|
||||
"users": "Brugere",
|
||||
"orgs": "Organisationer",
|
||||
"server": "API-server",
|
||||
"pocketbase": "PocketBase",
|
||||
"webapp": "Webapp",
|
||||
"plugins": "Plugins",
|
||||
@@ -84,6 +85,16 @@
|
||||
"confirmDeleteOwn": "Slet din organisation „{name}“? Du fjernes fra den og bliver en almindelig bruger."
|
||||
},
|
||||
|
||||
"server": {
|
||||
"title": "API-server",
|
||||
"subtitle": "Hvordan denne server identificerer sig over for de klienter, der forbinder til den",
|
||||
"name": "Servernavn",
|
||||
"nameHint": "Vises af klienter, der kan pege på mere end én DriverVault, for eksempel webappens serverskifter. Returneres af /api/health.",
|
||||
"saveApply": "Gem og anvend",
|
||||
"persistedEnv": "gemt i .env",
|
||||
"savedNotice": "Gemt. Det nye navn gælder fra næste anmodning."
|
||||
},
|
||||
|
||||
"pocketbase": {
|
||||
"title": "PocketBase",
|
||||
"subtitle": "Databaseforbindelse brugt af hvert endpoint",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"overview": "Overview",
|
||||
"users": "Users",
|
||||
"orgs": "Organizations",
|
||||
"server": "API Server",
|
||||
"pocketbase": "PocketBase",
|
||||
"webapp": "Web App",
|
||||
"plugins": "Plugins",
|
||||
@@ -84,6 +85,16 @@
|
||||
"confirmDeleteOwn": "Delete your organization \"{name}\"? You will be removed from it and become a regular user."
|
||||
},
|
||||
|
||||
"server": {
|
||||
"title": "API Server",
|
||||
"subtitle": "How this server identifies itself to the clients that connect to it",
|
||||
"name": "Server name",
|
||||
"nameHint": "Shown by clients that can be pointed at more than one DriverVault, such as the Web App's server switcher. Reported by /api/health.",
|
||||
"saveApply": "Save & apply",
|
||||
"persistedEnv": "persisted to .env",
|
||||
"savedNotice": "Saved. The new name applies to the next request."
|
||||
},
|
||||
|
||||
"pocketbase": {
|
||||
"title": "PocketBase",
|
||||
"subtitle": "Database connection used by every endpoint",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"overview": "Przegląd",
|
||||
"users": "Użytkownicy",
|
||||
"orgs": "Organizacje",
|
||||
"server": "Serwer API",
|
||||
"pocketbase": "PocketBase",
|
||||
"webapp": "Aplikacja webowa",
|
||||
"plugins": "Wtyczki",
|
||||
@@ -84,6 +85,16 @@
|
||||
"confirmDeleteOwn": "Usunąć Twoją organizację „{name}”? Zostaniesz z niej usunięty i staniesz się zwykłym użytkownikiem."
|
||||
},
|
||||
|
||||
"server": {
|
||||
"title": "Serwer API",
|
||||
"subtitle": "Jak ten serwer przedstawia się klientom, które się z nim łączą",
|
||||
"name": "Nazwa serwera",
|
||||
"nameHint": "Widoczna w klientach, które można skierować na więcej niż jeden DriverVault, na przykład w przełączniku serwerów aplikacji webowej. Zwracana przez /api/health.",
|
||||
"saveApply": "Zapisz i zastosuj",
|
||||
"persistedEnv": "zapisano w .env",
|
||||
"savedNotice": "Zapisano. Nowa nazwa obowiązuje od następnego żądania."
|
||||
},
|
||||
|
||||
"pocketbase": {
|
||||
"title": "PocketBase",
|
||||
"subtitle": "Połączenie z bazą danych używane przez każdy punkt końcowy",
|
||||
|
||||
Reference in New Issue
Block a user