Minor fixes:
removed clock added navigation arrow to main sighting screen added zoom functionality to rear (camera B) settings brought back navigation to rear cam page
This commit is contained in:
@@ -10,6 +10,7 @@ const FrontCameraOverviewCard = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const handlers = useSwipeable({
|
const handlers = useSwipeable({
|
||||||
onSwipedRight: () => navigate("/camera-settings"),
|
onSwipedRight: () => navigate("/camera-settings"),
|
||||||
|
onSwipedLeft: () => navigate("/rear-camera-settings"),
|
||||||
trackMouse: true,
|
trackMouse: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { SnapshotContainer } from "../CameraOverview/SnapshotContainer";
|
import { SnapshotContainer } from "../CameraOverview/SnapshotContainer";
|
||||||
import Card from "../UI/Card";
|
import Card from "../UI/Card";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate, useLocation } from "react-router";
|
||||||
import { useSwipeable } from "react-swipeable";
|
import { useSwipeable } from "react-swipeable";
|
||||||
import type { ZoomLevel } from "../../types/types";
|
import type { ZoomLevel } from "../../types/types";
|
||||||
|
|
||||||
@@ -18,8 +18,17 @@ const OverviewVideoContainer = ({
|
|||||||
onZoomLevelChange?: (level: ZoomLevel) => void;
|
onZoomLevelChange?: (level: ZoomLevel) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
|
console.log(location);
|
||||||
const handlers = useSwipeable({
|
const handlers = useSwipeable({
|
||||||
onSwipedLeft: () => navigate("/"),
|
onSwipedLeft: () => {
|
||||||
|
if (location.pathname === "/rear-camera-settings") return;
|
||||||
|
navigate("/");
|
||||||
|
},
|
||||||
|
onSwipedRight: () => {
|
||||||
|
if (location.pathname === "/camera-settings") return;
|
||||||
|
navigate("/");
|
||||||
|
},
|
||||||
trackMouse: true,
|
trackMouse: true,
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const SightingOverview = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col md:flex-row">
|
<div className="flex flex-col md:flex-row">
|
||||||
<NavigationArrow side={side} />
|
<NavigationArrow side={side} />
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
{mostRecent && (
|
{mostRecent && (
|
||||||
<div className="absolute inset-0 z-50 px-1 pt-2">
|
<div className="absolute inset-0 z-50 px-1 pt-2">
|
||||||
|
|||||||
@@ -3,56 +3,25 @@ import Logo from "/MAV.svg";
|
|||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import {
|
import {
|
||||||
faGear,
|
faGear,
|
||||||
|
faHome,
|
||||||
faListCheck,
|
faListCheck,
|
||||||
faMaximize,
|
faMaximize,
|
||||||
faMinimize,
|
faMinimize,
|
||||||
faRotate,
|
faRotate,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import type { VersionFieldType } from "../../types/types";
|
import { useState } from "react";
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import SoundBtn from "./SoundBtn";
|
import SoundBtn from "./SoundBtn";
|
||||||
import { useNPEDContext } from "../../context/NPEDUserContext";
|
import { useNPEDContext } from "../../context/NPEDUserContext";
|
||||||
|
|
||||||
async function fetchVersions(
|
|
||||||
signal?: AbortSignal
|
|
||||||
): Promise<VersionFieldType | undefined> {
|
|
||||||
try {
|
|
||||||
const res = await fetch("http://192.168.75.11/api/versions", { signal });
|
|
||||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
||||||
return res.json();
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const pad = (n: number) => String(n).padStart(2, "0");
|
|
||||||
const normalizeToMs = (ts: number) => (ts < 1e12 ? ts * 1000 : ts); // seconds → ms if needed
|
|
||||||
|
|
||||||
function formatFromMs(ms: number, tz: "local" | "utc" = "local") {
|
|
||||||
const d = new Date(ms);
|
|
||||||
const h = tz === "utc" ? d.getUTCHours() : d.getHours();
|
|
||||||
const m = tz === "utc" ? d.getUTCMinutes() : d.getMinutes();
|
|
||||||
const s = tz === "utc" ? d.getUTCSeconds() : d.getSeconds();
|
|
||||||
const day = tz === "utc" ? d.getUTCDate() : d.getDate();
|
|
||||||
const month = (tz === "utc" ? d.getUTCMonth() : d.getMonth()) + 1;
|
|
||||||
const year = tz === "utc" ? d.getUTCFullYear() : d.getFullYear();
|
|
||||||
return `${pad(h)}:${pad(m)}:${pad(s)} ${pad(day)}-${pad(month)}-${year}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
const [offsetMs, setOffsetMs] = useState<number | null>(null);
|
|
||||||
const [nowMs, setNowMs] = useState<number>(Date.now());
|
|
||||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||||
const { sessionStarted } = useNPEDContext();
|
const { sessionStarted } = useNPEDContext();
|
||||||
|
|
||||||
const toggleFullscreen = () => {
|
const toggleFullscreen = () => {
|
||||||
if (!document.fullscreenElement) {
|
if (!document.fullscreenElement) {
|
||||||
// Enter fullscreen on the entire app
|
|
||||||
document.documentElement.requestFullscreen();
|
document.documentElement.requestFullscreen();
|
||||||
setIsFullscreen(true);
|
setIsFullscreen(true);
|
||||||
} else {
|
} else {
|
||||||
// Exit fullscreen
|
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
setIsFullscreen(false);
|
setIsFullscreen(false);
|
||||||
}
|
}
|
||||||
@@ -62,38 +31,8 @@ export default function Header() {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const ac = new AbortController();
|
|
||||||
fetchVersions(ac.signal)
|
|
||||||
.then((data) => {
|
|
||||||
if (!data) throw new Error("No data");
|
|
||||||
const serverMs = normalizeToMs(data?.timeStamp);
|
|
||||||
setOffsetMs(serverMs - Date.now());
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
return () => ac.abort("failed");
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let timer: number;
|
|
||||||
const schedule = () => {
|
|
||||||
const now = Date.now();
|
|
||||||
setNowMs(now);
|
|
||||||
const delay = 1000 - (now % 1000);
|
|
||||||
timer = window.setTimeout(schedule, delay);
|
|
||||||
};
|
|
||||||
schedule();
|
|
||||||
return () => clearTimeout(timer);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const serverNowMs = offsetMs == null ? nowMs : nowMs + offsetMs;
|
|
||||||
const localStr = formatFromMs(serverNowMs, "local");
|
|
||||||
const utcStr = formatFromMs(serverNowMs, "utc");
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative bg-[#253445] border-b border-gray-500 items-center mx-auto px-2 sm:px-6 lg:px-8 p-4 flex flex-col md:flex-row justify-between">
|
<div className="relative bg-[#253445] border-b border-gray-500 items-center mx-auto px-2 sm:px-6 lg:px-8 p-4 flex flex-col md:flex-row justify-between mb-7">
|
||||||
<div className="w-30">
|
<div className="w-30">
|
||||||
<Link to={"/"}>
|
<Link to={"/"}>
|
||||||
<img src={Logo} alt="Logo" width={150} height={150} />
|
<img src={Logo} alt="Logo" width={150} height={150} />
|
||||||
@@ -103,11 +42,11 @@ export default function Header() {
|
|||||||
{sessionStarted && (
|
{sessionStarted && (
|
||||||
<div className="text-green-400 font-bold">Session Active</div>
|
<div className="text-green-400 font-bold">Session Active</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-col leading-tight text-white tabular-nums text-xl text-right mx-auto md:mx-10 space-y-1 my-2">
|
|
||||||
<h2>Local: {localStr}</h2>
|
|
||||||
<h2>UTC: {utcStr}</h2>
|
|
||||||
</div>
|
|
||||||
<div className="flex flex-row space-x-8">
|
<div className="flex flex-row space-x-8">
|
||||||
|
<Link to={"/"}>
|
||||||
|
<FontAwesomeIcon className="text-white" icon={faHome} size="2x" />
|
||||||
|
</Link>
|
||||||
<div onClick={toggleFullscreen} className="flex flex-col">
|
<div onClick={toggleFullscreen} className="flex flex-col">
|
||||||
{isFullscreen ? (
|
{isFullscreen ? (
|
||||||
<FontAwesomeIcon icon={faMinimize} size="2x" />
|
<FontAwesomeIcon icon={faMinimize} size="2x" />
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ type NavigationArrowProps = {
|
|||||||
|
|
||||||
const NavigationArrow = ({ side, settingsPage }: NavigationArrowProps) => {
|
const NavigationArrow = ({ side, settingsPage }: NavigationArrowProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const navigationDest = (side: string | undefined) => {
|
const navigationDest = (side: string | undefined) => {
|
||||||
if (settingsPage) {
|
if (settingsPage) {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
@@ -44,19 +43,17 @@ const NavigationArrow = ({ side, settingsPage }: NavigationArrowProps) => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{side === "Front" ? (
|
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon={faArrowLeft}
|
icon={faArrowLeft}
|
||||||
className="absolute top-[50%] left-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-30"
|
className="absolute top-[50%] left-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-30"
|
||||||
onClick={() => navigationDest(side)}
|
onClick={() => navigationDest(side)}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon={faArrowRight}
|
icon={faArrowRight}
|
||||||
className="absolute top-[50%] right-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-30"
|
className="absolute top-[50%] right-[2%] backdrop-blur-md hover:cursor-pointer animate-bounce z-30"
|
||||||
onClick={() => navigationDest(side)}
|
onClick={() => navigationDest(side)}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { CAM_BASE } from "../utils/config";
|
|||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
const base_url = `${CAM_BASE}/SightingListFront/sightingSummary?mostRecentRef=`;
|
const base_url = `${CAM_BASE}/SightingListFront/sightingSummary?mostRecentRef=`;
|
||||||
return (
|
return (
|
||||||
<SightingFeedProvider url={base_url} side="Front">
|
<SightingFeedProvider url={base_url}>
|
||||||
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
||||||
<FrontCameraOverviewCard />
|
<FrontCameraOverviewCard />
|
||||||
<SightingHistoryWidget title="Sightings" />
|
<SightingHistoryWidget title="Sightings" />
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const FrontCamera = () => {
|
|||||||
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
||||||
<OverviewVideoContainer
|
<OverviewVideoContainer
|
||||||
title={"Front Camera"}
|
title={"Front Camera"}
|
||||||
side="CameraRear"
|
side="CameraFront"
|
||||||
settingsPage={true}
|
settingsPage={true}
|
||||||
zoomLevel={zoomLevel}
|
zoomLevel={zoomLevel}
|
||||||
onZoomLevelChange={setZoomLevel}
|
onZoomLevelChange={setZoomLevel}
|
||||||
|
|||||||
@@ -1,27 +1,34 @@
|
|||||||
import { useNavigate } from "react-router";
|
|
||||||
import { useSwipeable } from "react-swipeable";
|
|
||||||
import OverviewVideoContainer from "../components/FrontCameraSettings/OverviewVideoContainer";
|
import OverviewVideoContainer from "../components/FrontCameraSettings/OverviewVideoContainer";
|
||||||
import CameraSettings from "../components/CameraSettings/CameraSettings";
|
import CameraSettings from "../components/CameraSettings/CameraSettings";
|
||||||
import { Toaster } from "sonner";
|
import { Toaster } from "sonner";
|
||||||
|
import { useState } from "react";
|
||||||
|
import type { ZoomLevel } from "../types/types";
|
||||||
|
|
||||||
const RearCamera = () => {
|
const RearCamera = () => {
|
||||||
const navigate = useNavigate();
|
const [zoomLevel, setZoomLevel] = useState<ZoomLevel>({
|
||||||
const handlers = useSwipeable({
|
left: 0,
|
||||||
onSwipedRight: () => navigate("/"),
|
top: 0,
|
||||||
trackMouse: true,
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
px: 0,
|
||||||
|
py: 0,
|
||||||
|
level: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto grid grid-cols-1 sm:grid-cols-1 lg:grid-cols-2 gap-4 px-2 sm:px-4 lg:px-0 w-full order-first">
|
<div className="mx-auto flex flex-col lg:flex-row gap-2 px-1 sm:px-2 lg:px-0 w-full min-h-screen">
|
||||||
<CameraSettings title="Rear Camera Settings" side={"CameraRear"} />
|
<CameraSettings
|
||||||
|
title="Rear Camera Settings"
|
||||||
<div {...handlers}>
|
side={"CameraRear"}
|
||||||
|
zoomLevel={zoomLevel}
|
||||||
|
onZoomLevelChange={setZoomLevel}
|
||||||
|
/>
|
||||||
<OverviewVideoContainer
|
<OverviewVideoContainer
|
||||||
title={"Rear Camera"}
|
title={"Rear Camera"}
|
||||||
side={"CameraRear"}
|
side={"CameraRear"}
|
||||||
settingsPage={true}
|
settingsPage={true}
|
||||||
|
zoomLevel={zoomLevel}
|
||||||
|
onZoomLevelChange={setZoomLevel}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<Toaster />
|
<Toaster />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user