fix side bar layout

This commit is contained in:
c9s 2021-02-05 09:09:59 +08:00
parent 5f1fc804df
commit 10f8a7864f
6 changed files with 43 additions and 61 deletions

View File

@ -35,7 +35,7 @@ func main() {
args = append(args, "--class=bbgo") args = append(args, "--class=bbgo")
// here allocate a chrome window with a blank page. // here allocate a chrome window with a blank page.
ui, err := lorca.New("", "", 800, 640, args...) ui, err := lorca.New("", "", 1024, 780, args...)
if err != nil { if err != nil {
log.WithError(err).Error("failed to initialize the window") log.WithError(err).Error("failed to initialize the window")
return return

View File

@ -1,22 +1,9 @@
import React from 'react'; import React from 'react';
import { useRouter } from 'next/router'; import {useRouter} from 'next/router';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
import List from '@material-ui/core/List';
import Card from '@material-ui/core/Card';
import CardHeader from '@material-ui/core/CardHeader';
import CardContent from '@material-ui/core/CardContent';
import Avatar from '@material-ui/core/Avatar';
import IconButton from '@material-ui/core/IconButton';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableContainer from '@material-ui/core/TableContainer';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import {makeStyles} from '@material-ui/core/styles'; import {makeStyles} from '@material-ui/core/styles';
@ -48,21 +35,16 @@ const useStyles = makeStyles((theme) => ({
export default function SaveConfigAndRestart({onBack, onRestarted}) { export default function SaveConfigAndRestart({onBack, onRestarted}) {
const classes = useStyles(); const classes = useStyles();
const { push } = useRouter(); const {push} = useRouter();
const [strategies, setStrategies] = React.useState([]);
const [response, setResponse] = React.useState({}); const [response, setResponse] = React.useState({});
React.useEffect(() => {
}, [])
const handleRestart = () => { const handleRestart = () => {
saveConfig((resp) => { saveConfig((resp) => {
setResponse(resp); setResponse(resp);
setupRestart((resp) => { setupRestart((resp) => {
let t let t
t = setInterval(function() { t = setInterval(() => {
ping(() => { ping(() => {
clearInterval(t) clearInterval(t)
push("/"); push("/");

View File

@ -11,20 +11,12 @@ import TrendingUpIcon from "@material-ui/icons/TrendingUp";
import React from "react"; import React from "react";
import {makeStyles} from "@material-ui/core/styles"; import {makeStyles} from "@material-ui/core/styles";
const drawerWidth = 260; const drawerWidth = 240;
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
// flexGrow: 1,
display: 'flex',
},
content: {
flexGrow: 1, flexGrow: 1,
height: '100vh', display: 'flex',
overflow: 'auto',
},
fixedHeight: {
height: 240,
}, },
toolbar: { toolbar: {
paddingRight: 24, // keep right padding when drawer closed paddingRight: 24, // keep right padding when drawer closed
@ -38,14 +30,20 @@ const useStyles = makeStyles((theme) => ({
}, },
appBarSpacer: theme.mixins.toolbar, appBarSpacer: theme.mixins.toolbar,
drawerPaper: { drawerPaper: {
[theme.breakpoints.up('sm')]: {
width: drawerWidth,
flexShrink: 0,
},
position: 'relative', position: 'relative',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
width: drawerWidth,
transition: theme.transitions.create('width', { transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp, easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen, duration: theme.transitions.duration.enteringScreen,
}), }),
}, },
drawer: {
width: drawerWidth,
},
})); }));
@ -54,7 +52,11 @@ export default function SideBar() {
return <Drawer return <Drawer
variant="permanent" variant="permanent"
className={classes.drawerPaper} className={classes.drawer}
PaperProps={{
className: classes.drawerPaper,
}}
anchor={"left"}
open={true}> open={true}>
<div className={classes.appBarSpacer}/> <div className={classes.appBarSpacer}/>

View File

@ -42,7 +42,7 @@ export default function DashboardLayout({children}) {
<main className={classes.content}> <main className={classes.content}>
<div className={classes.appBarSpacer}/> <div className={classes.appBarSpacer}/>
<Container> <Container maxWidth={false} disableGutters={true}>
{children} {children}
</Container> </Container>
</main> </main>

View File

@ -1,5 +1,5 @@
import React, {useState} from 'react'; import React from 'react';
import { useRouter } from 'next/router'; import {useRouter} from 'next/router';
import {makeStyles} from '@material-ui/core/styles'; import {makeStyles} from '@material-ui/core/styles';
import Typography from '@material-ui/core/Typography'; import Typography from '@material-ui/core/Typography';
@ -26,6 +26,7 @@ const useStyles = makeStyles((theme) => ({
height: 300, height: 300,
}, },
totalAssetsSummary: { totalAssetsSummary: {
margin: theme.spacing(2),
padding: theme.spacing(2), padding: theme.spacing(2),
}, },
control: { control: {
@ -34,11 +35,10 @@ const useStyles = makeStyles((theme) => ({
})); }));
// props are pageProps passed from _app.tsx // props are pageProps passed from _app.tsx
export default function Home() { export default function Home() {
const classes = useStyles(); const classes = useStyles();
const { push } = useRouter(); const router = useRouter();
const [sessions, setSessions] = React.useState([]) const [sessions, setSessions] = React.useState([])
@ -47,12 +47,12 @@ export default function Home() {
if (sessions && sessions.length > 0) { if (sessions && sessions.length > 0) {
setSessions(sessions) setSessions(sessions)
} else { } else {
push("/setup"); router.push("/setup");
} }
}).catch((err) => { }).catch((err) => {
console.error(err); console.error(err);
}) })
}, []) }, [router])
if (sessions.length == 0) { if (sessions.length == 0) {
return ( return (
@ -68,29 +68,27 @@ export default function Home() {
return ( return (
<DashboardLayout> <DashboardLayout>
<Box m={4}> <Paper className={classes.totalAssetsSummary}>
<Paper className={classes.totalAssetsSummary}> <Typography variant="h4" component="h2" gutterBottom>
<Typography variant="h4" component="h2" gutterBottom> Total Assets
Total Assets </Typography>
</Typography>
<Grid container spacing={3}> <Grid container spacing={3}>
<Grid item xs={12} md={6}> <Grid item xs={12} md={6}>
<TotalAssetSummary/> <TotalAssetSummary/>
</Grid>
<Grid item xs={12} md={6}>
<Box className={classes.totalAssetsBox}>
<TotalAssetsPie/>
</Box>
</Grid>
</Grid> </Grid>
</Paper>
<TradingVolumePanel/> <Grid item xs={12} md={6}>
<Box className={classes.totalAssetsBox}>
<TotalAssetsPie/>
</Box>
</Grid>
</Grid>
</Paper>
<ExchangeSessionTabPanel/> <TradingVolumePanel/>
</Box>
<ExchangeSessionTabPanel/>
</DashboardLayout> </DashboardLayout>
); );
} }

View File

@ -117,7 +117,7 @@ func (s *Server) setupRestart(c *gin.Context) {
logrus.WithError(err).Error("server forced to shutdown") logrus.WithError(err).Error("server forced to shutdown")
} }
logrus.Info("web server shutdown completed") logrus.Info("server shutdown completed")
bin := os.Args[0] bin := os.Args[0]
args := os.Args[0:] args := os.Args[0:]