diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..8c2a79e6a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "client/flight-data-reader"] + path = client/flight-data-reader + url = https://github.com/PokeyOne/flight-data-reader.git + branch = trunk diff --git a/client/Dockerfile b/client/Dockerfile index 711b158e4..955c2fdad 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,7 +1,15 @@ +FROM rust:1.73 as flight-data-reader + +RUN cargo install wasm-pack +COPY flight-data-reader /usr/src/flight-data-reader +WORKDIR /usr/src/flight-data-reader/web_package/rocket-data +RUN wasm-pack build + FROM node:18-alpine as base FROM base as dev WORKDIR /app +COPY --from=flight-data-reader /usr/src/flight-data-reader/web_package/rocket-data/pkg rocket-data RUN --mount=type=bind,source=package.json,target=package.json \ --mount=type=cache,target=/root/.cache/yarn \ yarn install diff --git a/client/flight-data-reader b/client/flight-data-reader new file mode 160000 index 000000000..28f1a0aaa --- /dev/null +++ b/client/flight-data-reader @@ -0,0 +1 @@ +Subproject commit 28f1a0aaa0cf569bb96ce53a8ea5a7f01bc7c85e diff --git a/client/package.json b/client/package.json index 4ae9674c6..68da9cd13 100644 --- a/client/package.json +++ b/client/package.json @@ -25,8 +25,11 @@ "react-dom": "^18.2.0", "react-material-file-upload": "^0.0.4", "react-syntax-highlighter": "^15.5.0", + "rocket-data": "file:./rocket-data", "socket-io": "^1.0.0", "typescript": "^4.8.4", + "vite-plugin-top-level-await": "^1.3.1", + "vite-plugin-wasm": "^3.2.2", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/client/src/components/DataUpload.tsx b/client/src/components/DataUpload.tsx index 91d4c391d..f3ac91eb7 100644 --- a/client/src/components/DataUpload.tsx +++ b/client/src/components/DataUpload.tsx @@ -1,8 +1,8 @@ -import { Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Slide, Stack, Tooltip, Typography } from "@mui/material"; +import { Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Tooltip, Typography } from "@mui/material"; import { useActiveMission } from "../utils/ActiveMissionContext"; -import React, { useState, forwardRef, useEffect } from 'react'; -import { TransitionProps } from "@mui/material/transitions"; +import React, { useState, useEffect } from 'react'; import FileUpload from "react-material-file-upload"; +import * as DataConverter from "rocket-data" @@ -16,8 +16,11 @@ const MissionConfig: React.FC<IDataUploadProps> = (props: IDataUploadProps) => { const { isOpen, onClose } = props; const [files, setFiles] = useState<File[]>([]); - const handleSave = () => { - // TODO: mateos rust library + const handleSave = async () => { + const config_file = files.find((element: File) => element.name.indexOf(".json") !== -1); + const bin_file = files.find((element: File) => element.name.indexOf(".bin") !== -1); + const csv_str = await DataConverter.convert_to_csv(config_file, bin_file); + console.log(csv_str); props.onClose(); }; @@ -43,9 +46,7 @@ const MissionConfig: React.FC<IDataUploadProps> = (props: IDataUploadProps) => { <Typography variant="subtitle1">Supported File Type:</Typography> <Chip label='.cvs' color="primary" variant="outlined"/> <Chip label='.json' color="primary" variant="outlined"/> - <Tooltip title="Raw data. not Supported yet"> - <Chip label='.bin' color="error" variant="outlined" /> - </Tooltip> + <Chip label='.bin' color="primary" variant="outlined"/> </Stack> <Tooltip title="To upload multiple files they both must be selected in your file system"> <div> diff --git a/client/vite.config.ts b/client/vite.config.ts index 740327aac..8b53308d3 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -1,10 +1,15 @@ import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import viteTsconfigPaths from'vite-tsconfig-paths'; +import wasm from 'vite-plugin-wasm'; +import topLevelAwait from 'vite-plugin-top-level-await'; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), viteTsconfigPaths()], + plugins: [react(), + viteTsconfigPaths(), + wasm(), + topLevelAwait()], server: { host: true, watch: { diff --git a/documentation/installation.md b/documentation/installation.md index 8b8a2bb5d..add42b100 100644 --- a/documentation/installation.md +++ b/documentation/installation.md @@ -59,6 +59,14 @@ Now if you haven't already you can clone the repository ```bash git clone https://github.com/UVicRocketry/Ground-Support.git ``` + +Then clone project submodules + +```bash +cd Ground-Support +git submodule update --init --recursive +``` + **Server Environment File** In the `/services/server` directory create a `.env` file. If not called exactly `.env`, create one and copy and paste