diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..19862d1 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "prettier.printWidth": 400, + "prettier.semi": false, + "prettier.singleQuote": true + } + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b492849 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "prettier.configPath": "${workspaceFolder}/.prettierrc.json" +} \ No newline at end of file diff --git a/couchdb/data/_dbs.couch b/couchdb/data/_dbs.couch index caa21ea..b1727a5 100644 Binary files a/couchdb/data/_dbs.couch and b/couchdb/data/_dbs.couch differ diff --git a/couchdb/data/shards/00000000-7fffffff/testdata.1643440069.couch b/couchdb/data/shards/00000000-7fffffff/testdata.1643440069.couch new file mode 100644 index 0000000..9e4db84 Binary files /dev/null and b/couchdb/data/shards/00000000-7fffffff/testdata.1643440069.couch differ diff --git a/couchdb/data/shards/80000000-ffffffff/testdata.1643440069.couch b/couchdb/data/shards/80000000-ffffffff/testdata.1643440069.couch new file mode 100644 index 0000000..0ed11ec Binary files /dev/null and b/couchdb/data/shards/80000000-ffffffff/testdata.1643440069.couch differ diff --git a/webserver/src/App.jsx b/webserver/src/App.jsx index cd1626d..8cb6c87 100644 --- a/webserver/src/App.jsx +++ b/webserver/src/App.jsx @@ -19,33 +19,41 @@ import InputPage from "./Pages/InputPage"; import { createMuiTheme, ThemeProvider } from '@material-ui/core' import { Formik, Field, Form } from 'formik'; import { TextField, Button, Grid, FormRow, Checkbox, Radio, FormControlLabel, FormControl, FormLabel, RadioGroup, IconButton, InputAdornment } from "@material-ui/core"; -import { AddCircleOutline, RemoveCircleOutline} from "@material-ui/icons"; +import { AddCircleOutline, RemoveCircleOutline } from "@material-ui/icons"; function App() { const darkTheme = createMuiTheme({ - + // Theme settings palette: { type: "dark", }, + typography: { + fontSize: 18 + } }); + const styles = { + bigbution: { + + } + } return (
- - - - - } /> - } /> - } /> - } /> - } /> - - - + + + + + } /> + } /> + } /> + } /> + } /> + + +
); diff --git a/webserver/src/DbContext.jsx b/webserver/src/DbContext.jsx index 0442222..94eda13 100644 --- a/webserver/src/DbContext.jsx +++ b/webserver/src/DbContext.jsx @@ -16,7 +16,7 @@ export function DbProvider({ children }) { const [localdb, setLocaldb] = useState(new PouchDB("testdata")); //used in development server const [remotedb, setRemotedb] = useState( - new PouchDB(window.location.hostname + ":5984/testdata", { + new PouchDB("http://" + window.location.hostname + ":5984/testdata", { skip_setup: true, auth: { username: "scouting", @@ -40,10 +40,12 @@ export function DbProvider({ children }) { live: true, retry: true, }) - .on("change", function (change) {}) - .on("paused", function (info) {}) - .on("active", function (info) {}) - .on("error", function (err) {}); + .on("change", function (change) { }) + .on("paused", function (info) { }) + .on("active", function (info) { }) + .on("error", function (err) { + console.error(err); + }); return ( diff --git a/webserver/src/Pages/DashboardPage/ProcessedDataContext.jsx b/webserver/src/Pages/DashboardPage/ProcessedDataContext.jsx new file mode 100644 index 0000000..2de95aa --- /dev/null +++ b/webserver/src/Pages/DashboardPage/ProcessedDataContext.jsx @@ -0,0 +1,85 @@ +import React, { useContext, useState } from "react"; +import { useLocalDb } from "../../DbContext"; + +const ProcessedDataContext = React.createContext(); +export function useProcessedData() { + return useContext(processedDataContext); +} + +export function ProcessedDataProvider({ children }) { + const [processedData, setProcessedData] = useState( + { + teamData: null, + matchData: null, + updateData: function () { + const localdb = useLocalDb(); + // let processed_data = {}; + localdb + .allDocs({ + include_docs: true, + }) + .then((result) => { + console.log(result); + result.rows.forEach((dbentry) => { + let doc = dbentry.doc; + console.log(doc); + //if there's no processed data on a team yet, create a default data entry + if (typeof teamData[doc.team_name] === "undefined") { + teamData[doc.team_name] = { + team_name: doc.team_name, + alliance: doc.alliance, + games_played: 0, + climbs_none: 0, + climbs_low: 0, + climbs_mid: 0, + climbs_high: 0, + climbs_transverse: 0, + points: 0, + point_average: 0, + num_disables: 0, + disables_average: 0, + num_flips: 0, + flips_average: 0, + fouls: 0, + fouls_average: 0, + fouls_tech: 0, + fouls_tech_average: 0, + }; + } + + let thisTeamData = teamData[doc.team_name]; + console.log(thisTeamData); + let new_team_data = { + ...team_data, + games_played: team_data.games_played + 1, + num_climbs: team_data.num_climbs + (doc.climb == true ? 1 : 0), + num_disables: team_data.num_disables + (doc.disabled == true ? 1 : 0), + num_flips: team_data.num_flips + (doc.flipped_over == true ? 1 : 0), + fouls: team_data.fouls + parseInt(doc.fouls), + fouls_tech: team_data.fouls_tech + parseInt(doc.fouls_tech), + inner_port: team_data.inner_port + parseInt(doc.inner_port), + outer_port: team_data.outer_port + parseInt(doc.outer_port), + lower_port: team_data.lower_port + parseInt(doc.lower_port), + }; + console.log(new_team_data); + }); + }) + .catch((err) => { + console.log("Error Fetching Docs from Database!"); + console.log(err); + }); + let datasets = [ + { + data: [], + }, + ]; + } + } + ); + //https://react-charts.js.org/examples/column + return ( + + {children} + + ); +}; \ No newline at end of file diff --git a/webserver/src/Pages/InputPage.css b/webserver/src/Pages/InputPage.css new file mode 100644 index 0000000..e687414 --- /dev/null +++ b/webserver/src/Pages/InputPage.css @@ -0,0 +1,13 @@ +.maxwidth { + display: block; + /* margin-left: auto; + margin-right: auto; */ + width: 100%; + text-align: center; + margin: auto; + max-width: fit-content; + /* max-width: 100% */ +} +.smallfeild { + max-width: 25%; +} \ No newline at end of file diff --git a/webserver/src/Pages/InputPage.jsx b/webserver/src/Pages/InputPage.jsx index aedf4fa..1051fa8 100644 --- a/webserver/src/Pages/InputPage.jsx +++ b/webserver/src/Pages/InputPage.jsx @@ -1,5 +1,6 @@ import React from "react"; import { useLocalDb } from "../DbContext"; +import "./InputPage.css" // import { Button, Intent, Spinner } from "@blueprintjs/core"; import FormRenderer from "@data-driven-forms/react-form-renderer/form-renderer"; import componentTypes from "@data-driven-forms/react-form-renderer/component-types"; @@ -27,7 +28,8 @@ const InputPage = () => { const localdb = useLocalDb(); console.log(localdb); return ( -
+
+
{ lower_hub: "0", climb_level: "", alliance: "", - notes_good: "", - notes_struggle: "", - notes_cant: "", + defence: "" }} onSubmit={(values, { setSubmitting, resetForm }) => { setTimeout(() => { @@ -61,17 +61,17 @@ const InputPage = () => { .then((result) => { alert("Input Saved Successfully!"); console.log(result); + console.log(localdb); }) .catch((err) => { console.log("Failed To Save Input!"); alert(err); }); // alert(JSON.stringify(values, null, 2)); - resetForm(); + // resetForm(); //Hah tobad setSubmitting(false); }, 400); - }} - > + }}> {({ values, setValues, @@ -82,14 +82,14 @@ const InputPage = () => { handleSubmit, isSubmitting, }) => ( -
+ + + spacing={3}> {" "} { type="radio" name="alliance" value="red" + style={{ fontSize: 50 }} /> } label="Red" + /> { -
+
+ spacing={3}> + spacing={3}> { direction="column" justify="flex-start" alignItems="center" - spacing={3} - > + spacing={3}> {" "} - {" "} + {" "} {" "} @@ -189,15 +188,14 @@ const InputPage = () => { {" "} -
+
+ spacing={3}> Climbing @@ -261,44 +259,117 @@ const InputPage = () => { -
+
+ spacing={3}> - - {" "} - {" "} - - {" "} - {" "} + + + {" "} + {" "} + + {" "} + {" "} + - - {" "} - {" "} - - {" "} + + + {" "} + {" "} + + {" "} + + + {/* {" "} */} + {" "} - - {/* {" "} */} - {" "} -
+
+ spacing={3}> + + + Defense + + + } + label="N/A" + /> + + } + label="Poor" + /> + + } + label="Good" + /> + + } + label="Exceptional" + /> + + + + + +
+ + {" "} { direction="row" justify="center" alignItems="flex-start" - spacing={3} - > + spacing={3}>