hide recordings page if record is not enabled, show error if no recordings available.

This commit is contained in:
Jason Hunter
2021-06-05 20:40:52 -04:00
committed by Blake Blackshear
parent 0bb998c465
commit 68dfaaf767
4 changed files with 37 additions and 17 deletions

View File

@@ -9,7 +9,7 @@ import NavigationDrawer, { Destination, Separator } from './components/Navigatio
export default function Sidebar() {
const { data: config } = useConfig();
const cameras = useMemo(() => Object.keys(config.cameras), [config]);
const cameras = useMemo(() => Object.entries(config.cameras), [config]);
return (
<NavigationDrawer header={<Header />}>
@@ -19,7 +19,7 @@ export default function Sidebar() {
matches ? (
<Fragment>
<Separator />
{cameras.map((camera) => (
{cameras.map(([camera]) => (
<Destination href={`/cameras/${camera}`} text={camera} />
))}
<Separator />
@@ -32,13 +32,18 @@ export default function Sidebar() {
matches ? (
<Fragment>
<Separator />
{cameras.map((camera) => (
<Destination
path={`/recording/${camera}/:date?/:hour?/:seconds?`}
href={`/recording/${camera}`}
text={camera}
/>
))}
{cameras.map(([camera, conf]) => {
if (conf.record.enabled) {
return (
<Destination
path={`/recording/${camera}/:date?/:hour?/:seconds?`}
href={`/recording/${camera}`}
text={camera}
/>
);
}
return null;
})}
<Separator />
</Fragment>
) : null