- Add /api/cover/<library_item_id> endpoint to proxy cover images from ABS - Return cover proxy URL instead of direct ABS URL to avoid CORS issues - Add visual progress bar to audiobook card - Add cache-busting timestamp to cover image URLs - Improve cover image error handling with fallback placeholder Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
417 lines
14 KiB
HTML
417 lines
14 KiB
HTML
<!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;
|
|
}
|
|
|
|
/* Cover Image Styles */
|
|
.cover-container {
|
|
text-align: center;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
|
|
.cover-image {
|
|
max-width: 100%;
|
|
max-height: 180px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
|
|
object-fit: contain;
|
|
background: rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.cover-placeholder {
|
|
width: 150px;
|
|
height: 150px;
|
|
margin: 0 auto;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #666;
|
|
font-size: 3rem;
|
|
}
|
|
|
|
.audiobook-info {
|
|
text-align: center;
|
|
}
|
|
|
|
.progress-bar-container {
|
|
width: 100%;
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 4px;
|
|
height: 6px;
|
|
margin-top: 0.75rem;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.progress-bar {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #4f46e5, #7c3aed);
|
|
border-radius: 4px;
|
|
transition: width 0.3s ease;
|
|
}
|
|
</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' }
|
|
};
|
|
|
|
// Medien-Typ Icons
|
|
const mediaTypeIcons = {
|
|
'podcast': '🎙️',
|
|
'book': '📖',
|
|
'item': '📚'
|
|
};
|
|
|
|
// 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;
|
|
}
|
|
|
|
const title = absData.title || 'Unbekannt';
|
|
const author = absData.author || '';
|
|
const coverUrl = absData.coverUrl;
|
|
const mediaType = absData.mediaType || 'item';
|
|
const progressPercent = absData.progress || 0;
|
|
const currentTime = absData.currentTime || '0:00';
|
|
const duration = absData.duration || '0:00';
|
|
const mediaIcon = mediaTypeIcons[mediaType] || '📚';
|
|
|
|
let html = '';
|
|
|
|
// Always show cover placeholder or image
|
|
html += '<div class="cover-container">';
|
|
|
|
if (coverUrl) {
|
|
// Add timestamp to prevent caching
|
|
const coverUrlWithCache = coverUrl.includes('?')
|
|
? `${coverUrl}&t=${Date.now()}`
|
|
: `${coverUrl}?t=${Date.now()}`;
|
|
|
|
html += `
|
|
<img src="${coverUrlWithCache}" alt="${title}" class="cover-image"
|
|
onerror="this.style.display='none'; this.nextElementSibling.style.display='block';">
|
|
<div class="cover-placeholder" style="display: none;">${mediaIcon}</div>
|
|
`;
|
|
} else {
|
|
html += `<div class="cover-placeholder">${mediaIcon}</div>`;
|
|
}
|
|
|
|
html += '</div>';
|
|
|
|
html += '<div class="audiobook-info">';
|
|
html += `<div class="card-value" style="font-size: 1.25rem; margin-top: 0.5rem;">${title}</div>`;
|
|
if (author) {
|
|
html += `<div class="card-subvalue">von ${author}</div>`;
|
|
}
|
|
html += `<div class="card-subvalue">${currentTime}/${duration}</div>`;
|
|
|
|
// Progress bar
|
|
html += '<div class="progress-bar-container">';
|
|
html += `<div class="progress-bar" style="width: ${progressPercent}%"></div>`;
|
|
html += '</div>';
|
|
|
|
html += `</div>`;
|
|
|
|
document.getElementById('audiobook').innerHTML = html;
|
|
}
|
|
|
|
// 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>
|