Dateien nach "frontend/src" hochladen
This commit is contained in:
@@ -93,31 +93,41 @@ export default function CalendarWidget() {
|
||||
const [selected, setSelected] = useState(null); // date object
|
||||
|
||||
const [errors, setErrors] = useState([]);
|
||||
const [debug, setDebug] = useState([]);
|
||||
|
||||
// Load all feeds
|
||||
const loadFeeds = async (feedList) => {
|
||||
if (!feedList.length) { setEvents([]); return; }
|
||||
if (!feedList.length) { setEvents([]); setDebug(['Keine Feeds konfiguriert']); return; }
|
||||
setLoading(true);
|
||||
setErrors([]);
|
||||
const all = [];
|
||||
const errs = [];
|
||||
const dbg = [];
|
||||
dbg.push(`Feeds: ${feedList.length}`);
|
||||
for (const f of feedList) {
|
||||
try {
|
||||
dbg.push(`Lade: ${f.name} (${f.url.slice(0,50)}…)`);
|
||||
const res = await fetch(`/api/calendar/fetch?url=${encodeURIComponent(f.url)}`, {
|
||||
headers: { Authorization: `Bearer ${localStorage.getItem('sk_token')}` }
|
||||
});
|
||||
dbg.push(`HTTP: ${res.status}`);
|
||||
if (res.ok) {
|
||||
const text = await res.text();
|
||||
dbg.push(`Bytes: ${text.length}, VCALENDAR: ${text.includes('BEGIN:VCALENDAR')}, VEVENTs: ${(text.match(/BEGIN:VEVENT/g)||[]).length}`);
|
||||
const evs = parseIcal(text).map(e => ({ ...e, color: f.color, feedName: f.name }));
|
||||
dbg.push(`Geparst: ${evs.length} Termine`);
|
||||
if (evs.length > 0) dbg.push(`Erstes: ${evs[0].summary} @ ${evs[0].dtstart}`);
|
||||
all.push(...evs);
|
||||
} else {
|
||||
const d = await res.json().catch(()=>({error:'Unbekannter Fehler'}));
|
||||
errs.push(`${f.name}: ${d.error}`);
|
||||
dbg.push(`Fehler: ${d.error}`);
|
||||
}
|
||||
} catch(e) { errs.push(`${f.name}: ${e.message}`); }
|
||||
} catch(e) { errs.push(`${f.name}: ${e.message}`); dbg.push(`Exception: ${e.message}`); }
|
||||
}
|
||||
setEvents(all);
|
||||
setErrors(errs);
|
||||
setDebug(dbg);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -258,6 +268,17 @@ export default function CalendarWidget() {
|
||||
Noch keine Kalender abonniert. Füge Kalender in den Einstellungen hinzu.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Debug Panel */}
|
||||
{debug.length > 0 && (
|
||||
<div style={{ marginTop:10, background:'rgba(0,0,0,0.4)', borderRadius:8,
|
||||
padding:'8px 10px', border:'1px solid rgba(255,255,255,0.08)' }}>
|
||||
<div style={{ color:'rgba(255,255,255,0.3)', fontFamily:'monospace', fontSize:9, marginBottom:4 }}>DEBUG</div>
|
||||
{debug.map((d,i) => (
|
||||
<div key={i} style={{ color:'rgba(255,255,255,0.55)', fontFamily:'monospace', fontSize:10, lineHeight:1.6 }}>{d}</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user