feat: implement photo management features in the application
- Added a new `resolve_photo_path` function to handle legacy and new photo paths effectively. - Updated the photo upload process to store only filenames in the database, improving path resolution. - Enhanced the photo retrieval and deletion processes to utilize the new path resolution logic. - Introduced a dedicated PhotosCapturePage for managing photo uploads and viewing. - Updated the dashboard and navigation to include links to the new photo management features. - Improved the photo grid display with sorting and deletion capabilities for better user experience.
This commit is contained in:
1 parent
7676897fda
commit
c91317df8e
9 files changed
+417
-38
No files matched your search
@@ -171,14 +171,21 @@ export const api = {
|
||||
},
|
||||
|
||||
// Photos
|
||||
uploadPhoto: (file,date='')=>{
|
||||
const fd=new FormData();fd.append('file',file);fd.append('date',date)
|
||||
return fetch(`${BASE}/photos`,{method:'POST',body:fd,headers:hdrs()}).then(r=>r.json())
|
||||
uploadPhoto: async (file, date = '') => {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
fd.append('date', date)
|
||||
const r = await fetch(`${BASE}/photos`, { method: 'POST', body: fd, headers: hdrs() })
|
||||
const d = await r.json().catch(() => ({}))
|
||||
if (!r.ok) throw new Error(formatFastApiDetail(d.detail, JSON.stringify(d)))
|
||||
return d
|
||||
},
|
||||
listPhotos: () => req('/photos'),
|
||||
photoUrl: (pid) => {
|
||||
listPhotos: () => req('/photos'),
|
||||
deletePhoto: (id) => req(`/photos/${id}`, { method: 'DELETE' }),
|
||||
/** Bild-URL; Query heißt `ssetoken` (require_auth_flexible), nicht `token`. */
|
||||
photoUrl: (pid) => {
|
||||
const token = getToken()
|
||||
return `${BASE}/photos/${pid}${token ? `?token=${token}` : ''}`
|
||||
return `${BASE}/photos/${pid}${token ? `?ssetoken=${encodeURIComponent(token)}` : ''}`
|
||||
},
|
||||
|
||||
// Nutrition
|
||||
|
||||
Reference in new issue
Block a user