Files
ersatztv/web/src/api/logs.ts
T
timothy 5530db7089
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 4m26s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m39s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
feat(web): logs and troubleshooting screens for SPA parity (#145)
Add typed API wrappers (api/logs.ts, api/troubleshoot.ts) and two new
screens: LogsScreen (paged, level-badged, server-side filtered log table)
and TroubleshootingScreen (General JSON viewer with copy, plus per-platform
NVIDIA/QSV/VAAPI/VideoToolbox capability tabs when populated). Both are
registered under a new "System" nav group in App.tsx alongside Settings.
Settings' Classic UI help text and About card now point at the new screens
instead of the Blazor logs/troubleshooting pages.
2026-07-07 13:42:01 +02:00

44 lines
1.1 KiB
TypeScript

import { ApiError, request } from './client';
import type { components } from './generated/v1';
export type LogEntry = components['schemas']['LogEntryResponseModel'];
export type PagedLogEntries = components['schemas']['PagedLogEntriesResponseModel'];
export interface GetLogsParams {
filter?: string;
pageNum?: number;
pageSize?: number;
}
export function getLogs(params: GetLogsParams = {}): Promise<PagedLogEntries> {
const searchParams = new URLSearchParams();
if (params.filter) {
searchParams.set('filter', params.filter);
}
if (params.pageNum != null) {
searchParams.set('pageNum', String(params.pageNum));
}
if (params.pageSize != null) {
searchParams.set('pageSize', String(params.pageSize));
}
const queryString = searchParams.toString();
return request<PagedLogEntries>(`/api/logs${queryString ? `?${queryString}` : ''}`);
}
export function messageFromLogsError(error: unknown, fallback = 'Unable to load logs'): string {
if (error instanceof ApiError) {
return error.detail ?? error.message;
}
if (error instanceof Error) {
return error.message;
}
return fallback;
}