rework of the event admin UI

This commit is contained in:
Codex Agent
2025-11-24 17:17:39 +01:00
parent 4667ec8073
commit 8947a37261
37 changed files with 4381 additions and 874 deletions

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
import { authorizedFetch } from './auth/tokens';
import { ApiError, emitApiErrorEvent } from './lib/apiError';
import type { EventLimitSummary } from './lib/limitWarnings';
@@ -141,6 +142,13 @@ export type EventStats = {
pending_photos?: number;
};
export type PhotoboothStatusMetrics = {
uploads_last_hour?: number | null;
uploads_today?: number | null;
uploads_total?: number | null;
last_upload_at?: string | null;
};
export type PhotoboothStatus = {
enabled: boolean;
status: string | null;
@@ -155,6 +163,7 @@ export type PhotoboothStatus = {
port: number;
require_ftps: boolean;
};
metrics?: PhotoboothStatusMetrics | null;
};
export type EventAddonCheckout = {
@@ -1144,6 +1153,27 @@ function photoboothEndpoint(slug: string): string {
function normalizePhotoboothStatus(payload: JsonValue): PhotoboothStatus {
const ftp = (payload.ftp ?? {}) as JsonValue;
const metricsPayload = ((payload.metrics ?? payload.stats) ?? null) as JsonValue | null;
let metrics: PhotoboothStatusMetrics | null = null;
if (metricsPayload && typeof metricsPayload === 'object') {
const record = metricsPayload as Record<string, JsonValue>;
const readNumber = (key: string): number | null => {
const value = record[key];
if (value === null || value === undefined) {
return null;
}
const parsed = Number(value);
return Number.isFinite(parsed) ? parsed : null;
};
metrics = {
uploads_last_hour: readNumber('uploads_last_hour') ?? readNumber('last_hour') ?? readNumber('hour'),
uploads_today: readNumber('uploads_today') ?? readNumber('today'),
uploads_total: readNumber('uploads_total') ?? readNumber('total'),
last_upload_at: typeof record.last_upload_at === 'string' ? record.last_upload_at : null,
};
}
return {
enabled: Boolean(payload.enabled),
@@ -1159,6 +1189,7 @@ function normalizePhotoboothStatus(payload: JsonValue): PhotoboothStatus {
port: Number(ftp.port ?? payload.ftp_port ?? 0) || 0,
require_ftps: Boolean(ftp.require_ftps ?? payload.require_ftps),
},
metrics,
};
}