982f9048e1
CI / build (push) Has been cancelled
A bind-mounted host directory made the app report storage as ready while media landed on the container host's local filesystem, so the NFS export was never actually used. mediaStorage() now reads the mount table: a share written as host:/export is only accepted when the media root is on a network filesystem, otherwise uploads, edits and filing are blocked with the real device and the fix. Settings and the Media page show the detected filesystem and host-mount steps, README section 9 documents the OS-level mount (including Docker-in-LXC) with docker-compose.nfs.yml as the alternative, and the E2E suites use path-style shares for local test directories. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
182 lines
6.4 KiB
TypeScript
182 lines
6.4 KiB
TypeScript
import Link from "next/link";
|
|
import { auth } from "@/auth/config";
|
|
import { hasPermission } from "@/auth/permissions";
|
|
import type { SystemRole } from "@/auth/roles";
|
|
import { getEmailSettings } from "@/db/settings";
|
|
import { getUserSecurity } from "@/db/users";
|
|
import { getStorageSettings } from "@/db/storage-settings";
|
|
import { mediaStorage } from "@/lib/media-storage";
|
|
import { CHURCH_TIMEZONE } from "@/lib/tz";
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card";
|
|
import { SettingsForm } from "@/components/app/settings-form";
|
|
import { StoragePanel } from "@/components/app/storage-panel";
|
|
import { PasswordForm } from "@/components/app/password-form";
|
|
|
|
export const metadata = { title: "Settings" };
|
|
|
|
/**
|
|
* Deployment facts plus the admin-editable email identity. The From address
|
|
* and admin notification inbox live in the database, so changing them does not
|
|
* require a deploy or a container restart.
|
|
*/
|
|
export default async function SettingsPage() {
|
|
const session = await auth();
|
|
const role = (session?.user as { systemRole?: SystemRole } | undefined)?.systemRole;
|
|
const userId = (session?.user as { id?: string } | undefined)?.id;
|
|
const security = userId ? await getUserSecurity(userId) : null;
|
|
const isAdmin = hasPermission(role, "admin.settings");
|
|
const emailSettings = isAdmin ? await getEmailSettings() : null;
|
|
// Keep the form populated even while the destination is unusable, so an
|
|
// admin can see and fix what is saved.
|
|
const storageSettings = isAdmin ? await getStorageSettings() : null;
|
|
const media = isAdmin ? await mediaStorage() : null;
|
|
const storageStatus = media
|
|
? {
|
|
ready: media.ok,
|
|
message: media.ok
|
|
? `Event photos and videos are stored in ${media.root}.`
|
|
: media.message,
|
|
freeBytes: media.ok ? media.freeBytes : null,
|
|
mount: media.ok ? media.mount : null,
|
|
}
|
|
: null;
|
|
const emailTransport = emailSettings?.smtpConfigured
|
|
? "Gmail (SMTP)"
|
|
: process.env.POSTMARK_SERVER_TOKEN
|
|
? "Postmark"
|
|
: "Console outbox (dev)";
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<div>
|
|
<h1 className="text-lg font-semibold tracking-tight">Settings</h1>
|
|
<p className="text-sm text-muted-foreground">
|
|
Church details and how the app is configured.
|
|
</p>
|
|
</div>
|
|
|
|
{security && (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="text-lg">My account</CardTitle>
|
|
<CardDescription>
|
|
Your username and password for signing in. Changing either does
|
|
not sign you out of this session.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent className="space-y-4">
|
|
<Link
|
|
href="/profile"
|
|
className="inline-flex text-sm font-medium text-primary underline"
|
|
>
|
|
Edit profile, notifications, skill comfort and calendar feed
|
|
</Link>
|
|
<PasswordForm
|
|
initialUsername={security.username}
|
|
hasPassword={Boolean(security.passwordHash)}
|
|
/>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="text-lg">Church</CardTitle>
|
|
<CardDescription>
|
|
Values that drive scheduling and message delivery.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<dl className="grid gap-4 sm:grid-cols-2">
|
|
<div>
|
|
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
|
Timezone
|
|
</dt>
|
|
<dd className="mt-1 text-sm text-foreground">{CHURCH_TIMEZONE}</dd>
|
|
</div>
|
|
<div>
|
|
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
|
Week starts
|
|
</dt>
|
|
<dd className="mt-1 text-sm text-foreground">Sunday</dd>
|
|
</div>
|
|
<div>
|
|
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
|
Email delivery
|
|
</dt>
|
|
<dd className="mt-1 text-sm text-foreground">{emailTransport}</dd>
|
|
</div>
|
|
<div>
|
|
<dt className="text-xs font-semibold uppercase tracking-tight text-muted-foreground">
|
|
Signed in as
|
|
</dt>
|
|
<dd className="mt-1 text-sm text-foreground">
|
|
{session?.user?.email ?? "—"}
|
|
{security && (
|
|
<span className="block text-xs text-muted-foreground">
|
|
Username: {security.username}
|
|
</span>
|
|
)}
|
|
</dd>
|
|
</div>
|
|
</dl>
|
|
</CardContent>
|
|
</Card>
|
|
|
|
{isAdmin && emailSettings && (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="text-lg">Email & notifications</CardTitle>
|
|
<CardDescription>
|
|
Sender identity for assignment mail and where admin test messages
|
|
are delivered.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<SettingsForm
|
|
emailFrom={emailSettings.emailFrom}
|
|
notificationEmail={emailSettings.notificationEmail}
|
|
/>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
{isAdmin && storageSettings && storageStatus && (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="text-lg">Media storage (NFS / local path)</CardTitle>
|
|
<CardDescription>
|
|
Mount an NFS export into this container. Finished event photos are
|
|
archived here, and every uploaded video keeps its camera original
|
|
on this mount. Photo archives include originals, saved edits, and a
|
|
manifest.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<StoragePanel
|
|
initial={storageSettings}
|
|
initialStatus={storageStatus}
|
|
/>
|
|
</CardContent>
|
|
</Card>
|
|
)}
|
|
|
|
{isAdmin && (
|
|
<p className="text-sm text-muted-foreground">
|
|
People, services, reminder rules, and the notification log live in{" "}
|
|
<Link href="/admin" className="font-medium text-primary underline">
|
|
Admin
|
|
</Link>
|
|
.
|
|
</p>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|