Build out the admin panel

- Overview: users, organizations, workspaces, spaces, pages, files and
  storage (org admins see their organization), plus pages open right now,
  the search index size, and version, uptime and database health.
- Users: invite people by email (with resend, revoke and a copyable link
  when mail fails) and send a password-reset email.
- Authentication: sign-up on or off, the email-domain allow-list, and
  sign-in links by email.
- Branding: instance name, accent colour and logo. The web app shows them
  on the sign-in pages and applies the accent colour everywhere.
- Email and Storage: SMTP and S3 settings with test buttons.
- Maintenance: create, download and delete database backups, and a view
  of the background jobs with their last run, duration and errors.

On the server, a small jobs registry records each search-indexing pass,
and "search.rebuild" replaces the separate reindex endpoint. A new
instance package serves the dashboard numbers, health and backups.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-31 17:34:48 +01:00
1 parent 92cd81fd96
commit ffc6cc4fbc
31 files changed
+2326 -134

No files matched your search

@@ -0,0 +1,116 @@
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<script setup lang="ts">
import type { Invite, Organization, Role } from "@docwell/api-client";
import { DwBadge, DwButton, DwCallout } from "@docwell/ui";
import { computed, onMounted, reactive, ref } from "vue";
import { api, errorMessage, isSuperadmin } from "../session";
// Invite people by email into an organization. The person picks their own
// name and password when they accept.
const props = defineProps<{ orgs: Organization[] }>();
const emit = defineEmits<{ accepted: [] }>();
const invites = ref<Invite[]>([]);
const form = reactive({ email: "", role: "user" as Role, organization: "" });
const error = ref("");
const result = ref<Invite | null>(null);
const busy = ref(false);
const copied = ref(false);
const roles = computed<Role[]>(() => (isSuperadmin.value ? ["user", "admin", "superadmin"] : ["user", "admin"]));
const roleLabel: Record<string, string> = { user: "User", admin: "Admin", superadmin: "Superadmin" };
async function load() {
invites.value = (await api.invites.list()).filter((i) => !i.workspace);
}
onMounted(() => load().catch((e) => (error.value = errorMessage(e))));
async function run(action: () => Promise<void>) {
busy.value = true;
error.value = "";
try {
await action();
await load();
emit("accepted");
} catch (e) {
error.value = errorMessage(e);
} finally {
busy.value = false;
}
}
const invite = () =>
run(async () => {
result.value = await api.invites.create({
email: form.email,
role: form.role,
organization: isSuperadmin.value ? form.organization : undefined,
});
form.email = "";
});
const resend = (i: Invite) =>
run(async () => {
result.value = await api.invites.resend(i.id);
});
const revoke = (i: Invite) => run(() => api.invites.revoke(i.id));
async function copy(link: string) {
await navigator.clipboard.writeText(link);
copied.value = true;
setTimeout(() => (copied.value = false), 2000);
}
</script>
<template>
<section class="mt-6 dw-card" data-testid="invites">
<h2 class="text-ui-lg">Invite people</h2>
<form class="mt-3 flex flex-wrap gap-2" @submit.prevent="invite">
<input
v-model="form.email"
type="email"
required
placeholder="name@example.com"
aria-label="Email to invite"
class="dw-input min-w-56 flex-1"
/>
<select v-model="form.role" aria-label="Role" class="dw-input">
<option v-for="r in roles" :key="r" :value="r">{{ roleLabel[r] }}</option>
</select>
<select v-if="isSuperadmin" v-model="form.organization" aria-label="Organization" class="dw-input">
<option value="">No organization</option>
<option v-for="o in props.orgs" :key="o.id" :value="o.id">{{ o.name }}</option>
</select>
<DwButton type="submit" variant="primary" :disabled="busy || !form.email">Send invite</DwButton>
</form>
<DwCallout v-if="error" tone="danger" size="ui" class="mt-3">{{ error }}</DwCallout>
<DwCallout v-else-if="result" :tone="result.mailed ? 'success' : 'warning'" size="ui" class="mt-3">
<span class="flex flex-wrap items-center gap-2">
{{
result.mailed
? `An invitation is on its way to ${result.email}.`
: `${result.email} is invited, but the email could not be sent. Send them the link yourself.`
}}
<button v-if="result.link && !result.mailed" class="dw-link" @click="copy(result.link)">
{{ copied ? "Copied" : "Copy link" }}
</button>
</span>
</DwCallout>
<ul v-if="invites.length" class="mt-4 divide-y divide-line">
<li v-for="i in invites" :key="i.id" class="flex flex-wrap items-center justify-between gap-2 py-2">
<div class="min-w-0">
<p class="truncate font-medium">{{ i.email }}</p>
<p class="truncate text-ui-sm text-ink-muted">
{{ roleLabel[i.role] }}<template v-if="i.organizationName"> · {{ i.organizationName }}</template> · invited
by {{ i.invitedBy || "someone" }}
</p>
</div>
<div class="flex items-center gap-2">
<DwBadge v-if="i.status === 'expired'" tone="danger">Expired</DwBadge>
<DwButton variant="ghost" size="sm" :disabled="busy" @click="resend(i)">Resend</DwButton>
<DwButton variant="ghost" size="sm" class="!text-danger" :disabled="busy" @click="revoke(i)">Revoke</DwButton>
</div>
</li>
</ul>
</section>
</template>