From 9fdcb888aa6f7c5350cc2b39e5ebf071088e5490 Mon Sep 17 00:00:00 2001 From: Stephan Rehfeld Date: Wed, 25 Nov 2026 06:40:58 +0100 Subject: [PATCH] =?UTF-8?q?Zeitplan:=20Linie=20f=C3=BCr=20die=20aktuelle?= =?UTF-8?q?=20Uhrzeit=20im=20heutigen=20Tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/ui/app.css | 4 ++++ proxy/ui/app.js | 15 +++++++++++++++ tests/ui/render_test.js | 16 ++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/proxy/ui/app.css b/proxy/ui/app.css index d95521f..ed303bd 100644 --- a/proxy/ui/app.css +++ b/proxy/ui/app.css @@ -246,6 +246,10 @@ input[type=date].field, input[type=time].field, input[type=datetime-local].field /* Ein Feld über zwei Spalten, sobald es zwei gibt */ @media (min-width: 560px) { .fields .wide { grid-column: span 2; } } +/* Linie für die aktuelle Uhrzeit im Kalender */ +.cal-now { position: absolute; left: 0; right: 0; z-index: 3; pointer-events: none; border-top: 2px solid var(--bad); } +.cal-now span { position: absolute; left: 3px; top: -8px; padding: 0 3px; border-radius: 4px; background: var(--bad); color: #1c1310; font: 10px var(--mono); } + /* Zeitraum im Kalender aufziehen */ .cal-col { cursor: crosshair; touch-action: none; user-select: none; } .cal-sel { position: absolute; left: 2px; right: 2px; border: 1px dashed var(--accent); border-radius: 6px; background: var(--accent-bg); color: var(--accent-text); font: 11px var(--mono); padding: 3px 5px; pointer-events: none; z-index: 2; } diff --git a/proxy/ui/app.js b/proxy/ui/app.js index fc4bee3..1ceb432 100644 --- a/proxy/ui/app.js +++ b/proxy/ui/app.js @@ -1463,6 +1463,21 @@ async function schedulePage() { h('span', { class: 'ev-kind' }, KIND_LABEL[e.kind.kind]), h('span', { class: 'mono' }, e.subject), e.note ? h('span', {}, e.note) : null, h('span', { class: 'ev-by' }, 'von ' + creator(e)), h('span', { class: 'mono' }, hhmm(from) + '–' + (to.getTime() === dayStart.getTime() + 86400000 ? '24:00' : hhmm(to))))); } + // Linie für die aktuelle Uhrzeit im heutigen Tag, hält sich alle 30 Sekunden aktuell + if (dayStart.toDateString() === new Date().toDateString()) { + const line = h('div', { class: 'cal-now' }, h('span', {})); + const place = () => { + const now = new Date(); + line.style.top = ((now.getHours() * 60 + now.getMinutes()) / 60 * HOUR) + 'px'; + line.firstChild.textContent = hhmm(now); + }; + place(); + const tick = setInterval(() => { + if (!col.isConnected) return clearInterval(tick); + place(); + }, 30000); + col.append(line); + } // Minuten seit Tagesbeginn an der Zeigerposition, auf halbe Stunden gerastert const minutes = (ev, round) => { const y = ev.clientY - col.getBoundingClientRect().top; diff --git a/tests/ui/render_test.js b/tests/ui/render_test.js index 0b8e677..95fc83b 100644 --- a/tests/ui/render_test.js +++ b/tests/ui/render_test.js @@ -319,6 +319,22 @@ async function flows(fail) { expect(c.style.width.includes('100%'), 'freier Termin nicht in voller Breite: ' + c.style.width); for (const n of ['lage-a-', 'lage-b-', 'lage-c-']) await click(w, 'Entfernen', n + tag); }); + await step('der heutige Tag zeigt eine Linie für die aktuelle Uhrzeit', async () => { + const { w } = browser(admin, '#/schedule'); + await settle(w); + const today = (new Date().getDay() + 6) % 7; + const cols = [...w.document.querySelectorAll('.cal-col')]; + const line = cols[today].querySelector('.cal-now'); + expect(line, 'Linie fehlt im heutigen Tag'); + const now = new Date(); + const top = (now.getHours() * 60 + now.getMinutes()) / 60 * 22; + expect(Math.abs(parseFloat(line.style.top) - top) <= 22, + 'Linie bei ' + line.style.top + ', erwartet etwa ' + Math.round(top) + 'px'); + const clock = String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0'); + expect(line.textContent === clock, 'Beschriftung „' + line.textContent + '“, erwartet ' + clock); + expect(cols.every((c, d) => d === today || !c.querySelector('.cal-now')), 'Linie auch an einem anderen Tag'); + return clock; + }); await step('admin nimmt spark3 aus dem Pool und wieder auf', async () => { const { w } = browser(admin, '#/status'); await settle(w);