UX: Jahresbericht — Wahlmöglichkeit wenn letzter Bericht <30 Tage alt — SW by-v506, APP_VER 483
This commit is contained in:
parent
9832cd24d8
commit
41d5d745cb
3 changed files with 53 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
Router, State-Management, Navigation, Initialisierung.
|
Router, State-Management, Navigation, Initialisierung.
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const APP_VER = '482'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
const APP_VER = '483'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||||
|
|
||||||
const App = (() => {
|
const App = (() => {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1292,6 +1292,57 @@ window.Page_zuchthunde = (() => {
|
||||||
// KI: Jahresbericht generieren
|
// KI: Jahresbericht generieren
|
||||||
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
||||||
async function _showJahresbericht() {
|
async function _showJahresbericht() {
|
||||||
|
// Zuerst prüfen ob bereits ein Bericht existiert
|
||||||
|
let vorhandeneBerichte = [];
|
||||||
|
try { vorhandeneBerichte = await API.zuchtKi.jahresberichtList(); } catch {}
|
||||||
|
|
||||||
|
if (vorhandeneBerichte.length) {
|
||||||
|
const letzter = vorhandeneBerichte[0];
|
||||||
|
const letzterTs = new Date(letzter.created_at);
|
||||||
|
const tageAlt = Math.floor((Date.now() - letzterTs) / 86400000);
|
||||||
|
const SCHWELLE = 30; // Tage
|
||||||
|
|
||||||
|
if (tageAlt < SCHWELLE) {
|
||||||
|
const datumStr = letzterTs.toLocaleDateString('de', {
|
||||||
|
day: '2-digit', month: '2-digit', year: 'numeric'
|
||||||
|
});
|
||||||
|
// Wahlmöglichkeit anbieten
|
||||||
|
UI.modal.open({
|
||||||
|
title: `${UI.icon('chart-bar')} KI-Jahresbericht`,
|
||||||
|
body: `
|
||||||
|
<div style="text-align:center;padding:var(--space-4) 0">
|
||||||
|
<div style="font-size:2rem;margin-bottom:var(--space-3)">${UI.icon('warning')}</div>
|
||||||
|
<p style="margin:0 0 var(--space-2);font-size:var(--text-sm)">
|
||||||
|
Du hast bereits einen Bericht vom <strong>${datumStr}</strong>.
|
||||||
|
</p>
|
||||||
|
<p style="margin:0;font-size:var(--text-sm);color:var(--c-text-secondary)">
|
||||||
|
Ein neuer Bericht kostet ein KI-Guthaben. Was möchtest du tun?
|
||||||
|
</p>
|
||||||
|
</div>`,
|
||||||
|
footer: `
|
||||||
|
<button class="btn btn-ghost btn-sm" id="ki-bericht-letzten-anzeigen">
|
||||||
|
${UI.icon('eye')} Letzten anzeigen (${datumStr})
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-primary btn-sm" id="ki-bericht-neu-erstellen">
|
||||||
|
${UI.icon('sparkle')} Neuen erstellen
|
||||||
|
</button>`,
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('ki-bericht-letzten-anzeigen')?.addEventListener('click', async () => {
|
||||||
|
try {
|
||||||
|
const r = await API.zuchtKi.jahresberichtGet(letzter.id);
|
||||||
|
_renderBerichtModal(r.text, r.jahr, r.id);
|
||||||
|
} catch { UI.toast.error('Bericht konnte nicht geladen werden.'); }
|
||||||
|
});
|
||||||
|
document.getElementById('ki-bericht-neu-erstellen')?.addEventListener('click', () => _generiereJahresbericht());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_generiereJahresbericht();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function _generiereJahresbericht() {
|
||||||
UI.modal.open({
|
UI.modal.open({
|
||||||
title: `${UI.icon('chart-bar')} KI-Jahresbericht`,
|
title: `${UI.icon('chart-bar')} KI-Jahresbericht`,
|
||||||
body: `<p style="color:var(--c-text-secondary);text-align:center;padding:var(--space-6)">KI analysiert deine Zuchtkartei…</p>`,
|
body: `<p style="color:var(--c-text-secondary);text-align:center;padding:var(--space-6)">KI analysiert deine Zuchtkartei…</p>`,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
Offline-Cache + Push Notifications + Tile-Cache
|
Offline-Cache + Push Notifications + Tile-Cache
|
||||||
============================================================ */
|
============================================================ */
|
||||||
|
|
||||||
const CACHE_VERSION = 'by-v505';
|
const CACHE_VERSION = 'by-v506';
|
||||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue