mirror of
https://github.com/Team4388/ScoutingApp2022.git
synced 2026-06-09 00:38:03 -06:00
processed data bucket functional
This commit is contained in:
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 236 KiB |
@@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useLocalDb } from "../DbContext";
|
import { useLocalDb } from "../DbContext";
|
||||||
import "./InputPage.css"
|
import "./InputPage.css";
|
||||||
// import { Button, Intent, Spinner } from "@blueprintjs/core";
|
// import { Button, Intent, Spinner } from "@blueprintjs/core";
|
||||||
import FormRenderer from "@data-driven-forms/react-form-renderer/form-renderer";
|
import FormRenderer from "@data-driven-forms/react-form-renderer/form-renderer";
|
||||||
import componentTypes from "@data-driven-forms/react-form-renderer/component-types";
|
import componentTypes from "@data-driven-forms/react-form-renderer/component-types";
|
||||||
@@ -8,21 +8,7 @@ import componentMapper from "@data-driven-forms/blueprint-component-mapper/compo
|
|||||||
import FormTemplate from "@data-driven-forms/blueprint-component-mapper/form-template";
|
import FormTemplate from "@data-driven-forms/blueprint-component-mapper/form-template";
|
||||||
import { Formik, FastField, Form } from "formik";
|
import { Formik, FastField, Form } from "formik";
|
||||||
import InputNumberField from "../components/InputNumberField.jsx";
|
import InputNumberField from "../components/InputNumberField.jsx";
|
||||||
import {
|
import { TextField, Button, Grid, FormRow, Divider, Checkbox, Radio, FormControlLabel, FormControl, FormLabel, RadioGroup, IconButton, InputAdornment } from "@material-ui/core";
|
||||||
TextField,
|
|
||||||
Button,
|
|
||||||
Grid,
|
|
||||||
FormRow,
|
|
||||||
Divider,
|
|
||||||
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";
|
||||||
|
|
||||||
const InputPage = () => {
|
const InputPage = () => {
|
||||||
@@ -51,7 +37,7 @@ const InputPage = () => {
|
|||||||
climb_level: "",
|
climb_level: "",
|
||||||
alliance: "",
|
alliance: "",
|
||||||
defence: "0",
|
defence: "0",
|
||||||
disabled: false
|
disabled: false,
|
||||||
}}
|
}}
|
||||||
validateOnChange="false"
|
validateOnChange="false"
|
||||||
onSubmit={(values, { setSubmitting, resetForm }) => {
|
onSubmit={(values, { setSubmitting, resetForm }) => {
|
||||||
@@ -74,18 +60,10 @@ const InputPage = () => {
|
|||||||
// resetForm(); //Hah tobad
|
// resetForm(); //Hah tobad
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
}, 400);
|
}, 400);
|
||||||
}}>
|
}}
|
||||||
{({
|
>
|
||||||
values,
|
{({ values, setValues, errors, touched, handleChange, handleBlur, handleSubmit, isSubmitting }) => (
|
||||||
setValues,
|
<Form>
|
||||||
errors,
|
|
||||||
touched,
|
|
||||||
handleChange,
|
|
||||||
handleBlur,
|
|
||||||
handleSubmit,
|
|
||||||
isSubmitting,
|
|
||||||
}) => (
|
|
||||||
<Form >
|
|
||||||
<Grid container direction="row" justifyContent="center" alignItems="flex-end" spacing={3}>
|
<Grid container direction="row" justifyContent="center" alignItems="flex-end" spacing={3}>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<FastField type="input" as={TextField} name="team_number" label="Team #" />
|
<FastField type="input" as={TextField} name="team_number" label="Team #" />
|
||||||
@@ -97,18 +75,8 @@ const InputPage = () => {
|
|||||||
<FormControl component="fieldset">
|
<FormControl component="fieldset">
|
||||||
<FormLabel component="legend">Alliance</FormLabel>
|
<FormLabel component="legend">Alliance</FormLabel>
|
||||||
<RadioGroup aria-label="Alliance" name="alliance" row>
|
<RadioGroup aria-label="Alliance" name="alliance" row>
|
||||||
<FormControlLabel
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="alliance" value="red" style={{ fontSize: 50 }} />} label="Red" />
|
||||||
control={
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="alliance" value="blue" />} label="Blue" />
|
||||||
<FastField as={Radio} type="radio" name="alliance" value="red" style={{ fontSize: 50 }} />
|
|
||||||
}
|
|
||||||
label="Red"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<FastField as={Radio} type="radio" name="alliance" value="blue" />
|
|
||||||
}
|
|
||||||
label="Blue"
|
|
||||||
/>
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -142,36 +110,11 @@ const InputPage = () => {
|
|||||||
<FormControl component="fieldset">
|
<FormControl component="fieldset">
|
||||||
<FormLabel component="legend">Climbing</FormLabel>
|
<FormLabel component="legend">Climbing</FormLabel>
|
||||||
<RadioGroup aria-label="Climbing" name="climb_level" row>
|
<RadioGroup aria-label="Climbing" name="climb_level" row>
|
||||||
<FormControlLabel
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="climb_level" value="0" />} label="None" />
|
||||||
control={
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="climb_level" value="1" />} label="Low" />
|
||||||
<FastField as={Radio} type="radio" name="climb_level" value="0" />
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="climb_level" value="2" />} label="Mid" />
|
||||||
}
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="climb_level" value="3" />} label="High" />
|
||||||
label="None"
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="climb_level" value="4" />} label="Traversal" />
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<FastField as={Radio} type="radio" name="climb_level" value="1" />
|
|
||||||
}
|
|
||||||
label="Low"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<FastField as={Radio} type="radio" name="climb_level" value="2" />
|
|
||||||
}
|
|
||||||
label="Mid"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<FastField as={Radio} type="radio" name="climb_level" value="3" />
|
|
||||||
}
|
|
||||||
label="High"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<FastField as={Radio} type="radio" name="climb_level" value="4" />
|
|
||||||
}
|
|
||||||
label="Traversal"
|
|
||||||
/>
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -205,30 +148,15 @@ const InputPage = () => {
|
|||||||
<FormControl component="fieldset">
|
<FormControl component="fieldset">
|
||||||
<FormLabel component="legend">Defense</FormLabel>
|
<FormLabel component="legend">Defense</FormLabel>
|
||||||
<RadioGroup aria-label="Defense" name="defence" row>
|
<RadioGroup aria-label="Defense" name="defence" row>
|
||||||
<FormControlLabel
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="defence" value="0" />} label="None" />
|
||||||
control={<FastField as={Radio} type="radio" name="defence" value="0" />}
|
|
||||||
label="None"
|
|
||||||
/>
|
|
||||||
{/* <Divider orientation="vertical" flexItem middle /> */}
|
{/* <Divider orientation="vertical" flexItem middle /> */}
|
||||||
<FormControlLabel
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="defence" value="1" />} label="Poor" />
|
||||||
control={<FastField as={Radio} type="radio" name="defence" value="1" />}
|
<FormControlLabel control={<FastField as={Radio} type="radio" name="defence" value="2" />} label="Good" /> <FormControlLabel control={<FastField as={Radio} type="radio" name="defence" value="3" />} label="Exceptional" />
|
||||||
label="Poor"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={<FastField as={Radio} type="radio" name="defence" value="2" />}
|
|
||||||
label="Good"
|
|
||||||
/> <FormControlLabel
|
|
||||||
control={<FastField as={Radio} type="radio" name="defence" value="3" />}
|
|
||||||
label="Exceptional"
|
|
||||||
/>
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<FormControlLabel
|
<FormControlLabel control={<FastField as={Checkbox} type="checkbox" name="disabled" />} label="Disabled" />
|
||||||
control={<FastField as={Checkbox} type="checkbox" name="disabled" />}
|
|
||||||
label="Disabled"
|
|
||||||
/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<div />
|
<div />
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.welcome img {
|
.welcome img {
|
||||||
max-width: 100%;
|
max-width: 50%
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import "./WelcomePage.css";
|
import "./WelcomePage.css";
|
||||||
import "../App.css";
|
import "../App.css";
|
||||||
const WelcomePage = () => {
|
const WelcomePage = () => {
|
||||||
return (
|
return (
|
||||||
<div className="welcome">
|
<div className="welcome">
|
||||||
<h1>Welcome to Ridgebotics Scouting Web Application 2022</h1>
|
<h1>Welcome to Ridgebotics Scouting Web Application 2022</h1>
|
||||||
<img src="/WelcomePageImage.webp" />
|
{/* <img src="/WelcomePageImage.webp" /> */}
|
||||||
</div>
|
<img src="/picgoeshard.jpg" />
|
||||||
)
|
</div>
|
||||||
}
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default WelcomePage
|
export default WelcomePage;
|
||||||
|
|||||||
@@ -1,109 +1,110 @@
|
|||||||
export class ProcessedDataBucket {
|
export class ProcessedDataBucket {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.teamData = {};
|
this.teamData = {};
|
||||||
this.matchData = {};
|
this.matchData = {};
|
||||||
this.updateData = (db) => {
|
this.updateData = (db) => {
|
||||||
//reset data
|
db.allDocs({
|
||||||
this.teamData = {};
|
include_docs: true,
|
||||||
this.matchData = {};
|
})
|
||||||
console.log(db);
|
.then((result) => {
|
||||||
|
//reset data
|
||||||
|
this.teamData = {};
|
||||||
|
this.matchData = {};
|
||||||
|
|
||||||
db.allDocs({
|
// console.log(result);
|
||||||
include_docs: true,
|
result.rows.forEach((dbentry) => {
|
||||||
})
|
let doc = dbentry.doc;
|
||||||
.then((result) => {
|
// console.log(doc);
|
||||||
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 there's no processed data on a team yet, create a default data entry
|
||||||
// if (typeof this.teamData[doc.team_number] === "undefined") {
|
if (typeof this.teamData[doc.team_number] === "undefined") {
|
||||||
// this.teamData[doc.team_number] = {
|
this.teamData[doc.team_number] = {
|
||||||
// team_number: doc.team_number,
|
team_number: doc.team_number,
|
||||||
// games_played: 0,
|
games_played: 0,
|
||||||
// data_sets: {
|
data_sets: {
|
||||||
// upper_hub_auto: [],
|
upper_hub_auto: [],
|
||||||
// lower_hub_auto: [],
|
lower_hub_auto: [],
|
||||||
// upper_hub: [],
|
upper_hub_teleop: [],
|
||||||
// lower_hub: [],
|
lower_hub_teleop: [],
|
||||||
// match_points: []
|
match_points: [],
|
||||||
// },
|
},
|
||||||
// climbs_none: 0,
|
climbs_none: 0,
|
||||||
// climbs_low: 0,
|
climbs_low: 0,
|
||||||
// climbs_mid: 0,
|
climbs_mid: 0,
|
||||||
// climbs_high: 0,
|
climbs_high: 0,
|
||||||
// climbs_transverse: 0,
|
climbs_transverse: 0,
|
||||||
// points_average: 0,
|
points_average: 0,
|
||||||
// num_disables: 0,
|
num_disables: 0,
|
||||||
// num_flips: 0,
|
num_flips: 0,
|
||||||
// fouls: 0,
|
fouls: 0,
|
||||||
// fouls_tech: 0,
|
fouls_tech: 0,
|
||||||
// red_cards: 0,
|
red_cards: 0,
|
||||||
// yellow_cards: 0
|
yellow_cards: 0,
|
||||||
// };
|
};
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //add this game's data to the respective team data:
|
//add this game's data to the respective team data:
|
||||||
// let thisTeamData = this.teamData[doc.team_number];
|
let thisTeamData = this.teamData[doc.team_number];
|
||||||
// thisTeamData.games_played++;
|
thisTeamData.games_played++;
|
||||||
|
|
||||||
// let match_points
|
let match_points =
|
||||||
// = parseInt(doc.taxi_auto)
|
(parseInt(doc.taxi_auto) ? 2 : 0) +
|
||||||
// + parseInt(doc.upper_hub_auto) * 4
|
parseInt(doc.upper_hub_auto) * 4 +
|
||||||
// + parseInt(doc.lower_hub_auto) * 2
|
parseInt(doc.lower_hub_auto) * 2 +
|
||||||
// + parseInt(doc.upper_hub_teleop) * 2
|
parseInt(doc.upper_hub_teleop) * 2 +
|
||||||
// + parseInt(doc.lower_hub_teleop) * 1
|
parseInt(doc.lower_hub_teleop) * 1 +
|
||||||
// + (parseInt(doc.climb_level) == 0 ? 4 : 0)
|
(parseInt(doc.climb_level) == 0 ? 4 : 0) +
|
||||||
// + (parseInt(doc.climb_level) == 1 ? 6 : 0)
|
(parseInt(doc.climb_level) == 1 ? 6 : 0) +
|
||||||
// + (parseInt(doc.climb_level) == 2 ? 10 : 0)
|
(parseInt(doc.climb_level) == 2 ? 10 : 0) +
|
||||||
// + (parseInt(doc.climb_level) == 3 ? 15 : 0)
|
(parseInt(doc.climb_level) == 3 ? 15 : 0);
|
||||||
// ;
|
//data sets
|
||||||
|
thisTeamData.data_sets.upper_hub_auto.push(parseInt(doc.upper_hub_auto));
|
||||||
|
thisTeamData.data_sets.lower_hub_auto.push(parseInt(doc.lower_hub_auto));
|
||||||
|
thisTeamData.data_sets.upper_hub_teleop.push(parseInt(doc.upper_hub_teleop));
|
||||||
|
thisTeamData.data_sets.lower_hub_teleop.push(parseInt(doc.lower_hub_teleop));
|
||||||
|
thisTeamData.data_sets.match_points.push(match_points);
|
||||||
|
|
||||||
// //data sets
|
//climb data
|
||||||
// thisTeamData.data_sets.upper_hub_auto.push(parseInt(doc.upper_hub_auto));
|
switch (parseInt(doc.climb_level)) {
|
||||||
// thisTeamData.data_sets.lower_hub_auto.push(parseInt(doc.lower_hub_auto));
|
case 0:
|
||||||
// thisTeamData.data_sets.upper_hub.push(parseInt(doc.upper_hub));
|
thisTeamData.climbs_none++;
|
||||||
// thisTeamData.data_sets.lower_hub.push(parseInt(doc.lower_hub));
|
break;
|
||||||
// thisTeamData.data_sets.match_points.push(match_points);
|
case 1:
|
||||||
|
thisTeamData.climbs_low++;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
thisTeamData.climbs_mid++;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
thisTeamData.climbs_high++;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
thisTeamData.climbs_transverse++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error("Invalid Climb Level (how did this even happen lol?): " + doc.climb_level);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// //climb data
|
//misc data
|
||||||
// switch (parseInt(doc.climb_level)) {
|
thisTeamData.num_disables += doc.disabled ? 1 : 0;
|
||||||
// case 0:
|
thisTeamData.num_flips += doc.flipped ? 1 : 0;
|
||||||
// thisTeamData.climbs_none++;
|
thisTeamData.fouls += parseInt(doc.fouls);
|
||||||
// break;
|
thisTeamData.fouls_tech += parseInt(doc.fouls_tech);
|
||||||
// case 1:
|
thisTeamData.red_cards += parseInt(doc.red_cards);
|
||||||
// thisTeamData.climbs_low++;
|
thisTeamData.yellow_cards += parseInt(doc.yellow_cards);
|
||||||
// break;
|
//sum of all points in the match points data set for this team
|
||||||
// case 2:
|
let total_points = thisTeamData.data_sets.match_points.reduce(function (accum, current) {
|
||||||
// thisTeamData.climbs_mid++;
|
return accum + current;
|
||||||
// break;
|
}, 0);
|
||||||
// case 3:
|
thisTeamData.points_average = total_points / thisTeamData.games_played;
|
||||||
// thisTeamData.climbs_high++;
|
});
|
||||||
// break;
|
console.log(this.teamData);
|
||||||
// case 4:
|
})
|
||||||
// thisTeamData.climbs_transverse++;
|
.catch((err) => {
|
||||||
// break;
|
console.log("Error while processing data!");
|
||||||
// default:
|
console.error(err);
|
||||||
// console.error('Invalid Climb Level (how did this even happen lol?): ' + doc.climb_level);
|
});
|
||||||
// break;
|
};
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //misc data
|
|
||||||
// thisTeamData.num_disables += doc.disabled ? 1 : 0;
|
|
||||||
// thisTeamData.num_flips += doc.flipped ? 1 : 0;
|
|
||||||
// thisTeamData.fouls += parseInt(doc.fouls);
|
|
||||||
// thisTeamData.fouls_tech += parseInt(doc.fouls_tech);
|
|
||||||
// thisTeamData.red_cards += parseInt(doc.red_cards);
|
|
||||||
// thisTeamData.yellow_cards += parseInt(doc.yellow_cards);
|
|
||||||
|
|
||||||
// console.log(thisTeamData);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log("Error while processing data!");
|
|
||||||
console.error(err);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ const Toolbar = props => {
|
|||||||
<header className="toolbar">
|
<header className="toolbar">
|
||||||
<nav className="toolbar_navigation">
|
<nav className="toolbar_navigation">
|
||||||
<DrawerButton click={props.drawerClickHandler} />
|
<DrawerButton click={props.drawerClickHandler} />
|
||||||
<div className = "toolbar_logo"><Link to="/">Ridgebotics Scouting ;)</Link></div>
|
<div className = "toolbar_logo"><Link to="/">Ridgebotics Scouting <3</Link></div>
|
||||||
<div className = "toolbar_spacer" />
|
<div className = "toolbar_spacer" />
|
||||||
<div className = "toolbar_items">
|
<div className = "toolbar_items">
|
||||||
<PagesList />
|
<PagesList />
|
||||||
|
|||||||
Reference in New Issue
Block a user