import { Component, createMemo, createResource, createSignal, For, Show } from "solid-js"; import { logsApi } from "../api/client"; import type { RequestLog as RequestLogType } from "../types"; import { Button } from "./ui/Button"; import { Card } from "./ui/Card"; import { Input } from "./ui/Input"; import { Select } from "./ui/Select"; import RequestDetails from "./RequestDetails"; const RequestLogs: Component = () => { const [search, setSearch] = createSignal(""); const [inputValue, setInputValue] = createSignal(""); const [method, setMethod] = createSignal(""); const [selectedLog, setSelectedLog] = createSignal(null); let debounceTimer: number; const handleInput = (e: { currentTarget: { value: string } }) => { const value = e.currentTarget.value; setInputValue(value); clearTimeout(debounceTimer); debounceTimer = window.setTimeout(() => setSearch(value), 300); }; const [logs, { refetch: refetchLogs }] = createResource( () => ({ search: search(), method: method() }), async (filters) => { return logsApi.list(filters); }, ); const [allLogs, { refetch: refetchAllLogs }] = createResource(async () => { return await logsApi.list(); }); const methods = createMemo(() => { return allLogs.loading ? [] : [...new Set(allLogs()!.map((log) => log.method))]; }); const refetch = () => { refetchLogs(); refetchAllLogs(); }; const handleLogClick = (log: RequestLogType) => { setSelectedLog(log); }; const handleCloseDetails = () => { setSelectedLog(null); }; const formatDate = (dateStr: string) => { return new Date(dateStr).toLocaleString(); }; return ( <>

Request Logs ({logs()?.length} of {allLogs()?.length} logs)

} > } > {(log) => ( handleLogClick(log)}> )}
Method Time Request Body
Loading...
No logs found.
{log.method} {formatDate(log.created_at)} {JSON.stringify(log.request_body)}
{(log) => } ); }; export default RequestLogs;