anvil/striker-ui/components/SharedStorage/SharedStorageHost.tsx

75 lines
1.8 KiB
TypeScript
Raw Normal View History

import { Box } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
2021-03-22 15:39:34 +00:00
import * as prettyBytes from 'pretty-bytes';
import { AllocationBar } from '../Bars';
import { BodyText } from '../Text';
2021-03-22 15:39:34 +00:00
const useStyles = makeStyles(() => ({
fs: {
2021-04-30 21:48:10 +00:00
paddingLeft: '.7em',
paddingRight: '.7em',
2021-04-30 17:39:28 +00:00
paddingTop: '1.2em',
},
bar: {
2021-04-30 21:48:10 +00:00
paddingLeft: '.7em',
paddingRight: '.7em',
},
2021-04-20 22:29:48 +00:00
decoratorBox: {
2021-04-30 21:48:10 +00:00
paddingRight: '.3em',
2021-04-20 22:29:48 +00:00
},
}));
const SharedStorageHost = ({
group,
2021-03-22 15:39:34 +00:00
}: {
group: AnvilSharedStorageGroup;
2021-03-22 15:39:34 +00:00
}): JSX.Element => {
const classes = useStyles();
2021-03-22 15:39:34 +00:00
return (
<>
<Box display="flex" width="100%" className={classes.fs}>
2021-04-20 22:29:48 +00:00
<Box flexGrow={1}>
<BodyText
text={`Used: ${prettyBytes.default(
group.storage_group_total - group.storage_group_free,
{
binary: true,
},
)}`}
/>
</Box>
<Box>
<BodyText
text={`Free: ${prettyBytes.default(group.storage_group_free, {
binary: true,
})}`}
/>
</Box>
</Box>
<Box display="flex" width="100%" className={classes.bar}>
<Box flexGrow={1}>
<AllocationBar
allocated={
((group.storage_group_total - group.storage_group_free) /
group.storage_group_total) *
100
}
/>
</Box>
</Box>
<Box display="flex" justifyContent="center" width="100%">
<BodyText
text={`Total Storage: ${prettyBytes.default(
group.storage_group_total,
{
binary: true,
},
)}`}
/>
</Box>
</>
2021-03-22 15:39:34 +00:00
);
};
export default SharedStorageHost;