add SaveConfigAndRestart panel

This commit is contained in:
c9s 2021-02-03 15:59:06 +08:00
parent f7a4f7d415
commit 2486204b2f
3 changed files with 103 additions and 20 deletions

View File

@ -1,29 +1,22 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import AndroidIcon from '@material-ui/icons/Android';
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 ExpandMoreIcon from '@material-ui/icons/ExpandMore';
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 CardActions from '@material-ui/core/CardActions';
import {makeStyles} from '@material-ui/core/styles';
import {querySessions, queryStrategies} from "../api/bbgo";
import {queryStrategies} from "../api/bbgo";
const useStyles = makeStyles((theme) => ({
strategyCard: {
@ -112,7 +105,7 @@ export default function ReviewStrategies({onBack, onNext}) {
}
action={
<IconButton aria-label="settings">
<MoreVertIcon />
<MoreVertIcon/>
</IconButton>
}
title={title}
@ -128,15 +121,6 @@ export default function ReviewStrategies({onBack, onNext}) {
</CardContent>
</Card>
);
return (
<ListItem key={i}>
<ListItemIcon>
<AndroidIcon/>
</ListItemIcon>
<ListItemText primary={o.strategy + desc} secondary={mounts}/>
</ListItem>
);
})
return (
@ -150,7 +134,11 @@ export default function ReviewStrategies({onBack, onNext}) {
</List>
<div className={classes.buttons}>
<Button onClick={() => { if (onBack) { onBack() } }}>
<Button onClick={() => {
if (onBack) {
onBack()
}
}}>
Add New Strategy
</Button>

View File

@ -0,0 +1,87 @@
import React from 'react';
import Button from '@material-ui/core/Button';
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 {queryStrategies} from "../api/bbgo";
const useStyles = makeStyles((theme) => ({
strategyCard: {
margin: theme.spacing(1),
},
formControl: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(1),
minWidth: 120,
},
buttons: {
display: 'flex',
justifyContent: 'flex-end',
marginTop: theme.spacing(2),
paddingTop: theme.spacing(2),
paddingBottom: theme.spacing(2),
'& > *': {
marginLeft: theme.spacing(1),
}
},
}));
export default function SaveConfigAndRestart({onBack, onRestarted}) {
const classes = useStyles();
const [strategies, setStrategies] = React.useState([]);
React.useEffect(() => {
queryStrategies((strategies) => {
setStrategies(strategies || [])
}).catch((err) => {
console.error(err);
});
}, [])
const handleRestart = () => {
};
return (
<React.Fragment>
<Typography variant="h6" gutterBottom>
Save Config and Restart
</Typography>
<Typography variant="body1" gutterBottom>
</Typography>
<div className={classes.buttons}>
<Button onClick={() => {
if (onBack) {
onBack()
}
}}>
Back
</Button>
<Button
variant="contained"
color="primary"
onClick={handleRestart}>
Restart
</Button>
</div>
</React.Fragment>
);
}

View File

@ -13,6 +13,7 @@ import AddExchangeSessionForm from "../../components/AddExchangeSessionForm";
import ReviewSessions from "../../components/ReviewSessions";
import ConfigureGridStrategyForm from "../../components/ConfigureGridStrategyForm";
import ReviewStrategies from "../../components/ReviewStrategies";
import SaveConfigAndRestart from "../../components/SaveConfigAndRestart";
import PlainLayout from '../../layouts/PlainLayout';
@ -60,7 +61,14 @@ function getStepContent(step, setActiveStep) {
);
case 5:
return
return (
<SaveConfigAndRestart
onBack={() => { setActiveStep(4) }}
onRestarted={() => {
}}
/>
)
default:
throw new Error('Unknown step');