Oberfläche nach Durchsicht: Kalender, Suchen, eigene Verwaltungsseiten, gemeinsame Gruppenkontingente
- Übersicht mit Anfragen diesen Monat; Aufzeichnungen mit Key-Name und Präfix - Ollama-API zusätzlich unter /ollama; Endpunkte in der Oberfläche einheitlich - Gruppen & Kontingente nur eigene; Alle Gruppen & Kontingente und Alle Keys für Administratoren, Keys meiner Kontingente für Lecturer, jeweils mit Suche - Kontingentformular: Modelle alle oder ausgewählte (nach Schnittstelle, aus GET /omega/api/models), Wochentage zum Anklicken, Uhrzeit- und Datumsfelder, je Person oder für die Gruppe gemeinsam (Spalte quotas.shared) - Auswahl beim Key-Anlegen zeigt, von wem ein Kontingent kommt - Zeitplan als Wochenkalender wie in den Mockups - Benutzer mit Suche und Ausblenden gesperrter Konten - Audit-Log mit deutschen Bezeichnungen, verständlichen Details und Suche - Gültigkeit um Mitternacht als "bis einschließlich"; start.sh wartet auf die Engines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d753fd9285
commit
11dbc1c781
18 files changed
+805
-164
No files matched your search
@@ -203,3 +203,41 @@ pre.settings { margin: 8px 0 0; background: var(--sunken); border: 1px solid var
|
||||
.main { padding: 20px 16px 40px; }
|
||||
.login-public { padding: 32px 16px; }
|
||||
}
|
||||
|
||||
/* Umschalter, Wochentage, Modellauswahl, Werkzeugleiste */
|
||||
.label { font-size: 13px; color: var(--text-3); }
|
||||
.stack.small { gap: 10px; }
|
||||
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line-3); border-radius: 7px; background: var(--sunken); }
|
||||
.seg { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 10px; border-radius: 5px; font-size: 13px; color: var(--text-2); cursor: pointer; text-align: center; }
|
||||
.seg:hover { color: var(--text); }
|
||||
.seg.on { background: var(--accent-bg); color: var(--accent-text); }
|
||||
.seg input { position: absolute; opacity: 0; pointer-events: none; }
|
||||
.seg:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
|
||||
.days { display: flex; flex-wrap: wrap; gap: 6px; }
|
||||
.day { font: 500 13px var(--sans); min-width: 44px; min-height: 36px; border-radius: 6px; border: 1px solid var(--line-3); background: var(--raised); color: var(--text-2); cursor: pointer; }
|
||||
.day:hover { background: var(--hover); }
|
||||
.day[aria-pressed="true"] { background: var(--accent-bg); border-color: #8a5a32; color: var(--accent-text); }
|
||||
.model-picker { display: flex; flex-direction: column; gap: 10px; }
|
||||
.model-picker fieldset { gap: 6px; }
|
||||
.model-picker .check { gap: 10px; min-height: 28px; }
|
||||
.model-picker .hint { margin-left: auto; }
|
||||
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
|
||||
.toolbar input[type=search] { flex: 1 1 260px; max-width: 420px; }
|
||||
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 { 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); }
|
||||
.cal-day.today { color: var(--accent); font-weight: 600; }
|
||||
.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 .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; }
|
||||
+438
-102
@@ -139,6 +139,65 @@ const list = (v) => (v ? v.split(/[\s,;]+/).filter(Boolean) : []);
|
||||
|
||||
// ---------- Navigation ----------
|
||||
|
||||
const WEEKDAYS = [['mo', 'Mo', 'Mon'], ['di', 'Di', 'Tue'], ['mi', 'Mi', 'Wed'], ['do', 'Do', 'Thu'], ['fr', 'Fr', 'Fri'], ['sa', 'Sa', 'Sat'], ['so', 'So', 'Sun']];
|
||||
|
||||
/** Umschalter wie in den Mockups: eine Auswahl aus wenigen Möglichkeiten */
|
||||
function segmented(name, options, value, onchange) {
|
||||
const wrap = h('div', { class: 'segmented', role: 'radiogroup' });
|
||||
for (const [v, label] of options) {
|
||||
const input = h('input', { type: 'radio', name, value: v, checked: v === value, onchange: () => { update(); if (onchange) onchange(v); } });
|
||||
wrap.append(h('label', { class: 'seg' }, input, label));
|
||||
}
|
||||
function update() { for (const l of wrap.children) l.classList.toggle('on', l.firstChild.checked); }
|
||||
update();
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** Wochentage zum Anklicken; liefert die Auswahl als "mo,mi" */
|
||||
function dayToggles(id) {
|
||||
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,
|
||||
onclick: () => b.setAttribute('aria-pressed', b.getAttribute('aria-pressed') === 'true' ? 'false' : 'true') }, label);
|
||||
wrap.append(b);
|
||||
}
|
||||
wrap.value = () => [...wrap.querySelectorAll('[aria-pressed=true]')].map((b) => b.dataset.day).join(',');
|
||||
return wrap;
|
||||
}
|
||||
|
||||
/** Modellauswahl, gruppiert nach Schnittstelle; `multiple` für Kontingente und Zeitfenster */
|
||||
function modelPicker(models, name, multiple) {
|
||||
const wrap = h('div', { class: 'model-picker' });
|
||||
for (const engine of ['ollama', 'llamacpp', 'vllm']) {
|
||||
const of = models.filter((m) => m.engine === engine);
|
||||
if (!of.length) continue;
|
||||
wrap.append(h('fieldset', {}, h('legend', {}, h('span', { class: 'chip ' + engine }, ENGINE[engine]), ' ', h('span', { class: 'mono muted' }, endpointPath(engine))),
|
||||
of.map((m) => h('label', { class: 'check' },
|
||||
h('input', { type: multiple ? 'checkbox' : 'radio', name, value: m.id }),
|
||||
h('span', { class: 'mono' }, m.model), h('span', { class: 'hint' }, m.nodes.join(', '))))));
|
||||
}
|
||||
if (!wrap.children.length) wrap.append(h('p', { class: 'empty' }, 'Keine Modelle verfügbar.'));
|
||||
return wrap;
|
||||
}
|
||||
|
||||
function endpointPath(engine) {
|
||||
return { ollama: '/ollama', llamacpp: '/llamacpp/v1', vllm: '/vllm/v1' }[engine];
|
||||
}
|
||||
|
||||
function checkedValues(root, name) {
|
||||
return [...root.querySelectorAll('input[name="' + name + '"]:checked')].map((i) => i.value);
|
||||
}
|
||||
|
||||
/** "2026-11-24T08:00" aus einem Datums-/Zeitfeld → "2026-11-24 08:00" für die API */
|
||||
const apiTime = (v) => (v ? v.replace('T', ' ') : undefined);
|
||||
/** Ein Enddatum gilt einschließlich: die API bekommt den Beginn des Folgetags. */
|
||||
function dayAfter(date) {
|
||||
if (!date) return undefined;
|
||||
const [y, m, d] = date.split('-').map(Number);
|
||||
const next = new Date(y, m - 1, d + 1);
|
||||
return next.getFullYear() + '-' + String(next.getMonth() + 1).padStart(2, '0') + '-' + String(next.getDate()).padStart(2, '0');
|
||||
}
|
||||
|
||||
function route() {
|
||||
const hash = location.hash.replace(/^#\/?/, '');
|
||||
const [page, ...rest] = hash.split('/');
|
||||
@@ -152,11 +211,14 @@ const PAGES = {
|
||||
keys: { title: 'API-Keys', icon: 'keys', render: keysPage, section: 'Persönlich' },
|
||||
account: { title: 'Konto & Sicherheit', icon: 'account', render: accountPage, section: 'Persönlich' },
|
||||
groups: { title: 'Gruppen & Kontingente', icon: 'groups', render: groupsPage, section: 'Lehre', role: 'lecturer' },
|
||||
groupkeys: { title: 'Keys meiner Kontingente', icon: 'keys', render: () => keysAdminPage('lecturer'), section: 'Lehre', role: 'lecturer' },
|
||||
group: { render: groupPage, parent: 'groups', role: 'lecturer' },
|
||||
quota: { render: quotaPage, parent: 'groups' },
|
||||
status: { title: 'Sparks & Modelle', icon: 'status', render: statusPage, section: 'Administration', role: 'admin' },
|
||||
schedule: { title: 'Zeitplan', icon: 'schedule', render: schedulePage, section: 'Administration', role: 'admin' },
|
||||
users: { title: 'Benutzer', icon: 'users', render: usersPage, section: 'Administration', role: 'admin' },
|
||||
allkeys: { title: 'Alle Keys', icon: 'keys', render: () => keysAdminPage('admin'), section: 'Administration', role: 'admin' },
|
||||
allgroups: { title: 'Alle Gruppen & Kontingente', icon: 'groups', render: allGroupsPage, section: 'Administration', role: 'admin' },
|
||||
audit: { title: 'Audit-Log', icon: 'audit', render: auditPage, section: 'Administration', role: 'admin' },
|
||||
public: { title: 'Öffentliches Dashboard', icon: 'public', render: publicPage, section: 'Administration', open: true },
|
||||
};
|
||||
@@ -344,6 +406,12 @@ function quotaMeters(q, usage) {
|
||||
return rows;
|
||||
}
|
||||
|
||||
function personLabel(p) {
|
||||
if (p.group_total) return 'Gruppe gesamt';
|
||||
if (p.user) return p.user;
|
||||
return p.usage ? '(ohne Inhaber)' : 'noch keine Nutzung';
|
||||
}
|
||||
|
||||
function keyState(k) {
|
||||
if (k.revoked) return h('span', { class: 'muted' }, 'widerrufen');
|
||||
if (k.recording) return h('span', { class: 'status' }, h('span', { class: 'dot accent' }), k.recording);
|
||||
@@ -368,21 +436,26 @@ async function overview() {
|
||||
h('div', { class: 'kpi' }, h('span', {}, 'Token heute'), h('span', { class: 'value' }, tokens(sum((u) => tok(u.day))))),
|
||||
h('div', { class: 'kpi' }, h('span', {}, 'Anfragen heute'), h('span', { class: 'value' }, num(sum((u) => u.day.requests)))),
|
||||
h('div', { class: 'kpi' }, h('span', {}, 'Token diesen Monat'), h('span', { class: 'value' }, tokens(sum((u) => tok(u.month))))),
|
||||
h('div', { class: 'kpi' }, h('span', {}, 'Anfragen diesen Monat'), h('span', { class: 'value' }, num(sum((u) => u.month.requests)))),
|
||||
h('div', { class: 'kpi' }, h('span', {}, 'Aktive Keys'), h('span', { class: 'value' }, num(active.length)))),
|
||||
];
|
||||
const quotaCard = h('section', { class: 'card grow' }, h('h2', {}, 'Kontingente'),
|
||||
me.quotas.length ? me.quotas.map((q) => h('div', { class: 'meter' },
|
||||
h('b', {}, q.name), h('span', { class: 'hint' }, q.describe), quotaMeters(q, q.usage[0].usage)))
|
||||
h('b', {}, q.name), h('span', { class: 'hint' }, q.describe + (q.owner ? ' · von ' + q.owner : '')),
|
||||
q.shared ? h('span', { class: 'hint' }, 'Gemeinsam für die ganze Gruppe:') : null,
|
||||
quotaMeters(q, q.usage[0].usage)))
|
||||
: h('p', { class: 'empty' }, atLeast('lecturer') ? 'Dir ist kein Kontingent zugeteilt; als ' + ROLE[role()] + ' kannst du unbegrenzte Keys anlegen.'
|
||||
: 'Dir ist noch kein Kontingent zugeteilt. Sobald dich eine Lehrkraft in eine Gruppe aufnimmt, kannst du Keys anlegen.'));
|
||||
parts.push(h('div', { class: 'row top' }, keysTableCard(me.keys, true), quotaCard));
|
||||
// Nur die eigenen Kontingente; die anderer stehen für Administratoren auf einer eigenen Seite.
|
||||
const ownQuotas = me.managed ? me.managed.quotas.filter((q) => q.owner_id === me.user.id) : [];
|
||||
if (me.managed) {
|
||||
parts.push(h('section', { class: 'card' },
|
||||
h('div', { class: 'card-head' }, h('h2', {}, 'Meine Kontingente'), h('a', { href: '#/groups' }, 'Gruppen & Kontingente')),
|
||||
me.managed.quotas.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
ownQuotas.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Kontingent'), h('th', {}, 'Zugeteilt'), h('th', {}, 'Person'), h('th', { class: 'num' }, 'Token heute'), h('th', { class: 'num' }, 'Anfragen heute'), h('th', { class: 'num' }, 'Token gesamt'))),
|
||||
h('tbody', {}, me.managed.quotas.flatMap((q) => (q.usage.length ? q.usage : [{ user: null, usage: null }]).map((p) => h('tr', {},
|
||||
h('td', {}, h('a', { href: '#/quota/' + q.id }, q.name)), h('td', {}, q.target || '–'), h('td', { class: 'mono' }, p.user || (p.usage ? '(ohne Inhaber)' : 'noch keine Nutzung')),
|
||||
h('tbody', {}, ownQuotas.flatMap((q) => (q.usage.length ? q.usage : [{ user: null, usage: null }]).map((p) => h('tr', {},
|
||||
h('td', {}, h('a', { href: '#/quota/' + q.id }, q.name)), h('td', {}, q.target || '–'), h('td', { class: 'mono' }, personLabel(p)),
|
||||
h('td', { class: 'num' }, p.usage ? tokens(tok(p.usage.day)) : '–'), h('td', { class: 'num' }, p.usage ? num(p.usage.day.requests) : '–'),
|
||||
h('td', { class: 'num' }, p.usage ? tokens(tok(p.usage.total)) : '–')))))))
|
||||
: h('p', { class: 'empty' }, 'Noch keine Kontingente. Lege unter Gruppen & Kontingente eine Gruppe und ein Kontingent an.')));
|
||||
@@ -419,7 +492,7 @@ async function keysPage() {
|
||||
const [keys, quotas, recordings] = await Promise.all([api('GET', '/keys'), api('GET', '/quotas'), api('GET', '/recordings')]);
|
||||
const me = state.me.user;
|
||||
const own = keys.filter((k) => k.user_id === me.id);
|
||||
const others = keys.filter((k) => k.user_id !== me.id);
|
||||
// Nutzbar sind Kontingente, die einem zugeteilt sind oder die man selbst verwaltet.
|
||||
const usable = quotas;
|
||||
const created = state.createdKey;
|
||||
state.createdKey = null;
|
||||
@@ -439,7 +512,7 @@ async function keysPage() {
|
||||
h('input', { id: 'key-name', name: 'name', class: 'field mono', required: true, placeholder: 'z. B. laptop' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'key-kind' }, 'Abgerechnet gegen'),
|
||||
h('select', { id: 'key-kind', name: 'kind', class: 'field' },
|
||||
usable.map((q) => h('option', { value: q.id }, q.name + (q.target ? ' · ' + q.target : ''))),
|
||||
usable.map((q) => h('option', { value: q.id }, [q.name, q.target, q.owner && q.owner !== me.username ? 'von ' + q.owner : null].filter(Boolean).join(' · '))),
|
||||
atLeast('lecturer') ? h('option', { value: 'none' }, 'Unbegrenzt (ohne Kontingent)') : null,
|
||||
atLeast('admin') ? h('option', { value: 'super' }, 'Super-Key (ohne alle Einschränkungen)') : null))),
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit', disabled: !usable.length && !atLeast('lecturer') }, 'Key erstellen')));
|
||||
@@ -455,8 +528,7 @@ async function keysPage() {
|
||||
parts.push(h('section', { class: 'card' }, h('h2', {}, 'Neuer Key'),
|
||||
!usable.length && !atLeast('lecturer') ? h('p', { class: 'empty' }, 'Dir ist noch kein Kontingent zugeteilt.') : form));
|
||||
parts.push(keysManageCard('Meine Keys', own, true));
|
||||
if (others.length) parts.push(keysManageCard(atLeast('admin') ? 'Keys anderer Personen' : 'Keys gegen meine Kontingente', others, false));
|
||||
parts.push(recordingsCard(recordings));
|
||||
parts.push(recordingsCard(recordings, own));
|
||||
parts.push(endpointsCard());
|
||||
return h('div', { class: 'stack' }, parts);
|
||||
}
|
||||
@@ -478,6 +550,43 @@ function keysManageCard(title, keys, own) {
|
||||
: h('p', { class: 'empty' }, 'Keine Keys.'));
|
||||
}
|
||||
|
||||
/** Keys anderer Personen mit Suche: für Lecturer die gegen ihre Kontingente, für Administratoren alle */
|
||||
async function keysAdminPage(mode) {
|
||||
const [keys, quotas] = await Promise.all([api('GET', '/keys'), api('GET', '/quotas')]);
|
||||
const me = state.me.user;
|
||||
const ownQuotaIds = new Set(quotas.filter((q) => q.owner_id === me.id).map((q) => q.id));
|
||||
const list = keys.filter((k) => k.user_id !== me.id && (mode === 'admin' || (k.quota && ownQuotaIds.has(k.quota.id))));
|
||||
const search = h('input', { type: 'search', class: 'field', placeholder: 'Name, Inhaber, Präfix oder Kontingent', 'aria-label': 'Keys durchsuchen', value: state.keySearch || '' });
|
||||
const showRevoked = h('input', { type: 'checkbox', id: 'show-revoked', checked: state.keyShowRevoked });
|
||||
const body = h('tbody', {});
|
||||
const count = h('span', { class: 'muted' });
|
||||
function update() {
|
||||
state.keySearch = search.value;
|
||||
state.keyShowRevoked = showRevoked.checked;
|
||||
const q = search.value.trim().toLowerCase();
|
||||
const shown = list.filter((k) => (showRevoked.checked || !k.revoked)
|
||||
&& (!q || [k.name, k.owner, k.prefix, k.quota && k.quota.name].some((v) => v && v.toLowerCase().includes(q))));
|
||||
body.replaceChildren(...shown.map((k) => h('tr', { class: k.revoked ? 'dim' : null },
|
||||
h('td', { class: 'mono' }, k.name), 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', {}, keyState(k)),
|
||||
h('td', {}, k.revoked ? null : h('div', { class: 'actions' }, h('button', { class: 'btn small danger', type: 'button', onclick: () => revokeKey(k) }, 'Widerrufen'))))));
|
||||
count.textContent = shown.length + ' von ' + list.length + ' Keys';
|
||||
}
|
||||
search.addEventListener('input', update);
|
||||
showRevoked.addEventListener('change', update);
|
||||
update();
|
||||
const admin = mode === 'admin';
|
||||
return h('div', { class: 'stack' },
|
||||
head(admin ? 'Administration' : 'Lehre', admin ? 'Alle Keys' : 'Keys meiner Kontingente',
|
||||
admin ? 'Keys aller Users und Lecturer, etwa um einen Key zu widerrufen.' : 'Keys, die gegen deine Kontingente abgerechnet werden.'),
|
||||
h('section', { class: 'card' },
|
||||
h('div', { class: 'toolbar' }, search, h('label', { class: 'check', for: 'show-revoked' }, showRevoked, 'Widerrufene zeigen'), count),
|
||||
h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Name'), h('th', {}, 'Inhaber'), h('th', {}, 'Key'), h('th', {}, 'Kontingent'),
|
||||
h('th', { class: 'num' }, 'Token (Monat)'), h('th', {}, 'Status'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))),
|
||||
body))));
|
||||
}
|
||||
|
||||
function revokeKey(k) {
|
||||
if (!confirm('Key „' + k.name + '“ widerrufen? Anwendungen, die ihn nutzen, werden sofort abgewiesen.')) return;
|
||||
act(() => api('DELETE', '/keys/' + k.id), 'Key „' + k.name + '“ widerrufen.');
|
||||
@@ -489,14 +598,18 @@ function startRecording(k) {
|
||||
act(() => api('POST', '/recordings', { key_id: k.id, count: Number(answer) }), 'Aufzeichnung gestartet.');
|
||||
}
|
||||
|
||||
function recordingsCard(recordings) {
|
||||
function recordingsCard(recordings, keys) {
|
||||
const keyLabel = (id) => {
|
||||
const k = keys.find((x) => x.id === id);
|
||||
return k ? [h('span', { class: 'mono' }, k.name), ' ', h('span', { class: 'mono muted' }, '(' + k.prefix + '…)')] : '#' + id;
|
||||
};
|
||||
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', { class: 'mono' }, '#' + r.key_id), h('td', { class: 'num' }, r.written + ' / ' + r.count),
|
||||
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.'));
|
||||
@@ -504,12 +617,12 @@ function recordingsCard(recordings) {
|
||||
|
||||
function endpointsCard() {
|
||||
const base = location.origin;
|
||||
const rows = [['Ollama', base], ['llama.cpp (OpenAI-kompatibel)', base + '/llamacpp/v1'], ['vLLM (OpenAI-kompatibel)', base + '/vllm/v1']];
|
||||
const rows = [['Ollama', base + '/ollama'], ['llama.cpp (OpenAI-kompatibel)', base + '/llamacpp/v1'], ['vLLM (OpenAI-kompatibel)', base + '/vllm/v1']];
|
||||
return h('section', { class: 'card' }, h('h2', {}, 'Endpunkte'),
|
||||
h('div', { class: 'table-wrap' }, h('table', {}, h('tbody', {}, rows.map(([name, url]) => h('tr', {},
|
||||
h('td', {}, name), h('td', { class: 'mono' }, url),
|
||||
h('td', {}, h('button', { class: 'btn small', type: 'button', onclick: (e) => copy(url, e.currentTarget) }, 'Kopieren'))))))),
|
||||
h('span', { class: 'hint' }, 'Den Key als „Authorization: Bearer …“ mitschicken.'));
|
||||
h('span', { class: 'hint' }, 'Den Key als „Authorization: Bearer …“ mitschicken. Bestehende Ollama-Anwendungen erreichen die Ollama-API auch weiterhin ohne /ollama.'));
|
||||
}
|
||||
|
||||
async function copy(text, button) {
|
||||
@@ -558,9 +671,10 @@ async function accountPage() {
|
||||
// ---------- Gruppen & Kontingente ----------
|
||||
|
||||
async function groupsPage() {
|
||||
const [groups, quotas] = await Promise.all([api('GET', '/groups'), api('GET', '/quotas')]);
|
||||
const [groups, quotas, models] = await Promise.all([api('GET', '/groups'), api('GET', '/quotas'), api('GET', '/models')]);
|
||||
const me = state.me.user;
|
||||
const managed = groups.filter((g) => g.owner_id === me.id || atLeast('admin'));
|
||||
const own = groups.filter((g) => g.owner_id === me.id);
|
||||
const ownQuotas = quotas.filter((q) => q.owner_id === me.id);
|
||||
const groupForm = h('form', {
|
||||
onsubmit: (e) => {
|
||||
e.preventDefault();
|
||||
@@ -572,74 +686,129 @@ async function groupsPage() {
|
||||
h('input', { id: 'group-name', name: 'name', class: 'field mono', required: true, placeholder: 'z. B. ki-praktikum-ws26' }))),
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Gruppe anlegen')));
|
||||
return h('div', { class: 'stack' },
|
||||
head('Lehre', 'Gruppen & Kontingente', 'Gruppen anlegen, Personen aufnehmen und Kontingente zuteilen.'),
|
||||
head('Lehre', 'Gruppen & Kontingente', 'Deine Gruppen und die Kontingente, die du zugeteilt hast.'),
|
||||
h('div', { class: 'row top' },
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Gruppen'),
|
||||
managed.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Gruppe'), h('th', { class: 'num' }, 'Mitglieder'), h('th', {}, 'Verwaltet von'))),
|
||||
h('tbody', {}, managed.map((g) => h('tr', {},
|
||||
h('td', {}, h('a', { class: 'mono', href: '#/group/' + encodeURIComponent(g.name) }, g.name)), h('td', { class: 'num' }, g.members), h('td', { class: 'mono' }, g.owner || '–'))))))
|
||||
: h('p', { class: 'empty' }, 'Noch keine Gruppen.')),
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Meine Gruppen'), groupsTable(own, false)),
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Neue Gruppe'), groupForm)),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Kontingente'), quotasTable(quotas)),
|
||||
quotaForm(managed, null));
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Meine Kontingente'), quotasTable(ownQuotas, false)),
|
||||
quotaForm(own, null, models));
|
||||
}
|
||||
|
||||
function quotasTable(quotas) {
|
||||
function groupsTable(groups, showOwner) {
|
||||
return groups.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Gruppe'), h('th', { class: 'num' }, 'Mitglieder'), showOwner ? h('th', {}, 'Verwaltet von') : null)),
|
||||
h('tbody', {}, groups.map((g) => h('tr', {},
|
||||
h('td', {}, h('a', { class: 'mono', href: '#/group/' + encodeURIComponent(g.name) }, g.name)), h('td', { class: 'num' }, g.members),
|
||||
showOwner ? h('td', { class: 'mono' }, g.owner || '–') : null)))))
|
||||
: h('p', { class: 'empty' }, 'Noch keine Gruppen.');
|
||||
}
|
||||
|
||||
/** Gruppen und Kontingente anderer, etwa wenn eine Lehrkraft krank ist (Administratoren) */
|
||||
async function allGroupsPage() {
|
||||
const [groups, quotas, models] = await Promise.all([api('GET', '/groups'), api('GET', '/quotas'), api('GET', '/models')]);
|
||||
const me = state.me.user;
|
||||
const others = groups.filter((g) => g.owner_id !== me.id);
|
||||
const otherQuotas = quotas.filter((q) => q.owner_id !== me.id);
|
||||
const search = h('input', { type: 'search', class: 'field', placeholder: 'Gruppe oder Lehrkraft', 'aria-label': 'Gruppen durchsuchen' });
|
||||
const tableWrap = h('div', {});
|
||||
function update() {
|
||||
const q = search.value.trim().toLowerCase();
|
||||
tableWrap.replaceChildren(groupsTable(others.filter((g) => !q || g.name.toLowerCase().includes(q) || (g.owner || '').toLowerCase().includes(q)), true));
|
||||
}
|
||||
search.addEventListener('input', update);
|
||||
update();
|
||||
return h('div', { class: 'stack' },
|
||||
head('Administration', 'Alle Gruppen & Kontingente', 'Gruppen und Kontingente anderer verwalten, etwa wenn eine Lehrkraft verhindert ist.'),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Gruppen'), h('div', { class: 'toolbar' }, search), tableWrap),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Kontingente'), quotasTable(otherQuotas, true)),
|
||||
quotaForm(others, null, models));
|
||||
}
|
||||
|
||||
function quotasTable(quotas, showOwner) {
|
||||
return quotas.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Kontingent'), h('th', {}, 'Zugeteilt'), h('th', {}, 'Grenzen'), h('th', { class: 'num' }, 'Keys'))),
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Kontingent'), h('th', {}, 'Zugeteilt'), showOwner ? h('th', {}, 'Von') : null, h('th', {}, 'Grenzen'), h('th', { class: 'num' }, 'Keys'))),
|
||||
h('tbody', {}, quotas.map((q) => h('tr', {},
|
||||
h('td', {}, h('a', { href: '#/quota/' + q.id }, q.name)), h('td', {}, q.target || '–'), h('td', { class: 'wrap' }, q.describe), h('td', { class: 'num' }, q.keys))))))
|
||||
h('td', {}, h('a', { href: '#/quota/' + q.id }, q.name)), h('td', {}, q.target || '–'), showOwner ? h('td', { class: 'mono' }, q.owner || '–') : null,
|
||||
h('td', { class: 'wrap' }, q.describe), h('td', { class: 'num' }, q.keys))))))
|
||||
: h('p', { class: 'empty' }, 'Noch keine Kontingente.');
|
||||
}
|
||||
|
||||
/** Formular für ein neues Kontingent, für eine feste Gruppe oder mit Auswahl */
|
||||
function quotaForm(groups, fixedGroup) {
|
||||
/** 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 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'),
|
||||
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';
|
||||
sharing.hidden = target.value === 'user';
|
||||
} },
|
||||
groups.map((g) => h('option', { value: 'group:' + g.name }, 'Gruppe ' + g.name)),
|
||||
h('option', { value: 'user' }, 'Eine Person …'));
|
||||
if (target && !groups.length) { person.hidden = false; sharing.hidden = true; }
|
||||
const form = h('form', {
|
||||
onsubmit: (e) => {
|
||||
e.preventDefault();
|
||||
const d = formData(form);
|
||||
const restricted = form.querySelector('input[name="q-models"]:checked').value === 'some';
|
||||
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();
|
||||
}
|
||||
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: d.models ? list(d.models) : undefined,
|
||||
from: optional(d.from), until: optional(d.until), weekly: optional(d.weekly), time: optional(d.time), note: d.note,
|
||||
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,
|
||||
};
|
||||
const target = fixedGroup || d.target;
|
||||
if (target.startsWith('group:')) body.group = target.slice(6);
|
||||
else if (target === 'user') body.user = d.username;
|
||||
const t = fixedGroup || d.target;
|
||||
if (t.startsWith('group:')) {
|
||||
body.group = t.slice(6);
|
||||
body.shared = form.querySelector('input[name="q-shared"]:checked').value === 'shared';
|
||||
} else body.user = d.username;
|
||||
act(() => api('POST', '/quotas', body), (q) => 'Kontingent „' + q.name + '“ angelegt: ' + q.describe);
|
||||
},
|
||||
},
|
||||
h('div', { class: 'fields' },
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-name' }, 'Name'), h('input', { id: 'q-name', name: 'name', class: 'field', required: true, placeholder: 'z. B. KI-Praktikum WS 26/27' })),
|
||||
fixedGroup ? null : h('div', { class: 'field-group' }, h('label', { for: 'q-target' }, 'Zugeteilt an'),
|
||||
h('select', { id: 'q-target', name: 'target', class: 'field' },
|
||||
groups.map((g) => h('option', { value: 'group:' + g.name }, 'Gruppe ' + g.name + ' (je Mitglied)')),
|
||||
h('option', { value: 'user' }, 'Eine Person …'))),
|
||||
fixedGroup ? null : h('div', { class: 'field-group' }, h('label', { for: 'q-username' }, 'Benutzername (bei einer Person)'),
|
||||
h('input', { id: 'q-username', name: 'username', class: 'field mono' }))),
|
||||
target ? h('div', { class: 'field-group' }, h('label', { for: 'q-target' }, 'Zugeteilt an'), target) : null,
|
||||
person, sharing),
|
||||
h('fieldset', {}, h('legend', {}, 'Token'), h('div', { class: 'fields' },
|
||||
limit('tokens_hour', 'je Stunde'), limit('tokens_day', 'je Tag'), limit('tokens_week', 'je Woche'), limit('tokens_month', 'je Monat'), limit('tokens_total', 'insgesamt'))),
|
||||
h('fieldset', {}, h('legend', {}, 'Anfragen'), h('div', { class: 'fields' },
|
||||
limit('requests_hour', 'je Stunde'), limit('requests_day', 'je Tag'), limit('requests_week', 'je Woche'), limit('requests_month', 'je Monat'), limit('requests_total', 'insgesamt'))),
|
||||
h('fieldset', {}, h('legend', {}, 'Wann und womit'), h('div', { class: 'fields' },
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-models' }, 'Nur diese Modelle'), h('input', { id: 'q-models', name: 'models', class: 'field mono', placeholder: 'ollama/qwen3:0.6b, vllm/…' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-weekly' }, 'Wochentage'), h('input', { id: 'q-weekly', name: 'weekly', class: 'field mono', placeholder: 'mo-fr' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-time' }, 'Uhrzeit'), h('input', { id: 'q-time', name: 'time', class: 'field mono', placeholder: '08:00-18:00' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-from' }, 'Gültig ab'), h('input', { id: 'q-from', name: 'from', class: 'field mono', placeholder: '2026-10-01' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-until' }, 'Gültig bis'), h('input', { id: 'q-until', name: 'until', class: 'field mono', placeholder: '2027-02-15' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-note' }, 'Anmerkung'), h('input', { id: 'q-note', name: 'note', class: 'field' }))),
|
||||
h('span', { class: 'hint' }, 'Leere Felder heißen unbegrenzt. Ein Gruppenkontingent gilt je Mitglied. Tage und Monate sind Kalenderzeiträume.')),
|
||||
h('fieldset', {}, h('legend', {}, 'Modelle'),
|
||||
segmented('q-models', [['all', 'Alle Modelle'], ['some', 'Nur ausgewählte']], 'all', (v) => { picker.hidden = v !== 'some'; }),
|
||||
picker),
|
||||
h('fieldset', {}, h('legend', {}, 'Nutzungszeiten'),
|
||||
days,
|
||||
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('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' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-valid-until' }, 'bis einschließlich'), h('input', { id: 'q-valid-until', name: 'valid_until', type: 'date', class: 'field mono' })),
|
||||
h('div', { class: 'field-group' }, h('label', { for: 'q-note' }, 'Anmerkung'), h('input', { id: 'q-note', name: 'note', class: 'field' })))),
|
||||
h('span', { class: 'hint' }, 'Leere Grenzen heißen unbegrenzt. Tage, Wochen und Monate sind Kalenderzeiträume.'),
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Kontingent anlegen')));
|
||||
return h('section', { class: 'card' }, h('h2', {}, fixedGroup ? 'Neues Kontingent für diese Gruppe' : 'Neues Kontingent'), form);
|
||||
}
|
||||
|
||||
async function groupPage(name) {
|
||||
const g = await api('GET', '/groups/' + encodeURIComponent(name));
|
||||
const [g, models] = await Promise.all([api('GET', '/groups/' + encodeURIComponent(name)), api('GET', '/models')]);
|
||||
const back = g.owner_id === state.me.user.id ? '#/groups' : '#/allgroups';
|
||||
const add = h('form', {
|
||||
onsubmit: (e) => {
|
||||
e.preventDefault();
|
||||
@@ -653,9 +822,9 @@ async function groupPage(name) {
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Aufnehmen')));
|
||||
return h('div', { class: 'stack' },
|
||||
head('Lehre · Gruppe', g.name, 'Verwaltet von ' + (g.owner || '–') + ' · ' + g.members.length + ' Mitglieder',
|
||||
h('a', { class: 'btn', href: '#/groups' }, 'Zurück'),
|
||||
h('a', { class: 'btn', href: back }, 'Zurück'),
|
||||
h('button', { class: 'btn danger', type: 'button', onclick: () => {
|
||||
if (confirm('Gruppe „' + g.name + '“ löschen?')) act(async () => { await api('DELETE', '/groups/' + encodeURIComponent(g.name)); go('groups'); }, 'Gruppe gelöscht.');
|
||||
if (confirm('Gruppe „' + g.name + '“ löschen?')) act(async () => { await api('DELETE', '/groups/' + encodeURIComponent(g.name)); location.hash = back; }, 'Gruppe gelöscht.');
|
||||
} }, 'Gruppe löschen')),
|
||||
h('div', { class: 'row top' },
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Mitglieder'),
|
||||
@@ -669,8 +838,8 @@ async function groupPage(name) {
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Personen aufnehmen'), add,
|
||||
h('span', { class: 'hint' }, 'Wer noch kein Konto hat, wird Mitglied, sobald es angelegt ist.'))),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Kontingente der Gruppe'),
|
||||
quotasTable(g.quotas.map((q) => ({ ...q, target: 'Gruppe ' + g.name, describe: describeQuota(q), keys: '–' })))),
|
||||
quotaForm([], 'group:' + g.name));
|
||||
quotasTable(g.quotas.map((q) => ({ ...q, target: 'Gruppe ' + g.name, describe: describeQuota(q), keys: '–' })), false)),
|
||||
quotaForm([], 'group:' + g.name, models));
|
||||
}
|
||||
|
||||
function describeQuota(q) {
|
||||
@@ -680,7 +849,8 @@ function describeQuota(q) {
|
||||
if (q.requests[p] != null) parts.push(num(q.requests[p]) + ' Anfragen/' + PERIOD[p]);
|
||||
}
|
||||
if (q.models) parts.push('Modelle: ' + q.models.join(', '));
|
||||
return parts.join('; ') || 'ohne Mengengrenzen';
|
||||
parts.push(q.shared ? 'für die Gruppe gemeinsam' : 'je Mitglied');
|
||||
return parts.join('; ');
|
||||
}
|
||||
|
||||
async function quotaPage(id) {
|
||||
@@ -688,7 +858,7 @@ async function quotaPage(id) {
|
||||
const manages = atLeast('admin') || q.owner_id === state.me.user.id;
|
||||
return h('div', { class: 'stack' },
|
||||
head('Kontingent', q.name, (q.target ? q.target + ' · ' : '') + 'verwaltet von ' + (q.owner || '–'),
|
||||
h('a', { class: 'btn', href: manages ? '#/groups' : '#/' }, 'Zurück'),
|
||||
h('a', { class: 'btn', href: !manages ? '#/' : q.owner_id === state.me.user.id ? '#/groups' : '#/allgroups' }, 'Zurück'),
|
||||
manages ? h('button', { class: 'btn danger', type: 'button', onclick: () => {
|
||||
if (confirm('Kontingent „' + q.name + '“ entfernen? Das geht nur, wenn keine Keys mehr daran hängen.')) act(async () => { await api('DELETE', '/quotas/' + q.id); go('groups'); }, 'Kontingent entfernt.');
|
||||
} }, 'Entfernen') : null),
|
||||
@@ -697,7 +867,7 @@ async function quotaPage(id) {
|
||||
q.usage.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Person'), Object.values(PERIOD).map((p) => h('th', { class: 'num' }, 'Token ' + p)), h('th', { class: 'num' }, 'Anfragen heute'))),
|
||||
h('tbody', {}, q.usage.map((p) => h('tr', {},
|
||||
h('td', { class: 'mono' }, p.user || '(ohne Inhaber)'),
|
||||
h('td', { class: 'mono' }, personLabel(p)),
|
||||
Object.keys(PERIOD).map((k) => h('td', { class: 'num' }, tokens(tok(p.usage[k])) + (q.tokens[k] != null ? ' / ' + tokens(q.tokens[k]) : ''))),
|
||||
h('td', { class: 'num' }, num(p.usage.day.requests) + (q.requests.day != null ? ' / ' + num(q.requests.day) : '')))))))
|
||||
: h('p', { class: 'empty' }, 'Noch keine Nutzung.')));
|
||||
@@ -757,64 +927,184 @@ function nodeCard(n) {
|
||||
|
||||
// ---------- Zeitplan ----------
|
||||
|
||||
const KIND_LABEL = { pin: 'Pin', exclusive: 'Exklusiv', window: 'Zeitfenster' };
|
||||
|
||||
function startOfWeek(offset) {
|
||||
const now = new Date();
|
||||
const monday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - ((now.getDay() + 6) % 7) + offset * 7);
|
||||
return monday;
|
||||
}
|
||||
|
||||
function isoWeek(date) {
|
||||
const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
||||
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
||||
const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
||||
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
|
||||
}
|
||||
|
||||
const hhmm = (d) => String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0');
|
||||
|
||||
function atTime(day, time) {
|
||||
const [hh, mm] = time.split(':').map(Number);
|
||||
return new Date(day.getFullYear(), day.getMonth(), day.getDate(), hh, mm);
|
||||
}
|
||||
|
||||
/** Abschnitte eines Eintrags an einem Tag, als [Beginn, Ende], beschnitten auf den Tag und die Gültigkeit */
|
||||
function occurrences(e, dayStart) {
|
||||
const dayEnd = new Date(dayStart.getTime() + 86400000);
|
||||
const from = e.time.from ? new Date(e.time.from * 1000) : null;
|
||||
const until = e.time.until ? new Date(e.time.until * 1000) : null;
|
||||
const clip = ([a, b]) => {
|
||||
const s2 = new Date(Math.max(a, dayStart, from || a));
|
||||
const e2 = new Date(Math.min(b, dayEnd, until || b));
|
||||
return e2 > s2 ? [[s2, e2]] : [];
|
||||
};
|
||||
const w = e.time.weekly;
|
||||
if (!w) return clip([dayStart, dayEnd]);
|
||||
const code = (d) => WEEKDAYS[(d.getDay() + 6) % 7][2];
|
||||
const result = [];
|
||||
const start = w.start.slice(0, 5);
|
||||
const end = w.end.slice(0, 5);
|
||||
if (w.days.includes(code(dayStart))) {
|
||||
const a = atTime(dayStart, start);
|
||||
const b = end > start ? atTime(dayStart, end) : dayEnd;
|
||||
result.push(...clip([a, b]));
|
||||
}
|
||||
// Über Mitternacht: der Rest vom Vortag
|
||||
const prev = new Date(dayStart.getTime() - 86400000);
|
||||
if (end < start && w.days.includes(code(prev))) result.push(...clip([dayStart, atTime(dayStart, end)]));
|
||||
return result;
|
||||
}
|
||||
|
||||
async function schedulePage() {
|
||||
const entries = await api('GET', '/schedule');
|
||||
const kindSel = h('select', { id: 's-kind', name: 'kind', class: 'field', onchange: () => update() },
|
||||
h('option', { value: 'pin' }, 'Pin: Modell garantiert im Speicher'),
|
||||
h('option', { value: 'exclusive' }, 'Exklusiv: nur bestimmte Gruppen oder Personen'),
|
||||
h('option', { value: 'window' }, 'Modellzeitfenster: nur bestimmte Modelle'));
|
||||
const field = (name, label, placeholder, hint) => h('div', { class: 'field-group', 'data-for': hint },
|
||||
h('label', { for: 's-' + name }, label), h('input', { id: 's-' + name, name, class: 'field mono', placeholder }));
|
||||
const [entries, models, groups] = await Promise.all([api('GET', '/schedule'), api('GET', '/models'), api('GET', '/groups')]);
|
||||
const weekStart = startOfWeek(state.week || 0);
|
||||
const weekEnd = new Date(weekStart.getTime() + 7 * 86400000);
|
||||
const label = 'KW ' + isoWeek(weekStart) + ' · ' + weekStart.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit' }) + '–'
|
||||
+ 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(); };
|
||||
|
||||
// Kalender: eine Spalte je Tag, eine Zeile je Stunde
|
||||
const HOUR = 22;
|
||||
const grid = h('div', { class: 'cal' });
|
||||
grid.append(h('div', { class: 'cal-corner' }));
|
||||
for (let d = 0; d < 7; d++) {
|
||||
const day = new Date(weekStart.getTime() + d * 86400000);
|
||||
const today = day.toDateString() === new Date().toDateString();
|
||||
grid.append(h('div', { class: 'cal-day' + (today ? ' today' : '') }, WEEKDAYS[d][1], ' ', h('span', { class: 'mono' }, day.getDate() + '.')));
|
||||
}
|
||||
const hours = h('div', { class: 'cal-hours mono', style: { height: (24 * HOUR) + 'px' } });
|
||||
for (let hr = 0; hr < 24; hr += 2) hours.append(h('span', { style: { top: (hr * HOUR) + 'px' } }, String(hr).padStart(2, '0')));
|
||||
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' } });
|
||||
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)))));
|
||||
lane = (lane + 1) % 3;
|
||||
}
|
||||
}
|
||||
grid.append(col);
|
||||
}
|
||||
|
||||
// Formular wie im Mockup: Art, Gegenstand, Zeit und Wiederholung
|
||||
const kindBox = h('div', {});
|
||||
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 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' })));
|
||||
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-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' }))));
|
||||
function showTime() {
|
||||
once.hidden = repeat.value !== 'once';
|
||||
weekly.hidden = repeat.value !== 'weekly';
|
||||
}
|
||||
let kind = 'pin';
|
||||
function showSubject() {
|
||||
if (kind === 'pin') subject.replaceChildren(h('span', { class: 'label' }, 'Modell'), modelPicker(models, 's-model', false));
|
||||
if (kind === 'exclusive') subject.replaceChildren(h('span', { class: 'label' }, 'Gruppen'),
|
||||
groups.length ? h('div', { class: 'model-picker' }, groups.map((g) => h('label', { class: 'check' }, h('input', { type: 'checkbox', name: 's-group', value: g.name }), h('span', { class: 'mono' }, g.name), h('span', { class: 'hint' }, g.owner || ''))))
|
||||
: h('p', { class: 'empty' }, 'Keine Gruppen.'),
|
||||
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', {
|
||||
onsubmit: (e) => {
|
||||
e.preventDefault();
|
||||
class: 'card cal-form',
|
||||
onsubmit: (ev) => {
|
||||
ev.preventDefault();
|
||||
const d = formData(form);
|
||||
const body = { kind: d.kind, from: optional(d.from), until: optional(d.until), weekly: optional(d.weekly), time: optional(d.time), note: d.note };
|
||||
if (d.kind === 'pin') Object.assign(body, { model: d.model, node: optional(d.node) });
|
||||
if (d.kind === 'exclusive') Object.assign(body, { groups: list(d.groups), users: list(d.users) });
|
||||
if (d.kind === 'window') body.models = list(d.models);
|
||||
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(); }
|
||||
body.model = m;
|
||||
const nodes = (models.find((x) => x.id === m) || { nodes: [] }).nodes;
|
||||
if (nodes.length > 1) body.node = d.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);
|
||||
},
|
||||
},
|
||||
h('div', { class: 'fields' },
|
||||
h('div', { class: 'field-group' }, h('label', { for: 's-kind' }, 'Art'), kindSel),
|
||||
field('model', 'Modell', 'ollama/qwen3:0.6b', 'pin'),
|
||||
field('node', 'Rechner (bei mehreren)', 'spark1', 'pin'),
|
||||
field('groups', 'Gruppen', 'ki-2026', 'exclusive'),
|
||||
field('users', 'Personen', 'hofmannol', 'exclusive'),
|
||||
field('models', 'Modelle', 'ollama/qwen3:0.6b, vllm/…', 'window')),
|
||||
h('div', { class: 'fields' },
|
||||
field('from', 'Beginn', '2026-11-24 08:00 oder +10m'), field('until', 'Ende', '2026-11-24 12:00'),
|
||||
field('weekly', 'Wochentage', 'mo,mi'), field('time', 'Uhrzeit', '08:00-11:15'), field('note', 'Anmerkung', 'Vorlesung KI')),
|
||||
h('span', { class: 'hint' }, 'Ohne Zeitangaben gilt ein Eintrag dauerhaft. Der Proxy lehnt Einträge ab, die nicht in den Speicher passen oder sich widersprechen.'),
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Eintrag anlegen')));
|
||||
function update() {
|
||||
for (const el of form.querySelectorAll('[data-for]')) {
|
||||
const kind = el.getAttribute('data-for');
|
||||
if (kind !== 'undefined') el.hidden = kind !== kindSel.value;
|
||||
}
|
||||
}
|
||||
update();
|
||||
const kinds = { pin: 'Pin', exklusiv: 'Exklusiv', fenster: 'Zeitfenster' };
|
||||
h('h2', {}, 'Eintrag anlegen'),
|
||||
h('div', { class: 'field-group' }, h('span', { class: 'label' }, 'Art des Eintrags'), kindBox),
|
||||
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')));
|
||||
|
||||
return h('div', { class: 'stack' },
|
||||
head('Administration', 'Zeitplan', 'Pins, exklusive Nutzung und Modellzeitfenster in einem Plan.'),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Einträge'),
|
||||
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' : '') }, kinds[e.kind.kind] || e.kind.kind)),
|
||||
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.')),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Neuer Eintrag'), form));
|
||||
: h('p', { class: 'empty' }, 'Der Zeitplan ist leer.')));
|
||||
}
|
||||
|
||||
// ---------- Benutzer ----------
|
||||
|
||||
async function usersPage() {
|
||||
const users = await api('GET', '/users');
|
||||
const search = h('input', { type: 'search', class: 'field', placeholder: 'Benutzername, E-Mail oder Gruppe', 'aria-label': 'Benutzer durchsuchen', value: state.userSearch || '' });
|
||||
const hideBlocked = h('input', { type: 'checkbox', id: 'hide-blocked', checked: state.hideBlocked });
|
||||
const count = h('span', { class: 'muted' });
|
||||
const patch = (u, body, done) => act(() => api('PATCH', '/users/' + encodeURIComponent(u.username), body), done);
|
||||
const form = h('form', {
|
||||
onsubmit: (e) => {
|
||||
@@ -835,25 +1125,54 @@ async function usersPage() {
|
||||
h('span', { class: 'hint' }, 'Im Betrieb registrieren sich Personen selbst mit dem Login der Hochschule (LDAP).'),
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn primary', type: 'submit' }, 'Benutzer anlegen')));
|
||||
const me = state.me.user;
|
||||
return h('div', { class: 'stack' },
|
||||
const userRows = h('tbody', {});
|
||||
const page = h('div', { class: 'stack' },
|
||||
head('Administration', 'Benutzer', users.length + ' Konten'),
|
||||
h('section', { class: 'card' }, h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('section', { class: 'card' },
|
||||
h('div', { class: 'toolbar' }, search, h('label', { class: 'check', for: 'hide-blocked' }, hideBlocked, 'Gesperrte und deaktivierte ausblenden'), count),
|
||||
h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Benutzer'), h('th', {}, 'E-Mail'), h('th', {}, 'Rolle'), h('th', {}, 'Gruppen'), h('th', {}, 'Stand'), h('th', {}, h('span', { class: 'sr-only' }, 'Aktionen')))),
|
||||
h('tbody', {}, users.map((u) => h('tr', { class: u.blocked || !u.active ? 'dim' : null },
|
||||
userRows))),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Neuer Benutzer'), form));
|
||||
function update() {
|
||||
state.userSearch = search.value;
|
||||
state.hideBlocked = hideBlocked.checked;
|
||||
const q = search.value.trim().toLowerCase();
|
||||
const shown = users.filter((u) => (!hideBlocked.checked || (!u.blocked && u.active))
|
||||
&& (!q || [u.username, u.email, ...u.groups].some((v) => v && v.toLowerCase().includes(q))));
|
||||
count.textContent = shown.length + ' von ' + users.length;
|
||||
userRows.replaceChildren(...shown.map((u) => h('tr', { class: u.blocked || !u.active ? 'dim' : null },
|
||||
h('td', { class: 'mono' }, u.username), h('td', {}, u.email || '–'),
|
||||
h('td', {}, h('select', { class: 'field', 'aria-label': 'Rolle von ' + u.username, onchange: (e) => patch(u, { role: e.target.value }, u.username + ' ist jetzt ' + ROLE[e.target.value] + '.') },
|
||||
Object.entries(ROLE).map(([v, l]) => h('option', { value: v, selected: v === u.role }, l)))),
|
||||
h('td', { class: 'wrap' }, u.groups.join(', ') || '–'),
|
||||
h('td', {}, u.blocked ? h('span', { class: 'chip bad' }, 'gesperrt') : !u.active ? h('span', { class: 'chip bad' }, 'deaktiviert') : h('span', { class: 'chip good' }, 'aktiv')),
|
||||
h('td', {}, u.id === me.id ? null : h('div', { class: 'actions' },
|
||||
h('button', { class: 'btn small' + (u.blocked ? '' : ' danger'), type: 'button', onclick: () => patch(u, { blocked: !u.blocked }, u.username + (u.blocked ? ' entsperrt.' : ' gesperrt; seine Keys werden abgewiesen.')) }, u.blocked ? 'Entsperren' : 'Sperren'))))))))),
|
||||
h('section', { class: 'card' }, h('h2', {}, 'Neuer Benutzer'), form));
|
||||
h('button', { class: 'btn small' + (u.blocked ? '' : ' danger'), type: 'button', onclick: () => patch(u, { blocked: !u.blocked }, u.username + (u.blocked ? ' entsperrt.' : ' gesperrt; seine Keys werden abgewiesen.')) }, u.blocked ? 'Entsperren' : 'Sperren'))))));
|
||||
}
|
||||
search.addEventListener('input', update);
|
||||
hideBlocked.addEventListener('change', update);
|
||||
update();
|
||||
return page;
|
||||
}
|
||||
|
||||
// ---------- Audit-Log ----------
|
||||
|
||||
async function auditPage() {
|
||||
const [entries, outbox] = await Promise.all([api('GET', '/audit?limit=300'), api('GET', '/outbox')]);
|
||||
const [entries, outbox] = await Promise.all([api('GET', '/audit?limit=1000'), api('GET', '/outbox')]);
|
||||
const search = h('input', { type: 'search', class: 'field', placeholder: 'Person, Vorgang oder Details', 'aria-label': 'Audit-Log durchsuchen' });
|
||||
const count = h('span', { class: 'muted' });
|
||||
const auditRows = h('tbody', {});
|
||||
function update() {
|
||||
const q = search.value.trim().toLowerCase();
|
||||
const shown = entries.filter((e) => !q || [e.actor, e.action, ACTIONS[e.action], e.detail].some((v) => v && v.toLowerCase().includes(q)));
|
||||
count.textContent = shown.length + ' von ' + entries.length;
|
||||
auditRows.replaceChildren(...shown.slice(0, 300).map((e) => h('tr', {},
|
||||
h('td', { class: 'mono muted' }, when(e.ts)), h('td', { class: 'mono' }, actor(e.actor)),
|
||||
h('td', {}, ACTIONS[e.action] || e.action), h('td', { class: 'wrap' }, e.detail))));
|
||||
}
|
||||
search.addEventListener('input', update);
|
||||
update();
|
||||
const prune = h('form', {
|
||||
onsubmit: (e) => {
|
||||
e.preventDefault();
|
||||
@@ -867,7 +1186,7 @@ async function auditPage() {
|
||||
h('span', { class: 'hint' }, 'Löscht Zeitpunkt, Key, Modell und Token einzelner Anfragen. Die Zähler der Kontingente und Keys bleiben, damit verbuchte Stände stimmen.'),
|
||||
h('div', { class: 'actions' }, h('button', { class: 'btn danger', type: 'submit' }, 'Metadaten löschen')));
|
||||
return h('div', { class: 'stack' },
|
||||
head('Administration', 'Audit-Log', 'Die letzten 300 Vorgänge. Inhalte von Anfragen und Antworten stehen hier nie.'),
|
||||
head('Administration', 'Audit-Log', 'Die letzten 1000 Vorgänge, durchsuchbar. Inhalte von Anfragen und Antworten stehen hier nie.'),
|
||||
h('div', { class: 'row top' },
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Alte Metadaten löschen'), prune),
|
||||
h('section', { class: 'card grow' }, h('h2', {}, 'Postausgang'),
|
||||
@@ -875,10 +1194,27 @@ async function auditPage() {
|
||||
outbox.length ? h('ol', { class: 'events' }, outbox.slice().reverse().map((m) => h('li', {},
|
||||
h('span', { class: 'mono' }, when(m.ts)), h('span', {}, h('b', {}, m.subject), ' an ', h('span', { class: 'mono' }, m.to || '(keine Adresse)')))))
|
||||
: h('p', { class: 'empty' }, 'Keine Benachrichtigungen.'))),
|
||||
h('section', { class: 'card' }, h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('section', { class: 'card' },
|
||||
h('div', { class: 'toolbar' }, search, count),
|
||||
h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Zeit'), h('th', {}, 'Wer'), h('th', {}, 'Vorgang'), h('th', {}, 'Details'))),
|
||||
h('tbody', {}, entries.map((e) => h('tr', {},
|
||||
h('td', { class: 'mono muted' }, when(e.ts)), h('td', { class: 'mono' }, e.actor), h('td', { class: 'mono' }, e.action), h('td', { class: 'wrap mono' }, e.detail))))))));
|
||||
auditRows))));
|
||||
}
|
||||
|
||||
const ACTIONS = {
|
||||
'login': 'Angemeldet', 'login.failed': 'Anmeldung gescheitert',
|
||||
'session.create': 'Sitzung angelegt', 'session.revoke': 'Sitzung beendet',
|
||||
'user.create': 'Benutzer angelegt', 'user.role': 'Rolle geändert', 'user.block': 'Benutzer gesperrt', 'user.unblock': 'Benutzer entsperrt',
|
||||
'user.deactivate': 'Konto deaktiviert', 'user.activate': 'Konto aktiviert', 'user.password': 'Passwort gesetzt',
|
||||
'group.create': 'Gruppe angelegt', 'group.delete': 'Gruppe gelöscht', 'group.add': 'Mitglied aufgenommen', 'group.remove': 'Mitglied entfernt',
|
||||
'quota.create': 'Kontingent angelegt', 'quota.remove': 'Kontingent entfernt',
|
||||
'key.create': 'Key angelegt', 'key.revoke': 'Key widerrufen', 'key.quota': 'Kontingent eines Keys geändert',
|
||||
'schedule.add': 'Zeitplan: Eintrag angelegt', 'schedule.remove': 'Zeitplan: Eintrag entfernt',
|
||||
'model.load': 'Modell geladen', 'model.unload': 'Modell entladen', 'model.load_failed': 'Laden gescheitert', 'pin.load_failed': 'Gepinntes Modell nicht geladen',
|
||||
'recording.start': 'Aufzeichnung gestartet', 'recording.end': 'Aufzeichnung beendet', 'recording.ready': 'Aufzeichnung bereitgestellt',
|
||||
'recording.download': 'Aufzeichnung heruntergeladen', 'recording.delete': 'Aufzeichnung gelöscht',
|
||||
'usage.prune': 'Alte Metadaten gelöscht',
|
||||
};
|
||||
const actor = (a) => ({ system: 'System', scheduler: 'Proxy', cli: 'Kommandozeile' }[a] || a);
|
||||
|
||||
render();
|
||||
Reference in new issue
Block a user