mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45:25 +03:00
Show camera name when camera is offline
This commit is contained in:
parent
d658035b60
commit
ff57e4daff
@ -46,7 +46,7 @@ export default function LivePlayer({
|
|||||||
}: LivePlayerProps) {
|
}: LivePlayerProps) {
|
||||||
// camera activity
|
// camera activity
|
||||||
|
|
||||||
const { activeMotion, activeTracking, objects } =
|
const { activeMotion, activeTracking, objects, offline } =
|
||||||
useCameraActivity(cameraConfig);
|
useCameraActivity(cameraConfig);
|
||||||
|
|
||||||
const cameraActive = useMemo(
|
const cameraActive = useMemo(
|
||||||
@ -224,9 +224,16 @@ export default function LivePlayer({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="absolute right-2 top-2 size-4">
|
<div className="absolute right-2 top-2">
|
||||||
{activeMotion && (
|
{!offline && activeMotion && (
|
||||||
<MdCircle className="size-2 animate-pulse text-danger shadow-danger drop-shadow-md" />
|
<MdCircle className="mr-2 size-2 animate-pulse text-danger shadow-danger drop-shadow-md" />
|
||||||
|
)}
|
||||||
|
{offline && (
|
||||||
|
<Chip
|
||||||
|
className={`z-0 flex items-start justify-between space-x-1 bg-gray-500 bg-gradient-to-br from-gray-400 to-gray-500 text-xs capitalize`}
|
||||||
|
>
|
||||||
|
{cameraConfig.name.replaceAll("_", " ")}
|
||||||
|
</Chip>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
useFrigateEvents,
|
useFrigateEvents,
|
||||||
|
useFrigateStats,
|
||||||
useInitialCameraState,
|
useInitialCameraState,
|
||||||
useMotionActivity,
|
useMotionActivity,
|
||||||
} from "@/api/ws";
|
} from "@/api/ws";
|
||||||
@ -10,11 +11,13 @@ import { useTimelineUtils } from "./use-timeline-utils";
|
|||||||
import { ObjectType } from "@/types/ws";
|
import { ObjectType } from "@/types/ws";
|
||||||
import useDeepMemo from "./use-deep-memo";
|
import useDeepMemo from "./use-deep-memo";
|
||||||
import { isEqual } from "lodash";
|
import { isEqual } from "lodash";
|
||||||
|
import useStats from "./use-stats";
|
||||||
|
|
||||||
type useCameraActivityReturn = {
|
type useCameraActivityReturn = {
|
||||||
activeTracking: boolean;
|
activeTracking: boolean;
|
||||||
activeMotion: boolean;
|
activeMotion: boolean;
|
||||||
objects: ObjectType[];
|
objects: ObjectType[];
|
||||||
|
offline: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useCameraActivity(
|
export function useCameraActivity(
|
||||||
@ -116,12 +119,31 @@ export function useCameraActivity(
|
|||||||
handleSetObjects(newObjects);
|
handleSetObjects(newObjects);
|
||||||
}, [camera, updatedEvent, objects, handleSetObjects]);
|
}, [camera, updatedEvent, objects, handleSetObjects]);
|
||||||
|
|
||||||
|
// determine if camera is offline
|
||||||
|
|
||||||
|
const { payload: frigateStats } = useFrigateStats();
|
||||||
|
|
||||||
|
const offline = useMemo(() => {
|
||||||
|
if (!frigateStats) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cameras = frigateStats["cameras"];
|
||||||
|
|
||||||
|
if (!cameras) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cameras[camera.name].camera_fps == 0;
|
||||||
|
}, [camera, frigateStats]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTracking: hasActiveObjects,
|
activeTracking: hasActiveObjects,
|
||||||
activeMotion: detectingMotion
|
activeMotion: detectingMotion
|
||||||
? detectingMotion === "ON"
|
? detectingMotion === "ON"
|
||||||
: initialCameraState?.motion === true,
|
: initialCameraState?.motion === true,
|
||||||
objects,
|
objects,
|
||||||
|
offline,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user