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.
81 lines
2.1 KiB
81 lines
2.1 KiB
4 years ago
|
import { Box } from '@material-ui/core';
|
||
|
import { makeStyles } from '@material-ui/core/styles';
|
||
4 years ago
|
import * as prettyBytes from 'pretty-bytes';
|
||
4 years ago
|
import { AllocationBar } from '../Bars';
|
||
|
import { BodyText } from '../Text';
|
||
4 years ago
|
import Decorator from '../Decorator';
|
||
4 years ago
|
|
||
4 years ago
|
const useStyles = makeStyles(() => ({
|
||
|
fs: {
|
||
4 years ago
|
paddingLeft: '.7em',
|
||
|
paddingRight: '.7em',
|
||
4 years ago
|
paddingTop: '1.2em',
|
||
4 years ago
|
},
|
||
|
bar: {
|
||
4 years ago
|
paddingLeft: '.7em',
|
||
|
paddingRight: '.7em',
|
||
4 years ago
|
},
|
||
4 years ago
|
decoratorBox: {
|
||
4 years ago
|
paddingRight: '.3em',
|
||
4 years ago
|
},
|
||
4 years ago
|
}));
|
||
|
|
||
3 years ago
|
const SharedStorageHost = ({
|
||
|
host,
|
||
4 years ago
|
}: {
|
||
3 years ago
|
host: AnvilSharedStorageHost;
|
||
4 years ago
|
}): JSX.Element => {
|
||
4 years ago
|
const classes = useStyles();
|
||
4 years ago
|
return (
|
||
4 years ago
|
<>
|
||
|
<Box display="flex" width="100%" className={classes.fs}>
|
||
4 years ago
|
<Box flexGrow={1}>
|
||
3 years ago
|
<BodyText text={host.host_name || 'Not Available'} />
|
||
4 years ago
|
</Box>
|
||
4 years ago
|
<Box className={classes.decoratorBox}>
|
||
3 years ago
|
<Decorator colour={host.is_mounted ? 'ok' : 'error'} />
|
||
4 years ago
|
</Box>
|
||
|
<Box>
|
||
3 years ago
|
<BodyText text={host.is_mounted ? 'Mounted' : 'Not Mounted'} />
|
||
4 years ago
|
</Box>
|
||
|
</Box>
|
||
3 years ago
|
{host.is_mounted && (
|
||
4 years ago
|
<>
|
||
|
<Box display="flex" width="100%" className={classes.fs}>
|
||
|
<Box flexGrow={1}>
|
||
|
<BodyText
|
||
3 years ago
|
text={`Used: ${prettyBytes.default(host.total - host.free, {
|
||
4 years ago
|
binary: true,
|
||
|
})}`}
|
||
|
/>
|
||
|
</Box>
|
||
|
<Box>
|
||
|
<BodyText
|
||
3 years ago
|
text={`Free: ${prettyBytes.default(host.free, {
|
||
4 years ago
|
binary: true,
|
||
|
})}`}
|
||
|
/>
|
||
|
</Box>
|
||
|
</Box>
|
||
|
<Box display="flex" width="100%" className={classes.bar}>
|
||
|
<Box flexGrow={1}>
|
||
|
<AllocationBar
|
||
3 years ago
|
allocated={((host.total - host.free) / host.total) * 100}
|
||
4 years ago
|
/>
|
||
|
</Box>
|
||
|
</Box>
|
||
|
<Box display="flex" justifyContent="center" width="100%">
|
||
|
<BodyText
|
||
3 years ago
|
text={`Total Storage: ${prettyBytes.default(host.total, {
|
||
4 years ago
|
binary: true,
|
||
|
})}`}
|
||
|
/>
|
||
|
</Box>
|
||
|
</>
|
||
|
)}
|
||
4 years ago
|
</>
|
||
4 years ago
|
);
|
||
|
};
|
||
|
|
||
3 years ago
|
export default SharedStorageHost;
|