diff --git a/app/templates/index.html b/app/templates/index.html index 5e429b4..60af7fe 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -867,11 +867,21 @@ const authBtn = document.getElementById('auth-btn'); if (!authBtn) return; if (currentUser) { - authBtn.textContent = currentUser.name || currentUser.email || 'Angemeldet'; + authBtn.textContent = 'โœ“ Angemeldet (Logout)'; authBtn.classList.add('logged-in'); - authBtn.onclick = () => { /* TODO: Logout */ }; + authBtn.style.color = '#889e33'; + authBtn.onclick = () => { + // Cookie lรถschen + Keycloak-Logout + document.cookie = 'access_token=; Max-Age=0; path=/; secure; samesite=lax'; + currentUser = null; + updateAuthUI(); + loadAssessments(); // Liste neu rendern (Buttons deaktivieren) + }; + // Bestehende Liste neu rendern damit Buttons aktiv werden + if (allAssessments.length > 0) renderList(allAssessments); } else { authBtn.textContent = '๐Ÿ”‘ Anmelden'; + authBtn.style.color = ''; authBtn.classList.remove('logged-in'); authBtn.onclick = async () => { const resp = await fetch(`/api/auth/login-url?redirect=${encodeURIComponent(window.location.pathname)}`); @@ -1241,27 +1251,49 @@ } async function reAnalyze(drucksache, bundesland, btn) { + if (!currentUser) { + alert('Bitte zuerst anmelden.'); + return; + } btn.disabled = true; - btn.textContent = 'โณ Wird neu bewertet...'; + btn.style.background = '#ffc107'; + btn.textContent = 'โณ Lรถsche alte Bewertung...'; try { // Altes Assessment lรถschen - await fetch(`/api/assessment/delete?drucksache=${encodeURIComponent(drucksache)}`, {method: 'DELETE'}); + const delResp = await fetch(`/api/assessment/delete?drucksache=${encodeURIComponent(drucksache)}`, {method: 'DELETE'}); + if (delResp.status === 401) { + btn.textContent = '๐Ÿ”’ Nicht angemeldet'; + btn.style.background = '#dc3545'; + setTimeout(() => { btn.textContent = '๐Ÿ”„ Neu bewerten'; btn.style.background = '#6c757d'; btn.disabled = false; }, 3000); + return; + } + btn.textContent = 'โณ Analyse gestartet...'; // Neue Analyse enqueuen const resp = await fetch('/api/analyze-drucksache', { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `drucksache=${encodeURIComponent(drucksache)}&bundesland=${encodeURIComponent(bundesland)}` }); + if (resp.status === 401) { + btn.textContent = '๐Ÿ”’ Nicht angemeldet'; + btn.style.background = '#dc3545'; + setTimeout(() => { btn.textContent = '๐Ÿ”„ Neu bewerten'; btn.style.background = '#6c757d'; btn.disabled = false; }, 3000); + return; + } const data = await resp.json(); if (data.status === 'queued') { + btn.textContent = 'โณ Wird analysiert...'; + btn.style.background = '#009da5'; pollAnalysis(data.job_id, drucksache, btn); } else { - btn.textContent = 'โŒ Fehler'; - setTimeout(() => { btn.textContent = '๐Ÿ”„ Neu bewerten'; btn.disabled = false; }, 3000); + btn.textContent = 'โŒ ' + (data.detail || 'Fehler'); + btn.style.background = '#dc3545'; + setTimeout(() => { btn.textContent = '๐Ÿ”„ Neu bewerten'; btn.style.background = '#6c757d'; btn.disabled = false; }, 3000); } } catch (e) { - btn.textContent = 'โŒ Fehler'; - setTimeout(() => { btn.textContent = '๐Ÿ”„ Neu bewerten'; btn.disabled = false; }, 3000); + btn.textContent = 'โŒ ' + e.message; + btn.style.background = '#dc3545'; + setTimeout(() => { btn.textContent = '๐Ÿ”„ Neu bewerten'; btn.style.background = '#6c757d'; btn.disabled = false; }, 3000); } } @@ -1708,7 +1740,7 @@
- Bewertet am ${item.updatedAt ? new Date(item.updatedAt).toLocaleDateString('de-DE') : 'โ€“'} + Bewertet am ${item.updatedAt ? new Date(item.updatedAt).toLocaleDateString('de-DE') + ', ' + new Date(item.updatedAt).toLocaleTimeString('de-DE', {hour:'2-digit', minute:'2-digit'}) + ' Uhr' : 'โ€“'} ${item.source ? ` ยท Quelle: ${item.source}` : ''} ${item.model ? ` ยท Modell: ${item.model}` : ''}