-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
174 additions
and
108 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"timestamp": "2024-05-20T05:50:15.085340", "dcu": {"eva1": {"batt": false, "oxy": true, "comm": false, "fan": true, "pump": false, "co2": false}, "eva2": {"batt": false, "oxy": false, "comm": true, "fan": false, "pump": false, "co2": false}}, "uia": {"eva1_power": false, "eva1_oxy": false, "eva1_water_supply": false, "eva1_water_waste": false, "eva2_power": false, "eva2_oxy": false, "eva2_water_supply": false, "eva2_water_waste": false, "oxy_vent": false, "depress": false}} | ||
{"timestamp": "2024-05-22T02:15:24.677766", "dcu": {"eva1": {"batt": false, "oxy": false, "comm": false, "fan": false, "pump": false, "co2": false}, "eva2": {"batt": false, "oxy": false, "comm": false, "fan": false, "pump": false, "co2": false}}, "uia": {"eva1_power": false, "eva1_oxy": false, "eva1_water_supply": false, "eva1_water_waste": true, "eva2_power": false, "eva2_oxy": false, "eva2_water_supply": true, "eva2_water_waste": false, "oxy_vent": false, "depress": true}} |
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,70 +1,124 @@ | ||
import React, { useState } from "react"; | ||
import React, { useState, useEffect } from "react"; | ||
import { NavLink as Link } from "react-router-dom"; | ||
import './navbar.css'; | ||
|
||
// WarningModal Component | ||
const WarningModal = ({ closeModal, isVisible }) => { | ||
return ( | ||
<div className={`warning ${isVisible ? '' : 'hidden'}`}> | ||
<div className="warning-modal-content"> | ||
<p>This is a warning message!</p> | ||
<button className="warning-acknowledge" onClick={closeModal}> | ||
I Acknowledge | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
// Navbar Component | ||
const Navbar = () => { | ||
const [showModal, setShowModal] = useState(false); | ||
const [isVisible, setIsVisible] = useState(true); | ||
const [showModal, setShowModal] = useState(false); | ||
const [isVisible, setIsVisible] = useState(false); | ||
const [warnings, setWarnings] = useState([]); | ||
|
||
const openModal = () => { | ||
setShowModal(true); | ||
setIsVisible(true); | ||
}; | ||
useEffect(() => { | ||
const fetchWarnings = async () => { | ||
try { | ||
const response = await fetch('http://localhost:8000/warnings'); | ||
const data = await response.json(); | ||
const activeWarnings = Object.entries(data.error) | ||
.filter(([key, value]) => value) | ||
.map(([key]) => key); | ||
|
||
const closeModal = () => { | ||
setIsVisible(false); | ||
setTimeout(() => setShowModal(false), 500); // Wait for the fade-out transition to complete | ||
if (activeWarnings.length > 0) { | ||
setWarnings(activeWarnings); | ||
setShowModal(true); | ||
setIsVisible(true); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching warnings:', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<nav className="Navbar"> | ||
<div className="NavMenu"> | ||
<img className="img" src={require("./../assets/Images/logo.jpg")} alt="Logo"/> | ||
<h1 id="title">CUITS LMCC 2024</h1> | ||
<Link className="NavLink" to="/Constant" activeStyle={{ color: '#69b3e7' }}> | ||
Constant | ||
</Link> | ||
<Link className="NavLink" to="/Setup" activeStyle={{ color: '#69b3e7' }}> | ||
Setup | ||
</Link> | ||
<Link className="NavLink" to="/Egress" activeStyle={{ color: '#69b3e7' }}> | ||
Egress | ||
</Link> | ||
<Link className="NavLink" to="/Nav" activeStyle={{ color: '#69b3e7' }}> | ||
Nav | ||
</Link> | ||
<Link className="NavLink" to="/Equipment" activeStyle={{ color: '#69b3e7' }}> | ||
Equipment | ||
</Link> | ||
<Link className="NavLink" to="/Rocks" activeStyle={{ color: '#69b3e7' }}> | ||
Rocks | ||
</Link> | ||
<Link className="NavLink" to="/Rover" activeStyle={{ color: '#69b3e7' }}> | ||
Rover | ||
</Link> | ||
<Link className="NavLink" to="/Ingress" activeStyle={{ color: '#69b3e7' }}> | ||
Ingress | ||
</Link> | ||
<button className="warning-btn" onClick={openModal}>Show Warning</button> | ||
{showModal && <WarningModal closeModal={closeModal} isVisible={isVisible} />} | ||
const interval = setInterval(fetchWarnings, 3000); // Fetch warnings every 3 seconds | ||
return () => clearInterval(interval); | ||
}, []); | ||
|
||
const closeModal = () => { | ||
setIsVisible(false); | ||
setTimeout(() => setShowModal(false), 500); // Wait for the fade-out transition to complete | ||
}; | ||
|
||
const getProcedure = (errorType) => { | ||
switch (errorType) { | ||
case 'fan_error': | ||
return ( | ||
<> | ||
<p>Fan Error Detected!</p> | ||
<ol> | ||
<li>Swap FAN switch to secondary position</li> | ||
<li>Relay FAN position switch to LMCC</li> | ||
<li>Begin navigation back to airlock</li> | ||
</ol> | ||
</> | ||
); | ||
case 'oxy_error': | ||
return ( | ||
<> | ||
<p>Oxygen Error Detected!</p> | ||
<ol> | ||
<li>Swap O2 switch to secondary position</li> | ||
<li>Relay O2 position switch to LMCC</li> | ||
<li>Begin navigation back to airlock</li> | ||
</ol> | ||
</> | ||
); | ||
case 'pump_error': | ||
return ( | ||
<> | ||
<p>Abort Procedure Detected!</p> | ||
<ol> | ||
<li>Relay abort mission and return to airlock command to EVs</li> | ||
</ol> | ||
</> | ||
); | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
return ( | ||
<nav className="Navbar"> | ||
<div className="NavMenu"> | ||
<img className="img" src={require("./../assets/Images/logo.jpg")} alt="Logo"/> | ||
<h1 id="title">CUITS LMCC 2024</h1> | ||
<Link className="NavLink" to="/Constant" activeStyle={{ color: '#69b3e7' }}> | ||
Constant | ||
</Link> | ||
<Link className="NavLink" to="/Setup" activeStyle={{ color: '#69b3e7' }}> | ||
Setup | ||
</Link> | ||
<Link className="NavLink" to="/Egress" activeStyle={{ color: '#69b3e7' }}> | ||
Egress | ||
</Link> | ||
<Link className="NavLink" to="/Nav" activeStyle={{ color: '#69b3e7' }}> | ||
Nav | ||
</Link> | ||
<Link className="NavLink" to="/Equipment" activeStyle={{ color: '#69b3e7' }}> | ||
Equipment | ||
</Link> | ||
<Link className="NavLink" to="/Rocks" activeStyle={{ color: '#69b3e7' }}> | ||
Rocks | ||
</Link> | ||
<Link className="NavLink" to="/Rover" activeStyle={{ color: '#69b3e7' }}> | ||
Rover | ||
</Link> | ||
<Link className="NavLink" to="/Ingress" activeStyle={{ color: '#69b3e7' }}> | ||
Ingress | ||
</Link> | ||
{showModal && ( | ||
<div className={`warning ${isVisible ? '' : 'hidden'}`}> | ||
<div className="warning-modal-content"> | ||
{warnings.map((errorType) => ( | ||
<div key={errorType}> | ||
{getProcedure(errorType)} | ||
</div> | ||
))} | ||
<button className="warning-acknowledge" onClick={closeModal}> | ||
I Acknowledge | ||
</button> | ||
</div> | ||
</nav> | ||
); | ||
</div> | ||
)} | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Navbar; |
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
Oops, something went wrong.