Skip to content

Commit

Permalink
Preliminary status indicator box
Browse files Browse the repository at this point in the history
  • Loading branch information
samderanova committed May 27, 2024
1 parent 130ad40 commit d281547
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 10 deletions.
8 changes: 6 additions & 2 deletions control-station/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { ControlPanel, Navbar, SensorData } from "@/components";
import { ControlPanel, Navbar, SensorData, StatusIndicator } from "@/components";
import usePodData from "./services/usePodData";

function App() {
const { podData, podSocketClient } = usePodData();

return (
<main>
<Navbar />
<SensorData />
<ControlPanel />
<StatusIndicator state={podData.state} />
<ControlPanel podSocketClient={podSocketClient} />
</main>
);
}
Expand Down
2 changes: 0 additions & 2 deletions control-station/src/components/ControlPanel/ControlPanel.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.controlpanel {
position: fixed;
bottom: 0;
width: 100%;
background-color: black;
height: 9%;
Expand Down
10 changes: 6 additions & 4 deletions control-station/src/components/ControlPanel/ControlPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import "./ControlPanel.css";
import usePodData from "@/services/usePodData";
import PodSocketClient from "@/services/PodSocketClient";

function ControlPanel() {
const { podData, podSocketClient } = usePodData();
interface ControlPanelProps {
podSocketClient: PodSocketClient;
}

function ControlPanel({ podSocketClient }: ControlPanelProps) {
return (
<div className="controlpanel">
<h2 style={{ color: "white" }}>Current State: {podData.state}</h2>
<button className="button run" onClick={() => podSocketClient.sendRun()}>
Run
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ function SensorContainer() {
<SensorBox />
<SensorBox />
<SensorBox />
<SensorBox />
<SensorBox />
</div>
);
}
Expand Down
53 changes: 53 additions & 0 deletions control-station/src/components/StatusIndicator/StatusIndicator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.status-indicator {
background-color: lightgray;
border-radius: 10px;
padding: 1rem;
margin: 2rem;
}

.group {
margin-bottom: 1rem;
}

.state-text {
display: inline-block;
vertical-align: middle;
}

.circle {
width: 25px;
height: 25px;
border-radius: 50%;
display: inline-block;
vertical-align: middle;
margin-right: 20px;
background-color: gray;
}

.disconnected-state > .active {
background-color: white;
}

.init-state > .active {
background-color: pink;
}

.running-state > .active {
background-color: green;
}

.stopped-state > .active {
background-color: red;
}

.halted-state > .active {
background-color: darkred;
}

.faulted-state > .active {
background-color: darkred;
}

.load-state > .active {
background-color: rgb(0, 100, 188);
}
23 changes: 23 additions & 0 deletions control-station/src/components/StatusIndicator/StatusIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { State } from "@/services/PodSocketClient";
import "./StatusIndicator.css";

interface StatusIndicatorProps {
state: State;
}

function StatusIndicator({ state }: StatusIndicatorProps) {
return (
<div className="status-indicator">
{Object.values(State).map((s) => {
return (
<div key={s} className={`group ${s.toLowerCase()}-state`}>
<span className={`circle` + (s === state ? " active" : "")}></span>
<div className="state-text">{s}</div>
</div>
);
})}
</div>
);
}

export default StatusIndicator;
1 change: 1 addition & 0 deletions control-station/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as ControlPanel } from "./ControlPanel/ControlPanel";
export { default as Navbar } from "./Navbar/Navbar";
export { default as SensorData } from "./SensorBoxes/SensorData";
export { default as Status } from "./Status/Status";
export { default as StatusIndicator } from "./StatusIndicator/StatusIndicator";

0 comments on commit d281547

Please sign in to comment.