|
|
@ -1,7 +1,7 @@ |
|
|
|
import { useContext } from 'react'; |
|
|
|
import { useContext } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import { Box } from '@material-ui/core'; |
|
|
|
import { Box } from '@mui/material'; |
|
|
|
import { makeStyles } from '@material-ui/core/styles'; |
|
|
|
import { styled } from '@mui/material/styles'; |
|
|
|
import { BodyText, HeaderText } from '../Text'; |
|
|
|
import { BodyText, HeaderText } from '../Text'; |
|
|
|
import { Panel, InnerPanel, PanelHeader } from '../Panels'; |
|
|
|
import { Panel, InnerPanel, PanelHeader } from '../Panels'; |
|
|
|
import SharedStorageHost from './FileSystemsHost'; |
|
|
|
import SharedStorageHost from './FileSystemsHost'; |
|
|
@ -10,12 +10,20 @@ import { AnvilContext } from '../AnvilContext'; |
|
|
|
import Spinner from '../Spinner'; |
|
|
|
import Spinner from '../Spinner'; |
|
|
|
import { LARGE_MOBILE_BREAKPOINT } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
import { LARGE_MOBILE_BREAKPOINT } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
|
|
|
|
const useStyles = makeStyles((theme) => ({ |
|
|
|
const PREFIX = 'SharedStorage'; |
|
|
|
header: { |
|
|
|
|
|
|
|
|
|
|
|
const classes = { |
|
|
|
|
|
|
|
header: `${PREFIX}-header`, |
|
|
|
|
|
|
|
root: `${PREFIX}-root`, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const StyledDiv = styled('div')(({ theme }) => ({ |
|
|
|
|
|
|
|
[`& .${classes.header}`]: { |
|
|
|
paddingTop: '.1em', |
|
|
|
paddingTop: '.1em', |
|
|
|
paddingRight: '.7em', |
|
|
|
paddingRight: '.7em', |
|
|
|
}, |
|
|
|
}, |
|
|
|
root: { |
|
|
|
|
|
|
|
|
|
|
|
[`& .${classes.root}`]: { |
|
|
|
overflow: 'auto', |
|
|
|
overflow: 'auto', |
|
|
|
height: '78vh', |
|
|
|
height: '78vh', |
|
|
|
paddingLeft: '.3em', |
|
|
|
paddingLeft: '.3em', |
|
|
@ -26,51 +34,56 @@ const useStyles = makeStyles((theme) => ({ |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
const SharedStorage = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { |
|
|
|
const SharedStorage = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { |
|
|
|
const classes = useStyles(); |
|
|
|
|
|
|
|
const { uuid } = useContext(AnvilContext); |
|
|
|
const { uuid } = useContext(AnvilContext); |
|
|
|
const { data, isLoading } = PeriodicFetch<AnvilSharedStorage>( |
|
|
|
const { data, isLoading } = PeriodicFetch<AnvilSharedStorage>( |
|
|
|
`${process.env.NEXT_PUBLIC_API_URL}/get_shared_storage?anvil_uuid=${uuid}`, |
|
|
|
`${process.env.NEXT_PUBLIC_API_URL}/get_shared_storage?anvil_uuid=${uuid}`, |
|
|
|
); |
|
|
|
); |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Panel> |
|
|
|
<Panel> |
|
|
|
<HeaderText text="Shared Storage" /> |
|
|
|
<StyledDiv> |
|
|
|
{!isLoading ? ( |
|
|
|
<HeaderText text="Shared Storage" /> |
|
|
|
<Box className={classes.root}> |
|
|
|
{!isLoading ? ( |
|
|
|
{data?.file_systems && |
|
|
|
<Box className={classes.root}> |
|
|
|
data.file_systems.map( |
|
|
|
{data?.file_systems && |
|
|
|
(fs: AnvilFileSystem): JSX.Element => ( |
|
|
|
data.file_systems.map( |
|
|
|
<InnerPanel key={fs.mount_point}> |
|
|
|
(fs: AnvilFileSystem): JSX.Element => ( |
|
|
|
<PanelHeader> |
|
|
|
<InnerPanel key={fs.mount_point}> |
|
|
|
<Box display="flex" width="100%" className={classes.header}> |
|
|
|
<PanelHeader> |
|
|
|
<Box> |
|
|
|
<Box |
|
|
|
<BodyText text={fs.mount_point} /> |
|
|
|
display="flex" |
|
|
|
|
|
|
|
width="100%" |
|
|
|
|
|
|
|
className={classes.header} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<Box> |
|
|
|
|
|
|
|
<BodyText text={fs.mount_point} /> |
|
|
|
|
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</PanelHeader> |
|
|
|
</PanelHeader> |
|
|
|
{fs?.hosts && |
|
|
|
{fs?.hosts && |
|
|
|
fs.hosts.map( |
|
|
|
fs.hosts.map( |
|
|
|
( |
|
|
|
( |
|
|
|
host: AnvilFileSystemHost, |
|
|
|
host: AnvilFileSystemHost, |
|
|
|
index: number, |
|
|
|
index: number, |
|
|
|
): JSX.Element => ( |
|
|
|
): JSX.Element => ( |
|
|
|
<SharedStorageHost |
|
|
|
<SharedStorageHost |
|
|
|
host={{ |
|
|
|
host={{ |
|
|
|
...host, |
|
|
|
...host, |
|
|
|
...anvil[ |
|
|
|
...anvil[ |
|
|
|
anvil.findIndex((a) => a.anvil_uuid === uuid) |
|
|
|
anvil.findIndex((a) => a.anvil_uuid === uuid) |
|
|
|
].hosts[index], |
|
|
|
].hosts[index], |
|
|
|
}} |
|
|
|
}} |
|
|
|
key={fs.hosts[index].free} |
|
|
|
key={fs.hosts[index].free} |
|
|
|
/> |
|
|
|
/> |
|
|
|
), |
|
|
|
), |
|
|
|
)} |
|
|
|
)} |
|
|
|
</InnerPanel> |
|
|
|
</InnerPanel> |
|
|
|
), |
|
|
|
), |
|
|
|
)} |
|
|
|
)} |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<Spinner /> |
|
|
|
<Spinner /> |
|
|
|
)} |
|
|
|
)} |
|
|
|
</StyledDiv> |
|
|
|
</Panel> |
|
|
|
</Panel> |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|