mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-23 22:07:07 +03:00
* Notice and status bar improvements Status bar problems added in the same pass got the same `Date.now()` id and overwrote each other, so usually only one showed. Messages now fall back to their text as the id. The desktop status bar shows the most severe message with a count of the rest that opens a popover listing all of them, and the mobile drawer stacks them vertically instead of placing them side by side. Dismissing a notice hid it for good, so a detector that restarted again after a dismissal was never shown. Dismiss is replaced by acknowledge, which hides a notice until it happens again, and mute, which hides it permanently. Kinds that never repeat (config and stream checks, the update notice) can only be muted. `reopen_at_count` is removed since acknowledge covers the failed login case. * move camera CPU warnings to notices High ffmpeg and detect CPU warnings sat in the status bar with no way to dismiss them. They're now `ffmpeg_high_cpu` and `detect_high_cpu` notices, raised per episode by the same tracker as skipped detections. Also stop failed login attempts held from before an acknowledgement from reopening the notice. * fix mypy and handle missing cpu stats in notices
79 lines
1.7 KiB
TypeScript
79 lines
1.7 KiB
TypeScript
import { StatusMessage } from "@/context/statusbar-context";
|
|
import { cn } from "@/lib/utils";
|
|
import { ProblemSeverity } from "@/types/stats";
|
|
import { IoIosWarning } from "react-icons/io";
|
|
import { Link } from "react-router-dom";
|
|
|
|
const SEVERITY_COLOR: Record<ProblemSeverity, string> = {
|
|
error: "text-danger",
|
|
warning: "text-orange-400",
|
|
info: "text-selected",
|
|
};
|
|
|
|
type StatusMessageItemProps = {
|
|
message: StatusMessage;
|
|
className?: string;
|
|
onNavigate?: () => void;
|
|
};
|
|
|
|
/** One status bar message, a link when it has one. */
|
|
export function StatusMessageItem({
|
|
message,
|
|
className,
|
|
onNavigate,
|
|
}: StatusMessageItemProps) {
|
|
const content = (
|
|
<div
|
|
className={cn(
|
|
"flex items-center gap-2 text-sm",
|
|
message.link && "cursor-pointer hover:underline",
|
|
className,
|
|
)}
|
|
>
|
|
<IoIosWarning
|
|
className={cn("size-5 shrink-0", SEVERITY_COLOR[message.severity])}
|
|
/>
|
|
{message.text}
|
|
</div>
|
|
);
|
|
|
|
if (!message.link) {
|
|
return content;
|
|
}
|
|
|
|
return (
|
|
<Link to={message.link} onClick={onNavigate}>
|
|
{content}
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
type StatusMessageListProps = {
|
|
messages: StatusMessage[];
|
|
className?: string;
|
|
onNavigate?: () => void;
|
|
};
|
|
|
|
/** Status bar messages stacked one per line. */
|
|
export default function StatusMessageList({
|
|
messages,
|
|
className,
|
|
onNavigate,
|
|
}: StatusMessageListProps) {
|
|
return (
|
|
<div
|
|
className={cn("flex flex-col gap-2", className)}
|
|
data-testid="status-message-list"
|
|
>
|
|
{messages.map((message, index) => (
|
|
// ids are unique only within a message key
|
|
<StatusMessageItem
|
|
key={`${index}:${message.id}`}
|
|
message={message}
|
|
onNavigate={onNavigate}
|
|
/>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|