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');
|
const authBtn = document.getElementById('auth-btn');
|
||||||
if (!authBtn) return;
|
if (!authBtn) return;
|
||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
authBtn.textContent = currentUser.name || currentUser.email || 'Angemeldet';
|
authBtn.textContent = '✓ Angemeldet (Logout)';
|
||||||
authBtn.classList.add('logged-in');
|
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 {
|
} else {
|
||||||
authBtn.textContent = '🔑 Anmelden';
|
authBtn.textContent = '🔑 Anmelden';
|
||||||
|
authBtn.style.color = '';
|
||||||
authBtn.classList.remove('logged-in');
|
authBtn.classList.remove('logged-in');
|
||||||
authBtn.onclick = async () => {
|
authBtn.onclick = async () => {
|
||||||
const resp = await fetch(`/api/auth/login-url?redirect=${encodeURIComponent(window.location.pathname)}`);
|
const resp = await fetch(`/api/auth/login-url?redirect=${encodeURIComponent(window.location.pathname)}`);
|
||||||
@ -1241,27 +1251,49 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function reAnalyze(drucksache, bundesland, btn) {
|
async function reAnalyze(drucksache, bundesland, btn) {
|
||||||
|
if (!currentUser) {
|
||||||
|
alert('Bitte zuerst anmelden.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.textContent = '⏳ Wird neu bewertet...';
|
btn.style.background = '#ffc107';
|
||||||
|
btn.textContent = '⏳ Lösche alte Bewertung...';
|
||||||
try {
|
try {
|
||||||
// Altes Assessment löschen
|
// 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
|
// Neue Analyse enqueuen
|
||||||
const resp = await fetch('/api/analyze-drucksache', {
|
const resp = await fetch('/api/analyze-drucksache', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||||
body: `drucksache=${encodeURIComponent(drucksache)}&bundesland=${encodeURIComponent(bundesland)}`
|
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();
|
const data = await resp.json();
|
||||||
if (data.status === 'queued') {
|
if (data.status === 'queued') {
|
||||||
|
btn.textContent = '⏳ Wird analysiert...';
|
||||||
|
btn.style.background = '#009da5';
|
||||||
pollAnalysis(data.job_id, drucksache, btn);
|
pollAnalysis(data.job_id, drucksache, btn);
|
||||||
} else {
|
} else {
|
||||||
btn.textContent = '❌ Fehler';
|
btn.textContent = '❌ ' + (data.detail || 'Fehler');
|
||||||
setTimeout(() => { btn.textContent = '🔄 Neu bewerten'; btn.disabled = false; }, 3000);
|
btn.style.background = '#dc3545';
|
||||||
|
setTimeout(() => { btn.textContent = '🔄 Neu bewerten'; btn.style.background = '#6c757d'; btn.disabled = false; }, 3000);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
btn.textContent = '❌ Fehler';
|
btn.textContent = '❌ ' + e.message;
|
||||||
setTimeout(() => { btn.textContent = '🔄 Neu bewerten'; btn.disabled = false; }, 3000);
|
btn.style.background = '#dc3545';
|
||||||
|
setTimeout(() => { btn.textContent = '🔄 Neu bewerten'; btn.style.background = '#6c757d'; btn.disabled = false; }, 3000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1708,7 +1740,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 0.75rem; font-size: 0.8rem; color: #999; border-top: 1px solid #eee; padding-top: 0.5rem;">
|
<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.source ? ` · Quelle: ${item.source}` : ''}
|
||||||
${item.model ? ` · Modell: ${item.model}` : ''}
|
${item.model ? ` · Modell: ${item.model}` : ''}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user