Compare commits

..

8 Commits

Author SHA1 Message Date
Josh Hawkins
cfc220e083 fix popovers from being immediately dismissed on safari 2025-11-20 17:38:41 -06:00
Josh Hawkins
e20b788966 fix npu graph 2025-11-20 17:26:53 -06:00
Josh Hawkins
8de0b84227 move npu graph inside of gpu grid 2025-11-20 17:26:09 -06:00
Nicolas Mowen
4ef37df8bd Use skeleton instead of icon 2025-11-20 16:01:33 -07:00
Josh Hawkins
8122c31575 fix re-render crash in camera group mobile page
the callback only needs a single state update for the useeffect to fire
2025-11-20 16:54:38 -06:00
Josh Hawkins
7a7ab98888 always show camera group buttons on mobile so users don't get stuck 2025-11-20 16:39:36 -06:00
Josh Hawkins
bb31dd18a4 camera group changes for custom viewer roles
- hide camera groups with no accessible cameras
- hide camera group edit button
2025-11-20 16:36:26 -06:00
Josh Hawkins
5d3f31175d hide birdseye from custom viewer role users 2025-11-20 16:34:41 -06:00
8 changed files with 333 additions and 270 deletions

View File

@ -177,6 +177,10 @@
"noCameras": { "noCameras": {
"title": "No Cameras Configured", "title": "No Cameras Configured",
"description": "Get started by connecting a camera to Frigate.", "description": "Get started by connecting a camera to Frigate.",
"buttonText": "Add Camera" "buttonText": "Add Camera",
"restricted": {
"title": "No Cameras Available",
"description": "You don't have permission to view any cameras in this group."
}
} }
} }

View File

@ -9,7 +9,7 @@ import useSWR from "swr";
import { MdHome } from "react-icons/md"; import { MdHome } from "react-icons/md";
import { usePersistedOverlayState } from "@/hooks/use-overlay-state"; import { usePersistedOverlayState } from "@/hooks/use-overlay-state";
import { Button, buttonVariants } from "../ui/button"; import { Button, buttonVariants } from "../ui/button";
import { useCallback, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"; import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip";
import { LuPencil, LuPlus } from "react-icons/lu"; import { LuPencil, LuPlus } from "react-icons/lu";
import { import {
@ -87,6 +87,8 @@ type CameraGroupSelectorProps = {
export function CameraGroupSelector({ className }: CameraGroupSelectorProps) { export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
const { t } = useTranslation(["components/camera"]); const { t } = useTranslation(["components/camera"]);
const { data: config } = useSWR<FrigateConfig>("config"); const { data: config } = useSWR<FrigateConfig>("config");
const allowedCameras = useAllowedCameras();
const isCustomRole = useIsCustomRole();
// tooltip // tooltip
@ -119,10 +121,22 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
return []; return [];
} }
return Object.entries(config.camera_groups).sort( const allGroups = Object.entries(config.camera_groups);
(a, b) => a[1].order - b[1].order,
); // If custom role, filter out groups where user has no accessible cameras
}, [config]); if (isCustomRole) {
return allGroups
.filter(([, groupConfig]) => {
// Check if user has access to at least one camera in this group
return groupConfig.cameras.some((cameraName) =>
allowedCameras.includes(cameraName),
);
})
.sort((a, b) => a[1].order - b[1].order);
}
return allGroups.sort((a, b) => a[1].order - b[1].order);
}, [config, allowedCameras, isCustomRole]);
// add group // add group
@ -139,6 +153,7 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
activeGroup={group} activeGroup={group}
setGroup={setGroup} setGroup={setGroup}
deleteGroup={deleteGroup} deleteGroup={deleteGroup}
isCustomRole={isCustomRole}
/> />
<Scroller className={`${isMobile ? "whitespace-nowrap" : ""}`}> <Scroller className={`${isMobile ? "whitespace-nowrap" : ""}`}>
<div <div
@ -206,14 +221,16 @@ export function CameraGroupSelector({ className }: CameraGroupSelectorProps) {
); );
})} })}
<Button {!isCustomRole && (
className="bg-secondary text-muted-foreground" <Button
aria-label={t("group.add")} className="bg-secondary text-muted-foreground"
size="xs" aria-label={t("group.add")}
onClick={() => setAddGroup(true)} size="xs"
> onClick={() => setAddGroup(true)}
<LuPlus className="size-4 text-primary" /> >
</Button> <LuPlus className="size-4 text-primary" />
</Button>
)}
{isMobile && <ScrollBar orientation="horizontal" className="h-0" />} {isMobile && <ScrollBar orientation="horizontal" className="h-0" />}
</div> </div>
</Scroller> </Scroller>
@ -228,6 +245,7 @@ type NewGroupDialogProps = {
activeGroup?: string; activeGroup?: string;
setGroup: (value: string | undefined, replace?: boolean | undefined) => void; setGroup: (value: string | undefined, replace?: boolean | undefined) => void;
deleteGroup: () => void; deleteGroup: () => void;
isCustomRole?: boolean;
}; };
function NewGroupDialog({ function NewGroupDialog({
open, open,
@ -236,6 +254,7 @@ function NewGroupDialog({
activeGroup, activeGroup,
setGroup, setGroup,
deleteGroup, deleteGroup,
isCustomRole,
}: NewGroupDialogProps) { }: NewGroupDialogProps) {
const { t } = useTranslation(["components/camera"]); const { t } = useTranslation(["components/camera"]);
const { mutate: updateConfig } = useSWR<FrigateConfig>("config"); const { mutate: updateConfig } = useSWR<FrigateConfig>("config");
@ -261,6 +280,12 @@ function NewGroupDialog({
`${activeGroup}-draggable-layout`, `${activeGroup}-draggable-layout`,
); );
useEffect(() => {
if (!open) {
setEditState("none");
}
}, [open]);
// callbacks // callbacks
const onDeleteGroup = useCallback( const onDeleteGroup = useCallback(
@ -349,13 +374,7 @@ function NewGroupDialog({
position="top-center" position="top-center"
closeButton={true} closeButton={true}
/> />
<Overlay <Overlay open={open} onOpenChange={setOpen}>
open={open}
onOpenChange={(open) => {
setEditState("none");
setOpen(open);
}}
>
<Content <Content
className={cn( className={cn(
"scrollbar-container overflow-y-auto", "scrollbar-container overflow-y-auto",
@ -371,28 +390,30 @@ function NewGroupDialog({
> >
<Title>{t("group.label")}</Title> <Title>{t("group.label")}</Title>
<Description className="sr-only">{t("group.edit")}</Description> <Description className="sr-only">{t("group.edit")}</Description>
<div {!isCustomRole && (
className={cn( <div
"absolute",
isDesktop && "right-6 top-10",
isMobile && "absolute right-0 top-4",
)}
>
<Button
size="sm"
className={cn( className={cn(
isDesktop && "absolute",
"size-6 rounded-md bg-secondary-foreground p-1 text-background", isDesktop && "right-6 top-10",
isMobile && "text-secondary-foreground", isMobile && "absolute right-0 top-4",
)} )}
aria-label={t("group.add")}
onClick={() => {
setEditState("add");
}}
> >
<LuPlus /> <Button
</Button> size="sm"
</div> className={cn(
isDesktop &&
"size-6 rounded-md bg-secondary-foreground p-1 text-background",
isMobile && "text-secondary-foreground",
)}
aria-label={t("group.add")}
onClick={() => {
setEditState("add");
}}
>
<LuPlus />
</Button>
</div>
)}
</Header> </Header>
<div className="flex flex-col gap-4 md:gap-3"> <div className="flex flex-col gap-4 md:gap-3">
{currentGroups.map((group) => ( {currentGroups.map((group) => (
@ -401,6 +422,7 @@ function NewGroupDialog({
group={group} group={group}
onDeleteGroup={() => onDeleteGroup(group[0])} onDeleteGroup={() => onDeleteGroup(group[0])}
onEditGroup={() => onEditGroup(group)} onEditGroup={() => onEditGroup(group)}
isReadOnly={isCustomRole}
/> />
))} ))}
</div> </div>
@ -512,12 +534,14 @@ type CameraGroupRowProps = {
group: [string, CameraGroupConfig]; group: [string, CameraGroupConfig];
onDeleteGroup: () => void; onDeleteGroup: () => void;
onEditGroup: () => void; onEditGroup: () => void;
isReadOnly?: boolean;
}; };
export function CameraGroupRow({ export function CameraGroupRow({
group, group,
onDeleteGroup, onDeleteGroup,
onEditGroup, onEditGroup,
isReadOnly,
}: CameraGroupRowProps) { }: CameraGroupRowProps) {
const { t } = useTranslation(["components/camera"]); const { t } = useTranslation(["components/camera"]);
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
@ -564,7 +588,7 @@ export function CameraGroupRow({
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
{isMobile && ( {isMobile && !isReadOnly && (
<> <>
<DropdownMenu modal={!isDesktop}> <DropdownMenu modal={!isDesktop}>
<DropdownMenuTrigger> <DropdownMenuTrigger>
@ -589,7 +613,7 @@ export function CameraGroupRow({
</DropdownMenu> </DropdownMenu>
</> </>
)} )}
{!isMobile && ( {!isMobile && !isReadOnly && (
<div className="flex flex-row items-center gap-2"> <div className="flex flex-row items-center gap-2">
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>

View File

@ -377,7 +377,7 @@ export default function Step1NameCamera({
); );
return selectedBrand && return selectedBrand &&
selectedBrand.value != "other" ? ( selectedBrand.value != "other" ? (
<Popover> <Popover modal={true}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<Button <Button
variant="ghost" variant="ghost"

View File

@ -600,7 +600,7 @@ export default function Step3StreamConfig({
<Label className="text-sm font-medium text-primary-variant"> <Label className="text-sm font-medium text-primary-variant">
{t("cameraWizard.step3.roles")} {t("cameraWizard.step3.roles")}
</Label> </Label>
<Popover> <Popover modal={true}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<Button variant="ghost" size="sm" className="h-4 w-4 p-0"> <Button variant="ghost" size="sm" className="h-4 w-4 p-0">
<LuInfo className="size-3" /> <LuInfo className="size-3" />
@ -670,7 +670,7 @@ export default function Step3StreamConfig({
<Label className="text-sm font-medium text-primary-variant"> <Label className="text-sm font-medium text-primary-variant">
{t("cameraWizard.step3.featuresTitle")} {t("cameraWizard.step3.featuresTitle")}
</Label> </Label>
<Popover> <Popover modal={true}>
<PopoverTrigger asChild> <PopoverTrigger asChild>
<Button variant="ghost" size="sm" className="h-4 w-4 p-0"> <Button variant="ghost" size="sm" className="h-4 w-4 p-0">
<LuInfo className="size-3" /> <LuInfo className="size-3" />

View File

@ -93,19 +93,23 @@ function Live() {
const allowedCameras = useAllowedCameras(); const allowedCameras = useAllowedCameras();
const includesBirdseye = useMemo(() => { const includesBirdseye = useMemo(() => {
// Restricted users should never have access to birdseye
if (isCustomRole) {
return false;
}
if ( if (
config && config &&
Object.keys(config.camera_groups).length && Object.keys(config.camera_groups).length &&
cameraGroup && cameraGroup &&
config.camera_groups[cameraGroup] && config.camera_groups[cameraGroup] &&
cameraGroup != "default" && cameraGroup != "default"
(!isCustomRole || "birdseye" in allowedCameras)
) { ) {
return config.camera_groups[cameraGroup].cameras.includes("birdseye"); return config.camera_groups[cameraGroup].cameras.includes("birdseye");
} else { } else {
return false; return false;
} }
}, [config, cameraGroup, allowedCameras, isCustomRole]); }, [config, cameraGroup, isCustomRole]);
const cameras = useMemo(() => { const cameras = useMemo(() => {
if (!config) { if (!config) {

View File

@ -39,6 +39,7 @@ import {
AlertDialogTitle, AlertDialogTitle,
} from "@/components/ui/alert-dialog"; } from "@/components/ui/alert-dialog";
import BlurredIconButton from "@/components/button/BlurredIconButton"; import BlurredIconButton from "@/components/button/BlurredIconButton";
import { Skeleton } from "@/components/ui/skeleton";
const allModelTypes = ["objects", "states"] as const; const allModelTypes = ["objects", "states"] as const;
type ModelType = (typeof allModelTypes)[number]; type ModelType = (typeof allModelTypes)[number];
@ -332,9 +333,7 @@ function ModelCard({ config, onClick, onUpdate, onDelete }: ModelCardProps) {
<ImageShadowOverlay lowerClassName="h-[30%] z-0" /> <ImageShadowOverlay lowerClassName="h-[30%] z-0" />
</> </>
) : ( ) : (
<div className="flex size-full items-center justify-center bg-background_alt"> <Skeleton className="flex size-full items-center justify-center" />
<MdModelTraining className="size-16 text-muted-foreground" />
</div>
)} )}
<div className="absolute bottom-2 left-3 text-lg text-white smart-capitalize"> <div className="absolute bottom-2 left-3 text-lg text-white smart-capitalize">
{config.name} {config.name}

View File

@ -20,7 +20,14 @@ import {
FrigateConfig, FrigateConfig,
} from "@/types/frigateConfig"; } from "@/types/frigateConfig";
import { ReviewSegment } from "@/types/review"; import { ReviewSegment } from "@/types/review";
import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import {
useCallback,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { import {
isDesktop, isDesktop,
isMobile, isMobile,
@ -46,6 +53,8 @@ import { useStreamingSettings } from "@/context/streaming-settings-provider";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { EmptyCard } from "@/components/card/EmptyCard"; import { EmptyCard } from "@/components/card/EmptyCard";
import { BsFillCameraVideoOffFill } from "react-icons/bs"; import { BsFillCameraVideoOffFill } from "react-icons/bs";
import { AuthContext } from "@/context/auth-context";
import { useIsCustomRole } from "@/hooks/use-is-custom-role";
type LiveDashboardViewProps = { type LiveDashboardViewProps = {
cameras: CameraConfig[]; cameras: CameraConfig[];
@ -374,10 +383,6 @@ export default function LiveDashboardView({
onSaveMuting(true); onSaveMuting(true);
}; };
if (cameras.length == 0 && !includeBirdseye) {
return <NoCameraView />;
}
return ( return (
<div <div
className="scrollbar-container size-full select-none overflow-y-auto px-1 pt-2 md:p-2" className="scrollbar-container size-full select-none overflow-y-auto px-1 pt-2 md:p-2"
@ -439,198 +444,215 @@ export default function LiveDashboardView({
</div> </div>
)} )}
{!fullscreen && events && events.length > 0 && ( {cameras.length == 0 && !includeBirdseye ? (
<ScrollArea> <NoCameraView />
<TooltipProvider> ) : (
<div className="flex items-center gap-2 px-1">
{events.map((event) => {
return (
<AnimatedEventCard
key={event.id}
event={event}
selectedGroup={cameraGroup}
updateEvents={updateEvents}
/>
);
})}
</div>
</TooltipProvider>
<ScrollBar orientation="horizontal" />
</ScrollArea>
)}
{!cameraGroup || cameraGroup == "default" || isMobileOnly ? (
<> <>
<div {!fullscreen && events && events.length > 0 && (
className={cn( <ScrollArea>
"mt-2 grid grid-cols-1 gap-2 px-2 md:gap-4", <TooltipProvider>
mobileLayout == "grid" && <div className="flex items-center gap-2 px-1">
"grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4", {events.map((event) => {
isMobile && "px-0", return (
)} <AnimatedEventCard
> key={event.id}
{includeBirdseye && birdseyeConfig?.enabled && ( event={event}
selectedGroup={cameraGroup}
updateEvents={updateEvents}
/>
);
})}
</div>
</TooltipProvider>
<ScrollBar orientation="horizontal" />
</ScrollArea>
)}
{!cameraGroup || cameraGroup == "default" || isMobileOnly ? (
<>
<div <div
className={(() => { className={cn(
const aspectRatio = "mt-2 grid grid-cols-1 gap-2 px-2 md:gap-4",
birdseyeConfig.width / birdseyeConfig.height; mobileLayout == "grid" &&
if (aspectRatio > 2) { "grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4",
return `${mobileLayout == "grid" && "col-span-2"} aspect-wide`; isMobile && "px-0",
} else if (aspectRatio < 1) { )}
return `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
return "aspect-video";
}
})()}
ref={birdseyeContainerRef}
> >
<BirdseyeLivePlayer {includeBirdseye && birdseyeConfig?.enabled && (
birdseyeConfig={birdseyeConfig}
liveMode={birdseyeConfig.restream ? "mse" : "jsmpeg"}
onClick={() => onSelectCamera("birdseye")}
containerRef={birdseyeContainerRef}
/>
</div>
)}
{cameras.map((camera) => {
let grow;
const aspectRatio = camera.detect.width / camera.detect.height;
if (aspectRatio > 2) {
grow = `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
} else if (aspectRatio < 1) {
grow = `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
grow = "aspect-video";
}
const availableStreams = camera.live.streams || {};
const firstStreamEntry = Object.values(availableStreams)[0] || "";
const streamNameFromSettings =
currentGroupStreamingSettings?.[camera.name]?.streamName || "";
const streamExists =
streamNameFromSettings &&
Object.values(availableStreams).includes(
streamNameFromSettings,
);
const streamName = streamExists
? streamNameFromSettings
: firstStreamEntry;
const streamType =
currentGroupStreamingSettings?.[camera.name]?.streamType;
const autoLive =
streamType !== undefined
? streamType !== "no-streaming"
: undefined;
const showStillWithoutActivity =
currentGroupStreamingSettings?.[camera.name]?.streamType !==
"continuous";
const useWebGL =
currentGroupStreamingSettings?.[camera.name]
?.compatibilityMode || false;
return (
<LiveContextMenu
className={grow}
key={camera.name}
camera={camera.name}
cameraGroup={cameraGroup}
streamName={streamName}
preferredLiveMode={preferredLiveModes[camera.name] ?? "mse"}
isRestreamed={isRestreamedStates[camera.name]}
supportsAudio={
supportsAudioOutputStates[streamName]?.supportsAudio ??
false
}
audioState={audioStates[camera.name]}
toggleAudio={() => toggleAudio(camera.name)}
statsState={statsStates[camera.name]}
toggleStats={() => toggleStats(camera.name)}
volumeState={volumeStates[camera.name] ?? 1}
setVolumeState={(value) =>
setVolumeStates({
[camera.name]: value,
})
}
muteAll={muteAll}
unmuteAll={unmuteAll}
resetPreferredLiveMode={() =>
resetPreferredLiveMode(camera.name)
}
config={config}
>
<LivePlayer
cameraRef={cameraRef}
key={camera.name}
className={`${grow} rounded-lg bg-black md:rounded-2xl`}
windowVisible={
windowVisible && visibleCameras.includes(camera.name)
}
cameraConfig={camera}
preferredLiveMode={preferredLiveModes[camera.name] ?? "mse"}
autoLive={autoLive ?? globalAutoLive}
showStillWithoutActivity={showStillWithoutActivity ?? true}
alwaysShowCameraName={displayCameraNames}
useWebGL={useWebGL}
playInBackground={false}
showStats={statsStates[camera.name]}
streamName={streamName}
onClick={() => onSelectCamera(camera.name)}
onError={(e) => handleError(camera.name, e)}
onResetLiveMode={() => resetPreferredLiveMode(camera.name)}
playAudio={audioStates[camera.name] ?? false}
volume={volumeStates[camera.name]}
/>
</LiveContextMenu>
);
})}
</div>
{isDesktop && (
<div
className={cn(
"fixed",
isDesktop && "bottom-12 lg:bottom-9",
isMobile && "bottom-12 lg:bottom-16",
hasScrollbar && isDesktop ? "right-6" : "right-3",
"z-50 flex flex-row gap-2",
)}
>
<Tooltip>
<TooltipTrigger asChild>
<div <div
className="cursor-pointer rounded-lg bg-secondary text-secondary-foreground opacity-60 transition-all duration-300 hover:bg-muted hover:opacity-100" className={(() => {
onClick={toggleFullscreen} const aspectRatio =
birdseyeConfig.width / birdseyeConfig.height;
if (aspectRatio > 2) {
return `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
} else if (aspectRatio < 1) {
return `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
return "aspect-video";
}
})()}
ref={birdseyeContainerRef}
> >
{fullscreen ? ( <BirdseyeLivePlayer
<FaCompress className="size-5 md:m-[6px]" /> birdseyeConfig={birdseyeConfig}
) : ( liveMode={birdseyeConfig.restream ? "mse" : "jsmpeg"}
<FaExpand className="size-5 md:m-[6px]" /> onClick={() => onSelectCamera("birdseye")}
)} containerRef={birdseyeContainerRef}
/>
</div> </div>
</TooltipTrigger> )}
<TooltipContent> {cameras.map((camera) => {
{fullscreen let grow;
? t("button.exitFullscreen", { ns: "common" }) const aspectRatio =
: t("button.fullscreen", { ns: "common" })} camera.detect.width / camera.detect.height;
</TooltipContent> if (aspectRatio > 2) {
</Tooltip> grow = `${mobileLayout == "grid" && "col-span-2"} aspect-wide`;
</div> } else if (aspectRatio < 1) {
grow = `${mobileLayout == "grid" && "row-span-2 h-full"} aspect-tall`;
} else {
grow = "aspect-video";
}
const availableStreams = camera.live.streams || {};
const firstStreamEntry =
Object.values(availableStreams)[0] || "";
const streamNameFromSettings =
currentGroupStreamingSettings?.[camera.name]?.streamName ||
"";
const streamExists =
streamNameFromSettings &&
Object.values(availableStreams).includes(
streamNameFromSettings,
);
const streamName = streamExists
? streamNameFromSettings
: firstStreamEntry;
const streamType =
currentGroupStreamingSettings?.[camera.name]?.streamType;
const autoLive =
streamType !== undefined
? streamType !== "no-streaming"
: undefined;
const showStillWithoutActivity =
currentGroupStreamingSettings?.[camera.name]?.streamType !==
"continuous";
const useWebGL =
currentGroupStreamingSettings?.[camera.name]
?.compatibilityMode || false;
return (
<LiveContextMenu
className={grow}
key={camera.name}
camera={camera.name}
cameraGroup={cameraGroup}
streamName={streamName}
preferredLiveMode={
preferredLiveModes[camera.name] ?? "mse"
}
isRestreamed={isRestreamedStates[camera.name]}
supportsAudio={
supportsAudioOutputStates[streamName]?.supportsAudio ??
false
}
audioState={audioStates[camera.name]}
toggleAudio={() => toggleAudio(camera.name)}
statsState={statsStates[camera.name]}
toggleStats={() => toggleStats(camera.name)}
volumeState={volumeStates[camera.name] ?? 1}
setVolumeState={(value) =>
setVolumeStates({
[camera.name]: value,
})
}
muteAll={muteAll}
unmuteAll={unmuteAll}
resetPreferredLiveMode={() =>
resetPreferredLiveMode(camera.name)
}
config={config}
>
<LivePlayer
cameraRef={cameraRef}
key={camera.name}
className={`${grow} rounded-lg bg-black md:rounded-2xl`}
windowVisible={
windowVisible && visibleCameras.includes(camera.name)
}
cameraConfig={camera}
preferredLiveMode={
preferredLiveModes[camera.name] ?? "mse"
}
autoLive={autoLive ?? globalAutoLive}
showStillWithoutActivity={
showStillWithoutActivity ?? true
}
alwaysShowCameraName={displayCameraNames}
useWebGL={useWebGL}
playInBackground={false}
showStats={statsStates[camera.name]}
streamName={streamName}
onClick={() => onSelectCamera(camera.name)}
onError={(e) => handleError(camera.name, e)}
onResetLiveMode={() =>
resetPreferredLiveMode(camera.name)
}
playAudio={audioStates[camera.name] ?? false}
volume={volumeStates[camera.name]}
/>
</LiveContextMenu>
);
})}
</div>
{isDesktop && (
<div
className={cn(
"fixed",
isDesktop && "bottom-12 lg:bottom-9",
isMobile && "bottom-12 lg:bottom-16",
hasScrollbar && isDesktop ? "right-6" : "right-3",
"z-50 flex flex-row gap-2",
)}
>
<Tooltip>
<TooltipTrigger asChild>
<div
className="cursor-pointer rounded-lg bg-secondary text-secondary-foreground opacity-60 transition-all duration-300 hover:bg-muted hover:opacity-100"
onClick={toggleFullscreen}
>
{fullscreen ? (
<FaCompress className="size-5 md:m-[6px]" />
) : (
<FaExpand className="size-5 md:m-[6px]" />
)}
</div>
</TooltipTrigger>
<TooltipContent>
{fullscreen
? t("button.exitFullscreen", { ns: "common" })
: t("button.fullscreen", { ns: "common" })}
</TooltipContent>
</Tooltip>
</div>
)}
</>
) : (
<DraggableGridLayout
cameras={cameras}
cameraGroup={cameraGroup}
containerRef={containerRef}
cameraRef={cameraRef}
includeBirdseye={includeBirdseye}
onSelectCamera={onSelectCamera}
windowVisible={windowVisible}
visibleCameras={visibleCameras}
isEditMode={isEditMode}
setIsEditMode={setIsEditMode}
fullscreen={fullscreen}
toggleFullscreen={toggleFullscreen}
/>
)} )}
</> </>
) : (
<DraggableGridLayout
cameras={cameras}
cameraGroup={cameraGroup}
containerRef={containerRef}
cameraRef={cameraRef}
includeBirdseye={includeBirdseye}
onSelectCamera={onSelectCamera}
windowVisible={windowVisible}
visibleCameras={visibleCameras}
isEditMode={isEditMode}
setIsEditMode={setIsEditMode}
fullscreen={fullscreen}
toggleFullscreen={toggleFullscreen}
/>
)} )}
</div> </div>
); );
@ -638,15 +660,26 @@ export default function LiveDashboardView({
function NoCameraView() { function NoCameraView() {
const { t } = useTranslation(["views/live"]); const { t } = useTranslation(["views/live"]);
const { auth } = useContext(AuthContext);
const isCustomRole = useIsCustomRole();
// Check if this is a restricted user with no cameras in this group
const isRestricted = isCustomRole && auth.isAuthenticated;
return ( return (
<div className="flex size-full items-center justify-center"> <div className="flex size-full items-center justify-center">
<EmptyCard <EmptyCard
icon={<BsFillCameraVideoOffFill className="size-8" />} icon={<BsFillCameraVideoOffFill className="size-8" />}
title={t("noCameras.title")} title={
description={t("noCameras.description")} isRestricted ? t("noCameras.restricted.title") : t("noCameras.title")
buttonText={t("noCameras.buttonText")} }
link="/settings?page=cameraManagement" description={
isRestricted
? t("noCameras.restricted.description")
: t("noCameras.description")
}
buttonText={!isRestricted ? t("noCameras.buttonText") : undefined}
link={!isRestricted ? "/settings?page=cameraManagement" : undefined}
/> />
</div> </div>
); );

View File

@ -729,33 +729,32 @@ export default function GeneralMetrics({
) : ( ) : (
<Skeleton className="aspect-video w-full" /> <Skeleton className="aspect-video w-full" />
)} )}
</>
)} {statsHistory[0]?.npu_usages && (
{statsHistory[0]?.npu_usages && ( <>
<div {statsHistory.length != 0 ? (
className={cn("mt-4 grid grid-cols-1 gap-2 sm:grid-cols-2")} <div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl">
> <div className="mb-5">
{statsHistory.length != 0 ? ( {t("general.hardwareInfo.npuUsage")}
<div className="rounded-lg bg-background_alt p-2.5 md:rounded-2xl"> </div>
<div className="mb-5"> {npuSeries.map((series) => (
{t("general.hardwareInfo.npuUsage")} <ThresholdBarGraph
</div> key={series.name}
{npuSeries.map((series) => ( graphId={`${series.name}-npu`}
<ThresholdBarGraph name={series.name}
key={series.name} unit="%"
graphId={`${series.name}-npu`} threshold={GPUUsageThreshold}
name={series.name} updateTimes={updateTimes}
unit="%" data={[series]}
threshold={GPUUsageThreshold} />
updateTimes={updateTimes} ))}
data={[series]} </div>
/> ) : (
))} <Skeleton className="aspect-video w-full" />
</div> )}
) : ( </>
<Skeleton className="aspect-video w-full" />
)} )}
</div> </>
)} )}
</div> </div>
</> </>