feat(signage): gallery widget (pictures and videos one after another, from a list or a media folder); media folders on the Media page
Folders are only a grouping in the database (media_folders, media.folder_id, Alembic 0046): made, renamed, deleted (files stay) on the Media page, a file filed from its details, uploads go into the folder shown, the picker filters by folder. The gallery widget: its own pictures/videos in order or a folder as it is now, seconds each, fade / slide / zoom, cover / contain. Plan 6R.16, F-114. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,11 +6,11 @@ import toast from 'react-hot-toast'
|
||||
import { Trash2 } from 'lucide-react'
|
||||
import { errorMessage } from '@xenia/api'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Button, Dialog, Field, Input, Spinner, cx } from '@xenia/ui'
|
||||
import { deleteMedia, getMedia, renameMedia } from './mediaApi'
|
||||
import { Button, Dialog, Dropdown, Field, Input, Spinner, cx } from '@xenia/ui'
|
||||
import { deleteMedia, getMedia, renameMedia, setFolder } from './mediaApi'
|
||||
import { duration, fileSize, preparing, resolution, VARIANT_ORDER, videoState } from './mediaLogic'
|
||||
|
||||
export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
|
||||
export default function MediaDetails({ id, onClose, onChanged, onDeleted, folders = [] }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const { formatDateTime, formatNumber } = useFormat()
|
||||
const [item, setItem] = useState(null)
|
||||
@@ -43,6 +43,10 @@ export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
|
||||
catch (err) { toast.error(errorMessage(err, t)) }
|
||||
setBusy(false)
|
||||
}
|
||||
const fileIn = async folderId => {
|
||||
try { const m = await setFolder(id, folderId); setItem(it => ({ ...it, ...m })); onChanged?.(m); toast.success(t('media.folders.moved')) }
|
||||
catch (err) { toast.error(errorMessage(err, t)) }
|
||||
}
|
||||
const remove = async () => {
|
||||
setBusy(true)
|
||||
try { await deleteMedia(id); toast.success(t('media.deleted')); onDeleted?.(id); onClose() }
|
||||
@@ -93,6 +97,11 @@ export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
|
||||
<p className="text-caption text-ink-3">{t(item.builtin ? 'media.builtinHint' : 'media.displayNameHint')}</p>
|
||||
</div>
|
||||
|
||||
<Field label={t('media.folders.folder')} className="max-w-sm">
|
||||
<Dropdown value={item.folder_id ?? ''} onChange={v => fileIn(v === '' ? null : Number(v))} data-testid="media-folder-pick"
|
||||
options={[{ value: '', label: t('media.folders.none') }, ...folders.map(f => ({ value: f.id, label: f.name }))]} />
|
||||
</Field>
|
||||
|
||||
<dl className="grid gap-x-4 gap-y-1 text-label" style={{ gridTemplateColumns: 'max-content 1fr' }}>
|
||||
{rows.map(([k, v]) => <div key={k} className="contents"><dt className="text-ink-3">{k}</dt><dd className="text-ink break-all">{v}</dd></div>)}
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user