Auth-UI: Logout-Button + Re-Analyze-Feedback + Uhrzeit beim Bewertungsdatum
This commit is contained in:
parent
9195d976bc
commit
0d0c06106a
@ -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 @@
|
||||
</button>
|
||||
</div>
|
||||
<div style="margin-top: 0.75rem; font-size: 0.8rem; color: #999; border-top: 1px solid #eee; padding-top: 0.5rem;">
|
||||
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}` : ''}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user