feat(manager): Media page, photo field for products and categories (platform-v2 step 5.2)
- Management → Media (src/pages/media/): every picture and video, search, pictures / videos, batch upload (many files or drop on the page) with a result per file, details (preview, display name, kind, resolution, length, file size, uploaded file, when / who, the sizes made, what uses it, delete off while used). - MediaField: upload on the spot (into the library and set at once), pick from the library (MediaPicker, which can also upload), remove; after an upload on the spot "Name it after the product / category" renames it in Latin letters. Used by the product editor and the category dialog. - nav: `anyPerm` (any of the keys that manage pictures); the route guard uses the same rule. Product rows have test ids. - @xenia/i18n: latin() (Greek to Latin, the way venues write it) + tests. - tests: manager media.test.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// 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, limit = 500 } = {}) =>
|
||||
client.get('/api/media', { params: { kind: kind || undefined, q: q || 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 } = {}) {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
if (name) fd.append('name', name)
|
||||
return client.post('/api/media', fd, {
|
||||
onUploadProgress: e => { if (onProgress && e.total) onProgress(Math.round((e.loaded / e.total) * 100)) },
|
||||
}).then(r => r.data)
|
||||
}
|
||||
|
||||
export const renameMedia = (id, name) => client.patch(`/api/media/${id}`, { name }).then(r => r.data)
|
||||
|
||||
export const deleteMedia = id => client.delete(`/api/media/${id}`)
|
||||
Reference in New Issue
Block a user