Timer-App unter Versionsverwaltung stellen

Stand der laufenden Anwendung von 192.168.1.5:/opt/timer-app (systemd-Dienst
timer-app, Port 3003). Zeiterfassung mit Kostenberechnung: Node/Express,
SQLite, Anmeldung ausschliesslich ueber Authentik (OIDC, PKCE, RP-Logout) -
der frueher vorhandene Passwort-Login ist entfernt.

Nicht im Repo, bewusst:
- backend/.env und die .env-Sicherung: enthalten Session-Secret und die
  Authentik-Zugangsdaten. Vorlage ist backend/.env.example.
- data/: die Datenbank mit den echten Zeiterfassungen.
- node_modules/.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-04 17:47:07 +02:00
co-authored by Claude Opus 5
commit a7e77793a8
16 changed files with 5192 additions and 0 deletions
+564
View File
@@ -0,0 +1,564 @@
/**
* Timer App - Frontend
*
* Die Timer selbst leben auf dem Server. Der Browser zaehlt zwischen zwei
* Server-Abgleichen nur lokal weiter, damit die Anzeige fluessig laeuft.
* Gerechnet wird lokal ausschliesslich fuer die Anzeige - der verbindliche
* Betrag entsteht beim Beenden auf dem Server.
*/
const state = {
timers: [], // {id, customerName, isRunning, baseMs, syncedAt}
rate: { rateAmount: 10, rateInterval: 10 },
tickHandle: null,
syncHandle: null,
history: { offset: 0, limit: 50, reachedEnd: false }
};
const SYNC_INTERVAL_MS = 15000; // Abgleich mit dem Server
const TICK_INTERVAL_MS = 250; // Anzeige-Aktualisierung
let oidcConfigured = false; // ob Authentik erreichbar ist
let loggedInUser = null; // {username, displayName, email} nach SSO-Login
// ---------------------------------------------------------------------------
// Hilfsfunktionen
// ---------------------------------------------------------------------------
function formatTime(ms) {
const total = Math.floor(Math.max(0, ms) / 1000);
const p = n => String(n).padStart(2, '0');
return `${p(Math.floor(total / 3600))}:${p(Math.floor((total % 3600) / 60))}:${p(total % 60)}`;
}
function formatEuro(value) {
return '€' + Number(value || 0).toLocaleString('de-DE', {
minimumFractionDigits: Number.isInteger(Number(value)) ? 0 : 2,
maximumFractionDigits: 2
});
}
function calcAmount(ms) {
if (!ms || ms <= 0) return 0;
const minutes = Math.ceil(ms / 60000);
const units = Math.ceil(minutes / state.rate.rateInterval);
return Math.round(units * state.rate.rateAmount * 100) / 100;
}
/** Aktuelle Zeit eines Timers - lokal fortgeschrieben seit dem letzten Sync. */
function currentMs(timer) {
if (!timer.isRunning) return timer.baseMs;
return timer.baseMs + (Date.now() - timer.syncedAt);
}
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str == null ? '' : String(str);
return div.innerHTML;
}
let toastTimeout = null;
function toast(message, kind = 'info') {
const el = document.getElementById('toast');
el.textContent = message;
el.className = 'toast show ' + kind;
clearTimeout(toastTimeout);
toastTimeout = setTimeout(() => { el.className = 'toast'; }, 4000);
}
async function api(url, options = {}) {
const response = await fetch(url, {
headers: { 'Content-Type': 'application/json' },
...options
});
if (response.status === 401) {
stopLoops();
showLogin();
throw new Error('Nicht angemeldet');
}
if (!response.ok) {
let msg = 'Serverfehler';
try { msg = (await response.json()).error || msg; } catch (e) { /* egal */ }
throw new Error(msg);
}
return response.status === 204 ? null : response.json();
}
// ---------------------------------------------------------------------------
// Ansichten
// ---------------------------------------------------------------------------
function switchView(id) {
document.querySelectorAll('.view').forEach(v => v.classList.remove('active'));
document.getElementById(id).classList.add('active');
}
function showLogin() {
document.getElementById('header').style.display = 'none';
switchView('loginView');
applyLoginMode();
}
// Anmeldung ausschliesslich ueber Authentik. Ist Authentik nicht erreichbar,
// wird der Hinweis unter dem Button eingeblendet.
function applyLoginMode() {
const err = document.getElementById('loginError');
if (err) err.classList.toggle('show', !oidcConfigured);
}
function showTimer() {
switchView('timerView');
}
async function showHistory() {
switchView('historyView');
state.history.offset = 0;
state.history.reachedEnd = false;
await loadHistory(true);
}
async function showSettings() {
switchView('settingsView');
await loadSettings();
}
// ---------------------------------------------------------------------------
// Anmeldung
// ---------------------------------------------------------------------------
async function checkAuth() {
try {
const data = await api('/api/auth/status');
oidcConfigured = !!data.oidcConfigured;
loggedInUser = data.user || null;
if (data.authenticated) {
await enterApp();
} else {
showLogin();
}
} catch (e) {
showLogin();
}
}
async function enterApp() {
document.getElementById('header').style.display = 'flex';
renderCurrentUser();
showTimer();
await syncTimers();
startLoops();
}
// Zeigt den angemeldeten Authentik-Nutzer oben rechts im Header.
function renderCurrentUser() {
const el = document.getElementById('currentUser');
if (!el) return;
const u = loggedInUser;
el.textContent = u ? (u.displayName || u.username || '') : '';
el.title = u && u.email ? u.email : 'Angemeldet';
}
async function logout() {
const running = state.timers.filter(t => t.isRunning).length;
if (running > 0 && !confirm(
`${running} Timer ${running === 1 ? 'läuft' : 'laufen'} noch.\n\n` +
`Sie laufen serverseitig weiter und sind nach dem nächsten Anmelden wieder da. Trotzdem abmelden?`
)) return;
stopLoops();
state.timers = [];
// GET-Navigation: beendet lokale Sitzung und bei Authentik-Login auch die SSO-Sitzung
window.location.href = '/auth/logout';
}
// ---------------------------------------------------------------------------
// Timer-Synchronisation
// ---------------------------------------------------------------------------
async function syncTimers() {
const data = await api('/api/timers');
state.rate = data.rate;
const now = Date.now();
state.timers = data.timers.map(t => ({
id: t.id,
customerName: t.customerName,
isRunning: t.isRunning,
baseMs: t.elapsedMs,
syncedAt: now,
createdAt: t.createdAt
}));
renderTimers();
}
function startLoops() {
stopLoops();
state.tickHandle = setInterval(tick, TICK_INTERVAL_MS);
state.syncHandle = setInterval(() => { syncTimers().catch(() => {}); }, SYNC_INTERVAL_MS);
}
function stopLoops() {
clearInterval(state.tickHandle);
clearInterval(state.syncHandle);
state.tickHandle = null;
state.syncHandle = null;
}
// Nach Ruhezustand/Tabwechsel sofort abgleichen statt bis zum naechsten Sync warten
document.addEventListener('visibilitychange', () => {
if (!document.hidden && state.syncHandle) syncTimers().catch(() => {});
});
/** Aktualisiert nur die Zahlen - baut das DOM nicht neu (sonst springt der Fokus). */
function tick() {
for (const timer of state.timers) {
const ms = currentMs(timer);
const timeEl = document.getElementById(`time-${timer.id}`);
const amountEl = document.getElementById(`amount-${timer.id}`);
if (timeEl) timeEl.textContent = formatTime(ms);
if (amountEl) amountEl.textContent = formatEuro(calcAmount(ms));
}
}
// ---------------------------------------------------------------------------
// Timer-Darstellung
// ---------------------------------------------------------------------------
function renderTimers() {
const list = document.getElementById('timerList');
const empty = document.getElementById('timerEmpty');
document.getElementById('rateHint').textContent =
`Tarif: ${formatEuro(state.rate.rateAmount)} pro angefangene ${state.rate.rateInterval} Minuten`;
if (state.timers.length === 0) {
list.innerHTML = '';
empty.style.display = 'block';
return;
}
empty.style.display = 'none';
list.innerHTML = state.timers.map(timer => {
const ms = currentMs(timer);
const since = new Date(timer.createdAt).toLocaleTimeString('de-DE',
{ hour: '2-digit', minute: '2-digit' });
return `
<div class="timer-card ${timer.isRunning ? 'running' : 'paused'}" data-id="${timer.id}">
<div class="timer-card-head">
<input class="timer-name" type="text" value="${escapeHtml(timer.customerName)}"
placeholder="Name / Platz (optional)" maxlength="80"
onchange="renameTimer(${timer.id}, this.value)">
<span class="timer-badge">${timer.isRunning ? '● läuft' : '❚❚ pausiert'}</span>
</div>
<div class="timer-card-time" id="time-${timer.id}">${formatTime(ms)}</div>
<div class="timer-card-amount" id="amount-${timer.id}">${formatEuro(calcAmount(ms))}</div>
<div class="timer-card-since">gestartet um ${since} Uhr</div>
<div class="timer-card-actions">
${timer.isRunning
? `<button class="btn btn-stop btn-sm" onclick="pauseTimer(${timer.id})">❚❚ Pause</button>`
: `<button class="btn btn-start btn-sm" onclick="resumeTimer(${timer.id})">▶ Weiter</button>`}
<button class="btn btn-sm" onclick="stopTimer(${timer.id})">✓ Beenden</button>
<button class="btn btn-danger btn-sm" onclick="discardTimer(${timer.id})">✕ Verwerfen</button>
</div>
</div>`;
}).join('');
}
// ---------------------------------------------------------------------------
// Timer-Aktionen
// ---------------------------------------------------------------------------
async function addTimer() {
const field = document.getElementById('newTimerName');
const name = field.value.trim();
try {
await api('/api/timers', { method: 'POST', body: JSON.stringify({ customerName: name }) });
field.value = '';
await syncTimers();
toast(name ? `Timer für „${name}" gestartet` : 'Timer gestartet', 'success');
} catch (e) {
toast('Timer konnte nicht gestartet werden: ' + e.message, 'error');
}
}
async function renameTimer(id, value) {
try {
await api(`/api/timers/${id}`, {
method: 'PATCH',
body: JSON.stringify({ customerName: value.trim() })
});
const timer = state.timers.find(t => t.id === id);
if (timer) timer.customerName = value.trim();
} catch (e) {
toast('Name konnte nicht gespeichert werden: ' + e.message, 'error');
}
}
async function pauseTimer(id) {
try {
await api(`/api/timers/${id}/pause`, { method: 'POST' });
await syncTimers();
} catch (e) {
toast('Pause fehlgeschlagen: ' + e.message, 'error');
}
}
async function resumeTimer(id) {
try {
await api(`/api/timers/${id}/resume`, { method: 'POST' });
await syncTimers();
} catch (e) {
toast('Fortsetzen fehlgeschlagen: ' + e.message, 'error');
}
}
async function stopTimer(id) {
const timer = state.timers.find(t => t.id === id);
if (!timer) return;
const ms = currentMs(timer);
const label = timer.customerName ? `${timer.customerName}"` : 'Timer';
if (!confirm(`${label} beenden?\n\nZeit: ${formatTime(ms)}\nBetrag: ${formatEuro(calcAmount(ms))}\n\nDer Eintrag wird in der Historie gespeichert.`)) return;
try {
const result = await api(`/api/timers/${id}/stop`, { method: 'POST' });
await syncTimers();
if (result.saved) {
toast(`Gespeichert: ${formatTime(result.duration)} ${formatEuro(result.amount)}`, 'success');
} else {
toast(result.reason || 'Nichts gespeichert.', 'info');
}
} catch (e) {
toast('Beenden fehlgeschlagen: ' + e.message, 'error');
}
}
async function discardTimer(id) {
const timer = state.timers.find(t => t.id === id);
if (!timer) return;
const label = timer.customerName ? `${timer.customerName}"` : 'Timer';
if (!confirm(`${label} verwerfen?\n\nDie erfasste Zeit (${formatTime(currentMs(timer))}) wird NICHT gespeichert.`)) return;
try {
await api(`/api/timers/${id}`, { method: 'DELETE' });
await syncTimers();
toast('Timer verworfen - nichts gespeichert.', 'info');
} catch (e) {
toast('Verwerfen fehlgeschlagen: ' + e.message, 'error');
}
}
document.getElementById('newTimerForm').addEventListener('submit', (e) => {
e.preventDefault();
addTimer();
});
// ---------------------------------------------------------------------------
// Historie
// ---------------------------------------------------------------------------
function historyQuery() {
const params = new URLSearchParams();
const from = document.getElementById('filterFrom').value;
const to = document.getElementById('filterTo').value;
const q = document.getElementById('filterName').value.trim();
if (from) params.set('from', from);
if (to) params.set('to', to);
if (q) params.set('q', q);
return params;
}
async function loadHistory(reset = false) {
if (reset) {
state.history.offset = 0;
state.history.reachedEnd = false;
}
const params = historyQuery();
params.set('limit', state.history.limit);
params.set('offset', state.history.offset);
try {
const data = await api('/api/sessions?' + params.toString());
renderHistory(data, reset);
} catch (e) {
document.getElementById('historyList').innerHTML =
`<div class="empty-state"><div class="empty-state-icon">⚠️</div><p>Fehler beim Laden: ${escapeHtml(e.message)}</p></div>`;
}
}
function renderHistory(data, reset) {
const listEl = document.getElementById('historyList');
const statsEl = document.getElementById('historyStats');
const moreBtn = document.getElementById('historyMore');
statsEl.innerHTML = `
<div class="stat-card"><h3>Einträge</h3><p>${data.totals.count}</p></div>
<div class="stat-card"><h3>Gesamtzeit</h3><p>${formatTime(data.totals.duration)}</p></div>
<div class="stat-card"><h3>Gesamtbetrag</h3><p>${formatEuro(data.totals.amount)}</p></div>
`;
if (data.totals.count === 0) {
listEl.innerHTML = '<div class="empty-state"><div class="empty-state-icon">📭</div><p>Keine Einträge für diesen Zeitraum</p></div>';
moreBtn.style.display = 'none';
return;
}
const rows = data.sessions.map(s => {
const date = new Date(s.created_at * 1000).toLocaleString('de-DE', {
day: '2-digit', month: '2-digit', year: 'numeric',
hour: '2-digit', minute: '2-digit'
});
const name = s.customer_name
? `<span class="history-item-name">${escapeHtml(s.customer_name)}</span>`
: '<span class="history-item-name muted">ohne Namen</span>';
return `
<div class="history-item">
<div class="history-item-info">
${name}
<div class="history-item-date">${date} Uhr</div>
<div class="history-item-duration">${formatTime(s.duration)}</div>
</div>
<div class="history-item-right">
<div class="history-item-amount">${formatEuro(s.amount)}</div>
<button class="btn btn-danger btn-sm" onclick="deleteSession(${s.id})" title="Eintrag löschen">🗑</button>
</div>
</div>`;
}).join('');
if (reset) {
listEl.innerHTML = rows;
} else {
listEl.insertAdjacentHTML('beforeend', rows);
}
const shown = state.history.offset + data.sessions.length;
state.history.reachedEnd = shown >= data.totals.count;
moreBtn.style.display = state.history.reachedEnd ? 'none' : 'inline-block';
moreBtn.textContent = `Weitere laden (${shown} von ${data.totals.count})`;
}
async function loadMoreHistory() {
state.history.offset += state.history.limit;
await loadHistory(false);
}
async function deleteSession(id) {
if (!confirm('Diesen Eintrag endgültig aus der Historie löschen?')) return;
try {
await api(`/api/sessions/${id}`, { method: 'DELETE' });
await loadHistory(true);
toast('Eintrag gelöscht', 'info');
} catch (e) {
toast('Löschen fehlgeschlagen: ' + e.message, 'error');
}
}
function exportCsv() {
const params = historyQuery();
window.location.href = '/api/sessions/export.csv?' + params.toString();
}
function resetFilter() {
document.getElementById('filterFrom').value = '';
document.getElementById('filterTo').value = '';
document.getElementById('filterName').value = '';
loadHistory(true);
}
function filterToday() {
const today = new Date().toISOString().slice(0, 10);
document.getElementById('filterFrom').value = today;
document.getElementById('filterTo').value = today;
loadHistory(true);
}
function filterThisMonth() {
const now = new Date();
const first = new Date(now.getFullYear(), now.getMonth(), 1);
const pad = n => String(n).padStart(2, '0');
document.getElementById('filterFrom').value =
`${first.getFullYear()}-${pad(first.getMonth() + 1)}-01`;
document.getElementById('filterTo').value =
`${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
loadHistory(true);
}
['filterFrom', 'filterTo'].forEach(id =>
document.getElementById(id).addEventListener('change', () => loadHistory(true)));
document.getElementById('filterName').addEventListener('input', (() => {
let handle = null;
return () => { clearTimeout(handle); handle = setTimeout(() => loadHistory(true), 350); };
})());
// ---------------------------------------------------------------------------
// Einstellungen (serverseitig - gelten fuer alle Geraete)
// ---------------------------------------------------------------------------
async function loadSettings() {
try {
const rate = await api('/api/settings');
state.rate = rate;
document.getElementById('rateAmount').value = rate.rateAmount;
document.getElementById('rateInterval').value = rate.rateInterval;
updateSettingsPreview();
} catch (e) {
toast('Einstellungen konnten nicht geladen werden: ' + e.message, 'error');
}
}
async function saveSettings() {
const rateAmount = parseFloat(document.getElementById('rateAmount').value);
const rateInterval = parseInt(document.getElementById('rateInterval').value);
try {
const rate = await api('/api/settings', {
method: 'PUT',
body: JSON.stringify({ rateAmount, rateInterval })
});
state.rate = rate;
renderTimers();
toast('Einstellungen gespeichert - gilt für alle Geräte', 'success');
showTimer();
} catch (e) {
toast('Speichern fehlgeschlagen: ' + e.message, 'error');
}
}
async function resetSettings() {
if (!confirm('Tarif auf Standard zurücksetzen (€10 pro 10 Minuten)?')) return;
document.getElementById('rateAmount').value = 10;
document.getElementById('rateInterval').value = 10;
await saveSettings();
}
function updateSettingsPreview() {
const amount = parseFloat(document.getElementById('rateAmount').value) || 0;
const interval = parseInt(document.getElementById('rateInterval').value) || 1;
document.getElementById('settingsPreview').textContent =
`${formatEuro(amount)} pro angefangene ${interval} Minuten`;
const examples = [Math.max(1, interval - 5), interval + 5, interval * 2, 60]
.filter((v, i, a) => a.indexOf(v) === i)
.map(mins => `${mins} Min = ${formatEuro(Math.ceil(mins / interval) * amount)}`);
document.getElementById('previewExamples').innerHTML =
`<strong>Beispiele:</strong><br>${examples.join(' | ')}`;
}
document.getElementById('settingsForm').addEventListener('submit', (e) => {
e.preventDefault();
saveSettings();
});
document.getElementById('rateAmount').addEventListener('input', updateSettingsPreview);
document.getElementById('rateInterval').addEventListener('input', updateSettingsPreview);
// ---------------------------------------------------------------------------
checkAuth();
Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

+738
View File
@@ -0,0 +1,738 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timer - Zeiterfassung</title>
<link rel="icon" type="image/jpeg" href="/favicon.jpg">
<style>
/* Bewusst KEIN Google-Fonts-Import: kein externer Abruf zur Laufzeit.
Der System-Font-Stack sieht praktisch identisch aus (Segoe UI /
Roboto / SF Pro). Wer Inter zwingend will: siehe DEPLOY.md. */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 50%, #1a1a2e 100%);
min-height: 100vh;
color: #ffffff;
display: flex;
flex-direction: column;
position: relative;
overflow-x: hidden;
}
body::before {
content: '';
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(45, 27, 105, 0.1) 0%, transparent 50%);
pointer-events: none;
z-index: 0;
}
@keyframes pulse {
0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.3; }
50% { transform: scale(1.1) rotate(180deg); opacity: 0.5; }
}
@media (prefers-reduced-motion: reduce) {
body::before { animation: none; }
.view { animation: none; }
}
.container {
position: relative;
z-index: 1;
flex: 1;
display: flex;
flex-direction: column;
}
header {
padding: 1.5rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
flex-wrap: wrap;
background: rgba(26, 26, 46, 0.8);
border-bottom: 1px solid rgba(45, 27, 105, 0.3);
}
.logo {
height: 50px;
width: auto;
object-fit: contain;
}
.header-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
align-items: center;
}
.header-user {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 0.45rem 0.85rem;
border-radius: 10px;
background: rgba(45, 27, 105, 0.35);
border: 1px solid rgba(255, 255, 255, 0.12);
font-size: 0.9rem;
font-weight: 600;
white-space: nowrap;
}
.header-user::before { content: '👤'; }
.header-user:empty { display: none; }
.btn {
padding: 0.625rem 1.5rem;
background: linear-gradient(135deg, #2D1B69, #3d2589);
color: white;
border: none;
border-radius: 8px;
font-size: 0.95rem;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
font-family: inherit;
box-shadow: 0 4px 15px rgba(45, 27, 105, 0.3);
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(45, 27, 105, 0.5);
background: linear-gradient(135deg, #3d2589, #4d35a9);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:focus-visible {
outline: 2px solid #a8a8ff;
outline-offset: 2px;
}
.btn-sm {
padding: 0.5rem 1rem;
font-size: 0.875rem;
box-shadow: none;
}
.btn-secondary {
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: none;
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.15);
border-color: rgba(255, 255, 255, 0.3);
}
.btn-danger { background: linear-gradient(135deg, #8B1538, #a01848); }
.btn-danger:hover { background: linear-gradient(135deg, #a01848, #b02058); }
.btn-start { background: linear-gradient(135deg, #10b981, #059669); }
.btn-start:hover { background: linear-gradient(135deg, #059669, #047857); }
.btn-stop { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-stop:hover { background: linear-gradient(135deg, #d97706, #b45309); }
main {
flex: 1;
display: flex;
align-items: flex-start;
justify-content: center;
padding: 2rem;
}
.view {
display: none;
width: 100%;
max-width: 1200px;
animation: fadeIn 0.4s ease-out;
}
.view.active { display: block; }
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
/* ---------- Login ---------- */
#loginView { display: none; }
#loginView.active { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.login-container {
max-width: 450px;
width: 100%;
margin: 0 auto;
background: rgba(26, 26, 46, 0.8);
border-radius: 20px;
padding: 3rem;
border: 1px solid rgba(45, 27, 105, 0.3);
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-logo {
width: 120px;
height: 120px;
margin: 0 auto 2rem;
display: block;
border-radius: 50%;
}
.login-container h1 {
text-align: center;
margin-bottom: 2rem;
font-size: 1.8rem;
font-weight: 600;
background: linear-gradient(135deg, #ffffff, #a8a8ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.form-group { margin-bottom: 1.5rem; }
.form-group label {
display: block;
margin-bottom: 0.5rem;
font-size: 0.9rem;
font-weight: 500;
color: rgba(255, 255, 255, 0.8);
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"] {
width: 100%;
padding: 0.875rem 1.125rem;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
font-size: 1rem;
color: white;
font-family: inherit;
transition: all 0.3s ease;
}
input:focus {
outline: none;
border-color: #4d35a9;
background: rgba(255, 255, 255, 0.08);
box-shadow: 0 0 0 3px rgba(45, 27, 105, 0.35);
}
input::placeholder { color: rgba(255, 255, 255, 0.35); }
/* Datumsfelder im Dark Theme lesbar halten */
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.6; cursor: pointer; }
.error-message {
color: #ff8787;
font-size: 0.875rem;
margin-top: 0.5rem;
display: none;
}
.error-message.show { display: block; }
/* ---------- Timer-Uebersicht ---------- */
.timer-toolbar {
background: rgba(26, 26, 46, 0.6);
border-radius: 20px;
padding: 1.5rem;
margin-bottom: 2rem;
border: 1px solid rgba(45, 27, 105, 0.3);
}
.timer-toolbar form {
display: flex;
gap: 1rem;
align-items: center;
flex-wrap: wrap;
}
.timer-toolbar input {
flex: 1;
min-width: 220px;
}
.timer-toolbar .btn { white-space: nowrap; }
.rate-hint {
margin-top: 1rem;
font-size: 0.9rem;
color: rgba(255, 255, 255, 0.6);
}
.timer-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 1.5rem;
}
.timer-card {
background: rgba(26, 26, 46, 0.6);
border-radius: 20px;
padding: 1.75rem;
border: 2px solid rgba(45, 27, 105, 0.4);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
text-align: center;
transition: border-color 0.3s ease;
}
.timer-card.running { border-color: rgba(16, 185, 129, 0.45); }
.timer-card.paused { border-color: rgba(245, 158, 11, 0.45); }
.timer-card-head {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 1.25rem;
}
.timer-name {
flex: 1;
padding: 0.5rem 0.75rem !important;
font-size: 0.95rem !important;
font-weight: 500;
text-align: left;
}
.timer-badge {
font-size: 0.75rem;
font-weight: 600;
padding: 0.35rem 0.6rem;
border-radius: 6px;
white-space: nowrap;
letter-spacing: 0.03em;
}
.timer-card.running .timer-badge { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.timer-card.paused .timer-badge { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.timer-card-time {
font-size: 3.2rem;
font-weight: 300;
letter-spacing: 0.03em;
font-variant-numeric: tabular-nums;
margin-bottom: 0.75rem;
background: linear-gradient(135deg, #ffffff, #c8c8ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.timer-card-amount {
font-size: 1.8rem;
font-weight: 600;
color: #ffffff;
background: linear-gradient(135deg, #2D1B69, #3d2589);
padding: 0.6rem 1.5rem;
border-radius: 12px;
display: inline-block;
min-width: 140px;
border: 2px solid rgba(255, 255, 255, 0.18);
font-variant-numeric: tabular-nums;
}
.timer-card-since {
margin-top: 0.75rem;
font-size: 0.8rem;
color: rgba(255, 255, 255, 0.45);
}
.timer-card-actions {
display: flex;
gap: 0.5rem;
justify-content: center;
margin-top: 1.5rem;
flex-wrap: wrap;
}
/* ---------- Historie ---------- */
.history-container,
.settings-container {
background: rgba(26, 26, 46, 0.6);
border-radius: 20px;
padding: 2rem;
border: 1px solid rgba(45, 27, 105, 0.3);
}
.settings-container { max-width: 700px; margin: 0 auto; padding: 2.5rem; }
.history-container h2,
.settings-container h2 {
margin-bottom: 1.5rem;
font-size: 2rem;
font-weight: 600;
background: linear-gradient(135deg, #ffffff, #a8a8ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.filter-bar {
display: flex;
gap: 1rem;
align-items: flex-end;
flex-wrap: wrap;
margin-bottom: 1.5rem;
padding-bottom: 1.5rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.filter-field { display: flex; flex-direction: column; gap: 0.4rem; }
.filter-field label {
font-size: 0.8rem;
color: rgba(255, 255, 255, 0.6);
font-weight: 500;
}
.filter-field input { min-width: 150px; padding: 0.6rem 0.9rem !important; font-size: 0.9rem !important; }
.filter-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.history-stats {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.stat-card {
background: rgba(45, 27, 105, 0.2);
padding: 1.5rem;
border-radius: 15px;
border: 1px solid rgba(45, 27, 105, 0.3);
}
.stat-card h3 {
font-size: 0.8rem;
font-weight: 500;
color: rgba(255, 255, 255, 0.7);
margin-bottom: 0.5rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.stat-card p {
font-size: 1.9rem;
font-weight: 600;
color: #ffffff;
font-variant-numeric: tabular-nums;
}
.history-list { max-height: 55vh; overflow-y: auto; }
.history-item {
background: rgba(255, 255, 255, 0.05);
padding: 1.1rem 1.25rem;
border-radius: 12px;
margin-bottom: 0.75rem;
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.25s ease;
}
.history-item:hover {
background: rgba(255, 255, 255, 0.08);
border-color: rgba(45, 27, 105, 0.4);
}
.history-item-info { flex: 1; min-width: 0; }
.history-item-name {
display: block;
font-size: 1.05rem;
font-weight: 600;
margin-bottom: 0.15rem;
}
.history-item-name.muted { color: rgba(255, 255, 255, 0.4); font-weight: 400; font-style: italic; }
.history-item-date { font-size: 0.85rem; color: rgba(255, 255, 255, 0.55); }
.history-item-duration {
font-size: 1.05rem;
font-weight: 500;
font-variant-numeric: tabular-nums;
margin-top: 0.15rem;
}
.history-item-right { display: flex; align-items: center; gap: 0.75rem; }
.history-item-amount {
font-size: 1.4rem;
font-weight: 600;
background: linear-gradient(135deg, #2D1B69, #3d2589);
padding: 0.5rem 1rem;
border-radius: 8px;
min-width: 100px;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.15);
font-variant-numeric: tabular-nums;
}
.history-footer { text-align: center; margin-top: 1rem; }
.empty-state {
text-align: center;
padding: 3rem;
color: rgba(255, 255, 255, 0.5);
}
.empty-state-icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.3; }
/* ---------- Einstellungen ---------- */
.settings-description { color: rgba(255, 255, 255, 0.7); margin-bottom: 2rem; font-size: 0.95rem; }
.settings-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.5rem;
margin-bottom: 2rem;
}
.form-group small {
display: block;
margin-top: 0.5rem;
font-size: 0.8rem;
color: rgba(255, 255, 255, 0.5);
}
.settings-preview {
background: rgba(45, 27, 105, 0.2);
padding: 1.5rem;
border-radius: 15px;
margin-bottom: 2rem;
border: 1px solid rgba(45, 27, 105, 0.3);
text-align: center;
}
.settings-preview h3 {
font-size: 0.9rem;
font-weight: 600;
color: rgba(255, 255, 255, 0.7);
margin-bottom: 1rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.settings-preview p { font-size: 1.7rem; font-weight: 600; margin-bottom: 0.5rem; }
.preview-examples {
font-size: 0.95rem !important;
font-weight: 400 !important;
color: rgba(255, 255, 255, 0.7) !important;
margin-top: 1rem !important;
}
.settings-actions { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.settings-actions .btn { flex: 1; padding: 1rem; }
.settings-info {
background: rgba(255, 255, 255, 0.05);
padding: 1rem;
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.settings-info p { font-size: 0.875rem; color: rgba(255, 255, 255, 0.7); margin: 0; }
/* ---------- Toast ---------- */
.toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%) translateY(200%);
background: rgba(26, 26, 46, 0.97);
border: 1px solid rgba(45, 27, 105, 0.6);
color: #fff;
padding: 1rem 1.75rem;
border-radius: 12px;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
z-index: 100;
transition: transform 0.35s ease, opacity 0.35s ease;
opacity: 0;
max-width: 90vw;
font-size: 0.95rem;
text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: rgba(16, 185, 129, 0.7); }
.toast.error { border-color: rgba(220, 38, 38, 0.8); }
/* ---------- Mobil ---------- */
@media (max-width: 768px) {
header { padding: 1rem; }
main { padding: 1rem; }
.logo { height: 38px; }
.header-actions { gap: 0.5rem; width: 100%; }
.header-actions .btn { flex: 1; padding: 0.6rem 0.75rem; font-size: 0.85rem; }
.login-container { padding: 2rem 1.5rem; }
.timer-grid { grid-template-columns: 1fr; }
.timer-card-time { font-size: 2.6rem; }
.settings-grid { grid-template-columns: 1fr; }
.settings-actions { flex-direction: column; }
.history-item { flex-direction: column; align-items: stretch; text-align: center; }
.history-item-right { justify-content: center; }
.filter-field, .filter-field input { width: 100%; }
}
</style>
</head>
<body>
<div class="container">
<header id="header" style="display: none;">
<img src="/logo.png" alt="Logo" class="logo">
<div class="header-actions">
<span id="currentUser" class="header-user" title="Angemeldet"></span>
<button class="btn btn-secondary" onclick="showTimer()">⏱️ Timer</button>
<button class="btn btn-secondary" onclick="showHistory()">📊 Historie</button>
<button class="btn btn-secondary" onclick="showSettings()">⚙️ Einstellungen</button>
<button class="btn btn-secondary" onclick="logout()">🚪 Abmelden</button>
</div>
</header>
<main>
<!-- Anmeldung -->
<div id="loginView" class="view active">
<div class="login-container">
<img src="/favicon.jpg" alt="" class="login-logo">
<h1>Zeiterfassung</h1>
<!-- Anmeldung ausschliesslich ueber Authentik (SSO) -->
<a id="ssoLoginBtn" href="/auth/login" class="btn"
style="width: 100%; padding: 1rem; text-decoration: none; box-sizing: border-box;">🔐 Anmelden mit Authentik</a>
<div class="error-message" id="loginError" style="margin-top: 1rem;">
Anmeldung derzeit nicht möglich Authentik ist nicht erreichbar.
</div>
</div>
</div>
<!-- Timer-Uebersicht -->
<div id="timerView" class="view">
<div class="timer-toolbar">
<form id="newTimerForm">
<input type="text" id="newTimerName" maxlength="80"
placeholder="Name oder Platz (optional) - z. B. „Tisch 2" oder Herr Müller"">
<button type="submit" class="btn btn-start">▶ Neuer Timer</button>
</form>
<div class="rate-hint" id="rateHint">Tarif wird geladen …</div>
</div>
<div class="timer-grid" id="timerList"></div>
<div class="empty-state" id="timerEmpty" style="display: none;">
<div class="empty-state-icon">⏱️</div>
<p>Kein Timer läuft gerade.<br>Oben einen neuen starten.</p>
</div>
</div>
<!-- Historie -->
<div id="historyView" class="view">
<div class="history-container">
<h2>📊 Historie</h2>
<div class="filter-bar">
<div class="filter-field">
<label for="filterFrom">Von</label>
<input type="date" id="filterFrom">
</div>
<div class="filter-field">
<label for="filterTo">Bis</label>
<input type="date" id="filterTo">
</div>
<div class="filter-field">
<label for="filterName">Name</label>
<input type="text" id="filterName" placeholder="Kunde / Platz">
</div>
<div class="filter-actions">
<button class="btn btn-secondary btn-sm" onclick="filterToday()">Heute</button>
<button class="btn btn-secondary btn-sm" onclick="filterThisMonth()">Dieser Monat</button>
<button class="btn btn-secondary btn-sm" onclick="resetFilter()">Alle</button>
<button class="btn btn-sm" onclick="exportCsv()">⬇ CSV-Export</button>
</div>
</div>
<div class="history-stats" id="historyStats"></div>
<div class="history-list" id="historyList"></div>
<div class="history-footer">
<button class="btn btn-secondary" id="historyMore"
onclick="loadMoreHistory()" style="display: none;">Weitere laden</button>
</div>
</div>
</div>
<!-- Einstellungen -->
<div id="settingsView" class="view">
<div class="settings-container">
<h2>⚙️ Einstellungen</h2>
<p class="settings-description">Der Tarif gilt für alle Geräte gemeinsam.</p>
<form id="settingsForm">
<div class="settings-grid">
<div class="form-group">
<label for="rateAmount">Betrag (€)</label>
<input type="number" id="rateAmount" min="0.5" max="10000" step="0.5" value="10" required>
<small>Euro pro Intervall</small>
</div>
<div class="form-group">
<label for="rateInterval">Intervall (Minuten)</label>
<input type="number" id="rateInterval" min="1" max="600" step="1" value="10" required>
<small>Jede angefangene Einheit wird voll berechnet</small>
</div>
</div>
<div class="settings-preview">
<h3>Vorschau</h3>
<p id="settingsPreview">€10 pro angefangene 10 Minuten</p>
<p class="preview-examples" id="previewExamples"></p>
</div>
<div class="settings-actions">
<button type="submit" class="btn">💾 Speichern</button>
<button type="button" class="btn btn-secondary" onclick="resetSettings()">🔄 Zurücksetzen</button>
</div>
</form>
<div class="settings-info">
<p><strong>Hinweis:</strong> Eine Tarifänderung gilt ab sofort für laufende und neue Timer.
Bereits gespeicherte Einträge in der Historie behalten den Tarif, der beim Beenden galt.</p>
</div>
</div>
</div>
</main>
</div>
<div class="toast" id="toast"></div>
<script src="/app.js?v=20260803-sso"></script>
</body>
</html>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 639 KiB