diff --git a/src/App.tsx b/src/App.tsx index 75d423d..07e0fc8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import ConnectedRobots from './pages/ConnectedRobots/ConnectedRobots.tsx' import VisProg from "./pages/VisProgPage/VisProg.tsx"; import {useState} from "react"; import Logging from "./components/Logging/Logging.tsx"; +import GesturePage from './pages/GesturePage/GesturePage.tsx'; function App(){ const [showLogs, setShowLogs] = useState(false); @@ -25,6 +26,7 @@ function App(){ } /> } /> } /> + } /> {showLogs && } diff --git a/src/pages/GesturePage/GesturePage.tsx b/src/pages/GesturePage/GesturePage.tsx new file mode 100644 index 0000000..acebde3 --- /dev/null +++ b/src/pages/GesturePage/GesturePage.tsx @@ -0,0 +1,51 @@ +import { useState } from 'react' + +/** + * + * @returns A JSX element representing the app’s gesture page. + */ +export default function GesturePage() { + + const [tags, setTags] = useState([]) + function getTags(){ + fetch( + "http://localhost:8000/robot/get_available_gesture_tags", + { + method: "GET" + } + ).then((res) => { + if (!res.ok) throw new Error("Failed communicating with the backend.") + res.json().then((jsonRes) => setTags(jsonRes["tags"])) + + }).catch(() => console.log("Failed to send program to the backend.")); + } + + const gesture = {endpoint: "actuate/gesture/tag", data: "happy"} + function doGesture(){ + fetch( + "http://localhost:8000/robot/command", + { + method: "POST", + headers: {"Content-Type": "application/json"}, + body: JSON.stringify(gesture), + } + ).then((res) => { + if (!res.ok) throw new Error("Failed communicating with the backend.") + console.log("Successfully sent the gesture command to the backend."); + }).catch(() => console.log("Failed to send gesture command to the backend.")); + } + + return ( +
+ + + + + +
+ ) +} \ No newline at end of file diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx index c998e25..8d96adc 100644 --- a/src/pages/Home/Home.tsx +++ b/src/pages/Home/Home.tsx @@ -23,6 +23,7 @@ function Home() { Editor → Template → Connected Robots → + Gesture Robot → )