-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from feedernet/prettier-js
Add Prettier Formatting
- Loading branch information
Showing
96 changed files
with
5,305 additions
and
4,516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ To run the daemon locally: | |
poetry run python -m feeder | ||
``` | ||
|
||
If you are planning on soley developing for the backend, you can build a static version of the frontend and access the backend directly: | ||
If you are planning on solely developing for the backend, you can build a static version of the frontend and access the backend directly: | ||
|
||
``` | ||
cd static | ||
|
@@ -46,6 +46,23 @@ Otherwise, in a different shell, run the Webpack development server: | |
npm start | ||
``` | ||
|
||
### Linting and Code Formatting | ||
We use Black formatting for Python and Prettier for JS, JSON, etc. | ||
|
||
Tox will automatically run both of these tools when it runs it's normal test suite. | ||
If either step fails, you will need to rerun the respective formatter. | ||
|
||
#### Black | ||
```shell | ||
black --target-version py38 feeder/ tests/ | ||
``` | ||
|
||
#### Prettier | ||
```shell | ||
cd static | ||
npx prettier --check ./src | ||
``` | ||
|
||
## Database and Schema Migrations | ||
|
||
This project uses SQLAlchemy and Alembic for managing database models and schema migrations. | ||
|
@@ -66,7 +83,7 @@ DATABASE_PATH=./data.db alembic upgrade head | |
|
||
# How can I help? | ||
|
||
If you have tech and coding experience, you can help! Drop Ted an email ([email protected]); introduce yourself and he'll send you a Slack invite. | ||
If you have tech and coding experience, you can help! Drop Ted an email ([email protected]); introduce yourself, and he'll send you a Slack invite. | ||
|
||
**The Slack channel is _NOT_ for support requests.** | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,100 @@ | ||
import React from 'react'; | ||
import {Switch, Route, withRouter, Link} from 'react-router-dom'; | ||
import React from "react"; | ||
import { Switch, Route, withRouter, Link } from "react-router-dom"; | ||
import Container from "react-bootstrap/Container"; | ||
import Navbar from "react-bootstrap/Navbar"; | ||
import Nav from "react-bootstrap/Nav"; | ||
import Icon from '@mdi/react' | ||
import {mdiSilverwareForkKnife, mdiCog, mdiPaw} from '@mdi/js'; | ||
import {ErrorComponent} from "./components/Error"; | ||
import Icon from "@mdi/react"; | ||
import { mdiSilverwareForkKnife, mdiCog, mdiPaw } from "@mdi/js"; | ||
import { ErrorComponent } from "./components/Error"; | ||
import FeederCardList from "./containers/FeederCardListContainer"; | ||
import FeedHistory from "./containers/FeedHistoryTableContainer"; | ||
import {getRootPath} from "./util"; | ||
import ProjectLogo from "./images/feeder-project-logo.svg" | ||
import { getRootPath } from "./util"; | ||
import ProjectLogo from "./images/feeder-project-logo.svg"; | ||
import NewFeederWizard from "./containers/NewFeederWizard"; | ||
import SnackModal from "./containers/SnackModalContainer"; | ||
import EditFeederModal from "./containers/EditFeederModalContainer"; | ||
import PetCardList from "./containers/PetCardListContainer"; | ||
import EditPetModal from "./containers/EditPetModalContainer"; | ||
import ScheduleModal from "./containers/ScheduleModalContainer"; | ||
|
||
const rootPath = getRootPath() | ||
const rootPath = getRootPath(); | ||
|
||
class App extends React.Component { | ||
state = { | ||
routes: [ | ||
{ | ||
path: rootPath, | ||
label: 'Feeder List', | ||
exact: true, | ||
render: props => { | ||
return <> | ||
<PetCardList {...props} /> | ||
<FeederCardList {...props} /> | ||
<FeedHistory {...props} /> | ||
<NewFeederWizard/> | ||
<SnackModal/> | ||
<EditFeederModal/> | ||
<EditPetModal/> | ||
<ScheduleModal/> | ||
</> | ||
} | ||
}, | ||
{ | ||
label: 'Page Not Found', | ||
render: () => { | ||
return <ErrorComponent message="Page Not Found!"/>; | ||
} | ||
} | ||
] | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Navbar | ||
expand="lg" | ||
variant="dark" | ||
bg="primary" | ||
fixed="top" | ||
className={window.navigator.standalone === true ? "ios-app-nav" : null}> | ||
<Container> | ||
<Navbar.Brand href="#"> | ||
<img src={ProjectLogo} alt={"FeederNet Logo"} width={175}/> | ||
</Navbar.Brand> | ||
<Navbar.Toggle aria-controls="basic-navbar-nav"/> | ||
<Navbar.Collapse id="basic-navbar-nav"> | ||
<Nav className="mr-auto"> | ||
<Link | ||
to={rootPath} | ||
component={Nav.Link} | ||
active={window.location.pathname === `${rootPath}/`} | ||
> | ||
<Icon path={mdiPaw} size={.75}/> Home | ||
</Link> | ||
<Link to={`${rootPath}/settings`} component={Nav.Link}> | ||
<Icon path={mdiCog} size={.75}/> Settings | ||
</Link> | ||
</Nav> | ||
</Navbar.Collapse> | ||
</Container> | ||
</Navbar> | ||
<Container style={{marginTop: window.navigator.standalone === true ? 70 : 100}}> | ||
<Switch> | ||
{this.state.routes.map(ea => { | ||
return <Route key={ea.path} {...ea} />; | ||
})} | ||
</Switch> | ||
</Container> | ||
</div> | ||
); | ||
} | ||
state = { | ||
routes: [ | ||
{ | ||
path: rootPath, | ||
label: "Feeder List", | ||
exact: true, | ||
render: (props) => { | ||
return ( | ||
<> | ||
<PetCardList {...props} /> | ||
<FeederCardList {...props} /> | ||
<FeedHistory {...props} /> | ||
<NewFeederWizard /> | ||
<SnackModal /> | ||
<EditFeederModal /> | ||
<EditPetModal /> | ||
<ScheduleModal /> | ||
</> | ||
); | ||
}, | ||
}, | ||
{ | ||
label: "Page Not Found", | ||
render: () => { | ||
return <ErrorComponent message="Page Not Found!" />; | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<Navbar | ||
expand="lg" | ||
variant="dark" | ||
bg="primary" | ||
fixed="top" | ||
className={ | ||
window.navigator.standalone === true ? "ios-app-nav" : null | ||
} | ||
> | ||
<Container> | ||
<Navbar.Brand href="#"> | ||
<img src={ProjectLogo} alt={"FeederNet Logo"} width={175} /> | ||
</Navbar.Brand> | ||
<Navbar.Toggle aria-controls="basic-navbar-nav" /> | ||
<Navbar.Collapse id="basic-navbar-nav"> | ||
<Nav className="mr-auto"> | ||
<Link | ||
to={rootPath} | ||
component={Nav.Link} | ||
active={window.location.pathname === `${rootPath}/`} | ||
> | ||
<Icon path={mdiPaw} size={0.75} /> Home | ||
</Link> | ||
<Link to={`${rootPath}/settings`} component={Nav.Link}> | ||
<Icon path={mdiCog} size={0.75} /> Settings | ||
</Link> | ||
</Nav> | ||
</Navbar.Collapse> | ||
</Container> | ||
</Navbar> | ||
<Container | ||
style={{ marginTop: window.navigator.standalone === true ? 70 : 100 }} | ||
> | ||
<Switch> | ||
{this.state.routes.map((ea) => { | ||
return <Route key={ea.path} {...ea} />; | ||
})} | ||
</Switch> | ||
</Container> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default withRouter(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,40 @@ | ||
import {PET_API_BASE} from "../constants"; | ||
import {createPet} from "../constants/pet"; | ||
import {createAction} from "redux-api-middleware"; | ||
import { PET_API_BASE } from "../constants"; | ||
import { createPet } from "../constants/pet"; | ||
import { createAction } from "redux-api-middleware"; | ||
|
||
export const createPetAction = (name, animal_type, weight, birthday, activity_level, image = null, device_hid = null) => { | ||
const body = JSON.stringify({ | ||
name, | ||
animal_type, | ||
weight, | ||
birthday, | ||
image, | ||
activity_level, | ||
device_hid | ||
}); | ||
export const createPetAction = ( | ||
name, | ||
animal_type, | ||
weight, | ||
birthday, | ||
activity_level, | ||
image = null, | ||
device_hid = null | ||
) => { | ||
const body = JSON.stringify({ | ||
name, | ||
animal_type, | ||
weight, | ||
birthday, | ||
image, | ||
activity_level, | ||
device_hid, | ||
}); | ||
|
||
const meta = { | ||
method: 'POST', | ||
endpoint: `${PET_API_BASE}`, | ||
body | ||
}; | ||
return createAction({ | ||
endpoint: meta.endpoint, | ||
types: [ | ||
{type: createPet.CREATE_PET, meta}, | ||
{type: createPet.CREATE_PET_SUCCESS, meta}, | ||
{type: createPet.CREATE_PET_FAILURE, meta}, | ||
], | ||
method: meta.method, | ||
credentials: 'include', | ||
body | ||
}); | ||
}; | ||
const meta = { | ||
method: "POST", | ||
endpoint: `${PET_API_BASE}`, | ||
body, | ||
}; | ||
return createAction({ | ||
endpoint: meta.endpoint, | ||
types: [ | ||
{ type: createPet.CREATE_PET, meta }, | ||
{ type: createPet.CREATE_PET_SUCCESS, meta }, | ||
{ type: createPet.CREATE_PET_FAILURE, meta }, | ||
], | ||
method: meta.method, | ||
credentials: "include", | ||
body, | ||
}); | ||
}; |
Oops, something went wrong.