created app skeleton

This commit is contained in:
Evan Lanham
2022-02-02 23:23:43 -07:00
parent 70981f88b2
commit be24aa8076
29 changed files with 2994 additions and 132 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
COUCHDB_USER=2021 COUCHDB_USER=scouting
COUCHDB_PASSWORD=Ridgebotics COUCHDB_PASSWORD=Ridgebotics
+1 -2
View File
@@ -12,7 +12,7 @@ services:
- './webserver:/app' - './webserver:/app'
- '/app/node_modules' - '/app/node_modules'
ports: ports:
- "3001:3000" - "3000:3000"
environment: environment:
- CHOKIDAR_USEPOLLING=true - CHOKIDAR_USEPOLLING=true
couchdb: couchdb:
@@ -35,4 +35,3 @@ services:
volumes: volumes:
- ./couchdb/db.local.ini:/opt/couchdb/etc/local.ini - ./couchdb/db.local.ini:/opt/couchdb/etc/local.ini
- ./couchdb/data:/opt/couchdb/data - ./couchdb/data:/opt/couchdb/data
+1
View File
@@ -0,0 +1 @@
docker-compose up -d --build
+1
View File
@@ -0,0 +1 @@
docker-compose -f docker-compose.prod.yml up -d --build
+1
View File
@@ -0,0 +1 @@
docker-compose down
+3 -1
View File
@@ -1,5 +1,7 @@
FROM node:16-alpine as build-step FROM node:16-alpine as build-step
RUN mkdir /app/ RUN mkdir /app/
RUN mkdir /app/node_modules
RUN chown -R node:node /app/node_modules
WORKDIR /app/ WORKDIR /app/
ENV PATH /app/node_modules/.bin:$PATH ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./ COPY package.json ./
@@ -7,5 +9,5 @@ COPY package-lock.json ./
RUN npm install RUN npm install
RUN npm install react-scripts RUN npm install react-scripts
COPY . ./ COPY . ./
# USER node #USER node
CMD ["npm", "start"] CMD ["npm", "start"]
+1
View File
@@ -2,6 +2,7 @@ FROM node:16-alpine as build-step
RUN mkdir /app/ RUN mkdir /app/
WORKDIR /app/ WORKDIR /app/
ENV PATH /app/node_modules/.bin:$PATH ENV PATH /app/node_modules/.bin:$PATH
RUN chown -R node:node /app/node_modules
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install
COPY . ./ COPY . ./
+12 -51
View File
@@ -1,70 +1,31 @@
# Getting Started with Create React App # Ridgebotics Scouting App 2022
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts ## Scripts
In the project directory, you can run: In the project directory, you can run:
### `npm start` ### `start_dev.sh`
Runs the app in the development mode.\ Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\ The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test` This will also run the couchdb server.
Open [http://localhost:5984](http://localhost:5984) to open the couchdb web interface
Launches the test runner in the interactive watch mode.\ ### `start_prod.sh`
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\ Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance. It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\ This runs and nginx server that serves the app over http
Your app is ready to be deployed! Open [http://localhost](http://localhost) to view it in your browser.
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. This will also run the couchdb server.
Open [http://localhost:5984](http://localhost:5984) to open the couchdb web interface
### `npm run eject` ### `stop.sh`
**Note: this is a one-way operation. Once you `eject`, you can't go back!** Stops any running containers
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
+2467
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -3,11 +3,19 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@blueprintjs/core": "^3.52.0",
"@data-driven-forms/blueprint-component-mapper": "^3.16.1",
"@data-driven-forms/react-form-renderer": "^3.16.1",
"@testing-library/jest-dom": "^5.16.1", "@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2", "@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"formik": "^2.2.9",
"pouchdb": "^7.2.2",
"react": "^17.0.2", "react": "^17.0.2",
"react-chartjs-2": "^4.0.0",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-router": "^6.2.1",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0", "react-scripts": "5.0.0",
"web-vitals": "^2.1.3" "web-vitals": "^2.1.3"
}, },
+1 -36
View File
@@ -1,38 +1,3 @@
.App { .App {
text-align: center; /* height: 100%; */
}
.App-logo {
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
} }
+29 -16
View File
@@ -1,23 +1,36 @@
import logo from './logo.svg'; import logo from "./logo.svg";
import './App.css'; import Navigation from "./components/Navigation/Navigation";
import { DbProvider } from "./DbContext";
import {
BrowserRouter as Router,
Routes,
Route,
Link,
Navigate,
} from "react-router-dom";
import "./App.css";
// const Cushion = require('cushiondb-client');
//Pages
import NotFoundPage from "./Pages/NotFoundPage";
import DashboardPage from "./Pages/DashboardPage/DashboardPage";
import InputPage from "./Pages/InputPage";
function App() { function App() {
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <DbProvider>
<img src={logo} className="App-logo" alt="logo" /> <Router>
<p> <Navigation />
Edit <code>src/App.js</code> and save to reload. <Routes>
</p> <Route path="/" element={<DashboardPage />} />
<a <Route path="/Dashboard" element={<DashboardPage />} />
className="App-link" <Route path="/Input" element={<InputPage />} />
href="https://reactjs.org" <Route path="/404" element={<NotFoundPage />} />
target="_blank" <Route path="*" element={<NotFoundPage />} />
rel="noopener noreferrer" </Routes>
> </Router>
Learn React </DbProvider>
</a>
</header>
</div> </div>
); );
} }
-8
View File
@@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
+55
View File
@@ -0,0 +1,55 @@
import PouchDB from "pouchdb";
import React, { useContext, useState } from "react";
const LocalDbContext = React.createContext();
const RemoteDbContext = React.createContext();
export function useLocalDb() {
return useContext(LocalDbContext);
}
export function useRemoteDb() {
return useContext(RemoteDbContext);
}
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", {
skip_setup: true,
auth: {
username: "scouting",
password: "Ridgebotics",
},
})
);
console.log(remotedb);
// const [remotedb, setRemotedb] = useState(new PouchDB(window.location.protocol + "//" + window.location.hostname + ":5984/kcmt2021", {skip_setup: true}))
//Login to the Remote Database
// remotedb.logIn('2021', 'Ridgebotics').then(function () {
// console.log("CouchDb Login Successful!");
// }).catch(function (err) {
// console.log("Unable to login to CouchDb!");
// console.log(err);
// });
localdb
.sync(remotedb, {
live: true,
retry: true,
})
.on("change", function (change) {})
.on("paused", function (info) {})
.on("active", function (info) {})
.on("error", function (err) {});
return (
<LocalDbContext.Provider value={localdb}>
<RemoteDbContext.Provider value={remotedb}>
{children}
</RemoteDbContext.Provider>
</LocalDbContext.Provider>
);
}
@@ -0,0 +1,71 @@
import React from "react";
import { useLocalDb } from "../../DbContext";
import { Bar, Chart } from "react-chartjs-2";
const DashboardPage = () => {
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 processed_data[doc.team_name] === "undefined") {
processed_data[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 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) => {
console.log("Error Fetching Docs from Database!");
console.log(err);
});
let datasets = [
{
data: [],
},
];
//https://react-charts.js.org/examples/column
return <div></div>;
};
export default DashboardPage;
+34
View File
@@ -0,0 +1,34 @@
import React from 'react'
import { useLocalDb } from '../DbContext';
// 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';
import componentMapper from '@data-driven-forms/blueprint-component-mapper/component-mapper';
import FormTemplate from '@data-driven-forms/blueprint-component-mapper/form-template';
const schema = {
fields: [{
component: componentTypes.TEXT_FIELD,
name: 'name',
label: 'Your name',
isRequired: true,
// validate: [{type: validatorTypes.REQUIRED}],
default: 'test'
}]
}
const InputPage = () => {
const localdb = useLocalDb();
console.log(localdb);
return (
<div>
<FormRenderer
schema={schema}
componentMapper={componentMapper}
FormTemplate={FormTemplate}
/>
</div>
)
}
export default InputPage
+11
View File
@@ -0,0 +1,11 @@
import React from 'react';
const NotFoundPage = () => {
return (
<div>
<h3>404 Page Not Found!</h3>
</div>
)
}
export default NotFoundPage
+15
View File
@@ -0,0 +1,15 @@
import React from 'react'
const Header = ({ title }) => {
return (
<header>
<h1> {title} </h1>
</header>
)
}
Header.defaultProps = {
title: 'Ridgebotics Scouting',
}
export default Header
+32
View File
@@ -0,0 +1,32 @@
import React from 'react'
// import {Navigation} from 'react-minimal-side-navigation';
// import 'react-minimal-side-navigation/lib/ReactMinimalSideNavigation.css';
const Navbar = () => {
return (
<div>
{/* <Navigation
activeItemId="/dashboard"
onSelect={({itemId}) => {
}}
items={[
{
title: 'Dashboard',
itemID: '/dashboard'
},
{
title: 'Team Comparison',
itemID: '/TeamComparison'
},
{
title: 'Input',
itemID: '/Input'
}
]}
/> */}
</div>
)
}
export default Navbar;
@@ -0,0 +1,28 @@
.drawer_button {
display: flex;
flex-direction: column;
justify-content: space-around;
height: 30px;
width: 30px;
background: transparent;
border: none;
cursor: pointer;
padding: 0;
box-sizing: border-box;
}
.drawer_button:focus {
outline:none;
}
.drawer_button_line {
width: 100%;
height: 2px;
background: white;
}
@media (min-width: 769px) {
.drawer_button {
display: none;
}
}
@@ -0,0 +1,15 @@
import React from 'react'
import './DrawerButton.css'
const DrawerButton = props => {
return (
<button className="drawer_button" onClick={props.click}>
<div className="drawer_button_line" />
<div className="drawer_button_line" />
<div className="drawer_button_line" />
</button>
)
}
export default DrawerButton
@@ -0,0 +1,55 @@
.side_drawer {
position: fixed;
height: 100%;
width: 100%;
background: #009954;
opacity: 0;
transition:opacity 0.3s;
pointer-events: none;
}
.side_drawer.open {
opacity: 1;
transition:opacity 0.3s;
display: flex;
pointer-events: all;
/* animation: fadeInOpacity 0.5s linear; */
}
.side_drawer ul {
/* height: 100%; */
list-style: none;
display: flex;
flex-direction: column;
justify-content: top;
}
.side_drawer li {
margin: 0.5rem 0;
}
.side_drawer a {
color: white;
text-decoration: none;
font-size: 2rem;
}
.side_drawer a:hover,
.side_drawer a:active {
color: #ff3b76;
}
@keyframes fadeInOpacity {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/* @media (max-width: 769px) {
.side_drawer {
display: none;
}
} */
@@ -0,0 +1,18 @@
import React from 'react'
import PagesList from '../PagesList';
import './SideDrawer.css'
const SideDrawer = props => {
let drawerClasses = 'side_drawer';
if (props.show) {
drawerClasses = 'side_drawer open';
}
return (
<nav className={drawerClasses}>
<PagesList click={props.drawerClickHandler}/>
</nav>
)
}
export default SideDrawer
@@ -0,0 +1,26 @@
import React, {Component} from 'react'
import Toolbar from './Toolbar/Toolbar'
import SideDrawer from './Drawer/SideDrawer'
class Navigation extends Component {
state = {
sideDrawerOpen: false
};
drawerToggleClickHandler = () => {
this.setState((prevState) => {
return {sideDrawerOpen: !prevState.sideDrawerOpen};
});
};
render() {
return (
<div>
<Toolbar drawerClickHandler={this.drawerToggleClickHandler} />
<SideDrawer show={this.state.sideDrawerOpen} drawerClickHandler={this.drawerToggleClickHandler}/>
</div>
)
}
}
export default Navigation
@@ -0,0 +1,13 @@
import React from 'react'
import { Link } from "react-router-dom";
const PagesList = props => {
return (
<ul>
<li><Link onClick={props.click} to="/Dashboard">Dashboard</Link></li>
<li><Link onClick={props.click} to="/Input">Input</Link></li>
</ul>
)
}
export default PagesList
@@ -0,0 +1,56 @@
.toolbar {
position: sticky;
top: 0px;
left: 0;
width: 100%;
background: #00a65a;
height: 56px
}
.toolbar_navigation {
display: flex;
height: 100%;
align-items: center;
padding: 0 1rem;
}
.toolbar_logo {
margin-left: 0.5rem;
}
.toolbar_logo a {
color: white;
text-decoration: none;
font-size: 1.5rem;
}
.toolbar_spacer {
flex: 1;
}
.toolbar_items ul {
list-style: none;
margin: 0;
padding: 0 0;
display: flex;
}
.toolbar_items li {
padding: 0 0.6rem;
}
.toolbar_items a {
color: white;
text-decoration: none;
}
.toolbar_items a:hover,
.toolbar_items a:active {
color: #ff3b76;
}
@media (max-width: 768px) {
.toolbar_items {
display: none;
}
}
@@ -0,0 +1,23 @@
import React from 'react'
import DrawerButton from '../Drawer/DrawerButton';
import PagesList from '../PagesList';
import './Toolbar.css';
import { Link } from 'react-router-dom';
const Toolbar = props => {
return (
<header className="toolbar">
<nav className="toolbar_navigation">
<DrawerButton click={props.drawerClickHandler} />
<div className = "toolbar_logo"><Link to="/">Ridgebotics Scouting</Link></div>
<div className = "toolbar_spacer" />
<div className = "toolbar_items">
<PagesList />
</div>
</nav>
</header>
)
}
export default Toolbar
+4 -5
View File
@@ -1,13 +1,12 @@
body { body {
background-color: rgb(20, 26, 24);
color: white;
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
code { code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
monospace;
} }
+6 -6
View File
@@ -1,14 +1,14 @@
import React from 'react'; import React from "react";
import ReactDOM from 'react-dom'; import ReactDOM from "react-dom";
import './index.css'; import "./index.css";
import App from './App'; import App from "./App";
import reportWebVitals from './reportWebVitals'; import reportWebVitals from "./reportWebVitals";
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<App /> <App />
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById("root")
); );
// If you want to start measuring performance in your app, pass a function // If you want to start measuring performance in your app, pass a function