mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 21:44:13 +03:00
* Implement alerts on statusbar when a potential problem is detected * Add alert to mobile
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import { navbarLinks } from "@/pages/site-navigation";
|
|
import NavItem from "./NavItem";
|
|
import SettingsNavItems from "../settings/SettingsNavItems";
|
|
import { IoIosWarning } from "react-icons/io";
|
|
import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer";
|
|
import useSWR from "swr";
|
|
import { FrigateStats } from "@/types/stats";
|
|
import { useFrigateStats } from "@/api/ws";
|
|
import { useMemo } from "react";
|
|
import useStats from "@/hooks/use-stats";
|
|
|
|
function Bottombar() {
|
|
return (
|
|
<div className="absolute h-16 inset-x-4 bottom-0 flex flex-row items-center justify-between">
|
|
{navbarLinks.map((item) => (
|
|
<NavItem
|
|
className=""
|
|
variant="secondary"
|
|
key={item.id}
|
|
Icon={item.icon}
|
|
title={item.title}
|
|
url={item.url}
|
|
dev={item.dev}
|
|
/>
|
|
))}
|
|
<SettingsNavItems className="flex flex-shrink-0 justify-between gap-4" />
|
|
<StatusAlertNav />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function StatusAlertNav() {
|
|
const { data: initialStats } = useSWR<FrigateStats>("stats", {
|
|
revalidateOnFocus: false,
|
|
});
|
|
const { payload: latestStats } = useFrigateStats();
|
|
const stats = useMemo(() => {
|
|
if (latestStats) {
|
|
return latestStats;
|
|
}
|
|
|
|
return initialStats;
|
|
}, [initialStats, latestStats]);
|
|
const { potentialProblems } = useStats(stats);
|
|
|
|
if (!potentialProblems || potentialProblems.length == 0) {
|
|
return;
|
|
}
|
|
|
|
return (
|
|
<Drawer>
|
|
<DrawerTrigger>
|
|
<IoIosWarning className="size-5 text-danger" />
|
|
</DrawerTrigger>
|
|
<DrawerContent className="max-h-[75dvh] px-2 mx-1 rounded-t-2xl overflow-hidden">
|
|
<div className="w-full h-auto py-4 overflow-y-auto overflow-x-hidden flex flex-col items-center gap-2">
|
|
{potentialProblems.map((prob) => (
|
|
<div className="w-full flex items-center text-xs gap-2 capitalize">
|
|
<IoIosWarning className={`size-5 ${prob.color}`} />
|
|
{prob.text}
|
|
</div>
|
|
))}
|
|
</div>
|
|
</DrawerContent>
|
|
</Drawer>
|
|
);
|
|
}
|
|
|
|
export default Bottombar;
|