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.
44 lines
1.1 KiB
TypeScript
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;
|
|
}
|