Skip to content

Commit

Permalink
Height weight dof (#110)
Browse files Browse the repository at this point in the history
* ui changes

* homepage ui styling

* formatting

* adding edit/delete parts buttons

* edit and delete parts features + minor fixes

* Added robots height, weight, dof

* obligatory formatting

* fixed merge
  • Loading branch information
is2ac2 authored Jun 12, 2024
1 parent 3b8eb69 commit c90d372
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/hooks/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export interface Robot {
owner: string;
bom: Bom[];
images: Image[];
height: string;
weight: string;
degrees_of_freedom: string;
}

export class api {
Expand Down
39 changes: 39 additions & 0 deletions frontend/src/pages/EditRobotForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const EditRobotForm: React.FC = () => {
const [message, setMessage] = useState<string | null>(null);
const [robot_name, setName] = useState<string>("");
const [robot_description, setDescription] = useState<string>("");
const [robot_height, setHeight] = useState<string>("");
const [robot_weight, setWeight] = useState<string>("");
const [robot_degrees_of_freedom, setDof] = useState<string>("");
const [robot_bom, setBom] = useState<Bom[]>([]);
const [robot_images, setImages] = useState<Image[]>([]);
const [parts, setParts] = useState<Part[]>([]);
Expand All @@ -33,6 +36,9 @@ const EditRobotForm: React.FC = () => {
setBom(robotData.bom);
setImages(robotData.images);
setRobotId(robotData.robot_id);
setHeight(robotData.height);
setWeight(robotData.weight);
setDof(robotData.degrees_of_freedom);
} catch (err) {
addAlert(humanReadableError(err), "error");
}
Expand Down Expand Up @@ -96,6 +102,9 @@ const EditRobotForm: React.FC = () => {
owner: "",
bom: robot_bom,
images: robot_images,
height: robot_height,
weight: robot_weight,
degrees_of_freedom: robot_degrees_of_freedom,
};
try {
await auth_api.editRobot(newFormData);
Expand Down Expand Up @@ -134,6 +143,36 @@ const EditRobotForm: React.FC = () => {
value={robot_name}
required
/>
Height:
<Form.Control
className="mb-3"
type="text"
placeholder="(Optional) Robot Height:"
onChange={(e) => {
setHeight(e.target.value);
}}
value={robot_height}
/>
Weight:
<Form.Control
className="mb-3"
type="text"
placeholder="(Optional) Robot Weight:"
onChange={(e) => {
setWeight(e.target.value);
}}
value={robot_weight}
/>
Total Degrees of Freedom:
<Form.Control
className="mb-3"
type="text"
placeholder="(Optional) Robot Total Degrees of Freedom:"
onChange={(e) => {
setDof(e.target.value);
}}
value={robot_degrees_of_freedom}
/>
Description:
<Form.Control
className="mb-3"
Expand Down
31 changes: 31 additions & 0 deletions frontend/src/pages/RobotDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ interface RobotDetailsResponse {
description: string;
images: { url: string; caption: string }[];
bom: Bom[];
height: string;
weight: string;
degrees_of_freedom: string;
}

interface ExtendedBom {
Expand Down Expand Up @@ -127,6 +130,9 @@ const RobotDetails = () => {
description: robot?.description,
images: robot?.images,
bom: robot?.bom,
height: robot?.height,
weight: robot?.weight,
degrees_of_freedom: robot?.degrees_of_freedom,
};

const { name, description, images } = response;
Expand All @@ -151,6 +157,31 @@ const RobotDetails = () => {
<a href={"mailto:" + ownerEmail}>{ownerEmail}</a>
</Col>
</Row>
{((response.height && response.height !== "") ||
(response.weight && response.weight !== "") ||
(response.degrees_of_freedom &&
response.degrees_of_freedom !== "")) && (
<>
<hr />
{response.height !== "" && (
<p className="text-muted">
<strong>Height:</strong> {response.height}
</p>
)}
{response.weight !== "" && (
<p className="text-muted">
<strong>Weight: </strong>
{response.weight}
</p>
)}
{response.degrees_of_freedom !== "" && (
<p className="text-muted">
<strong>Total Degrees of Freedom:</strong>{" "}
{response.degrees_of_freedom}
</p>
)}
</>
)}
<hr />
<Row>
<Col>
Expand Down
36 changes: 36 additions & 0 deletions frontend/src/pages/RobotForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const RobotForm: React.FC = () => {
const auth_api = new api(auth.api);
const [message, setMessage] = useState<string | null>(null);
const [robot_name, setName] = useState<string>("");
const [robot_height, setHeight] = useState<string>("");
const [robot_weight, setWeight] = useState<string>("");
const [robot_degrees_of_freedom, setDof] = useState<string>("");
const [robot_description, setDescription] = useState<string>("");
const [robot_bom, setBom] = useState<Bom[]>([]);
const [robot_images, setImages] = useState<Image[]>([]);
Expand Down Expand Up @@ -70,6 +73,9 @@ const RobotForm: React.FC = () => {
owner: "",
bom: robot_bom,
images: robot_images,
height: robot_height,
weight: robot_weight,
degrees_of_freedom: robot_degrees_of_freedom,
};
try {
await auth_api.addRobot(newFormData);
Expand Down Expand Up @@ -108,6 +114,36 @@ const RobotForm: React.FC = () => {
value={robot_name}
required
/>
Height:
<Form.Control
className="mb-3"
type="text"
placeholder="(Optional) Robot Height:"
onChange={(e) => {
setHeight(e.target.value);
}}
value={robot_height}
/>
Weight:
<Form.Control
className="mb-3"
type="text"
placeholder="(Optional) Robot Weight:"
onChange={(e) => {
setWeight(e.target.value);
}}
value={robot_weight}
/>
Total Degrees of Freedom:
<Form.Control
className="mb-3"
type="text"
placeholder="(Optional) Robot Total Degrees of Freedom:"
onChange={(e) => {
setDof(e.target.value);
}}
value={robot_degrees_of_freedom}
/>
Description:
<Form.Control
className="mb-3"
Expand Down
4 changes: 4 additions & 0 deletions store/app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import uuid
from typing import Optional

from pydantic import BaseModel

Expand Down Expand Up @@ -54,6 +55,9 @@ class Robot(BaseModel):
description: str
bom: list[Bom]
images: list[Image]
height: Optional[str] = ""
weight: Optional[str] = ""
degrees_of_freedom: Optional[str] = ""


class Part(BaseModel):
Expand Down

0 comments on commit c90d372

Please sign in to comment.