diff --git a/frontend/src/components/RequestDetails.tsx b/frontend/src/components/RequestDetails.tsx index 3618fdb..208ad29 100644 --- a/frontend/src/components/RequestDetails.tsx +++ b/frontend/src/components/RequestDetails.tsx @@ -61,7 +61,7 @@ interface RequestDetailsProps { const RequestDetails: Component = (props) => { return ( - +

Request Details

@@ -69,7 +69,7 @@ const RequestDetails: Component = (props) => {

- +

Request

diff --git a/frontend/src/components/RequestLog.tsx b/frontend/src/components/RequestLog.tsx index 06c55ba..f1c21a4 100644 --- a/frontend/src/components/RequestLog.tsx +++ b/frontend/src/components/RequestLog.tsx @@ -1,6 +1,7 @@ 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"; @@ -8,22 +9,29 @@ import RequestDetails from "./RequestDetails"; const RequestLog: Component = () => { const [search, setSearch] = createSignal(""); + const [inputValue, setInputValue] = createSignal(""); const [method, setMethod] = createSignal(""); const [selectedLog, setSelectedLog] = createSignal(null); - const [logs] = createResource( + 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) => { - // Solid's createResource refetches when the source accessor changes. - // We can add a debounce here if we want to avoid too many requests. return logsApi.list(filters); }, ); - + const [allLogs] = createResource(async () => { + return await logsApi.list(); + }); const methods = createMemo(() => { - if (!logs()) return []; - const allMethods = logs()!.map((log) => log.method); - return [...new Set(allMethods)]; + return allLogs.loading ? [] : [...new Set(allLogs()!.map((log) => log.method))]; }); const handleLogClick = (log: RequestLogType) => { @@ -41,24 +49,32 @@ const RequestLog: Component = () => { return ( <>
-

Request Log

+
+

+ Request Log + + + ({logs()?.length} of {allLogs()?.length} logs) + + +

+ +
-
-
+
+
setSearch(e.currentTarget.value)} + value={inputValue()} + onInput={handleInput} />
-
- setMethod(e.currentTarget.value)} class="w-full"> {(m) => }