-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add device and camera management features, update layout #1
- Loading branch information
1 parent
3577103
commit 1cafc6d
Showing
12 changed files
with
471 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
//window.process = {}; | ||
import axios from 'axios' | ||
//import dotenv from 'dotenv'; | ||
//dotenv.config(); | ||
|
||
// Ensure API_BASE_URL is defined | ||
if (!import.meta.env.VITE_API_BASE_URL) { | ||
throw new Error('VITE_API_BASE_URL environment variable is not defined!'); | ||
} | ||
|
||
const api = axios.create({ | ||
baseURL: 'http://framework:8000' | ||
baseURL: import.meta.env.VITE_API_BASE_URL, // Load from environment variable | ||
}); | ||
|
||
//const api = axios.create({ | ||
// baseURL: 'http://framework:8000' | ||
//}); | ||
|
||
|
||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.footer { | ||
background-color: #2c3e50; /* Consistent color */ | ||
color: white; | ||
text-align: center; | ||
padding: 1rem; | ||
position: relative; /* Static positioning by default */ | ||
z-index: 10; | ||
bottom: 0; /* Will always remain at the bottom with flex layout */ | ||
width: 100%; /* Ensure the footer spans the full width of the screen */ | ||
} | ||
|
||
.footer-content img { | ||
display: inline-block; | ||
} | ||
|
||
.footer-content p { | ||
margin: 0; | ||
display: inline-block; | ||
font-size: 0.9rem | ||
align-items: center; | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import './Footer.css' | ||
|
||
const Footer = () => { | ||
return ( | ||
<footer className="footer bg-primary"> | ||
<div className="footer-content"> | ||
<img src="./public/orc_favicon.svg" alt="ORC Logo" width="20" className="footer-logo"/> | ||
{' '} | ||
<p>© {new Date().getFullYear()} <a href="https://rainbowsensing.com">Rainbowsensing</a>. All rights reserved.</p> | ||
</div> | ||
</footer> | ||
); | ||
}; | ||
|
||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import React, {useState, useEffect} from 'react'; | ||
|
||
import reactLogo from '/react.svg' | ||
import orcLogo from '/orc_favicon.svg' | ||
import api from "../api" | ||
|
||
const CameraAim = () => { | ||
const [count, setCount] = useState(0) | ||
const [videoFeedUrl, setVideoFeedUrl] = useState(""); | ||
const [error, setError] = useState(null); | ||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
// submit form to display stream | ||
const handleFormSubmit = async (event) => { | ||
event.preventDefault(); | ||
setIsLoading(true); | ||
setError(null); // reset errors before doing a new check | ||
const getVideoFeed = async () => { | ||
try { | ||
console.log(event); | ||
const videoUrl = event.target.videoUrl.value; | ||
// const videoUrl = "rtsp://nodeorcpi:8554/cam"; | ||
const feedUrl = `${api.defaults.baseURL}/video-feed/?video_url=${encodeURIComponent(videoUrl)}`; // Dynamically get it from Axios | ||
// test the feed by doing an API call | ||
const response = await api.head('/video-feed/?video_url=' + encodeURIComponent(videoUrl)); | ||
if (response.status === 200) { | ||
setVideoFeedUrl(feedUrl); // Set the dynamically generated URL | ||
console.log("Setting load status to false"); | ||
setIsLoading(false); | ||
|
||
} else { | ||
console.log("We have an error") | ||
throw new Error(`Invalid video feed. Status Code: ${response.status}`); | ||
} | ||
} catch (error) { | ||
setError('Failed to load video feed. Ensure the camera is connected and available.'); | ||
console.error("Error generating video feed URL:", error); | ||
} finally { | ||
console.log("Setting load status to false") | ||
setIsLoading(false); | ||
} | ||
|
||
}; | ||
|
||
getVideoFeed(); | ||
}; | ||
|
||
// Dynamically generate the stream URL | ||
// useEffect(() => { | ||
// setIsLoading(true); | ||
// setError(null); // reset errors before doing a new check | ||
// const getVideoFeed = async () => { | ||
// try { | ||
// const feedUrl = `${api.defaults.baseURL}/video-feed/`; // Dynamically get it from Axios | ||
// // test the feed by doing an API call | ||
// const response = await api.head('/video-feed/'); | ||
// console.log(response); | ||
// if (response.status === 200) { | ||
// setVideoFeedUrl(feedUrl); // Set the dynamically generated URL | ||
// console.log("Setting load status to false"); | ||
// setIsLoading(false); | ||
// | ||
// } else { | ||
// console.log("We have an error") | ||
// throw new Error(`Invalid video feed. Status Code: ${response.status}`); | ||
// } | ||
// } catch (error) { | ||
// setError('Failed to load video feed. Ensure the camera is connected and available.'); | ||
// console.error("Error generating video feed URL:", error); | ||
// } finally { | ||
// console.log("Setting load status to false") | ||
// setIsLoading(false); | ||
// } | ||
// | ||
// }; | ||
// | ||
// getVideoFeed(); | ||
// }, []); // Empty dependency to run this once after the component is mounted | ||
|
||
return ( | ||
<> | ||
<h1>NodeORC configuration</h1> | ||
{isLoading && <p>Loading video feed...</p>} | ||
{error ? ( | ||
<p className="text-danger">{error}</p> | ||
) : ( | ||
videoFeedUrl && ( | ||
<img | ||
src={videoFeedUrl} // Dynamically set the URL | ||
alt="Live Video Stream" | ||
style={{ maxWidth: "100%", height: "auto" }} | ||
/> | ||
) | ||
)} | ||
<div className='container'> | ||
<form onSubmit={handleFormSubmit}> | ||
<div className='mb-3 mt-3'> | ||
<label htmlFor='name' className='form-label'> | ||
Video stream URL (e.g. rtsp://... or http://) | ||
</label> | ||
<input type='text' className='form-control' id='videoUrl' name='videoUrl'/> | ||
</div> | ||
<button type='submit' className='btn btn-primary'> | ||
Submit | ||
</button> | ||
</form> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
|
||
export default CameraAim; |
Oops, something went wrong.