refactor(front-end): use 2 columns for wider layout and display server at the top

main
Josue 4 years ago
parent 9f8303ed61
commit ea91b36291
  1. 60
      striker-ui/pages/index.tsx

@ -11,13 +11,15 @@ import PeriodicFetch from '../lib/fetchers/periodicFetch';
import Servers from '../components/Servers'; import Servers from '../components/Servers';
import Header from '../components/Header'; import Header from '../components/Header';
import AnvilProvider from '../components/AnvilContext'; import AnvilProvider from '../components/AnvilContext';
import { LARGE_MOBILE_BREAKPOINT } from '../lib/consts/DEFAULT_THEME';
import useWindowDimensions from '../hooks/useWindowDimenions';
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
child: { child: {
width: '22%', width: '22%',
height: '100%', height: '100%',
[theme.breakpoints.down('lg')]: { [theme.breakpoints.down(LARGE_MOBILE_BREAKPOINT)]: {
width: '25%', width: '50%',
}, },
[theme.breakpoints.down('md')]: { [theme.breakpoints.down('md')]: {
width: '100%', width: '100%',
@ -26,9 +28,6 @@ const useStyles = makeStyles((theme) => ({
server: { server: {
width: '35%', width: '35%',
height: '100%', height: '100%',
[theme.breakpoints.down('lg')]: {
width: '25%',
},
[theme.breakpoints.down('md')]: { [theme.breakpoints.down('md')]: {
width: '100%', width: '100%',
}, },
@ -46,6 +45,7 @@ const useStyles = makeStyles((theme) => ({
const Home = (): JSX.Element => { const Home = (): JSX.Element => {
const classes = useStyles(); const classes = useStyles();
const width = useWindowDimensions();
const { data } = PeriodicFetch<AnvilList>( const { data } = PeriodicFetch<AnvilList>(
`${process.env.NEXT_PUBLIC_API_URL}/get_anvils`, `${process.env.NEXT_PUBLIC_API_URL}/get_anvils`,
@ -55,25 +55,41 @@ const Home = (): JSX.Element => {
<> <>
<AnvilProvider> <AnvilProvider>
<Header /> <Header />
{data?.anvils && ( {data?.anvils &&
<Box className={classes.container}> width &&
<Box className={classes.child}> (width > LARGE_MOBILE_BREAKPOINT ? (
<Anvils list={data} /> <Box className={classes.container}>
<Hosts anvil={data.anvils} /> <Box className={classes.child}>
</Box> <Anvils list={data} />
<Box className={classes.server}> <Hosts anvil={data.anvils} />
<Servers anvil={data.anvils} /> </Box>
</Box> <Box className={classes.server}>
<Box className={classes.child}> <Servers anvil={data.anvils} />
<SharedStorage /> </Box>
<Box className={classes.child}>
<SharedStorage />
</Box>
<Box className={classes.child}>
<Network />
<CPU />
<Memory />
</Box>
</Box> </Box>
<Box className={classes.child}> ) : (
<Network /> <Box className={classes.container}>
<CPU /> <Box className={classes.child}>
<Memory /> <Servers anvil={data.anvils} />
<Anvils list={data} />
<Hosts anvil={data.anvils} />
</Box>
<Box className={classes.child}>
<Network />
<SharedStorage />
<CPU />
<Memory />
</Box>
</Box> </Box>
</Box> ))}
)}
</AnvilProvider> </AnvilProvider>
</> </>
); );

Loading…
Cancel
Save