diff --git a/README.md b/README.md index 7cc1c6b..628f036 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ session_days = 7 secure_cookie = false # hinter einem HTTPS-Reverse-Proxy einschalten ``` -Ausprobieren mit den simulierten Sparks: `tests/multispark/start.sh && tests/multispark/demo.sh`, +Ausprobieren mit den simulierten Sparks: `tests/multispark/start.sh --demo && tests/multispark/demo.sh`, dann `http://127.0.0.1:8000/omega/` mit `admin`, `dozent` oder `student` (Passwort `1234`). Rendertest aller Seiten und Abläufe: `cd tests/ui && npm install && npm test`. diff --git a/proxy/src/main.rs b/proxy/src/main.rs index ff3bf43..6125446 100644 --- a/proxy/src/main.rs +++ b/proxy/src/main.rs @@ -192,7 +192,7 @@ pub struct TimeArgs { /// Wochentage, z. B. "mo,mi" oder "mo-fr" #[arg(long, requires = "time")] weekly: Option, - /// Uhrzeit für --weekly, z. B. "08:00-11:15" oder über Mitternacht "22:00-02:00" + /// Uhrzeit für --weekly, z. B. "08:00-11:15" oder über Mitternacht "22:00-02:00"; ohne: ganztags #[arg(long, requires = "weekly")] time: Option, /// Anmerkung, z. B. die Lehrveranstaltung diff --git a/proxy/src/schedule.rs b/proxy/src/schedule.rs index 85199ee..009bbb6 100644 --- a/proxy/src/schedule.rs +++ b/proxy/src/schedule.rs @@ -157,13 +157,24 @@ fn fmt_until(ts: i64) -> String { } impl Weekly { + /// Ganze Tage, ohne Uhrzeit angegeben + pub fn whole_days(days: Vec) -> Self { + Weekly { days, start: NaiveTime::MIN, end: NaiveTime::MIN } + } + + pub fn all_day(&self) -> bool { + self.start == self.end + } + fn overnight(&self) -> bool { self.end < self.start } fn contains(&self, t: DateTime) -> bool { let (day, time) = (t.weekday(), t.time()); - if self.overnight() { + if self.all_day() { + self.days.contains(&day) + } else if self.overnight() { (self.days.contains(&day) && time >= self.start) || (self.days.contains(&day.pred()) && time < self.end) } else { self.days.contains(&day) && self.start <= time && time < self.end @@ -173,6 +184,17 @@ impl Weekly { /// Ende des Abschnitts, der t enthält fn end_after(&self, t: DateTime) -> Option> { let mut date = t.date_naive(); + if self.all_day() { + // Bis zum Beginn des ersten folgenden Tages, der nicht dazugehört + date = date.succ_opt()?; + for _ in 0..7 { + if !self.days.contains(&date.weekday()) { + break; + } + date = date.succ_opt()?; + } + return local(date.and_time(NaiveTime::MIN)).ok(); + } if self.overnight() && t.time() >= self.start { date = date.succ_opt()?; } @@ -223,7 +245,11 @@ impl TimeSpec { pub fn describe(&self) -> String { let mut parts = Vec::new(); if let Some(w) = &self.weekly { - parts.push(format!("wöchentlich {} {}-{}", days_str(&w.days), w.start.format("%H:%M"), w.end.format("%H:%M"))); + if w.all_day() { + parts.push(format!("wöchentlich {} ganztags", days_str(&w.days))); + } else { + parts.push(format!("wöchentlich {} {}-{}", days_str(&w.days), w.start.format("%H:%M"), w.end.format("%H:%M"))); + } } match (self.from, self.until) { (Some(f), Some(u)) => parts.push(format!("{} bis {}", fmt_from(f), fmt_until(u))), @@ -411,6 +437,18 @@ mod tests { assert_eq!(t.current_end(at("2026-11-23 09:00")), Some(at("2026-11-23 11:15"))); } + #[test] + fn weekly_whole_days() { + let w = Weekly::whole_days(parse_days("sa,so").unwrap()); + let at = |s: &str| Local.from_local_datetime(&NaiveDateTime::parse_from_str(s, "%Y-%m-%d %H:%M").unwrap()).unwrap(); + // 2026-11-21 ist ein Samstag + assert!(w.contains(at("2026-11-21 00:00")) && w.contains(at("2026-11-22 23:59"))); + assert!(!w.contains(at("2026-11-20 23:59")) && !w.contains(at("2026-11-23 00:00"))); + assert_eq!(w.end_after(at("2026-11-21 10:00")), Some(at("2026-11-23 00:00"))); + let spec = TimeSpec { from: None, until: None, weekly: Some(w) }; + assert_eq!(spec.describe(), "wöchentlich sa,so ganztags"); + } + #[test] fn weekly_over_midnight() { // Freitag 22:00 bis Samstag 02:00 diff --git a/proxy/src/service.rs b/proxy/src/service.rs index 9d85eb6..9946eab 100644 --- a/proxy/src/service.rs +++ b/proxy/src/service.rs @@ -82,8 +82,9 @@ impl TimeInput { let (start, end) = schedule::parse_time_range(time).map_err(|e| invalid(format!("{e:#}")))?; Some(Weekly { days: schedule::parse_days(days).map_err(|e| invalid(format!("{e:#}")))?, start, end }) } + (Some(days), None) => Some(Weekly::whole_days(schedule::parse_days(days).map_err(|e| invalid(format!("{e:#}")))?)), (None, None) => None, - _ => return Err(invalid("Wochentage und Uhrzeit nur zusammen angeben")), + (None, Some(_)) => return Err(invalid("zur Uhrzeit fehlen die Wochentage")), }; Ok(TimeSpec { from: from.map(|t| t.timestamp()), until: until.map(|t| t.timestamp()), weekly }) } diff --git a/proxy/ui/app.css b/proxy/ui/app.css index 91d8336..c334efd 100644 --- a/proxy/ui/app.css +++ b/proxy/ui/app.css @@ -226,8 +226,7 @@ pre.settings { margin: 8px 0 0; background: var(--sunken); border: 1px solid var input[type=date].field, input[type=time].field, input[type=datetime-local].field { color-scheme: dark; } /* Wochenkalender */ -.cal-card { flex: 999 1 640px; overflow-x: auto; } -.cal-form { flex: 1 1 340px; max-width: 460px; } +.cal-card { overflow-x: auto; } .cal { display: grid; grid-template-columns: 40px repeat(7, minmax(92px, 1fr)); column-gap: 6px; min-width: 720px; } .cal-corner { height: 32px; } .cal-day { height: 32px; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--line); } @@ -235,9 +234,25 @@ input[type=date].field, input[type=time].field, input[type=datetime-local].field .cal-hours { position: relative; font-size: 11px; color: var(--muted); } .cal-hours span { position: absolute; right: 4px; transform: translateY(-1px); } .cal-col { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0 43px, var(--raised) 43px 44px); } -.ev { position: absolute; right: 4px; border-radius: 6px; padding: 4px 6px; font-size: 11px; line-height: 1.3; overflow: hidden; display: flex; flex-direction: column; gap: 1px; } +.ev { position: absolute; right: 4px; border-radius: 6px; padding: 4px 6px; font: 11px/1.3 var(--sans); text-align: left; overflow: hidden; display: flex; flex-direction: column; gap: 1px; cursor: pointer; z-index: 1; } +.ev:hover { filter: brightness(1.2); } .ev .ev-kind { font-weight: 600; } .ev.pin, .swatch.ev-pin { background: #2c2117; border: 1px solid #8a5a32; color: #ffe2c6; } .ev.exclusive, .swatch.ev-exclusive { background: rgba(180,140,240,.16); border: 1px solid rgba(180,140,240,.55); color: #e3d6fb; } .ev.window, .swatch.ev-window { background: rgba(79,209,197,.12); border: 1px solid rgba(79,209,197,.5); color: #b8f0ea; } .toolbar .legend { margin-left: auto; } + +/* Ein Feld über zwei Spalten, sobald es zwei gibt */ +@media (min-width: 560px) { .fields .wide { grid-column: span 2; } } + +/* 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; } +button.chip { border: 0; cursor: pointer; font: inherit; } + +/* Overlay */ +.overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; background: rgba(0,0,0,.55); overflow-y: auto; } +.dialog { width: 100%; max-width: 560px; box-shadow: 0 18px 48px rgba(0,0,0,.5); } +.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; } +.facts dt { color: var(--text-3); } +.facts dd { margin: 0; } diff --git a/proxy/ui/app.js b/proxy/ui/app.js index 2372691..91a232b 100644 --- a/proxy/ui/app.js +++ b/proxy/ui/app.js @@ -153,11 +153,11 @@ function segmented(name, options, value, onchange) { return wrap; } -/** Wochentage zum Anklicken; liefert die Auswahl als "mo,mi" */ -function dayToggles(id) { +/** Wochentage zum Anklicken, vorausgewählt `selected` (Kürzel); liefert die Auswahl als "mo,mi" */ +function dayToggles(id, selected = []) { const wrap = h('div', { class: 'days', id, role: 'group', 'aria-label': 'Wochentage' }); for (const [code, label] of WEEKDAYS) { - const b = h('button', { type: 'button', class: 'day', 'aria-pressed': 'false', 'data-day': code, + const b = h('button', { type: 'button', class: 'day', 'aria-pressed': String(selected.includes(code)), 'data-day': code, onclick: () => b.setAttribute('aria-pressed', b.getAttribute('aria-pressed') === 'true' ? 'false' : 'true') }, label); wrap.append(b); } @@ -266,6 +266,7 @@ function head(section, title, sub, ...actions) { } async function render() { + closeOverlays(); const { page, arg } = route(); const def = PAGES[page] || PAGES['']; if (!state.me) { @@ -534,19 +535,30 @@ async function keysPage() { } function keysManageCard(title, keys, own) { - return h('section', { class: 'card' }, h('h2', {}, title), + const hide = h('input', { type: 'checkbox', id: 'hide-revoked', checked: state.hideRevoked ?? true }); + const revoked = keys.filter((k) => k.revoked).length; + const body = h('tbody', {}); + function update() { + state.hideRevoked = hide.checked; + body.replaceChildren(...keys.filter((k) => !hide.checked || !k.revoked).map((k) => h('tr', { class: k.revoked ? 'dim' : null }, + h('td', { class: 'mono' }, k.name), own ? null : h('td', { class: 'mono' }, k.owner || '–'), + h('td', { class: 'mono muted' }, k.prefix + '…'), h('td', {}, quotaLabel(k)), + h('td', { class: 'num' }, tokens(tok(k.usage.month))), h('td', { class: 'num' }, num(k.usage.month.requests)), + h('td', {}, keyState(k)), + h('td', {}, k.revoked ? null : h('div', { class: 'actions' }, + own && !k.recording ? h('button', { class: 'btn small', type: 'button', onclick: () => startRecording(k) }, 'Aufzeichnen') : null, + own && k.recording ? h('button', { class: 'btn small', type: 'button', onclick: () => act(() => api('POST', '/recordings/stop', { key_id: k.id }), 'Aufzeichnung beendet; sie liegt jetzt zum Herunterladen bereit.') }, 'Aufzeichnung beenden') : null, + h('button', { class: 'btn small danger', type: 'button', onclick: () => revokeKey(k) }, 'Widerrufen')))))); + } + hide.addEventListener('change', update); + update(); + return h('section', { class: 'card' }, + h('div', { class: 'card-head' }, h('h2', {}, title), + revoked ? h('label', { class: 'check', for: 'hide-revoked' }, hide, 'Widerrufene ausblenden (' + revoked + ')') : null), keys.length ? h('div', { class: 'table-wrap' }, h('table', {}, h('thead', {}, h('tr', {}, h('th', {}, 'Name'), own ? null : h('th', {}, 'Inhaber'), h('th', {}, 'Key'), h('th', {}, 'Kontingent'), h('th', { class: 'num' }, 'Token (Monat)'), h('th', { class: 'num' }, 'Anfragen (Monat)'), h('th', {}, 'Status'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))), - h('tbody', {}, keys.map((k) => h('tr', { class: k.revoked ? 'dim' : null }, - h('td', { class: 'mono' }, k.name), own ? null : h('td', { class: 'mono' }, k.owner || '–'), - h('td', { class: 'mono muted' }, k.prefix + '…'), h('td', {}, quotaLabel(k)), - h('td', { class: 'num' }, tokens(tok(k.usage.month))), h('td', { class: 'num' }, num(k.usage.month.requests)), - h('td', {}, keyState(k)), - h('td', {}, k.revoked ? null : h('div', { class: 'actions' }, - own && !k.recording ? h('button', { class: 'btn small', type: 'button', onclick: () => startRecording(k) }, 'Aufzeichnen') : null, - own && k.recording ? h('button', { class: 'btn small', type: 'button', onclick: () => act(() => api('POST', '/recordings/stop', { key_id: k.id }), 'Aufzeichnung beendet; sie liegt jetzt zum Herunterladen bereit.') }, 'Aufzeichnung beenden') : null, - h('button', { class: 'btn small danger', type: 'button', onclick: () => revokeKey(k) }, 'Widerrufen')))))))) + body)) : h('p', { class: 'empty' }, 'Keine Keys.')); } @@ -603,16 +615,33 @@ function recordingsCard(recordings, keys) { const k = keys.find((x) => x.id === id); return k ? [h('span', { class: 'mono' }, k.name), ' ', h('span', { class: 'mono muted' }, '(' + k.prefix + '…)')] : '#' + id; }; + // Vergangen: läuft nicht mehr und hat keine Daten mehr zum Herunterladen + const past = (r) => !r.state.startsWith('zeichnet') && !r.state.startsWith('bereit'); + const pastCount = recordings.filter(past).length; + const hide = h('input', { type: 'checkbox', id: 'hide-past-recordings', checked: state.hidePastRecordings ?? true }); + const body = h('tbody', {}); + const empty = h('p', { class: 'empty' }); + function update() { + state.hidePastRecordings = hide.checked; + const shown = recordings.slice().reverse().filter((r) => !hide.checked || !past(r)); + body.replaceChildren(...shown.map((r) => h('tr', { class: past(r) ? 'dim' : null }, + h('td', { class: 'mono' }, r.id), h('td', {}, keyLabel(r.key_id)), h('td', { class: 'num' }, r.written + ' / ' + r.count), + h('td', {}, r.state), h('td', { class: 'muted' }, r.end_reason || '–'), + h('td', {}, r.state.startsWith('bereit') ? h('a', { class: 'btn small primary', href: '/omega/api/recordings/' + r.id + '/download', download: 'aufzeichnung-' + r.id + '.jsonl', onclick: () => setTimeout(render, 1500) }, 'JSONL herunterladen') : null)))); + empty.hidden = shown.length > 0; + empty.textContent = recordings.length ? 'Keine laufenden oder bereitliegenden Aufzeichnungen.' : 'Noch keine Aufzeichnungen. Starte eine über „Aufzeichnen“ bei einem deiner Keys.'; + table.hidden = !shown.length; + } + const table = h('div', { class: 'table-wrap' }, h('table', {}, + h('thead', {}, h('tr', {}, h('th', {}, 'Nr.'), h('th', {}, 'Key'), h('th', { class: 'num' }, 'Einträge'), h('th', {}, 'Stand'), h('th', {}, 'Ende'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))), + body)); + hide.addEventListener('change', update); + update(); return h('section', { class: 'card' }, h('div', { class: 'card-head' }, h('h2', {}, 'Aufzeichnung für Debugging'), - h('span', { class: 'muted' }, 'Verschlüsselt gespeichert, nur für dich abrufbar, eine Stunde bereit, nach dem Download gelöscht.')), - recordings.length ? h('div', { class: 'table-wrap' }, h('table', {}, - h('thead', {}, h('tr', {}, h('th', {}, 'Nr.'), h('th', {}, 'Key'), h('th', { class: 'num' }, 'Einträge'), h('th', {}, 'Stand'), h('th', {}, 'Ende'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))), - h('tbody', {}, recordings.slice().reverse().map((r) => h('tr', {}, - h('td', { class: 'mono' }, r.id), h('td', {}, keyLabel(r.key_id)), h('td', { class: 'num' }, r.written + ' / ' + r.count), - h('td', {}, r.state), h('td', { class: 'muted' }, r.end_reason || '–'), - h('td', {}, r.state.startsWith('bereit') ? h('a', { class: 'btn small primary', href: '/omega/api/recordings/' + r.id + '/download', download: 'aufzeichnung-' + r.id + '.jsonl', onclick: () => setTimeout(render, 1500) }, 'JSONL herunterladen') : null)))))) - : h('p', { class: 'empty' }, 'Noch keine Aufzeichnungen. Starte eine über „Aufzeichnen“ bei einem deiner Keys.')); + pastCount ? h('label', { class: 'check', for: 'hide-past-recordings' }, hide, 'Vergangene ausblenden (' + pastCount + ')') : null), + h('span', { class: 'hint' }, 'Verschlüsselt gespeichert, nur für dich abrufbar, eine Stunde bereit, nach dem Download gelöscht.'), + table, empty); } function endpointsCard() { @@ -733,16 +762,15 @@ function quotasTable(quotas, showOwner) { : h('p', { class: 'empty' }, 'Noch keine Kontingente.'); } -/** Formular für ein neues Kontingent, für eine feste Gruppe oder mit Auswahl */ /** Formular für ein neues Kontingent, für eine feste Gruppe oder mit Auswahl */ function quotaForm(groups, fixedGroup, models) { const limit = (name, label) => h('div', { class: 'field-group' }, h('label', { for: 'q-' + name }, label), h('input', { id: 'q-' + name, name, class: 'field mono', type: 'number', min: 1, inputmode: 'numeric', placeholder: 'unbegrenzt' })); - const days = dayToggles('q-days'); + const days = dayToggles('q-days', WEEKDAYS.map(([code]) => code)); const picker = h('div', { hidden: true }, modelPicker(models || [], 'q-model', true)); const person = h('div', { class: 'field-group', hidden: true }, h('label', { for: 'q-username' }, 'Benutzername'), h('input', { id: 'q-username', name: 'username', class: 'field mono' })); - const sharing = h('div', { class: 'field-group' }, h('span', { class: 'label' }, 'Grenzen gelten'), + const sharing = h('div', { class: 'field-group wide' }, h('span', { class: 'label' }, 'Grenzen gelten'), segmented('q-shared', [['each', 'je Person'], ['shared', 'für die Gruppe gemeinsam']], 'each')); const target = fixedGroup ? null : h('select', { id: 'q-target', name: 'target', class: 'field', onchange: () => { person.hidden = target.value !== 'user'; @@ -759,17 +787,18 @@ function quotaForm(groups, fixedGroup, models) { const chosen = checkedValues(form, 'q-model'); if (restricted && !chosen.length) { state.flash = { kind: 'error', text: 'Bei begrenzten Modellen mindestens ein Modell auswählen.' }; return render(); } const weekly = days.value(); - if (!!weekly !== !!(d.time_start && d.time_end) && (weekly || d.time_start || d.time_end)) { - state.flash = { kind: 'error', text: 'Für Nutzungszeiten Wochentage und Uhrzeit von–bis angeben.' }; - return render(); - } + if (!weekly) { state.flash = { kind: 'error', text: 'Mindestens einen Wochentag auswählen.' }; return render(); } + if (!d.time_start !== !d.time_end) { state.flash = { kind: 'error', text: 'Für die Uhrzeit Beginn und Ende angeben.' }; return render(); } + const time = d.time_start ? d.time_start + '-' + d.time_end : undefined; + // Alle Tage ohne Uhrzeit heißt: jederzeit + const always = weekly.split(',').length === 7 && !time; const body = { name: d.name, tokens: { hour: optNum(d.tokens_hour), day: optNum(d.tokens_day), week: optNum(d.tokens_week), month: optNum(d.tokens_month), total: optNum(d.tokens_total) }, requests: { hour: optNum(d.requests_hour), day: optNum(d.requests_day), week: optNum(d.requests_week), month: optNum(d.requests_month), total: optNum(d.requests_total) }, models: restricted ? chosen : undefined, from: optional(d.valid_from), until: dayAfter(d.valid_until), - weekly: weekly || undefined, time: weekly ? d.time_start + '-' + d.time_end : undefined, note: d.note, + weekly: always ? undefined : weekly, time, note: d.note, }; const t = fixedGroup || d.target; if (t.startsWith('group:')) { @@ -795,7 +824,7 @@ function quotaForm(groups, fixedGroup, models) { h('div', { class: 'fields' }, h('div', { class: 'field-group' }, h('label', { for: 'q-time-start' }, 'von'), h('input', { id: 'q-time-start', name: 'time_start', type: 'time', class: 'field mono' })), h('div', { class: 'field-group' }, h('label', { for: 'q-time-end' }, 'bis'), h('input', { id: 'q-time-end', name: 'time_end', type: 'time', class: 'field mono' }))), - h('span', { class: 'hint' }, 'Ohne Auswahl jederzeit nutzbar. Endet die Zeit vor dem Beginn, reicht sie über Mitternacht.')), + h('span', { class: 'hint' }, 'Ohne Uhrzeit ganztags. Endet die Uhrzeit vor dem Beginn, reicht sie über Mitternacht.')), h('fieldset', {}, h('legend', {}, 'Gültigkeit'), h('div', { class: 'fields' }, h('div', { class: 'field-group' }, h('label', { for: 'q-valid-from' }, 'ab'), h('input', { id: 'q-valid-from', name: 'valid_from', type: 'date', class: 'field mono' })), @@ -984,9 +1013,11 @@ async function schedulePage() { + new Date(weekEnd.getTime() - 1).toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' }); const permanent = entries.filter((e) => !e.time.from && !e.time.until && !e.time.weekly); const shiftWeek = (d) => { state.week = d === 0 ? 0 : (state.week || 0) + d; render(); }; + const newEntry = (preset) => openOverlay('Neuer Eintrag', (close) => scheduleForm(models, groups, preset, close)); - // Kalender: eine Spalte je Tag, eine Zeile je Stunde + // Kalender: eine Spalte je Tag, eine Zeile je Stunde. Ziehen markiert einen Zeitraum, ein Klick eine Stunde. const HOUR = 22; + const SLOT = 30; const grid = h('div', { class: 'cal' }); grid.append(h('div', { class: 'cal-corner' })); for (let d = 0; d < 7; d++) { @@ -999,37 +1030,128 @@ async function schedulePage() { grid.append(hours); for (let d = 0; d < 7; d++) { const dayStart = new Date(weekStart.getTime() + d * 86400000); - const col = h('div', { class: 'cal-col', style: { height: (24 * HOUR) + 'px' } }); + const col = h('div', { class: 'cal-col', style: { height: (24 * HOUR) + 'px' }, title: 'Zeitraum aufziehen, um einen Eintrag anzulegen' }); let lane = 0; for (const e of entries) { if (permanent.includes(e)) continue; for (const [from, to] of occurrences(e, dayStart)) { const top = (from - dayStart) / 3600000 * HOUR; const height = Math.max(16, (to - from) / 3600000 * HOUR); - col.append(h('div', { class: 'ev ' + e.kind.kind, style: { top: top + 'px', height: height + 'px', left: (4 + lane * 6) + 'px' }, title: e.subject + ' · ' + e.describe }, - 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: 'mono' }, hhmm(from) + '–' + (to.getTime() === dayStart.getTime() + 86400000 ? '24:00' : hhmm(to))))); + col.append(h('button', { type: 'button', class: 'ev ' + e.kind.kind, style: { top: top + 'px', height: height + 'px', left: (4 + lane * 6) + 'px' }, + title: e.subject + ' · ' + e.describe, onpointerdown: (ev) => ev.stopPropagation(), onclick: () => showEntry(e) }, + 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: 'mono' }, hhmm(from) + '–' + (to.getTime() === dayStart.getTime() + 86400000 ? '24:00' : hhmm(to))))); lane = (lane + 1) % 3; } } + // Minuten seit Tagesbeginn an der Zeigerposition, auf halbe Stunden gerastert + const minutes = (ev, round) => { + const y = ev.clientY - col.getBoundingClientRect().top; + return Math.min(24 * 60, Math.max(0, round(y / HOUR * 60 / SLOT) * SLOT)); + }; + let drag = null; + const sel = h('div', { class: 'cal-sel', hidden: true }); + col.append(sel); + const show = () => { + const [a, b] = [Math.min(drag.start, drag.end), Math.max(drag.start, drag.end)]; + Object.assign(sel.style, { top: (a / 60 * HOUR) + 'px', height: ((b - a) / 60 * HOUR) + 'px' }); + sel.textContent = mm(a) + '–' + mm(b); + sel.hidden = false; + }; + col.addEventListener('pointerdown', (ev) => { + if (ev.button !== 0) return; + ev.preventDefault(); + if (col.setPointerCapture && ev.pointerId !== undefined) col.setPointerCapture(ev.pointerId); + const start = minutes(ev, Math.floor); + drag = { start, end: Math.min(24 * 60, start + 60) }; + show(); + }); + col.addEventListener('pointermove', (ev) => { + if (!drag) return; + const m = minutes(ev, Math.ceil); + // Nach oben gezogen: der Beginn rastet nach unten ab + drag.end = m > drag.start ? m : Math.max(0, minutes(ev, Math.floor)); + if (drag.end === drag.start) drag.end = drag.start + SLOT; + show(); + }); + col.addEventListener('pointerup', () => { + if (!drag) return; + const [a, b] = [Math.min(drag.start, drag.end), Math.max(drag.start, drag.end)]; + drag = null; + newEntry({ day: dayStart, start: a, end: b }); + sel.hidden = true; + }); + col.addEventListener('pointercancel', () => { drag = null; sel.hidden = true; }); grid.append(col); } - // Formular wie im Mockup: Art, Gegenstand, Zeit und Wiederholung - const kindBox = h('div', {}); + function showEntry(e) { + openOverlay(KIND_LABEL[e.kind.kind] + ': ' + e.subject, (close) => h('div', { class: 'stack small' }, + h('dl', { class: 'facts' }, + h('dt', {}, 'Wann'), h('dd', {}, e.describe), + h('dt', {}, 'Stand'), h('dd', {}, e.active ? 'gerade aktiv' : 'gerade nicht aktiv'), + e.note ? [h('dt', {}, 'Anmerkung'), h('dd', {}, e.note)] : null), + h('div', { class: 'actions' }, + h('button', { class: 'btn', type: 'button', onclick: close }, 'Schließen'), + h('button', { class: 'btn danger', type: 'button', onclick: () => { close(); act(() => api('DELETE', '/schedule/' + e.id), 'Eintrag entfernt.'); } }, 'Entfernen')))); + } + + return h('div', { class: 'stack' }, + head('Administration', 'Zeitplan', 'Pins, exklusive Nutzung und Modellzeitfenster in einem gemeinsamen Plan. Zum Anlegen einen Zeitraum im Kalender aufziehen.', + h('button', { class: 'btn icon', type: 'button', 'aria-label': 'Vorige Woche', onclick: () => shiftWeek(-1) }, '‹'), + h('span', { class: 'mono' }, label), + h('button', { class: 'btn icon', type: 'button', 'aria-label': 'Nächste Woche', onclick: () => shiftWeek(1) }, '›'), + h('button', { class: 'btn', type: 'button', onclick: () => shiftWeek(0) }, 'Heute'), + h('button', { class: 'btn primary', type: 'button', onclick: () => newEntry(null) }, 'Neuer Eintrag')), + h('div', { class: 'toolbar' }, + h('span', { class: 'muted' }, 'Dauerhaft'), + permanent.length ? permanent.map((e) => h('button', { type: 'button', class: 'chip ' + (e.kind.kind === 'pin' ? 'accent' : '') + ' mono', onclick: () => showEntry(e) }, KIND_LABEL[e.kind.kind] + ' · ' + e.subject)) : h('span', { class: 'muted' }, '–'), + h('span', { class: 'legend' }, ['pin', 'exclusive', 'window'].map((k) => h('span', {}, h('span', { class: 'swatch ev-' + k }), KIND_LABEL[k])))), + h('section', { class: 'card cal-card' }, grid), + h('section', { class: 'card' }, h('h2', {}, 'Alle Einträge'), + entries.length ? h('div', { class: 'table-wrap' }, h('table', {}, + h('thead', {}, h('tr', {}, h('th', {}, 'Art'), h('th', {}, 'Was'), h('th', {}, 'Wann'), h('th', {}, 'Stand'), h('th', {}, 'Anmerkung'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))), + h('tbody', {}, entries.map((e) => h('tr', {}, + h('td', {}, h('span', { class: 'chip' + (e.kind.kind === 'pin' ? ' accent' : '') }, KIND_LABEL[e.kind.kind] || e.kind.kind)), + h('td', { class: 'mono wrap' }, e.subject), h('td', { class: 'wrap' }, e.describe), + h('td', {}, e.active ? h('span', { class: 'status' }, h('span', { class: 'dot good' }), 'aktiv') : h('span', { class: 'muted' }, 'inaktiv')), + h('td', { class: 'wrap' }, e.note), + h('td', {}, h('button', { class: 'btn small danger', type: 'button', onclick: () => act(() => api('DELETE', '/schedule/' + e.id), 'Eintrag entfernt.') }, 'Entfernen'))))))) + : h('p', { class: 'empty' }, 'Der Zeitplan ist leer.'))); +} + +const mm = (m) => String(Math.floor(m / 60)).padStart(2, '0') + ':' + String(m % 60).padStart(2, '0'); + +/** Datum und Minuten seit Tagesbeginn als Wert für ein datetime-local-Feld */ +function localValue(day, minutes) { + const d = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, minutes); + const p = (n) => String(n).padStart(2, '0'); + return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate()) + 'T' + p(d.getHours()) + ':' + p(d.getMinutes()); +} + +/** Formular für einen Zeitplaneintrag; `preset` ist der im Kalender markierte Zeitraum */ +function scheduleForm(models, groups, preset, close) { + const error = h('div', { class: 'notice error', role: 'alert', hidden: true }); + const fail = (text) => { error.textContent = text; error.hidden = false; }; const subject = h('div', { class: 'stack small' }); const repeat = h('select', { id: 's-repeat', name: 'repeat', class: 'field', onchange: () => showTime() }, h('option', { value: 'once' }, 'einmalig'), h('option', { value: 'weekly' }, 'wöchentlich'), h('option', { value: 'permanent' }, 'dauerhaft')); - const days = dayToggles('s-days'); + const weekday = preset ? WEEKDAYS[(preset.day.getDay() + 6) % 7][0] : null; + const days = dayToggles('s-days', weekday ? [weekday] : []); const once = h('div', { class: 'fields' }, - h('div', { class: 'field-group' }, h('label', { for: 's-from' }, 'Beginn'), h('input', { id: 's-from', name: 'from', type: 'datetime-local', class: 'field mono' })), - h('div', { class: 'field-group' }, h('label', { for: 's-until' }, 'Ende'), h('input', { id: 's-until', name: 'until', type: 'datetime-local', class: 'field mono' }))); + h('div', { class: 'field-group' }, h('label', { for: 's-from' }, 'Beginn'), + h('input', { id: 's-from', name: 'from', type: 'datetime-local', class: 'field mono', value: preset ? localValue(preset.day, preset.start) : '' })), + h('div', { class: 'field-group' }, h('label', { for: 's-until' }, 'Ende'), + h('input', { id: 's-until', name: 'until', type: 'datetime-local', class: 'field mono', value: preset ? localValue(preset.day, preset.end) : '' }))); const weekly = h('div', { class: 'stack small' }, days, h('div', { class: 'fields' }, - h('div', { class: 'field-group' }, h('label', { for: 's-time-start' }, 'von'), h('input', { id: 's-time-start', name: 'time_start', type: 'time', class: 'field mono' })), - h('div', { class: 'field-group' }, h('label', { for: 's-time-end' }, 'bis'), h('input', { id: 's-time-end', name: 'time_end', type: 'time', class: 'field mono' })), + h('div', { class: 'field-group' }, h('label', { for: 's-time-start' }, 'von'), + h('input', { id: 's-time-start', name: 'time_start', type: 'time', class: 'field mono', value: preset ? mm(preset.start) : '' })), + h('div', { class: 'field-group' }, h('label', { for: 's-time-end' }, 'bis'), + h('input', { id: 's-time-end', name: 'time_end', type: 'time', class: 'field mono', value: preset ? mm(preset.end % (24 * 60)) : '' })), h('div', { class: 'field-group' }, h('label', { for: 's-valid-from' }, 'erstmals am'), h('input', { id: 's-valid-from', name: 'valid_from', type: 'date', class: 'field mono' })), - h('div', { class: 'field-group' }, h('label', { for: 's-valid-until' }, 'letztmals am'), h('input', { id: 's-valid-until', name: 'valid_until', type: 'date', class: 'field mono' })))); + h('div', { class: 'field-group' }, h('label', { for: 's-valid-until' }, 'letztmals am'), h('input', { id: 's-valid-until', name: 'valid_until', type: 'date', class: 'field mono' }))), + h('span', { class: 'hint' }, 'Ohne Uhrzeit ganztags.')); function showTime() { once.hidden = repeat.value !== 'once'; weekly.hidden = repeat.value !== 'weekly'; @@ -1043,59 +1165,89 @@ async function schedulePage() { h('div', { class: 'field-group' }, h('label', { for: 's-users' }, 'Personen (Benutzernamen)'), h('input', { id: 's-users', name: 'users', class: 'field mono', placeholder: 'hofmannol, mueller' }))); if (kind === 'window') subject.replaceChildren(h('span', { class: 'label' }, 'Nur diese Modelle'), modelPicker(models, 's-model', true)); } - kindBox.append(segmented('s-kind', [['pin', 'Pinnen'], ['exclusive', 'Exklusiv'], ['window', 'Zeitfenster']], 'pin', (v) => { kind = v; showSubject(); })); showSubject(); showTime(); const form = h('form', { - class: 'card cal-form', - onsubmit: (ev) => { + class: 'stack small', + onsubmit: async (ev) => { ev.preventDefault(); + error.hidden = true; const d = formData(form); const body = { kind, note: d.note }; if (kind === 'pin') { const m = checkedValues(form, 's-model')[0]; - if (!m) { state.flash = { kind: 'error', text: 'Ein Modell auswählen.' }; return render(); } + if (!m) return fail('Ein Modell auswählen.'); body.model = m; const nodes = (models.find((x) => x.id === m) || { nodes: [] }).nodes; - if (nodes.length > 1) body.node = d.node || nodes[0]; + if (nodes.length > 1) body.node = nodes[0]; } if (kind === 'exclusive') Object.assign(body, { groups: checkedValues(form, 's-group'), users: list(d.users) }); - if (kind === 'window') body.models = checkedValues(form, 's-model'); - if (d.repeat === 'once') Object.assign(body, { from: apiTime(d.from), until: apiTime(d.until) }); - if (d.repeat === 'weekly') Object.assign(body, { weekly: days.value(), time: d.time_start + '-' + d.time_end, from: optional(d.valid_from), until: dayAfter(d.valid_until) }); - act(() => api('POST', '/schedule', body), (e2) => 'Eintrag angelegt: ' + e2.subject + ', ' + e2.describe); + if (kind === 'window') { + body.models = checkedValues(form, 's-model'); + if (!body.models.length) return fail('Mindestens ein Modell auswählen.'); + } + if (d.repeat === 'once') { + if (!d.from || !d.until) return fail('Beginn und Ende angeben.'); + Object.assign(body, { from: apiTime(d.from), until: apiTime(d.until) }); + } + if (d.repeat === 'weekly') { + if (!days.value()) return fail('Mindestens einen Wochentag auswählen.'); + if (!d.time_start !== !d.time_end) return fail('Für die Uhrzeit Beginn und Ende angeben.'); + Object.assign(body, { weekly: days.value(), time: d.time_start ? d.time_start + '-' + d.time_end : undefined, from: optional(d.valid_from), until: dayAfter(d.valid_until) }); + } + // Fehler bleiben im Overlay, damit die Eingaben erhalten bleiben + try { + const created = await api('POST', '/schedule', body); + close(); + state.flash = { kind: 'ok', text: 'Eintrag angelegt: ' + created.subject + ', ' + created.describe }; + render(); + } catch (e) { + fail(e.message); + } }, }, - h('h2', {}, 'Eintrag anlegen'), - h('div', { class: 'field-group' }, h('span', { class: 'label' }, 'Art des Eintrags'), kindBox), + h('div', { class: 'field-group' }, h('span', { class: 'label' }, 'Art des Eintrags'), + segmented('s-kind', [['pin', 'Pinnen'], ['exclusive', 'Exklusiv'], ['window', 'Zeitfenster']], 'pin', (v) => { kind = v; showSubject(); })), subject, h('div', { class: 'field-group' }, h('label', { for: 's-repeat' }, 'Wiederholung'), repeat), once, weekly, h('div', { class: 'field-group' }, h('label', { for: 's-note' }, 'Anmerkung'), h('input', { id: 's-note', name: 'note', class: 'field', placeholder: 'z. B. Vorlesung KI' })), h('span', { class: 'hint' }, 'Der Proxy lehnt Einträge ab, die nicht in den Speicher passen oder sich widersprechen, und nennt den Grund.'), - h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Speichern'))); + error, + h('div', { class: 'actions' }, + h('button', { class: 'btn', type: 'button', onclick: close }, 'Abbrechen'), + h('button', { class: 'btn primary', type: 'submit' }, 'Speichern'))); + return form; +} - return h('div', { class: 'stack' }, - head('Administration', 'Zeitplan', 'Pins, exklusive Nutzung und Modellzeitfenster in einem gemeinsamen Plan.', - h('button', { class: 'btn icon', type: 'button', 'aria-label': 'Vorige Woche', onclick: () => shiftWeek(-1) }, '‹'), - h('span', { class: 'mono' }, label), - h('button', { class: 'btn icon', type: 'button', 'aria-label': 'Nächste Woche', onclick: () => shiftWeek(1) }, '›'), - h('button', { class: 'btn', type: 'button', onclick: () => shiftWeek(0) }, 'Heute')), - h('div', { class: 'toolbar' }, - h('span', { class: 'muted' }, 'Dauerhaft'), - permanent.length ? permanent.map((e) => h('span', { class: 'chip ' + (e.kind.kind === 'pin' ? 'accent' : '') + ' mono' }, KIND_LABEL[e.kind.kind] + ' · ' + e.subject)) : h('span', { class: 'muted' }, '–'), - h('span', { class: 'legend' }, ['pin', 'exclusive', 'window'].map((k) => h('span', {}, h('span', { class: 'swatch ev-' + k }), KIND_LABEL[k])))), - h('div', { class: 'row top' }, h('section', { class: 'card cal-card' }, grid), form), - h('section', { class: 'card' }, h('h2', {}, 'Alle Einträge'), - entries.length ? h('div', { class: 'table-wrap' }, h('table', {}, - h('thead', {}, h('tr', {}, h('th', {}, 'Art'), h('th', {}, 'Was'), h('th', {}, 'Wann'), h('th', {}, 'Stand'), h('th', {}, 'Anmerkung'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))), - h('tbody', {}, entries.map((e) => h('tr', {}, - h('td', {}, h('span', { class: 'chip' + (e.kind.kind === 'pin' ? ' accent' : '') }, KIND_LABEL[e.kind.kind] || e.kind.kind)), - h('td', { class: 'mono wrap' }, e.subject), h('td', { class: 'wrap' }, e.describe), - h('td', {}, e.active ? h('span', { class: 'status' }, h('span', { class: 'dot good' }), 'aktiv') : h('span', { class: 'muted' }, 'inaktiv')), - h('td', { class: 'wrap' }, e.note), - h('td', {}, h('button', { class: 'btn small danger', type: 'button', onclick: () => act(() => api('DELETE', '/schedule/' + e.id), 'Eintrag entfernt.') }, 'Entfernen'))))))) - : h('p', { class: 'empty' }, 'Der Zeitplan ist leer.'))); +/** Overlay über der Seite; schließt mit Escape, Klick daneben oder close() */ +function openOverlay(title, content) { + closeOverlays(); + const previous = document.activeElement; + const titleId = 'overlay-title'; + const backdrop = h('div', { class: 'overlay' }); + const close = () => { + backdrop.remove(); + document.removeEventListener('keydown', onKey); + if (previous && previous.focus) previous.focus(); + }; + const onKey = (e) => { if (e.key === 'Escape') close(); }; + const dialog = h('div', { class: 'dialog card', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': titleId }, + h('div', { class: 'card-head' }, h('h2', { id: titleId }, title), + h('button', { class: 'btn icon', type: 'button', 'aria-label': 'Schließen', onclick: close }, '×')), + content(close)); + backdrop.append(dialog); + backdrop.addEventListener('pointerdown', (e) => { if (e.target === backdrop) close(); }); + document.addEventListener('keydown', onKey); + backdrop.close = close; + document.body.append(backdrop); + const first = dialog.querySelector('input:not([type=hidden]), select, textarea, button:not(.icon)'); + if (first) first.focus(); + return close; +} + +function closeOverlays() { + for (const o of document.querySelectorAll('.overlay')) o.close(); } // ---------- Benutzer ---------- diff --git a/tests/multispark/demo.sh b/tests/multispark/demo.sh index 7ea90b2..5e44b98 100755 --- a/tests/multispark/demo.sh +++ b/tests/multispark/demo.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Testbenutzer und etwas Beispielnutzung für die Oberfläche (nach start.sh). +# Testbenutzer und etwas Beispielnutzung für die Oberfläche (nach start.sh --demo). # admin (Administrator, aus first_admin), dozent (Lecturer), student (User); Passwort jeweils 1234. set -e cd "$(dirname "$0")" diff --git a/tests/multispark/start.sh b/tests/multispark/start.sh index 2a89dc5..cc04595 100755 --- a/tests/multispark/start.sh +++ b/tests/multispark/start.sh @@ -1,11 +1,17 @@ #!/bin/bash # Startet drei simulierte Sparks (je eine Ollama-Instanz, dazu llama-server und Agenten) und den Proxy. # Voraussetzung: ollama und llama-server installiert, Modelle smollm2:135m und qwen3:0.6b in Ollama. +# Mit --demo gelten für Aufzeichnungen realistische Fristen statt der kurzen für die Tests. set -e cd "$(dirname "$0")" B=../../target/debug mkdir -p run/logs1 run/logs2 run/gguf rm -f run/test.db* run/pids +CONFIG=proxy.toml +if [ "$1" = "--demo" ]; then + sed -e 's/^max_duration_secs = .*/max_duration_secs = 86400/' -e 's/^ready_secs = .*/ready_secs = 3600/' proxy.toml > run/demo.toml + CONFIG=run/demo.toml +fi # llama-server bekommt dieselben GGUF-Dateien wie Ollama python3 -I - < run/key.txt -$B/omega-proxy -c proxy.toml serve > run/proxy.log 2>&1 & +$B/omega-proxy -c $CONFIG serve > run/proxy.log 2>&1 & echo "proxy $!" >> run/pids sleep 2 echo "gestartet: $(tr '\n' ' ' < run/pids)" diff --git a/tests/ui/render_test.js b/tests/ui/render_test.js index 67dfbe7..20ad445 100644 --- a/tests/ui/render_test.js +++ b/tests/ui/render_test.js @@ -201,6 +201,21 @@ async function flows(fail) { expect(row && row.textContent.includes('zeichnet auf: noch 2 von 2'), 'Stand fehlt: ' + (row && row.textContent)); }); + await step('student widerruft einen Key, der dann ausgeblendet ist', async () => { + const { w } = browser(student, '#/keys'); + await settle(w); + set(w, '#key-name', 'weg-' + tag); + await submit(w, '#key-name'); + w.confirm = () => true; + await click(w, 'Widerrufen', 'weg-' + tag); + const hide = $(w, '#hide-revoked'); + const visible = () => [...w.document.querySelectorAll('tr')].some((tr) => tr.textContent.includes('weg-' + tag)); + expect(hide && hide.checked && !visible(), 'widerrufener Key nicht ausgeblendet'); + hide.checked = false; + hide.dispatchEvent(new w.Event('change')); + expect(visible(), 'widerrufener Key lässt sich nicht einblenden'); + }); + const dozent = await login('dozent'); await step('dozent legt eine Gruppe an, nimmt student auf und teilt ein Kontingent zu', async () => { const { w } = browser(dozent, '#/groups'); @@ -221,6 +236,15 @@ async function flows(fail) { await step('admin legt im Kalender ein Modellzeitfenster an und entfernt es', async () => { const { w } = browser(admin, '#/schedule'); await settle(w); + // Heute von 10 bis 12 Uhr aufziehen (22 px je Stunde) + const col = w.document.querySelectorAll('.cal-col')[(new Date().getDay() + 6) % 7]; + const pointer = (type, hour) => col.dispatchEvent(new w.MouseEvent(type, { bubbles: true, cancelable: true, button: 0, clientY: hour * 22 })); + pointer('pointerdown', 10.2); + pointer('pointermove', 11.9); + pointer('pointerup', 11.9); + expect(w.document.querySelector('.overlay [role=dialog]'), 'Overlay öffnet sich nicht'); + expect($(w, '#s-from').value.endsWith('T10:00') && $(w, '#s-until').value.endsWith('T12:00'), + 'Zeitraum nicht übernommen: ' + $(w, '#s-from').value + ' – ' + $(w, '#s-until').value); check(w, 'input[name="s-kind"][value="window"]'); check(w, 'input[name="s-model"][value="ollama/smollm2:135m"]'); const now = new Date(); @@ -228,9 +252,15 @@ async function flows(fail) { set(w, '#s-until', local(new Date(now.getTime() + 2 * 3600000))); set(w, '#s-note', 'flow-' + tag); await submit(w, '#s-note'); + expect(!w.document.querySelector('.overlay'), 'Overlay bleibt offen: ' + (w.document.querySelector('.overlay .notice') || {}).textContent); expect([...w.document.querySelectorAll('tbody tr')].some((tr) => tr.textContent.includes('flow-' + tag)), 'Eintrag fehlt: ' + summary(w).errorsOnPage.join()); - expect([...w.document.querySelectorAll('.cal .ev.window')].some((e) => e.textContent.includes('flow-' + tag)), 'Eintrag fehlt im Kalender'); - await click(w, 'Entfernen', 'flow-' + tag); + const ev = [...w.document.querySelectorAll('.cal .ev.window')].find((e) => e.textContent.includes('flow-' + tag)); + expect(ev, 'Eintrag fehlt im Kalender'); + ev.click(); + const remove = [...w.document.querySelectorAll('.overlay button')].find((b) => b.textContent === 'Entfernen'); + expect(remove, 'Overlay mit Details fehlt'); + remove.click(); + await settle(w); expect(![...w.document.querySelectorAll('tbody tr')].some((tr) => tr.textContent.includes('flow-' + tag)), 'Eintrag noch da'); }); await step('dozent teilt ein gemeinsames Kontingent mit Modellen, Wochentagen und Gültigkeit zu', async () => { @@ -241,7 +271,8 @@ async function flows(fail) { check(w, 'input[name="q-shared"][value="shared"]'); check(w, 'input[name="q-models"][value="some"]'); check(w, 'input[name="q-model"][value="ollama/smollm2:135m"]'); - for (const d of ['mo', 'mi']) w.document.querySelector('#q-days [data-day="' + d + '"]').click(); + expect(w.document.querySelectorAll('#q-days [aria-pressed=true]').length === 7, 'nicht alle Tage vorausgewählt'); + for (const d of ['di', 'do', 'fr', 'sa', 'so']) w.document.querySelector('#q-days [data-day="' + d + '"]').click(); set(w, '#q-time-start', '08:00'); set(w, '#q-time-end', '18:00'); set(w, '#q-valid-until', '2027-02-15');