feat: enhance photo upload and management features
- Added `taken_at` timestamp to the photos table for improved photo metadata. - Updated the photo upload API to support optional EXIF data extraction and file last modified timestamp. - Enhanced the photo upload process to allow skipping EXIF data, defaulting to today's date if no other date is provided. - Improved the photo display in various components to utilize a unified caption format. - Refactored photo sorting and grouping logic for better organization in the UI.
This commit is contained in:
1 parent
c91317df8e
commit
0035d08149
12 files changed
+225
-36
No files matched your search
@@ -170,11 +170,15 @@ export const api = {
|
||||
const d=await r.json();if(!r.ok)throw new Error(formatFastApiDetail(d.detail, JSON.stringify(d)));return d
|
||||
},
|
||||
|
||||
// Photos
|
||||
uploadPhoto: async (file, date = '') => {
|
||||
// Photos: EXIF → File.lastModified → date-Feld → heute; skipExif nur Formular/heute
|
||||
uploadPhoto: async (file, date = '', opts = {}) => {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
fd.append('date', date)
|
||||
if (opts.skipExif) fd.append('skip_exif', '1')
|
||||
if (file && typeof file.lastModified === 'number' && !Number.isNaN(file.lastModified) && file.lastModified > 0) {
|
||||
fd.append('file_last_modified', String(file.lastModified))
|
||||
}
|
||||
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)))
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
/** Monatsschlüssel YYYY-MM für Gruppierung (EXIF-Zeit bevorzugt). */
|
||||
export function photoMonthKey(p) {
|
||||
if (p.taken_at) return p.taken_at.slice(0, 7)
|
||||
if (p.date) {
|
||||
return typeof p.date === 'string' ? p.date.slice(0, 7) : dayjs(p.date).format('YYYY-MM')
|
||||
}
|
||||
return (p.created || '').slice(0, 7) || '0000-00'
|
||||
}
|
||||
|
||||
/** Sortierung: ISO-Zeit oder Datum. */
|
||||
export function photoSortKey(p) {
|
||||
if (p.taken_at) return p.taken_at
|
||||
const d = p.date || p.created || ''
|
||||
return typeof d === 'string' ? d.slice(0, 10) : dayjs(d).format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
/** Badge / Untertitel: mit Uhrzeit wenn EXIF vorhanden. */
|
||||
export function formatPhotoCaption(p) {
|
||||
if (p.taken_at) return dayjs(p.taken_at).format('DD.MM.YYYY HH:mm')
|
||||
const raw = p.date || p.created
|
||||
if (!raw) return ''
|
||||
return typeof raw === 'string' ? raw.slice(0, 10) : dayjs(raw).format('DD.MM.YYYY')
|
||||
}
|
||||
Reference in new issue
Block a user