reorder and fix key

This commit is contained in:
Josh Hawkins 2025-01-15 14:10:46 -06:00
parent 9766b5c412
commit e90b39df73
2 changed files with 47 additions and 43 deletions

View File

@ -84,7 +84,7 @@ export function GeneralFilterContent({
<DropdownMenuSeparator /> <DropdownMenuSeparator />
<div className="my-2.5 flex flex-col gap-2.5"> <div className="my-2.5 flex flex-col gap-2.5">
{["debug", "info", "warning", "error"].map((item) => ( {["debug", "info", "warning", "error"].map((item) => (
<div className="flex items-center justify-between"> <div className="flex items-center justify-between" key={item}>
<Label <Label
className="mx-2 w-full cursor-pointer capitalize text-primary" className="mx-2 w-full cursor-pointer capitalize text-primary"
htmlFor={item} htmlFor={item}

View File

@ -52,48 +52,6 @@ function Logs() {
} }
}, [tabsRef, logService]); }, [tabsRef, logService]);
// handlers
const handleCopyLogs = useCallback(() => {
if (logs.length) {
copy(logs.join("\n"));
toast.success("Copied logs to clipboard");
} else {
toast.error("Could not copy logs to clipboard");
}
}, [logs]);
const handleDownloadLogs = useCallback(() => {
axios
.get(`api/logs/${logService}?download=true`)
.then((resp) => {
const element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(resp.data),
);
element.setAttribute("download", `${logService}-logs.txt`);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
})
.catch(() => {});
}, [logService]);
const handleRowClick = useCallback(
(rowInfo: { lineNumber: number; rowIndex: number }) => {
const clickedLine = parseLogLines(logService, [
logs[rowInfo.rowIndex],
])[0];
setSelectedLog(clickedLine);
},
[logs, logService],
);
// filter // filter
const filterLines = useCallback( const filterLines = useCallback(
@ -213,6 +171,52 @@ function Logs() {
}; };
}, [fetchInitialLogs, fetchLogsStream]); }, [fetchInitialLogs, fetchLogsStream]);
// handlers
const handleCopyLogs = useCallback(() => {
if (logs.length) {
fetchInitialLogs()
.then(() => {
copy(logs.join("\n"));
toast.success("Copied logs to clipboard");
})
.catch(() => {
toast.error("Could not copy logs to clipboard");
});
}
}, [logs, fetchInitialLogs]);
const handleDownloadLogs = useCallback(() => {
axios
.get(`logs/${logService}?download=true`)
.then((resp) => {
const element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(resp.data),
);
element.setAttribute("download", `${logService}-logs.txt`);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
})
.catch(() => {});
}, [logService]);
const handleRowClick = useCallback(
(rowInfo: { lineNumber: number; rowIndex: number }) => {
const clickedLine = parseLogLines(logService, [
logs[rowInfo.rowIndex],
])[0];
setSelectedLog(clickedLine);
},
[logs, logService],
);
// keyboard listener // keyboard listener
useKeyboardListener( useKeyboardListener(