mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-04-01 10:13:43 -04:00
ADD set search param after selected cam
Signed-off-by: Damian Krysta <damian@krysta.dev>
This commit is contained in:
parent
2d517c28dc
commit
3988c3922d
@ -9,6 +9,7 @@ import { Camera } from "../types";
|
|||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import { Theme } from "@mui/material/styles";
|
import { Theme } from "@mui/material/styles";
|
||||||
import {useSearchParams} from "react-router-dom";
|
import {useSearchParams} from "react-router-dom";
|
||||||
|
import {isNullOrUndefined} from "util";
|
||||||
|
|
||||||
export interface Layout {
|
export interface Layout {
|
||||||
className: string;
|
className: string;
|
||||||
@ -205,13 +206,19 @@ const Monoview = (props: MonoviewProps) => {
|
|||||||
const {
|
const {
|
||||||
target: { value },
|
target: { value },
|
||||||
} = event;
|
} = event;
|
||||||
|
if (value !== null && value !== undefined) {
|
||||||
|
setSearchParams(new URLSearchParams({cam: value.toString()}));
|
||||||
|
} else {
|
||||||
|
setSearchParams(new URLSearchParams({ }))
|
||||||
|
}
|
||||||
|
|
||||||
props.onSelect(typeof value === "string" ? parseInt(value) : value);
|
props.onSelect(typeof value === "string" ? parseInt(value) : value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fromQueryOrFirst = searchParams.has('cam') ? Number.parseInt(searchParams.get('cam') as string, 10) : 0;
|
const fromQueryIndexOrNull = searchParams.has('cam') ? Number.parseInt(searchParams.get('cam') as string, 10) : null;
|
||||||
const chooser = (
|
const chooser = (
|
||||||
<Select
|
<Select
|
||||||
value={props.cameraIndex == null ? fromQueryOrFirst: props.cameraIndex}
|
value={props.cameraIndex == null ? fromQueryIndexOrNull: props.cameraIndex}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
displayEmpty
|
displayEmpty
|
||||||
size="small"
|
size="small"
|
||||||
@ -232,7 +239,7 @@ const Monoview = (props: MonoviewProps) => {
|
|||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
return props.renderCamera(
|
return props.renderCamera(
|
||||||
props.cameraIndex === null ? props.cameras[fromQueryOrFirst] : props.cameras[props.cameraIndex],
|
props.cameraIndex === null ? fromQueryIndexOrNull === null ? null : props.cameras[fromQueryIndexOrNull] : props.cameras[props.cameraIndex],
|
||||||
chooser
|
chooser
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user