Debug Upload

This commit is contained in:
2026-04-19 11:34:08 +00:00
parent bebba79d9f
commit a6e29b16cb

View File

@@ -608,6 +608,7 @@ async function uploadMembersAdmin() {
if (!token) { alert('Bitte zuerst Admin-Token in den Einstellungen speichern.'); return; } if (!token) { alert('Bitte zuerst Admin-Token in den Einstellungen speichern.'); return; }
const statusEl = document.getElementById('members-status'); const statusEl = document.getElementById('members-status');
statusEl.textContent = 'Lädt hoch…'; statusEl.style.color = 'var(--muted)'; statusEl.textContent = 'Lädt hoch…'; statusEl.style.color = 'var(--muted)';
try {
const state = loadState(); const state = loadState();
const extras = loadExtras(); const extras = loadExtras();
const members = state.members.map(m => { const members = state.members.map(m => {
@@ -619,16 +620,28 @@ async function uploadMembersAdmin() {
const data = { lastUpdated: new Date().toISOString().slice(0,10), members }; const data = { lastUpdated: new Date().toISOString().slice(0,10), members };
const content = btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2)))); const content = btoa(unescape(encodeURIComponent(JSON.stringify(data, null, 2))));
const path = `chapters/${activeChapter.code}/members.json`; const path = `chapters/${activeChapter.code}/members.json`;
try { const url = giteaAuthUrl(path, token);
console.log('[Upload] URL:', url);
statusEl.textContent = 'Prüfe SHA…';
let sha = null; let sha = null;
const shaRes = await fetch(giteaAuthUrl(path, token)); const shaRes = await fetch(url);
console.log('[Upload] SHA-Status:', shaRes.status);
if (shaRes.ok) sha = (await shaRes.json()).sha; if (shaRes.ok) sha = (await shaRes.json()).sha;
const body = { message:`Mitglieder aktualisiert ${new Date().toLocaleDateString('de')}`, content }; const body = { message:`Mitglieder aktualisiert ${new Date().toLocaleDateString('de')}`, content };
if (sha) body.sha = sha; if (sha) body.sha = sha;
const res = await fetch(giteaAuthUrl(path, token), { method:sha?'PUT':'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body) }); statusEl.textContent = sha ? 'Aktualisiere…' : 'Erstelle…';
const res = await fetch(url, { method:sha?'PUT':'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify(body) });
console.log('[Upload] Upload-Status:', res.status);
if (res.ok) { statusEl.textContent = `✓ ${members.length} Mitglieder hochgeladen`; statusEl.style.color = 'var(--success)'; } if (res.ok) { statusEl.textContent = `✓ ${members.length} Mitglieder hochgeladen`; statusEl.style.color = 'var(--success)'; }
else { statusEl.textContent = 'Fehler beim Upload.'; statusEl.style.color = '#dc2626'; } else {
} catch(e) { statusEl.textContent = 'Verbindungsfehler.'; statusEl.style.color = '#dc2626'; } const errText = await res.text();
console.error('[Upload] Fehler:', errText);
statusEl.textContent = `Fehler ${res.status}: ${errText.slice(0,80)}`; statusEl.style.color = '#dc2626';
}
} catch(e) {
console.error('[Upload] Exception:', e);
statusEl.textContent = `Fehler: ${e.message}`; statusEl.style.color = '#dc2626';
}
} }
// ============================================================ // ============================================================