mirror of
https://github.com/Team4388/scouting-2021.git
synced 2026-06-09 00:38:01 -06:00
started processing of database docs
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
.env.production.local
|
.env.production.local
|
||||||
|
package-lock.json*
|
||||||
|
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
|
|||||||
@@ -10,3 +10,7 @@ RUN npm run build
|
|||||||
|
|
||||||
FROM nginx:1-alpine
|
FROM nginx:1-alpine
|
||||||
COPY --from=build-step /app/build /usr/share/nginx/html
|
COPY --from=build-step /app/build /usr/share/nginx/html
|
||||||
|
RUN rm /etc/nginx/conf.d/default.conf
|
||||||
|
COPY nginx/nginx.conf /etc/nginx/conf.d
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html/;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
-41532
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,6 @@ import './App.css';
|
|||||||
// const Cushion = require('cushiondb-client');
|
// const Cushion = require('cushiondb-client');
|
||||||
|
|
||||||
//Pages
|
//Pages
|
||||||
import LoginPage from './Pages/LoginPage'
|
|
||||||
import NotFoundPage from './Pages/NotFoundPage'
|
import NotFoundPage from './Pages/NotFoundPage'
|
||||||
import DashboardPage from './Pages/DashboardPage/DashboardPage';
|
import DashboardPage from './Pages/DashboardPage/DashboardPage';
|
||||||
import InputPage from './Pages/InputPage';
|
import InputPage from './Pages/InputPage';
|
||||||
@@ -19,7 +18,6 @@ function App() {
|
|||||||
<Navigation />
|
<Navigation />
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/" component={DashboardPage} />
|
<Route exact path="/" component={DashboardPage} />
|
||||||
<Route exact path="/Login" component={LoginPage} />
|
|
||||||
<Route exact path="/Dashboard" component={DashboardPage} />
|
<Route exact path="/Dashboard" component={DashboardPage} />
|
||||||
<Route exact path="/Input" component={InputPage} />
|
<Route exact path="/Input" component={InputPage} />
|
||||||
<Route exact path="/404" component={NotFoundPage} />
|
<Route exact path="/404" component={NotFoundPage} />
|
||||||
|
|||||||
@@ -15,13 +15,14 @@ export function useRemoteDb() {
|
|||||||
export function DbProvider({ children }) {
|
export function DbProvider({ children }) {
|
||||||
const [localdb, setLocaldb] = useState(new PouchDB('kcmt2021'));
|
const [localdb, setLocaldb] = useState(new PouchDB('kcmt2021'));
|
||||||
//used in development server
|
//used in development server
|
||||||
const [remotedb, setRemotedb] = useState(new PouchDB('http://192.168.7.190:5984/kcmt2021', {
|
const [remotedb, setRemotedb] = useState(new PouchDB('http://192.168.1.5:5984/kcmt2021', {
|
||||||
skip_setup: true,
|
skip_setup: true,
|
||||||
auth: {
|
auth: {
|
||||||
username: '2021',
|
username: '2021',
|
||||||
password: 'Ridgebotics'
|
password: 'Ridgebotics'
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
console.log(remotedb);
|
||||||
// const [remotedb, setRemotedb] = useState(new PouchDB(window.location.protocol + "//" + window.location.hostname + ":5984/kcmt2021", {skip_setup: true}))
|
// const [remotedb, setRemotedb] = useState(new PouchDB(window.location.protocol + "//" + window.location.hostname + ":5984/kcmt2021", {skip_setup: true}))
|
||||||
|
|
||||||
//Login to the Remote Database
|
//Login to the Remote Database
|
||||||
|
|||||||
@@ -4,30 +4,72 @@ import { Bar } from 'react-chartjs-2'
|
|||||||
|
|
||||||
const DashboardPage = () => {
|
const DashboardPage = () => {
|
||||||
const localdb = useLocalDb();
|
const localdb = useLocalDb();
|
||||||
let team_data = {};
|
let processed_data = {};
|
||||||
localdb.allDocs({
|
localdb.allDocs({
|
||||||
include_docs: true
|
include_docs: true
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
result.rows.forEach((doc) => {
|
result.rows.forEach((dbentry) => {
|
||||||
|
let doc = dbentry.doc;
|
||||||
console.log(doc);
|
console.log(doc);
|
||||||
|
if (typeof(processed_data[doc.team_name]) === 'undefined'){
|
||||||
|
processed_data[doc.team_name] = {
|
||||||
|
team_name: doc.team_name,
|
||||||
|
alliance: doc.alliance,
|
||||||
|
games_played: 0,
|
||||||
|
num_climbs: 0,
|
||||||
|
climb_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,
|
||||||
|
inner_port: 0,
|
||||||
|
inner_port_average: 0,
|
||||||
|
lower_port: 0,
|
||||||
|
lower_port_average: 0,
|
||||||
|
outer_port: 0,
|
||||||
|
outer_port_average: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let team_data = processed_data[doc.team_name];
|
||||||
|
console.log(team_data);
|
||||||
|
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) => {
|
}).catch((err) => {
|
||||||
console.log("Error Fetching Docs from Database!");
|
console.log("Error Fetching Docs from Database!");
|
||||||
console.log(err);
|
console.log(err);
|
||||||
})
|
})
|
||||||
|
let datasets = [{
|
||||||
|
data: []
|
||||||
|
}];
|
||||||
//https://react-charts.js.org/examples/column
|
//https://react-charts.js.org/examples/column
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Bar
|
{/* <Bar
|
||||||
data={{
|
data={{
|
||||||
labels: ['4388', '1619'],
|
labels: ['4388', '1619'],
|
||||||
datasets: [
|
datasets: [
|
||||||
|
{1, 0}
|
||||||
]
|
]
|
||||||
}}
|
}}
|
||||||
// height
|
// height
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,34 +195,6 @@ const InputPage = () => {
|
|||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
<button onClick={() => {
|
|
||||||
localdb.put({
|
|
||||||
//creates a uuid for pouchdb to index documents, doing it this way will make the db sort them by date when viewed
|
|
||||||
_id: "4388:" + new Date().toISOString(),
|
|
||||||
inner_port: 0,
|
|
||||||
outer_port: 0,
|
|
||||||
lower_port: 0,
|
|
||||||
control_panel: 0,
|
|
||||||
disabled: false,
|
|
||||||
assisted_climb: false,
|
|
||||||
climb: false,
|
|
||||||
leveling_climb: false,
|
|
||||||
trench_run: false,
|
|
||||||
yellow_card: false,
|
|
||||||
red_card: false,
|
|
||||||
flipped_over: false,
|
|
||||||
center_climb: false
|
|
||||||
}).then((result) => {
|
|
||||||
console.log("Input Saved Successfully!");
|
|
||||||
console.log(result);
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log("Failed To Save Input!");
|
|
||||||
console.log(err);
|
|
||||||
})
|
|
||||||
localdb.allDocs().then(console.log);
|
|
||||||
}}>
|
|
||||||
Test Save Button
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { useRemoteDb } from '../DbContext';
|
|
||||||
|
|
||||||
const LoginPage = () => {
|
|
||||||
const remotedb = useRemoteDb();
|
|
||||||
return (
|
|
||||||
// <div className = "form_inner">
|
|
||||||
// <form>
|
|
||||||
// <h2>Login</h2>
|
|
||||||
// <div className="form_group">
|
|
||||||
// <label htmlFor="name">Name: </label>
|
|
||||||
// <input type="text" name="name" id="name"/>
|
|
||||||
// </div>
|
|
||||||
// <div className="form_group">
|
|
||||||
// <label htmlFor="password">Password: </label>
|
|
||||||
// <input type="text" name="password" id="password"/>
|
|
||||||
// </div>
|
|
||||||
// <input type="submit" value="LOGIN" />
|
|
||||||
// </form>
|
|
||||||
// </div>
|
|
||||||
<div>
|
|
||||||
<button onClick={() => {
|
|
||||||
console.log(remotedb);
|
|
||||||
// remotedb.logIn('2021', 'Ridgebotics').then(function () {
|
|
||||||
// console.log("CouchDb Login Successful!");
|
|
||||||
// }).catch(function (err) {
|
|
||||||
// console.log("Unable to login to CouchDb!");
|
|
||||||
// console.log(err);
|
|
||||||
// });
|
|
||||||
}}>
|
|
||||||
Sign In 2021
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LoginPage
|
|
||||||
@@ -6,7 +6,6 @@ const PagesList = props => {
|
|||||||
<ul>
|
<ul>
|
||||||
<li><Link onClick={props.click} to="/Dashboard">Dashboard</Link></li>
|
<li><Link onClick={props.click} to="/Dashboard">Dashboard</Link></li>
|
||||||
<li><Link onClick={props.click} to="/Input">Input</Link></li>
|
<li><Link onClick={props.click} to="/Input">Input</Link></li>
|
||||||
<li><Link onClick={props.click} to="/Login">Login</Link></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user