Skip to content

Commit a0d6524

Browse files
committed
WIP - demo project
1 parent 4bb4871 commit a0d6524

File tree

17 files changed

+250
-20
lines changed

17 files changed

+250
-20
lines changed

interface/.env

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
REACT_APP_NAME=ESP8266 React
1+
# This is the name of your project. It appears on the sign-in page and in the menu bar.
2+
REACT_APP_PROJECT_NAME=ESP8266 React
3+
4+
# This is the url path your project will be exposed under.
5+
REACT_APP_PROJECT_PATH=project

interface/.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
REACT_APP_ENDPOINT_ROOT=http://192.168.0.11/rest/
1+
REACT_APP_ENDPOINT_ROOT=http://192.168.0.19/rest/

interface/src/AppRouting.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import React, { Component } from 'react';
22

33
import { Redirect, Switch } from 'react-router';
44

5+
import { PROJECT_PATH } from './constants/Env';
56
import * as Authentication from './authentication/Authentication';
67
import AuthenticationWrapper from './authentication/AuthenticationWrapper';
78
import AuthenticatedRoute from './authentication/AuthenticatedRoute';
89
import UnauthenticatedRoute from './authentication/UnauthenticatedRoute';
9-
1010
import SignInPage from './containers/SignInPage';
11-
1211
import WiFiConnection from './sections/WiFiConnection';
1312
import AccessPoint from './sections/AccessPoint';
1413
import NetworkTime from './sections/NetworkTime';
1514
import Security from './sections/Security';
1615
import System from './sections/System';
16+
import ProjectRouting from './project/ProjectRouting';
1717

1818
class AppRouting extends Component {
1919

@@ -31,6 +31,7 @@ class AppRouting extends Component {
3131
<AuthenticatedRoute exact path="/ntp/*" component={NetworkTime} />
3232
<AuthenticatedRoute exact path="/security/*" component={Security} />
3333
<AuthenticatedRoute exact path="/system/*" component={System} />
34+
<AuthenticatedRoute exact path={`/${PROJECT_PATH}/*`} component={ProjectRouting} />
3435
<Redirect to="/" />
3536
</Switch>
3637
</AuthenticationWrapper>

interface/src/authentication/Authentication.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import history from '../history';
2+
import { PROJECT_PATH } from '../constants/Env';
23

34
export const ACCESS_TOKEN = 'access_token';
45
export const LOGIN_PATHNAME = 'loginPathname';
@@ -21,7 +22,7 @@ export function fetchLoginRedirect() {
2122
const loginSearch = localStorage.getItem(LOGIN_SEARCH);
2223
clearLoginRedirect();
2324
return {
24-
pathname: loginPathname || "/wifi/",
25+
pathname: loginPathname || `/${PROJECT_PATH}/`,
2526
search: (loginPathname && loginSearch) || undefined
2627
};
2728
}

interface/src/components/MenuAppBar.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import CardContent from '@material-ui/core/CardContent';
3030
import CardActions from '@material-ui/core/CardActions';
3131
import Avatar from '@material-ui/core/Avatar';
3232

33-
import { APP_NAME } from '../constants/App';
33+
import ProjectMenu from '../project/ProjectMenu';
34+
import { PROJECT_NAME } from '../constants/Env';
3435
import { withAuthenticationContext } from '../authentication/Context.js';
3536

3637
const drawerWidth = 290;
@@ -65,8 +66,7 @@ const styles = theme => ({
6566
width: drawerWidth,
6667
},
6768
content: {
68-
flexGrow: 1,
69-
padding: theme.spacing(),
69+
flexGrow: 1
7070
},
7171
authMenu: {
7272
zIndex: theme.zIndex.tooltip,
@@ -112,11 +112,13 @@ class MenuAppBar extends React.Component {
112112
<div>
113113
<Toolbar>
114114
<Typography variant="h6" color="primary">
115-
{APP_NAME}
115+
{PROJECT_NAME}
116116
</Typography>
117117
<Divider absolute />
118118
</Toolbar>
119119
<Divider />
120+
<ProjectMenu />
121+
<Divider />
120122
<List>
121123
<ListItem to='/wifi/' selected={path.startsWith('/wifi/')} button component={Link}>
122124
<ListItemIcon>

interface/src/components/SectionContent.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import Typography from '@material-ui/core/Typography';
88
const styles = theme => ({
99
content: {
1010
padding: theme.spacing(2),
11-
margin: theme.spacing(2),
11+
margin: theme.spacing(3),
1212
}
1313
});
1414

1515
function SectionContent(props) {
16-
const { children, classes, title } = props;
16+
const { children, classes, title, titleGutter } = props;
1717
return (
1818
<Paper className={classes.content}>
19-
<Typography variant="h6">
19+
<Typography variant="h6" gutterBottom={titleGutter}>
2020
{title}
2121
</Typography>
2222
{children}
@@ -30,7 +30,8 @@ SectionContent.propTypes = {
3030
PropTypes.arrayOf(PropTypes.node),
3131
PropTypes.node
3232
]).isRequired,
33-
title: PropTypes.string.isRequired
33+
title: PropTypes.string.isRequired,
34+
titleGutter: PropTypes.bool
3435
};
3536

3637
export default withStyles(styles)(SectionContent);

interface/src/constants/App.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

interface/src/constants/Env.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const PROJECT_NAME = process.env.REACT_APP_PROJECT_NAME;
2+
export const PROJECT_PATH = process.env.REACT_APP_PROJECT_PATH;

interface/src/containers/APStatus.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ class APStatus extends Component {
9696
return (
9797
<div>
9898
<List>
99-
<Fragment>
100-
{this.createListItems(data, classes)}
101-
</Fragment>
99+
{this.createListItems(data, classes)}
102100
</List>
103101
<Button variant="contained" color="secondary" className={classes.button} onClick={this.props.loadData}>
104102
Refresh

interface/src/containers/ManageUsers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ManageUsers extends Component {
1414
render() {
1515
const { data, fetched, errorMessage } = this.props;
1616
return (
17-
<SectionContent title="Manage Users">
17+
<SectionContent title="Manage Users" titleGutter>
1818
<ManageUsersForm
1919
userData={data}
2020
userDataFetched={fetched}

0 commit comments

Comments
 (0)