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.
105 lines
2.6 KiB
105 lines
2.6 KiB
4 years ago
|
import { Box } from '@material-ui/core';
|
||
|
import { makeStyles } from '@material-ui/core/styles';
|
||
4 years ago
|
import { ClassNameMap } from '@material-ui/styles';
|
||
4 years ago
|
|
||
4 years ago
|
import * as prettyBytes from 'pretty-bytes';
|
||
|
|
||
4 years ago
|
import { AllocationBar } from '../Bars';
|
||
|
import { BodyText } from '../Text';
|
||
|
import { BLUE, RED_ON } from '../../lib/consts/DEFAULT_THEME';
|
||
4 years ago
|
|
||
|
const selectDecorator = (
|
||
|
state: boolean,
|
||
|
): keyof ClassNameMap<'mounted' | 'notMounted'> => {
|
||
|
return state ? 'mounted' : 'notMounted';
|
||
|
};
|
||
4 years ago
|
|
||
4 years ago
|
const useStyles = makeStyles(() => ({
|
||
|
fs: {
|
||
|
paddingLeft: '10px',
|
||
|
paddingRight: '10px',
|
||
4 years ago
|
paddingTop: '15px',
|
||
4 years ago
|
},
|
||
|
bar: {
|
||
|
paddingLeft: '10px',
|
||
|
paddingRight: '10px',
|
||
|
},
|
||
4 years ago
|
decorator: {
|
||
|
width: '20px',
|
||
|
height: '100%',
|
||
|
borderRadius: 2,
|
||
|
},
|
||
|
decoratorBox: {
|
||
|
paddingRight: '5px',
|
||
|
},
|
||
|
mounted: {
|
||
|
backgroundColor: BLUE,
|
||
|
},
|
||
|
notMounted: {
|
||
|
backgroundColor: RED_ON,
|
||
|
},
|
||
4 years ago
|
}));
|
||
|
|
||
4 years ago
|
const SharedStorageNode = ({
|
||
|
node,
|
||
|
}: {
|
||
|
node: AnvilSharedStorageNode;
|
||
|
}): 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}>
|
||
4 years ago
|
<BodyText text={node.nodeInfo?.node_name || 'Not Available'} />
|
||
4 years ago
|
</Box>
|
||
4 years ago
|
<Box className={classes.decoratorBox}>
|
||
|
<div
|
||
|
className={`${classes.decorator} ${
|
||
|
classes[selectDecorator(node.is_mounted)]
|
||
|
}`}
|
||
4 years ago
|
/>
|
||
4 years ago
|
</Box>
|
||
|
<Box>
|
||
4 years ago
|
<BodyText text={node.is_mounted ? 'Mounted' : 'Not Mounted'} />
|
||
4 years ago
|
</Box>
|
||
|
</Box>
|
||
4 years ago
|
{node.is_mounted && (
|
||
|
<>
|
||
|
<Box display="flex" width="100%" className={classes.fs}>
|
||
|
<Box flexGrow={1}>
|
||
|
<BodyText
|
||
|
text={`Used: ${prettyBytes.default(node.total - node.free, {
|
||
|
binary: true,
|
||
|
})}`}
|
||
|
/>
|
||
|
</Box>
|
||
|
<Box>
|
||
|
<BodyText
|
||
|
text={`Free: ${prettyBytes.default(node.free, {
|
||
|
binary: true,
|
||
|
})}`}
|
||
|
/>
|
||
|
</Box>
|
||
|
</Box>
|
||
|
<Box display="flex" width="100%" className={classes.bar}>
|
||
|
<Box flexGrow={1}>
|
||
|
<AllocationBar
|
||
|
allocated={((node.total - node.free) / node.total) * 100}
|
||
|
/>
|
||
|
</Box>
|
||
|
</Box>
|
||
|
<Box display="flex" justifyContent="center" width="100%">
|
||
|
<BodyText
|
||
|
text={`Total Storage: ${prettyBytes.default(node.total, {
|
||
|
binary: true,
|
||
|
})}`}
|
||
|
/>
|
||
|
</Box>
|
||
|
</>
|
||
|
)}
|
||
4 years ago
|
</>
|
||
4 years ago
|
);
|
||
|
};
|
||
|
|
||
|
export default SharedStorageNode;
|