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:
@@ -1,16 +1,17 @@
|
||||
// The media library's API (backend: local_backend/routers/media.py, plan steps 5.1 / 5.2).
|
||||
import client from '../../api/client'
|
||||
|
||||
export const listMedia = ({ kind, q, collection, limit = 500 } = {}) =>
|
||||
client.get('/api/media', { params: { kind: kind || undefined, q: q || undefined, collection: collection || undefined, limit } }).then(r => r.data)
|
||||
export const listMedia = ({ kind, q, collection, folder, limit = 500 } = {}) =>
|
||||
client.get('/api/media', { params: { kind: kind || undefined, q: q || undefined, collection: collection || undefined, folder: folder || undefined, limit } }).then(r => r.data)
|
||||
|
||||
export const getMedia = id => client.get(`/api/media/${id}`).then(r => r.data)
|
||||
|
||||
/** Upload one file → the library item (`existing: true` when the same file was already there). */
|
||||
export function uploadMedia(file, { name, onProgress } = {}) {
|
||||
export function uploadMedia(file, { name, folderId, onProgress } = {}) {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
if (name) fd.append('name', name)
|
||||
if (folderId) fd.append('folder_id', String(folderId))
|
||||
return client.post('/api/media', fd, {
|
||||
onUploadProgress: e => { if (onProgress && e.total) onProgress(Math.round((e.loaded / e.total) * 100)) },
|
||||
}).then(r => r.data)
|
||||
@@ -19,3 +20,11 @@ export function uploadMedia(file, { name, onProgress } = {}) {
|
||||
export const renameMedia = (id, name) => client.patch(`/api/media/${id}`, { name }).then(r => r.data)
|
||||
|
||||
export const deleteMedia = id => client.delete(`/api/media/${id}`)
|
||||
|
||||
// folders (6R.16): only a grouping in the database; the files stay where they are
|
||||
export const listFolders = () => client.get('/api/media/folders').then(r => r.data)
|
||||
export const createFolder = name => client.post('/api/media/folders', { name }).then(r => r.data)
|
||||
export const renameFolder = (id, name) => client.patch(`/api/media/folders/${id}`, { name }).then(r => r.data)
|
||||
export const deleteFolder = id => client.delete(`/api/media/folders/${id}`)
|
||||
export const moveMedia = (ids, folderId) => client.post('/api/media/move', { ids, folder_id: folderId ?? null }).then(r => r.data)
|
||||
export const setFolder = (id, folderId) => client.patch(`/api/media/${id}`, { folder_id: folderId ?? null }).then(r => r.data)
|
||||
|
||||
Reference in New Issue
Block a user