Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBC22-3293: added missing event handler for camera details page #808

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/frontend/src/pages/CameraDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ export default function CameraDetailsPage() {
const [show, setShow] = useState(true);
const [isUpdated, setIsUpdated] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [activeIndex, setActiveIndex] = useState(0);
const handleCameraImageClick = (event) => {
const container = event.currentTarget.closest(".camera-orientations");
const buttons = container.querySelectorAll(".camera-direction-btn");
let currentIndex = Array.from(buttons).findIndex(
(button) => button.classList.contains("current")
);
if (currentIndex === -1) {
currentIndex = activeIndex;
}
const nextIndex = (currentIndex + 1) % buttons.length;
buttons[nextIndex].focus();
setActiveIndex(nextIndex);
const nextCamera = camera.camGroup[nextIndex];
setCamera(nextCamera);
trackEvent("click", "camera-list", "camera", nextCamera.name);
};

useEffect(() => {
if (showLoader) {
Expand Down Expand Up @@ -575,6 +592,8 @@ export default function CameraDetailsPage() {
src={colocatedCamIcon}
role="presentation"
alt="colocated cameras icon"
onClick={handleCameraImageClick}
style={{ cursor: "pointer" }}
/>
<span>Direction</span>
</span>
Expand Down
Loading