Add the optional Immich integration and manual gallery push
Immich connections stay server-side with an encrypted API key, albums can be imported, and photos are only sent back when an event's push button is pressed: originals upload once, edited photos re-render, and edits hashes plus checksums skip anything already in Immich. This also lands the accompanying editor, cloud and administration work that was still uncommitted. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
@@ -15,14 +15,17 @@ import {
|
||||
adminCreateUser,
|
||||
adminDeleteEvent,
|
||||
adminDeleteUser,
|
||||
adminDisconnectImmich,
|
||||
adminRestoreCatalog,
|
||||
adminRevokeInvite,
|
||||
adminOverview,
|
||||
adminRenameEvent,
|
||||
adminSaveImmich,
|
||||
adminSaveMail,
|
||||
adminSchedulePrune,
|
||||
adminSetQuota,
|
||||
adminSetStorage,
|
||||
adminTestImmich,
|
||||
adminTestMail,
|
||||
adminUpdateUser,
|
||||
adminWarnUser,
|
||||
@@ -68,7 +71,7 @@ const planSummary = (quota: AdminQuota) => {
|
||||
return parts.length ? parts.join(', ') : 'nothing';
|
||||
};
|
||||
|
||||
type Tab = 'users' | 'invites' | 'content' | 'storage' | 'quotas' | 'backup';
|
||||
type Tab = 'users' | 'invites' | 'content' | 'storage' | 'quotas' | 'immich' | 'backup';
|
||||
|
||||
const inviteUrl = (token: string) => `${window.location.origin}/join/${token}`;
|
||||
|
||||
@@ -112,6 +115,8 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
|
||||
const [quotaDrafts, setQuotaDrafts] = useState<Record<string, string>>({});
|
||||
const [mailDraft, setMailDraft] = useState({ user: '', appPassword: '', from: '' });
|
||||
const [mail, setMail] = useState<MailStatus | null>(null);
|
||||
const [immichDraft, setImmichDraft] = useState({ url: '', apiKey: '', enabled: true });
|
||||
|
||||
|
||||
const restoreCatalog = async (file: File | undefined) => {
|
||||
if (!file || busy) return;
|
||||
@@ -161,6 +166,11 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
|
||||
user: current.user || next.mail.user,
|
||||
from: current.from || next.mail.from,
|
||||
}));
|
||||
setImmichDraft((current) => ({
|
||||
url: next.immich.hasKey ? current.url || next.immich.url : next.immich.url,
|
||||
apiKey: '',
|
||||
enabled: next.immich.hasKey ? (current.url ? current.enabled : next.immich.enabled) : true,
|
||||
}));
|
||||
setRootInput((current) => (current ? current : next.storage.root));
|
||||
onChanged();
|
||||
}, [onChanged]);
|
||||
@@ -174,6 +184,13 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
|
||||
setOverview(next);
|
||||
setMail(next.mail);
|
||||
setMailDraft({ user: next.mail.user, appPassword: '', from: next.mail.from });
|
||||
// A connection being set up for the first time defaults to on; the box
|
||||
// would otherwise be unchecked and silently save publishing as off.
|
||||
setImmichDraft({
|
||||
url: next.immich.url,
|
||||
apiKey: '',
|
||||
enabled: next.immich.hasKey ? next.immich.enabled : true,
|
||||
});
|
||||
setRootInput(next.storage.root);
|
||||
setQuotaDrafts(
|
||||
Object.fromEntries(
|
||||
@@ -345,6 +362,42 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
|
||||
setNote(`Test email sent to ${user.email}`);
|
||||
});
|
||||
|
||||
const saveImmich = () =>
|
||||
run(async () => {
|
||||
const next = await adminSaveImmich({
|
||||
url: immichDraft.url.trim(),
|
||||
apiKey: immichDraft.apiKey,
|
||||
enabled: immichDraft.enabled,
|
||||
});
|
||||
setImmichDraft({ url: next.url, apiKey: '', enabled: next.enabled });
|
||||
setNote(
|
||||
next.enabled
|
||||
? 'Immich connection saved for every account'
|
||||
: 'Immich connection saved; automatic publishing is off',
|
||||
);
|
||||
});
|
||||
|
||||
const testImmich = () =>
|
||||
run(async () => {
|
||||
const result = await adminTestImmich();
|
||||
setNote(
|
||||
`Connected to Immich ${result.version} · ${result.albumCount} album${
|
||||
result.albumCount === 1 ? '' : 's'
|
||||
}`,
|
||||
);
|
||||
});
|
||||
|
||||
const disconnectImmichConnection = () => {
|
||||
if (!window.confirm('Remove the server-wide Immich connection? Existing albums and photos stay in Immich.')) {
|
||||
return;
|
||||
}
|
||||
void run(async () => {
|
||||
const next = await adminDisconnectImmich();
|
||||
setImmichDraft({ url: next.url, apiKey: '', enabled: next.enabled });
|
||||
setNote('Immich connection removed');
|
||||
});
|
||||
};
|
||||
|
||||
const renameEvent = () => {
|
||||
if (!editEvent) return;
|
||||
const name = editEvent.name.trim();
|
||||
@@ -404,6 +457,9 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
|
||||
<button className={`tab ${tab === 'quotas' ? 'on' : ''}`} onClick={() => setTab('quotas')}>
|
||||
Quotas
|
||||
</button>
|
||||
<button className={`tab ${tab === 'immich' ? 'on' : ''}`} onClick={() => setTab('immich')}>
|
||||
Immich
|
||||
</button>
|
||||
<button className={`tab ${tab === 'backup' ? 'on' : ''}`} onClick={() => setTab('backup')}>
|
||||
Backup
|
||||
</button>
|
||||
@@ -926,6 +982,108 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
) : tab === 'immich' ? (
|
||||
<section className="admin-section">
|
||||
<h3>Immich connection</h3>
|
||||
<p className="muted small">
|
||||
One connection is shared by every account. When it is enabled, importing into a
|
||||
Luminary event creates a matching Immich album, publishes the originals there, and
|
||||
saves edited versions to the same album.
|
||||
</p>
|
||||
|
||||
<label className="field">
|
||||
<span>Immich server address</span>
|
||||
<input
|
||||
value={immichDraft.url}
|
||||
spellCheck={false}
|
||||
placeholder="http://192.168.1.10:2283"
|
||||
onChange={(e) =>
|
||||
setImmichDraft((current) => ({ ...current, url: e.target.value }))
|
||||
}
|
||||
onKeyDown={(e) => e.key === 'Enter' && saveImmich()}
|
||||
/>
|
||||
</label>
|
||||
<label className="field">
|
||||
<span>API key</span>
|
||||
<input
|
||||
type="password"
|
||||
autoComplete="off"
|
||||
value={immichDraft.apiKey}
|
||||
placeholder={overview.immich.hasKey ? 'Saved — type to replace' : 'Immich API key'}
|
||||
onChange={(e) =>
|
||||
setImmichDraft((current) => ({ ...current, apiKey: e.target.value }))
|
||||
}
|
||||
onKeyDown={(e) => e.key === 'Enter' && saveImmich()}
|
||||
/>
|
||||
</label>
|
||||
<label className="check-row">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={immichDraft.enabled}
|
||||
disabled={busy}
|
||||
onChange={(e) =>
|
||||
setImmichDraft((current) => ({ ...current, enabled: e.target.checked }))
|
||||
}
|
||||
/>
|
||||
Automatically publish event photos and edits
|
||||
</label>
|
||||
<div className="btn-row">
|
||||
<button
|
||||
className="btn primary"
|
||||
onClick={saveImmich}
|
||||
disabled={
|
||||
busy ||
|
||||
!immichDraft.url.trim() ||
|
||||
(!immichDraft.apiKey && !overview.immich.hasKey)
|
||||
}
|
||||
>
|
||||
Save connection
|
||||
</button>
|
||||
<button
|
||||
className="btn ghost"
|
||||
onClick={testImmich}
|
||||
disabled={busy || !overview.immich.hasKey}
|
||||
>
|
||||
Test connection
|
||||
</button>
|
||||
{overview.immich.hasKey && (
|
||||
<button
|
||||
className="btn ghost"
|
||||
onClick={disconnectImmichConnection}
|
||||
disabled={busy}
|
||||
>
|
||||
Disconnect
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{overview.immich.configured ? (
|
||||
<div className={`banner ${overview.immich.enabled ? 'ok' : 'info'}`}>
|
||||
{overview.immich.enabled
|
||||
? 'Connected and automatic publishing is on.'
|
||||
: 'Connection saved; automatic publishing is off.'}{' '}
|
||||
{overview.immich.version ? `Immich ${overview.immich.version}.` : 'Test it to verify access.'}
|
||||
</div>
|
||||
) : (
|
||||
<div className="banner info">
|
||||
Add the server address and API key to enable Immich publishing.
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="admin-note">
|
||||
<p>
|
||||
The key needs <code>album.read</code>, <code>album.create</code>,{' '}
|
||||
<code>albumAsset.create</code>, <code>asset.read</code>,{' '}
|
||||
<code>asset.download</code>, <code>asset.upload</code> and{' '}
|
||||
<code>asset.update</code>. Add <code>asset.delete</code> only if originals should
|
||||
move to the Immich trash after an edited version is uploaded.
|
||||
</p>
|
||||
<p className="muted small">
|
||||
The key is encrypted on the server and never sent back to a browser. Existing
|
||||
albums already in Immich stay untouched if the connection is removed.
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
) : tab === 'backup' ? (
|
||||
<section className="admin-section">
|
||||
<h3>Catalog backup</h3>
|
||||
|
||||
Reference in New Issue
Block a user