mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-18 19:43:00 +03:00
Improve System Health pane (#24188)
* build out system health pane * tweaks * fixes * fix notice link so it opens the correct camera * tweak language
This commit is contained in:
committed by
Nicolas Mowen
parent
6d33b31bc6
commit
70ce193e09
@@ -0,0 +1,67 @@
|
||||
import { useMemo } from "react";
|
||||
import useSWR from "swr";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type {
|
||||
DetectionHardware,
|
||||
HwaccelRecommendation,
|
||||
} from "@/types/hardware";
|
||||
import type { FrigateConfig } from "@/types/frigateConfig";
|
||||
import { useAutoFrigateStats } from "@/hooks/use-stats";
|
||||
import {
|
||||
cameraConnectionCells,
|
||||
detectionRows,
|
||||
enrichmentRows,
|
||||
hwaccelRows,
|
||||
isStartupWindow,
|
||||
} from "@/utils/health";
|
||||
|
||||
export function useHardwareHealth() {
|
||||
const { t } = useTranslation(["views/system", "views/setup"]);
|
||||
const { data: config } = useSWR<FrigateConfig>("config", {
|
||||
revalidateOnFocus: false,
|
||||
});
|
||||
const { data: hardware, error: probeError } = useSWR<DetectionHardware[]>(
|
||||
"hardware/probe",
|
||||
{ revalidateOnFocus: false },
|
||||
);
|
||||
const { data: hwaccel, error: hwaccelError } = useSWR<HwaccelRecommendation>(
|
||||
"hardware/hwaccel",
|
||||
{ revalidateOnFocus: false },
|
||||
);
|
||||
const stats = useAutoFrigateStats();
|
||||
const rows = useMemo(() => {
|
||||
if (!config) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const startup = isStartupWindow(stats);
|
||||
return {
|
||||
detection: detectionRows({
|
||||
models: config.models,
|
||||
hardware,
|
||||
probeFailed: !!probeError,
|
||||
stats,
|
||||
startup,
|
||||
t,
|
||||
}),
|
||||
hwaccel: hwaccelRows({
|
||||
config,
|
||||
hwaccel,
|
||||
hwaccelFailed: !!hwaccelError,
|
||||
stats,
|
||||
t,
|
||||
}),
|
||||
enrichments: enrichmentRows({
|
||||
config,
|
||||
hardware,
|
||||
probeFailed: !!probeError,
|
||||
stats,
|
||||
startup,
|
||||
t,
|
||||
}),
|
||||
cameras: cameraConnectionCells(config, stats),
|
||||
};
|
||||
}, [config, hardware, probeError, hwaccel, hwaccelError, stats, t]);
|
||||
|
||||
return { rows, statsLoaded: !!stats };
|
||||
}
|
||||
Reference in New Issue
Block a user