Files
vibe-test/dashboard.html
wralto-user-1 a61fc8d7d1 feat: add Flask API server for dashboard to avoid CORS issues with ABS
- Add dashboard_api.py as backend proxy for ABS and weather data
- Update dashboard.html to fetch data from local API instead of directly
- Add requirements.txt for Flask dependencies
- Add .gitignore for Python and pytest files

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-02 22:33:38 +01:00

329 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mein Dashboard</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
color: #e0e0e0;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem;
}
.container {
max-width: 800px;
width: 100%;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1.5rem;
}
.card {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(10px);
border-radius: 16px;
padding: 1.5rem;
border: 1px solid rgba(255, 255, 255, 0.1);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.card-title {
font-size: 0.875rem;
color: #888;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 0.75rem;
}
.card-value {
font-size: 1.75rem;
font-weight: 600;
color: #fff;
}
.card-subvalue {
font-size: 0.875rem;
color: #a0a0a0;
margin-top: 0.25rem;
}
.clock {
font-size: 3rem;
font-weight: 300;
color: #fff;
text-align: center;
margin-bottom: 1rem;
}
.date {
font-size: 1rem;
color: #a0a0a0;
text-align: center;
}
.weather-icon {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
.weather-container {
display: flex;
align-items: center;
gap: 1rem;
}
.weather-details {
display: flex;
flex-direction: column;
}
.loading {
color: #666;
font-style: italic;
}
.error {
color: #ff4444;
font-size: 0.875rem;
}
.refresh-btn {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #fff;
padding: 0.5rem 1rem;
border-radius: 8px;
cursor: pointer;
font-size: 0.875rem;
margin-top: 1rem;
transition: all 0.2s;
}
.refresh-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
.full-width {
grid-column: 1 / -1;
}
.status-bar {
margin-top: 2rem;
font-size: 0.75rem;
color: #666;
text-align: center;
}
.status-bar .error {
color: #ff4444;
}
.status-bar .success {
color: #44ff44;
}
</style>
</head>
<body>
<h1 style="margin-bottom: 2rem; color: #fff;">Dashboard</h1>
<div class="container">
<!-- Datum und Uhrzeit -->
<div class="card full-width">
<div class="clock" id="clock">--:--:--</div>
<div class="date" id="date">-- --- ----</div>
</div>
<!-- Wetter in Aachen -->
<div class="card">
<div class="card-title">Wetter in Aachen</div>
<div id="weather" class="loading">Lade Wetterdaten...</div>
</div>
<!-- Zuletzt gehörtes Hörbuch -->
<div class="card">
<div class="card-title">Zuletzt gehört auf ABS</div>
<div id="audiobook" class="loading">Lade ABS-Daten...</div>
</div>
</div>
<button class="refresh-btn" onclick="refreshAll()">Aktualisieren</button>
<div class="status-bar" id="status"></div>
<script>
// API endpoint (change this if your server runs on a different port)
const API_URL = '/api/dashboard';
// Wettercode zu Text Mapping (WMO codes)
const weatherCodes = {
0: { icon: '☀️', text: 'Klarer Himmel' },
1: { icon: '⛅', text: 'Überwiegend klar' },
2: { icon: '⛅', text: 'Teilweise bewölkt' },
3: { icon: '☁️', text: 'Bedeckt' },
45: { icon: '🌫️', text: 'Nebel' },
48: { icon: '🌫️', text: 'Gefrierender Nebel' },
51: { icon: '🌦️', text: 'Leichter Nieselregen' },
53: { icon: '🌧️', text: 'Mäßiger Nieselregen' },
55: { icon: '🌧️', text: 'Starker Nieselregen' },
56: { icon: '🌦️', text: 'Leichter gefrierender Nieselregen' },
57: { icon: '🌧️', text: 'Starker gefrierender Nieselregen' },
61: { icon: '🌦️', text: 'Leichter Regen' },
63: { icon: '🌧️', text: 'Mäßiger Regen' },
65: { icon: '🌧️', text: 'Starker Regen' },
66: { icon: '🌦️', text: 'Leichter gefrierender Regen' },
67: { icon: '🌧️', text: 'Starker gefrierender Regen' },
71: { icon: '❄️', text: 'Leichter Schneefall' },
73: { icon: '❄️', text: 'Mäßiger Schneefall' },
75: { icon: '❄️', text: 'Starker Schneefall' },
77: { icon: '❄️', text: 'Schneegriesel' },
80: { icon: '🌦️', text: 'Leichte Regenschauer' },
81: { icon: '🌧️', text: 'Mäßige Regenschauer' },
82: { icon: '🌧️', text: 'Heftige Regenschauer' },
85: { icon: '❄️', text: 'Leichte Schneeschauer' },
86: { icon: '❄️', text: 'Heftige Schneeschauer' },
95: { icon: '⛈️', text: 'Gewitter' },
96: { icon: '⛈️', text: 'Gewitter mit leichtem Hagel' },
99: { icon: '⛈️', text: 'Gewitter mit starkem Hagel' }
};
// Uhrzeit und Datum aktualisieren
function updateClock() {
const now = new Date();
const timeOptions = { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false };
const dateOptions = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
document.getElementById('clock').textContent = now.toLocaleTimeString('de-DE', timeOptions);
document.getElementById('date').textContent = now.toLocaleDateString('de-DE', dateOptions);
}
// Wetterdaten anzeigen
function displayWeather(weather) {
if (!weather) {
document.getElementById('weather').innerHTML = '<span class="error">Wetterdaten nicht verfügbar</span>';
return;
}
const temp = weather.temperature;
const wind = weather.windspeed;
const icon = weather.icon || '🌐';
const text = weather.text || 'Unbekannt';
const time = new Date(weather.time).toLocaleTimeString('de-DE', { hour: '2-digit', minute: '2-digit' });
document.getElementById('weather').innerHTML = `
<div class="weather-container">
<div class="weather-icon">${icon}</div>
<div class="weather-details">
<div class="card-value">${temp}°C</div>
<div class="card-subvalue">${text}</div>
<div class="card-subvalue">Wind: ${wind} km/h</div>
<div class="card-subvalue">Aktualisiert: ${time}</div>
</div>
</div>
`;
}
// ABS-Daten anzeigen
function displayAudiobook(absData) {
if (!absData) {
document.getElementById('audiobook').innerHTML = '<span class="error">ABS-Daten nicht verfügbar</span>';
return;
}
let displayText = absData.title;
if (absData.author) displayText = `${absData.title} – ${absData.author}`;
const mediaType = absData.mediaType === 'podcast' ? '🎙️ Podcast' : (absData.mediaType === 'book' ? '📖 Hörbuch' : '📚 Medium');
const progressPercent = absData.progress;
const currentTime = absData.currentTime;
const duration = absData.duration;
document.getElementById('audiobook').innerHTML = `
<div class="card-value" style="font-size: 1.25rem;">${displayText}</div>
<div class="card-subvalue">${mediaType}</div>
<div class="card-subvalue">Fortschritt: ${progressPercent}% (${currentTime}/${duration})</div>
`;
}
// Alle Daten von der API holen
async function fetchDashboardData() {
try {
const response = await fetch(API_URL);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error) {
console.error('API-Fehler:', error);
updateStatus(`Fehler: ${error.message}`, 'error');
return null;
}
}
// Status anzeigen
function updateStatus(message, type = '') {
const statusEl = document.getElementById('status');
statusEl.textContent = message;
statusEl.className = type;
}
// Alle Daten aktualisieren
async function refreshAll() {
updateClock();
updateStatus('Lade Daten...', 'loading');
try {
const data = await fetchDashboardData();
if (data) {
displayWeather(data.weather);
displayAudiobook(data.audiobook);
updateStatus('Daten erfolgreich geladen', 'success');
} else {
updateStatus('Keine Daten erhalten', 'error');
}
} catch (error) {
updateStatus(`Fehler: ${error.message}`, 'error');
}
}
// Initial laden
updateClock();
refreshAll();
// Uhrzeit jede Sekunde aktualisieren
setInterval(updateClock, 1000);
// Daten alle 5 Minuten aktualisieren
setInterval(refreshAll, 5 * 60 * 1000);
// Bei Fokus zurückkehren auch aktualisieren
window.addEventListener('focus', refreshAll);
// Status nach 5 Sekunden zurücksetzen
setTimeout(() => {
const statusEl = document.getElementById('status');
if (statusEl.className === 'success') {
statusEl.textContent = '';
statusEl.className = '';
}
}, 5000);
</script>
</body>
</html>