diff --git a/backend/main.py b/backend/main.py index 9a593a0..47de28b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -406,7 +406,7 @@ async def serve_media(path: str, request: _Request): raise _HE(404, "Nicht gefunden.") return _media_response(filepath) -APP_VER = "901" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "902" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/static/index.html b/backend/static/index.html index 809c1f1..cb1a3cd 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -591,10 +591,10 @@ - - - - + + + + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 24d20c7..5f52530 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '901'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '902'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.1'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; // Cache-Bust-Parameter nach Update-Reload sofort entfernen diff --git a/backend/static/js/pages/zuchthunde.js b/backend/static/js/pages/zuchthunde.js index 4d6bb63..8807396 100644 --- a/backend/static/js/pages/zuchthunde.js +++ b/backend/static/js/pages/zuchthunde.js @@ -11,6 +11,7 @@ window.Page_zuchthunde = (() => { let _hunde = []; // geladene Hunde let _query = ''; // Suchtext let _openSections = {}; // { : 'health'|'genetic'|'titles'|null } + let _breederId = null; // ID des Züchter-Profils // ---------------------------------------------------------- // Hilfsfunktionen @@ -110,6 +111,10 @@ window.Page_zuchthunde = (() => { + ${UI.icon('download-simple')} Export @@ -136,6 +141,10 @@ window.Page_zuchthunde = (() => { document.getElementById('zh-trial-btn')?.addEventListener('click', () => _showTrialMatingModal()); document.getElementById('zh-jahresbericht-btn')?.addEventListener('click', () => _showJahresbericht()); document.getElementById('zh-jahresbericht-archiv-btn')?.addEventListener('click', () => _showJahresberichtArchiv()); + document.getElementById('zh-photos-btn')?.addEventListener('click', () => { + if (!_breederId) { UI.toast.warning('Züchter-Profil noch nicht geladen.'); return; } + _showBreederPhotosModal(_breederId); + }); document.getElementById('zh-search')?.addEventListener('input', e => { _query = e.target.value.toLowerCase().trim(); @@ -148,7 +157,10 @@ window.Page_zuchthunde = (() => { // ---------------------------------------------------------- async function _load() { try { - _hunde = await API.zuchthunde.list(); + [_hunde] = await Promise.all([ + API.zuchthunde.list(), + API.breeder.status().then(s => { _breederId = s?.id || null; }).catch(() => {}), + ]); _renderList(); } catch (err) { const el = document.getElementById('zh-list'); @@ -1649,6 +1661,137 @@ window.Page_zuchthunde = (() => { document.head.appendChild(s); })(); + // ---------------------------------------------------------- + // Profilfotos & Logo verwalten + // ---------------------------------------------------------- + async function _showBreederPhotosModal(breederId) { + const galleryId = 'bp-gallery'; + const visLabels = { + public: { text: 'Öffentlich', color: '#16a34a' }, + inquiry: { text: 'Anfrage', color: '#f59e0b' }, + private: { text: 'Privat', color: '#6b7280' }, + }; + const visOrder = ['public', 'inquiry', 'private']; + + UI.modal.open({ + title: `${UI.icon('images')} Züchter-Profilfotos & Logo`, + body: ` +

+ Diese Fotos erscheinen im öffentlichen Züchterprofil. Das primäre Foto wird als Logo im Hero angezeigt. +

+
+

Lädt…

+
+
+
+ + + +
`, + footer: ``, + }); + + async function _loadGallery() { + const el = document.getElementById(galleryId); + if (!el) return; + try { + const photos = await API.breederPhotos.list('breeder', breederId); + if (!photos.length) { + el.innerHTML = `

Noch keine Fotos — lade das erste hoch.

`; + return; + } + el.innerHTML = ` +
+ ${photos.map(ph => { + const thumb = ph.thumbnail_url || ph.url || ''; + const vis = visLabels[ph.visibility] || visLabels.private; + const isPrimary = ph.is_primary; + return ` +
+ + ${_esc(ph.caption || '')} + + ${isPrimary ? `Logo` : ''} + + + + ${!isPrimary ? `` : ''} + + +
`; + }).join('')} +
`; + + el.querySelectorAll('.bp-vis-btn').forEach(btn => { + btn.addEventListener('click', async () => { + const next = visOrder[(visOrder.indexOf(btn.dataset.vis) + 1) % visOrder.length]; + try { await API.breederPhotos.updateVisibility(parseInt(btn.dataset.photoId), next); _loadGallery(); } + catch (err) { UI.toast.error(err.message); } + }); + }); + el.querySelectorAll('.bp-primary-btn').forEach(btn => { + btn.addEventListener('click', async () => { + try { await API.breederPhotos.setPrimary(parseInt(btn.dataset.photoId)); _loadGallery(); UI.toast.success('Als Logo gesetzt.'); } + catch (err) { UI.toast.error(err.message); } + }); + }); + el.querySelectorAll('.bp-del-btn').forEach(btn => { + btn.addEventListener('click', async () => { + if (!window.confirm('Foto löschen?')) return; + try { await API.breederPhotos.remove(parseInt(btn.dataset.photoId)); _loadGallery(); } + catch (err) { UI.toast.error(err.message); } + }); + }); + } catch (err) { + const el = document.getElementById(galleryId); + if (el) el.innerHTML = `

${_esc(err.message || 'Fehler')}

`; + } + } + + _loadGallery(); + + document.getElementById('bp-upload-form')?.addEventListener('submit', async e => { + e.preventDefault(); + const btn = document.getElementById('bp-upload-btn'); + const fileInput = e.target.querySelector('[name="file"]'); + const caption = e.target.querySelector('[name="caption"]')?.value?.trim() || ''; + if (!fileInput?.files?.length) { UI.toast.error('Bitte Datei auswählen.'); return; } + const fd = new FormData(); + fd.append('entity_type', 'breeder'); + fd.append('entity_id', String(breederId)); + fd.append('visibility', 'public'); + fd.append('caption', caption); + fd.append('file', fileInput.files[0]); + await UI.asyncButton(btn, async () => { + await API.breederPhotos.upload(fd); + UI.toast.success('Foto hochgeladen.'); + e.target.reset(); + await _loadGallery(); + }); + }); + } + return { init, refresh, onDogChange }; })(); diff --git a/backend/static/sw.js b/backend/static/sw.js index fd1652f..3dea315 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v901'; +const CACHE_VERSION = 'by-v902'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache