mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-10 21:25:24 +03:00
Add links to items
This commit is contained in:
parent
7e98d8c687
commit
e55d13f377
@ -43,7 +43,13 @@ export default function Statusbar() {
|
||||
useEffect(() => {
|
||||
clearMessages("stats");
|
||||
potentialProblems.forEach((problem) => {
|
||||
addMessage("stats", problem.text, problem.color);
|
||||
addMessage(
|
||||
"stats",
|
||||
problem.text,
|
||||
problem.color,
|
||||
undefined,
|
||||
problem.relevantLink,
|
||||
);
|
||||
});
|
||||
}, [potentialProblems, addMessage, clearMessages]);
|
||||
|
||||
@ -110,14 +116,25 @@ export default function Statusbar() {
|
||||
) : (
|
||||
Object.entries(messages).map(([key, messageArray]) => (
|
||||
<div key={key} className="h-full flex items-center gap-2">
|
||||
{messageArray.map(({ id, text, color }: StatusMessage) => (
|
||||
<div key={id} className="flex items-center text-sm gap-2">
|
||||
<IoIosWarning
|
||||
className={`size-5 ${color || "text-danger"}`}
|
||||
/>
|
||||
{text}
|
||||
</div>
|
||||
))}
|
||||
{messageArray.map(({ id, text, color, link }: StatusMessage) => {
|
||||
const message = (
|
||||
<div
|
||||
key={id}
|
||||
className={`flex items-center text-sm gap-2 ${link ? "hover:underline cursor-pointer" : ""}`}
|
||||
>
|
||||
<IoIosWarning
|
||||
className={`size-5 ${color || "text-danger"}`}
|
||||
/>
|
||||
{text}
|
||||
</div>
|
||||
);
|
||||
|
||||
if (link) {
|
||||
return <a href={link}>{message}</a>;
|
||||
} else {
|
||||
return message;
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
|
||||
@ -10,6 +10,7 @@ export type StatusMessage = {
|
||||
id: string;
|
||||
text: string;
|
||||
color?: string;
|
||||
link?: string;
|
||||
};
|
||||
|
||||
export type StatusMessagesState = {
|
||||
@ -27,6 +28,7 @@ type StatusBarMessagesContextValue = {
|
||||
message: string,
|
||||
color?: string,
|
||||
messageId?: string,
|
||||
link?: string,
|
||||
) => string;
|
||||
removeMessage: (key: string, messageId: string) => void;
|
||||
clearMessages: (key: string) => void;
|
||||
@ -43,14 +45,20 @@ export function StatusBarMessagesProvider({
|
||||
const messages = useMemo(() => messagesState, [messagesState]);
|
||||
|
||||
const addMessage = useCallback(
|
||||
(key: string, message: string, color?: string, messageId?: string) => {
|
||||
(
|
||||
key: string,
|
||||
message: string,
|
||||
color?: string,
|
||||
messageId?: string,
|
||||
link?: string,
|
||||
) => {
|
||||
const id = messageId || Date.now().toString();
|
||||
const msgColor = color || "text-danger";
|
||||
setMessagesState((prevMessages) => ({
|
||||
...prevMessages,
|
||||
[key]: [
|
||||
...(prevMessages[key] || []),
|
||||
{ id, text: message, color: msgColor },
|
||||
{ id, text: message, color: msgColor, link },
|
||||
],
|
||||
}));
|
||||
return id;
|
||||
|
||||
@ -53,6 +53,7 @@ export default function useStats(stats: FrigateStats | undefined) {
|
||||
problems.push({
|
||||
text: `${capitalizeFirstLetter(name.replaceAll("_", " "))} is offline`,
|
||||
color: "text-danger",
|
||||
relevantLink: "logs",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -62,6 +62,7 @@ export type StorageStats = {
|
||||
export type PotentialProblem = {
|
||||
text: string;
|
||||
color: string;
|
||||
relevantLink?: string;
|
||||
};
|
||||
|
||||
export type Vainfo = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user