You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.7 KiB
73 lines
1.7 KiB
4 years ago
|
import { useState } from 'react';
|
||
4 years ago
|
import { useRouter } from 'next/router';
|
||
4 years ago
|
import { Box } from '@material-ui/core';
|
||
|
import { makeStyles } from '@material-ui/core/styles';
|
||
|
|
||
4 years ago
|
import PeriodicFetch from '../../lib/fetchers/periodicFetch';
|
||
4 years ago
|
import { FullSize, Preview } from '../../components/Display';
|
||
4 years ago
|
import Header from '../../components/Header';
|
||
4 years ago
|
|
||
|
const useStyles = makeStyles((theme) => ({
|
||
|
child: {
|
||
|
width: '22%',
|
||
|
height: '100%',
|
||
|
[theme.breakpoints.down('lg')]: {
|
||
|
width: '25%',
|
||
|
},
|
||
|
[theme.breakpoints.down('md')]: {
|
||
|
width: '100%',
|
||
|
},
|
||
|
},
|
||
|
server: {
|
||
|
width: '35%',
|
||
|
[theme.breakpoints.down('lg')]: {
|
||
|
width: '25%',
|
||
|
},
|
||
|
[theme.breakpoints.down('md')]: {
|
||
|
width: '100%',
|
||
|
},
|
||
|
},
|
||
|
container: {
|
||
|
display: 'flex',
|
||
|
flexDirection: 'row',
|
||
|
width: '100%',
|
||
|
justifyContent: 'space-between',
|
||
|
[theme.breakpoints.down('md')]: {
|
||
|
display: 'block',
|
||
|
},
|
||
|
},
|
||
|
}));
|
||
|
|
||
4 years ago
|
const Server = (): JSX.Element => {
|
||
4 years ago
|
const [previewMode, setPreviewMode] = useState<boolean>(true);
|
||
4 years ago
|
const classes = useStyles();
|
||
|
|
||
4 years ago
|
const router = useRouter();
|
||
|
const { uuid } = router.query;
|
||
|
|
||
|
const { data } = PeriodicFetch<AnvilReplicatedStorage>(
|
||
4 years ago
|
`${process.env.NEXT_PUBLIC_API_URL}/get_replicated_storage?server_uuid=${uuid}`,
|
||
4 years ago
|
);
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Header />
|
||
4 years ago
|
{typeof uuid === 'string' &&
|
||
|
data &&
|
||
|
(previewMode ? (
|
||
|
<Box className={classes.container}>
|
||
|
<Box className={classes.child}>
|
||
4 years ago
|
<Preview setMode={setPreviewMode} />
|
||
4 years ago
|
</Box>
|
||
4 years ago
|
</Box>
|
||
4 years ago
|
) : (
|
||
|
<Box className={classes.container}>
|
||
3 years ago
|
<FullSize setMode={setPreviewMode} uuid={uuid} />
|
||
4 years ago
|
</Box>
|
||
4 years ago
|
))}
|
||
4 years ago
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
4 years ago
|
export default Server;
|