diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index d607b98e6..0ca8350c9 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -5,6 +5,7 @@ import { LuGithub, LuHardDrive, LuLifeBuoy, + LuList, LuMenu, LuMoon, LuMoreVertical, @@ -135,6 +136,12 @@ function Header({ onToggleNavbar }: HeaderProps) { System metrics + + + + System logs + + Configuration diff --git a/web/src/pages/Logs.tsx b/web/src/pages/Logs.tsx index 16cae73ba..05ff9143f 100644 --- a/web/src/pages/Logs.tsx +++ b/web/src/pages/Logs.tsx @@ -1,9 +1,86 @@ +import { Button } from "@/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuLabel, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; import Heading from "@/components/ui/heading"; +import copy from "copy-to-clipboard"; +import { useCallback, useEffect, useState } from "react"; +import useSWR from "swr"; + +const logTypes = ["frigate", "go2rtc", "nginx"] as const; +type LogType = (typeof logTypes)[number]; function Logs() { + const [logService, setLogService] = useState("frigate"); + const [logs, setLogs] = useState("frigate"); + + const { data: frigateLogs } = useSWR("logs/frigate"); + const { data: go2rtcLogs } = useSWR("logs/go2rtc"); + const { data: nginxLogs } = useSWR("logs/nginx"); + + const handleCopyLogs = useCallback(() => { + copy(logs); + }, [logs]); + + useEffect(() => { + switch (logService) { + case "frigate": + setLogs(frigateLogs); + break; + case "go2rtc": + setLogs(go2rtcLogs); + break; + case "nginx": + setLogs(nginxLogs); + break; + } + }, [frigateLogs, go2rtcLogs, nginxLogs, logService, setLogs]); + return ( <> - Logs + + + Logs + + + + + + {logService} Logs + + + + Select Logs To View + + setLogService(type as LogType)} + > + {Object.values(logTypes).map((item) => ( + + {item} Logs + + ))} + + + + Copy to Clipboard + + + + + {logs} + > ); }