Oberfläche: Fehler bei Keys und Zeitplan behoben, Rendertest, Metadaten löschen, Postausgang
- Übersicht und API-Keys brachen für alle Rollen ab, der Zeitplan bei vorhandenen Einträgen: Keys und Zeitplaneinträge liegen in der API flach im Objekt, nicht in einem Unterobjekt - tests/ui/render_test.js: rendert jede Seite für admin, dozent und student in jsdom gegen den laufenden Proxy und spielt Abläufe durch (Anmelden, Key, Aufzeichnung, Gruppe, Mitglied, Kontingent, Zeitplan, Benutzer, Metadaten löschen) - Audit-Log: alte Metadaten löschen und Postausgang - README und Beispielkonfiguration zur Oberfläche Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7aeb6f9d44
commit
d753fd9285
6 files changed
+326
-20
No files matched your search
+39
-20
@@ -345,13 +345,13 @@ function quotaMeters(q, usage) {
|
||||
}
|
||||
|
||||
function keyState(k) {
|
||||
if (k.key.revoked) return h('span', { class: 'muted' }, 'widerrufen');
|
||||
if (k.revoked) return h('span', { class: 'muted' }, 'widerrufen');
|
||||
if (k.recording) return h('span', { class: 'status' }, h('span', { class: 'dot accent' }), k.recording);
|
||||
return h('span', { class: 'status' }, h('span', { class: 'dot good' }), 'aktiv');
|
||||
}
|
||||
|
||||
function quotaLabel(k) {
|
||||
if (k.key.is_super) return h('span', { class: 'chip accent' }, 'Super-Key');
|
||||
if (k.is_super) return h('span', { class: 'chip accent' }, 'Super-Key');
|
||||
if (!k.quota) return h('span', { class: 'muted' }, 'unbegrenzt');
|
||||
return k.quota.name;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ function quotaLabel(k) {
|
||||
|
||||
async function overview() {
|
||||
const me = state.me = await api('GET', '/me');
|
||||
const active = me.keys.filter((k) => !k.key.revoked);
|
||||
const active = me.keys.filter((k) => !k.revoked);
|
||||
const sum = (f) => active.reduce((a, k) => a + f(k.usage), 0);
|
||||
const parts = [
|
||||
head('Persönlich', 'Übersicht', 'Deine Nutzung über alle Keys.'),
|
||||
@@ -406,8 +406,8 @@ function keysTableCard(keys, compact) {
|
||||
h('div', { class: 'card-head' }, h('h2', {}, 'Keys'), compact ? h('a', { href: '#/keys' }, 'Alle Keys verwalten') : null),
|
||||
keys.length ? h('div', { class: 'table-wrap' }, h('table', {},
|
||||
h('thead', {}, h('tr', {}, h('th', {}, 'Key'), h('th', {}, 'Kontingent'), h('th', { class: 'num' }, 'Token heute'), h('th', { class: 'num' }, 'Anfragen heute'), h('th', { class: 'num' }, 'Token gesamt'), h('th', {}, 'Status'))),
|
||||
h('tbody', {}, keys.map((k) => h('tr', { class: k.key.revoked ? 'dim' : null },
|
||||
h('td', { class: 'mono' }, k.key.name), h('td', {}, quotaLabel(k)),
|
||||
h('tbody', {}, keys.map((k) => h('tr', { class: k.revoked ? 'dim' : null },
|
||||
h('td', { class: 'mono' }, k.name), h('td', {}, quotaLabel(k)),
|
||||
h('td', { class: 'num' }, tokens(tok(k.usage.day))), h('td', { class: 'num' }, num(k.usage.day.requests)),
|
||||
h('td', { class: 'num' }, tokens(tok(k.usage.total))), h('td', {}, keyState(k)))))))
|
||||
: h('p', { class: 'empty' }, 'Noch keine Keys.'));
|
||||
@@ -418,8 +418,8 @@ function keysTableCard(keys, compact) {
|
||||
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.key.user_id === me.id);
|
||||
const others = keys.filter((k) => k.key.user_id !== me.id);
|
||||
const own = keys.filter((k) => k.user_id === me.id);
|
||||
const others = keys.filter((k) => k.user_id !== me.id);
|
||||
const usable = quotas;
|
||||
const created = state.createdKey;
|
||||
state.createdKey = null;
|
||||
@@ -466,27 +466,27 @@ function keysManageCard(title, keys, own) {
|
||||
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.key.revoked ? 'dim' : null },
|
||||
h('td', { class: 'mono' }, k.key.name), own ? null : h('td', { class: 'mono' }, k.owner || '–'),
|
||||
h('td', { class: 'mono muted' }, k.key.prefix + '…'), h('td', {}, quotaLabel(k)),
|
||||
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.key.revoked ? null : h('div', { class: 'actions' },
|
||||
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.key.id }), 'Aufzeichnung beendet; sie liegt jetzt zum Herunterladen bereit.') }, 'Aufzeichnung beenden') : 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'))))))))
|
||||
: h('p', { class: 'empty' }, 'Keine Keys.'));
|
||||
}
|
||||
|
||||
function revokeKey(k) {
|
||||
if (!confirm('Key „' + k.key.name + '“ widerrufen? Anwendungen, die ihn nutzen, werden sofort abgewiesen.')) return;
|
||||
act(() => api('DELETE', '/keys/' + k.key.id), 'Key „' + k.key.name + '“ widerrufen.');
|
||||
if (!confirm('Key „' + k.name + '“ widerrufen? Anwendungen, die ihn nutzen, werden sofort abgewiesen.')) return;
|
||||
act(() => api('DELETE', '/keys/' + k.id), 'Key „' + k.name + '“ widerrufen.');
|
||||
}
|
||||
|
||||
function startRecording(k) {
|
||||
const answer = prompt('Wie viele der nächsten Anfragen von „' + k.key.name + '“ sollen samt Antworten aufgezeichnet werden? (1 bis 100)', '20');
|
||||
const answer = prompt('Wie viele der nächsten Anfragen von „' + k.name + '“ sollen samt Antworten aufgezeichnet werden? (1 bis 100)', '20');
|
||||
if (!answer) return;
|
||||
act(() => api('POST', '/recordings', { key_id: k.key.id, count: Number(answer) }), 'Aufzeichnung gestartet.');
|
||||
act(() => api('POST', '/recordings', { key_id: k.id, count: Number(answer) }), 'Aufzeichnung gestartet.');
|
||||
}
|
||||
|
||||
function recordingsCard(recordings) {
|
||||
@@ -802,11 +802,11 @@ async function schedulePage() {
|
||||
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.entry.kind.kind === 'pin' ? ' accent' : '') }, kinds[e.entry.kind.kind] || e.entry.kind.kind)),
|
||||
h('td', {}, h('span', { class: 'chip' + (e.kind.kind === 'pin' ? ' accent' : '') }, kinds[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.entry.note),
|
||||
h('td', {}, h('button', { class: 'btn small danger', type: 'button', onclick: () => act(() => api('DELETE', '/schedule/' + e.entry.id), 'Eintrag entfernt.') }, 'Entfernen')))))))
|
||||
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));
|
||||
}
|
||||
@@ -853,9 +853,28 @@ async function usersPage() {
|
||||
// ---------- Audit-Log ----------
|
||||
|
||||
async function auditPage() {
|
||||
const entries = await api('GET', '/audit?limit=300');
|
||||
const [entries, outbox] = await Promise.all([api('GET', '/audit?limit=300'), api('GET', '/outbox')]);
|
||||
const prune = h('form', {
|
||||
onsubmit: (e) => {
|
||||
e.preventDefault();
|
||||
const days = Number(formData(prune).days);
|
||||
if (!confirm('Alle Einzeleinträge der Nutzung löschen, die älter als ' + days + ' Tage sind? Kontingentstände bleiben erhalten.')) return;
|
||||
act(() => api('POST', '/usage/prune', { older_than_days: days }), (r) => num(r.deleted) + ' Einträge gelöscht. Die Kontingentstände bleiben erhalten.');
|
||||
},
|
||||
},
|
||||
h('div', { class: 'fields' }, h('div', { class: 'field-group' }, h('label', { for: 'prune-days' }, 'Älter als (Tage)'),
|
||||
h('input', { id: 'prune-days', name: 'days', type: 'number', min: 0, class: 'field mono', value: '180', required: true }))),
|
||||
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.'),
|
||||
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'),
|
||||
h('span', { class: 'hint' }, 'Benachrichtigungen, bis es einen Mailversand gibt. Sie enthalten nie Inhalte von Anfragen.'),
|
||||
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('thead', {}, h('tr', {}, h('th', {}, 'Zeit'), h('th', {}, 'Wer'), h('th', {}, 'Vorgang'), h('th', {}, 'Details'))),
|
||||
h('tbody', {}, entries.map((e) => h('tr', {},
|
||||
|
||||
Reference in new issue
Block a user