feat: add dashboard with date/time, weather and ABS last heard audiobook
Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
322
dashboard.html
Normal file
322
dashboard.html
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
<!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;
|
||||||
|
}
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// ABS Configuration
|
||||||
|
const ABS_BASE_URL = 'https://abs.sphinx-morray.ts.net/audiobookshelf';
|
||||||
|
const ABS_TOKEN = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlJZCI6IjFiZTdiZmIzLTE1NGYtNGE3Yy1hMTFjLTZkNDg3YWNhMWZiYyIsIm5hbWUiOiJEYXNoYm9hcmQiLCJ0eXBlIjoiYXBpIiwiaWF0IjoxNzkzNjU0NjA3LCJleHAiOjE3OTM2ODYxNDJ9.h3284mhyio4GIIfAFoa6D6KXiUNWzGy622SiARqTplE';
|
||||||
|
|
||||||
|
// Wetter Configuration (Aachen: 50.7769, 6.0834)
|
||||||
|
const WEATHER_URL = 'https://api.open-meteo.com/v1/forecast?latitude=50.7769&longitude=6.0834¤t_weather=true&timezone=Europe/Berlin';
|
||||||
|
|
||||||
|
// 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 holen
|
||||||
|
async function fetchWeather() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(WEATHER_URL);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.current_weather) {
|
||||||
|
const weather = data.current_weather;
|
||||||
|
const code = weather.weathercode;
|
||||||
|
const weatherInfo = weatherCodes[code] || { icon: '🌐', text: 'Unbekannt' };
|
||||||
|
|
||||||
|
const temp = Math.round(weather.temperature * 10) / 10;
|
||||||
|
const wind = Math.round(weather.windspeed * 10) / 10;
|
||||||
|
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">${weatherInfo.icon}</div>
|
||||||
|
<div class="weather-details">
|
||||||
|
<div class="card-value">${temp}°C</div>
|
||||||
|
<div class="card-subvalue">${weatherInfo.text}</div>
|
||||||
|
<div class="card-subvalue">Wind: ${wind} km/h</div>
|
||||||
|
<div class="card-subvalue">Aktualisiert: ${time}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
document.getElementById('weather').innerHTML = '<span class="error">Wetterdaten nicht verfügbar</span>';
|
||||||
|
console.error('Wetter-API Fehler:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ABS Daten holen
|
||||||
|
async function fetchAudiobook() {
|
||||||
|
try {
|
||||||
|
// Benutzerdaten mit Fortschritt holen
|
||||||
|
const response = await fetch(`${ABS_BASE_URL}/api/me`, {
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${ABS_TOKEN}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const userData = await response.json();
|
||||||
|
|
||||||
|
if (userData.mediaProgress && userData.mediaProgress.length > 0) {
|
||||||
|
// Nach dem zuletzt aktualisierten Element sortieren
|
||||||
|
const sortedProgress = [...userData.mediaProgress].sort((a, b) =>
|
||||||
|
new Date(b.lastUpdate) - new Date(a.lastUpdate)
|
||||||
|
);
|
||||||
|
|
||||||
|
const latest = sortedProgress[0];
|
||||||
|
const libraryItemId = latest.libraryItemId;
|
||||||
|
|
||||||
|
// Details des Hörbuchs/Podcasts holen
|
||||||
|
const itemResponse = await fetch(`${ABS_BASE_URL}/api/items/${libraryItemId}`, {
|
||||||
|
headers: {
|
||||||
|
'Authorization': `Bearer ${ABS_TOKEN}`,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const itemData = await itemResponse.json();
|
||||||
|
const title = itemData.media?.metadata?.title || 'Unbekannt';
|
||||||
|
const author = itemData.media?.metadata?.author || '';
|
||||||
|
const mediaType = itemData.mediaType || 'item';
|
||||||
|
|
||||||
|
let displayText = title;
|
||||||
|
if (author) displayText = `${title} – ${author}`;
|
||||||
|
|
||||||
|
// Fortschritt anzeigen
|
||||||
|
const progressPercent = Math.round(latest.progress * 100);
|
||||||
|
const currentTime = formatDuration(latest.currentTime);
|
||||||
|
const duration = formatDuration(latest.duration);
|
||||||
|
|
||||||
|
document.getElementById('audiobook').innerHTML = `
|
||||||
|
<div class="card-value" style="font-size: 1.25rem;">${displayText}</div>
|
||||||
|
<div class="card-subvalue">${mediaType === 'podcast' ? '🎙️ Podcast' : '📖 Hörbuch'}</div>
|
||||||
|
<div class="card-subvalue">Fortschritt: ${progressPercent}% (${currentTime}/${duration})</div>
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
document.getElementById('audiobook').innerHTML = '<span class="card-subvalue">Kein aktuell gehörtes Hörbuch</span>';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
document.getElementById('audiobook').innerHTML = '<span class="error">ABS-Daten nicht verfügbar</span>';
|
||||||
|
console.error('ABS-API Fehler:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dauer formatieren (Sekunden zu HH:MM:SS)
|
||||||
|
function formatDuration(seconds) {
|
||||||
|
if (!seconds) return '0:00';
|
||||||
|
const hours = Math.floor(seconds / 3600);
|
||||||
|
const minutes = Math.floor((seconds % 3600) / 60);
|
||||||
|
const secs = Math.floor(seconds % 60);
|
||||||
|
|
||||||
|
if (hours > 0) {
|
||||||
|
return `${hours}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
||||||
|
}
|
||||||
|
return `${minutes}:${secs.toString().padStart(2, '0')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alle Daten aktualisieren
|
||||||
|
async function refreshAll() {
|
||||||
|
updateClock();
|
||||||
|
await Promise.all([fetchWeather(), fetchAudiobook()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user