feat(editor): bridge the advanced photo editor into the event workflow
CI / build (push) Has been cancelled
CI / build (push) Has been cancelled
Event photos can now be opened in Lumenroom, a WebGL2 develop module, from the photo editor's Advanced button. The dashboard signs a short-lived token scoped to one user and event; Lumenroom exchanges it, imports the event's photo list and proxies bytes on demand, so nothing is copied and the temporary catalog expires with the bridge session. Saving in Lumenroom renders the photo and writes it back as the event's edited JPEG, with the advanced recipe kept in event_photos.advanced_edit_json. Lumenroom is vendored under lumenroom/ and built as a second compose service, so one clone and `docker compose up -d --build` deploys both apps. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { Health, SessionUser } from '../lib/api';
|
||||
|
||||
interface Props {
|
||||
health: Health | null;
|
||||
user: SessionUser | null;
|
||||
busy: boolean;
|
||||
note: string | null;
|
||||
error: string | null;
|
||||
onLogin: (email: string, password: string) => void;
|
||||
onRegister: (input: { email: string; password: string; name: string; invite: string }) => void;
|
||||
onLogout: () => void;
|
||||
onSync: () => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
function fmtBytes(bytes: number) {
|
||||
if (bytes > 1024 ** 3) return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
|
||||
if (bytes > 1024 ** 2) return `${(bytes / 1024 ** 2).toFixed(0)} MB`;
|
||||
return `${Math.round(bytes / 1024)} KB`;
|
||||
}
|
||||
|
||||
export default function CloudPanel({
|
||||
health,
|
||||
user,
|
||||
busy,
|
||||
note,
|
||||
error,
|
||||
onLogin,
|
||||
onRegister,
|
||||
onLogout,
|
||||
onSync,
|
||||
onClose,
|
||||
}: Props) {
|
||||
const [mode, setMode] = useState<'signin' | 'signup'>('signin');
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [name, setName] = useState('');
|
||||
const [invite, setInvite] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.key !== 'Escape') return;
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
if (!busy) onClose();
|
||||
};
|
||||
window.addEventListener('keydown', onKey, true);
|
||||
return () => window.removeEventListener('keydown', onKey, true);
|
||||
}, [busy, onClose]);
|
||||
|
||||
const submit = () => {
|
||||
if (busy) return;
|
||||
if (mode === 'signin') onLogin(email.trim(), password);
|
||||
else onRegister({ email: email.trim(), password, name: name.trim(), invite: invite.trim() });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="modal-backdrop" onPointerDown={(e) => e.target === e.currentTarget && onClose()}>
|
||||
<div className="modal cloud-modal">
|
||||
<header className="modal-head">
|
||||
<h2>Team server</h2>
|
||||
<button className="icon-btn" onClick={onClose}>
|
||||
✕
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div className="modal-body">
|
||||
{!health ? (
|
||||
<div className="cloud-offline">
|
||||
<strong>No server detected</strong>
|
||||
<p className="muted small">
|
||||
The library is running fully in this browser. To share photos with the team, start the
|
||||
server and reload:
|
||||
</p>
|
||||
<pre className="code-block">npm run server</pre>
|
||||
<p className="muted small">
|
||||
Originals, edits and ratings are then stored on disk under <code>server/data</code>.
|
||||
</p>
|
||||
</div>
|
||||
) : user ? (
|
||||
<div className="cloud-account">
|
||||
<div className="cloud-hero">
|
||||
<div className="cloud-avatar">{(user.name || user.email).slice(0, 1).toUpperCase()}</div>
|
||||
<div>
|
||||
<strong>{user.name || user.email}</strong>
|
||||
<div className="muted small">
|
||||
{user.email} · {user.role}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<dl className="cloud-stats">
|
||||
<div>
|
||||
<dt>Photos on server</dt>
|
||||
<dd>{health.photos}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Storage used</dt>
|
||||
<dd>{fmtBytes(health.bytes)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Raw engine</dt>
|
||||
<dd>{health.raw.libraw ? 'LibRaw demosaic' : 'Embedded previews'}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Server version</dt>
|
||||
<dd>{health.version}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div className="btn-row">
|
||||
<button className="btn primary" onClick={onSync} disabled={busy}>
|
||||
{busy ? 'Syncing…' : 'Sync library'}
|
||||
</button>
|
||||
<button className="btn ghost" onClick={onLogout} disabled={busy}>
|
||||
Sign out
|
||||
</button>
|
||||
</div>
|
||||
{note && <div className="banner ok">{note}</div>}
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="tabs">
|
||||
<button className={`tab ${mode === 'signin' ? 'on' : ''}`} onClick={() => setMode('signin')}>
|
||||
Sign in
|
||||
</button>
|
||||
<button className={`tab ${mode === 'signup' ? 'on' : ''}`} onClick={() => setMode('signup')}>
|
||||
{health.needsSetup ? 'Create admin' : 'Join team'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<label className="field">
|
||||
<span>Email</span>
|
||||
<input
|
||||
type="email"
|
||||
autoComplete="username"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && submit()}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{mode === 'signup' && (
|
||||
<label className="field">
|
||||
<span>Display name</span>
|
||||
<input value={name} onChange={(e) => setName(e.target.value)} placeholder="Optional" />
|
||||
</label>
|
||||
)}
|
||||
|
||||
<label className="field">
|
||||
<span>Password</span>
|
||||
<input
|
||||
type="password"
|
||||
autoComplete={mode === 'signin' ? 'current-password' : 'new-password'}
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && submit()}
|
||||
/>
|
||||
</label>
|
||||
|
||||
{mode === 'signup' && !health.needsSetup && (
|
||||
<label className="field">
|
||||
<span>Invite code</span>
|
||||
<input
|
||||
value={invite}
|
||||
onChange={(e) => setInvite(e.target.value)}
|
||||
placeholder="From your admin"
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
|
||||
{mode === 'signup' && health.needsSetup && (
|
||||
<p className="muted small">
|
||||
The first account becomes the team admin. Share the invite code you set in{' '}
|
||||
<code>LUMENROOM_INVITE</code> with everyone else.
|
||||
</p>
|
||||
)}
|
||||
|
||||
<button className="btn primary wide" onClick={submit} disabled={busy || !email || !password}>
|
||||
{busy ? 'Working…' : mode === 'signin' ? 'Sign in' : 'Create account'}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{error && <div className="banner error">{error}</div>}
|
||||
|
||||
{health && (
|
||||
<p className="muted small cloud-foot">
|
||||
Server sharing the folder <code>server/data</code> · raw formats:{' '}
|
||||
{health.raw.formats.length} · {health.raw.sharp ? 'JPEG encoder ready' : 'PNG fallback'}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user