Merge pull request 'addFeatures' (#51) from addFeatures into master
Reviewed-by: Oliver Boehlk <ollitobiasb@gmail.com>
This commit was merged in pull request #51.
This commit is contained in:
@@ -147,6 +147,11 @@ app.post("/API/user/login", passport.authenticate('local-login'), function (req,
|
|||||||
return res.status(status.OK).send("login success");
|
return res.status(status.OK).send("login success");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.delete("/API/user/logout", function (req, res) {
|
||||||
|
req.logout();
|
||||||
|
return res.status(status.OK).send("logout success");
|
||||||
|
});
|
||||||
|
|
||||||
app.put("/API/user/create", function (req, res) {
|
app.put("/API/user/create", function (req, res) {
|
||||||
let { email, password } = req.body;
|
let { email, password } = req.body;
|
||||||
if (email && password) {
|
if (email && password) {
|
||||||
|
|||||||
74
frontend/src/components/accountMenu/accountMenu.js
Normal file
74
frontend/src/components/accountMenu/accountMenu.js
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
|
import Menu from '@material-ui/core/Menu';
|
||||||
|
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||||
|
import IconButton from '@material-ui/core/IconButton';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import Link1 from '@material-ui/core/Link';
|
||||||
|
|
||||||
|
function MenuItemLink(props) {
|
||||||
|
return <MenuItem component={Link1} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function AccountMenu(props) {
|
||||||
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
||||||
|
const openMenu = Boolean(anchorEl);
|
||||||
|
|
||||||
|
const handleMenu = (event) => {
|
||||||
|
setAnchorEl(event.currentTarget);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
setAnchorEl(null);
|
||||||
|
};
|
||||||
|
|
||||||
|
const logout = async () => {
|
||||||
|
await fetch(`/simcompanies/API/user/logout`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
mode: 'cors',
|
||||||
|
cache: 'no-cache',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
redirect: 'follow',
|
||||||
|
referrerPolicy: 'no-referrer'
|
||||||
|
}).then(
|
||||||
|
() => { window.location.reload() }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
logout()
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<IconButton
|
||||||
|
onClick={handleMenu}
|
||||||
|
color="inherit"
|
||||||
|
>
|
||||||
|
<AccountCircle fontSize="large" />
|
||||||
|
</IconButton>
|
||||||
|
<Menu
|
||||||
|
id="menu-appbar"
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: 'bottom',
|
||||||
|
horizontal: 'right',
|
||||||
|
}}
|
||||||
|
keepMounted
|
||||||
|
getContentAnchorEl={null}
|
||||||
|
transformOrigin={{
|
||||||
|
vertical: 'top',
|
||||||
|
horizontal: 'right',
|
||||||
|
}}
|
||||||
|
open={openMenu}
|
||||||
|
onClose={handleClose}
|
||||||
|
>
|
||||||
|
<MenuItemLink to={"/profile"} onClick={handleClose} component={Link}>Profile</MenuItemLink>
|
||||||
|
<MenuItem onClick={handleLogout}>Logout</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
} from "react-router-dom";
|
} from "react-router-dom";
|
||||||
import SelectResource from './selectResource';
|
import SelectResource from './selectResource';
|
||||||
import ResourceChart from './resourcechart/resourcechart';
|
import ResourceChart from './resourcechart/resourcechart';
|
||||||
|
import Profile from './profile/profile';
|
||||||
|
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
@@ -23,6 +24,7 @@ export default function Content() {
|
|||||||
|
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Route exact path="/" component={Overview} />
|
<Route exact path="/" component={Overview} />
|
||||||
|
<Route path="/profile" component={Profile} />
|
||||||
<Route path="/resources" component={SelectResource} />
|
<Route path="/resources" component={SelectResource} />
|
||||||
<Route path="/resourcechart/:id" component={ResourceChart} />
|
<Route path="/resourcechart/:id" component={ResourceChart} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ import EmojiObjectsIcon from '@material-ui/icons/EmojiObjects';
|
|||||||
import { ListItemIcon } from '@material-ui/core';
|
import { ListItemIcon } from '@material-ui/core';
|
||||||
import Tooltip from '@material-ui/core/Tooltip';
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
import Zoom from '@material-ui/core/Zoom';
|
import Zoom from '@material-ui/core/Zoom';
|
||||||
|
import ApartmentIcon from '@material-ui/icons/Apartment';
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
|
import Menu from '@material-ui/core/Menu';
|
||||||
|
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||||
|
import AccountMenu from './accountMenu/accountMenu';
|
||||||
|
|
||||||
const drawerWidth = 64;
|
const drawerWidth = 64;
|
||||||
const drawerWidthOpen = 240;
|
const drawerWidthOpen = 240;
|
||||||
@@ -168,6 +173,20 @@ export default function Navigation() {
|
|||||||
return <ListItem button component={Link1} {...props} />;
|
return <ListItem button component={Link1} {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showIcon = (text) => {
|
||||||
|
if (text === "Resources") {
|
||||||
|
return (
|
||||||
|
<EmojiObjectsIcon fontSize="large" color="secondary"></EmojiObjectsIcon>
|
||||||
|
)
|
||||||
|
} else if (text === "Traders") {
|
||||||
|
return (
|
||||||
|
<ApartmentIcon fontSize="large" color="secondary"></ApartmentIcon>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
@@ -188,19 +207,7 @@ export default function Navigation() {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
<Link1 href="/simcompanies" className="logo">Sim Companies Dashboard</Link1>
|
<Link1 href="/simcompanies" className="logo">Sim Companies Dashboard</Link1>
|
||||||
<div className={classes.grow} />
|
<div className={classes.grow} />
|
||||||
<div className={classes.search}>
|
<AccountMenu></AccountMenu>
|
||||||
<div className={classes.searchIcon}>
|
|
||||||
<SearchIcon />
|
|
||||||
</div>
|
|
||||||
<InputBase
|
|
||||||
placeholder="Search…"
|
|
||||||
classes={{
|
|
||||||
root: classes.inputRoot,
|
|
||||||
input: classes.inputInput,
|
|
||||||
}}
|
|
||||||
inputProps={{ 'aria-label': 'search' }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<Drawer
|
<Drawer
|
||||||
@@ -223,17 +230,15 @@ export default function Navigation() {
|
|||||||
</div>
|
</div>
|
||||||
<Divider />
|
<Divider />
|
||||||
<List>
|
<List>
|
||||||
{['Resources'].map((text, index) => (
|
{['Resources', 'Traders'].map((text, index) => (
|
||||||
|
|
||||||
<ListItemLink key={text} to={"/" + text.toLowerCase()} component={Link}>
|
<ListItemLink key={text} to={"/" + text.toLowerCase()} component={Link}>
|
||||||
<Tooltip TransitionComponent={Zoom} placement='right' title="Resources" arrow enterDelay={500}>
|
<Tooltip TransitionComponent={Zoom} placement='right' title={text} arrow enterDelay={500}>
|
||||||
<ListItemIcon><EmojiObjectsIcon fontSize="large" color="secondary"></EmojiObjectsIcon></ListItemIcon>
|
<ListItemIcon>
|
||||||
|
{showIcon(text)}
|
||||||
|
</ListItemIcon>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<ListItemText primary={text} />
|
<ListItemText primary={text} />
|
||||||
|
|
||||||
</ListItemLink>
|
</ListItemLink>
|
||||||
|
|
||||||
|
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|||||||
12
frontend/src/components/profile/profile.js
Normal file
12
frontend/src/components/profile/profile.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
|
||||||
|
export default function Profile(props) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Typography variant="h4">
|
||||||
|
Profile Page
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,12 +2,10 @@ import React from 'react';
|
|||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
import Typography from '@material-ui/core/Typography';
|
|
||||||
import Grid from '@material-ui/core/Grid';
|
import Grid from '@material-ui/core/Grid';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import Link1 from '@material-ui/core/Link';
|
import Link1 from '@material-ui/core/Link';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
|
||||||
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
||||||
import Tooltip from '@material-ui/core/Tooltip';
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
import Zoom from '@material-ui/core/Zoom';
|
import Zoom from '@material-ui/core/Zoom';
|
||||||
|
|||||||
Reference in New Issue
Block a user