import { Link } from "react-router-dom"; import Logo from "@/components/Logo"; import { LuActivity, LuGithub, LuHardDrive, LuLifeBuoy, LuMenu, LuMoon, LuMoreVertical, LuPenSquare, LuRotateCw, LuSettings, LuSun, LuSunMoon, } from "react-icons/lu"; import { IoColorPalette } from "react-icons/io5"; import { CgDarkMode } from "react-icons/cg"; import { Button } from "@/components/ui/button"; import Heading from "./ui/heading"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { colorSchemes, friendlyColorSchemeName, useTheme, } from "@/context/theme-provider"; import { useEffect, useState } from "react"; import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "./ui/sheet"; import ActivityIndicator from "./ui/activity-indicator"; import { useRestart } from "@/api/ws"; type HeaderProps = { onToggleNavbar: () => void; }; function Header({ onToggleNavbar }: HeaderProps) { const { theme, colorScheme, setTheme, setColorScheme } = useTheme(); const [restartDialogOpen, setRestartDialogOpen] = useState(false); const [restartingSheetOpen, setRestartingSheetOpen] = useState(false); const [countdown, setCountdown] = useState(60); const { send: sendRestart } = useRestart(); useEffect(() => { let countdownInterval: NodeJS.Timeout; if (restartingSheetOpen) { countdownInterval = setInterval(() => { setCountdown((prevCountdown) => prevCountdown - 1); }, 1000); } return () => { clearInterval(countdownInterval); }; }, [restartingSheetOpen]); useEffect(() => { if (countdown === 0) { window.location.href = "/"; } }, [countdown]); const handleForceReload = () => { window.location.href = "/"; }; return (
Frigate
System Storage System metrics Configuration Settings Configuration editor Appearance Dark Mode setTheme("light")}> {theme === "light" ? ( <> Light ) : ( Light )} setTheme("dark")}> {theme === "dark" ? ( <> Dark ) : ( Dark )} setTheme("system")}> {theme === "system" ? ( <> System ) : ( System )} Theme {colorSchemes.map((scheme) => ( setColorScheme(scheme)} > {scheme === colorScheme ? ( <> {friendlyColorSchemeName(scheme)} ) : ( {friendlyColorSchemeName(scheme)} )} ))} Help Documentation GitHub setRestartDialogOpen(true)}> Restart Frigate
{restartDialogOpen && ( setRestartDialogOpen(false)} > Are you sure you want to restart Frigate? Cancel { setRestartingSheetOpen(true); sendRestart("restart"); }} > Restart )} {restartingSheetOpen && ( <> setRestartingSheetOpen(false)} > e.preventDefault()} >
Frigate is Restarting

This page will reload in {countdown} seconds.

)}
); } export default Header;