|
|
@ -1,8 +1,10 @@ |
|
|
|
import { useState } from 'react'; |
|
|
|
import { useState } from 'react'; |
|
|
|
import { Switch, Box } from '@material-ui/core'; |
|
|
|
import { Switch, Box } from '@material-ui/core'; |
|
|
|
|
|
|
|
import { ClassNameMap } from '@material-ui/styles'; |
|
|
|
import { makeStyles } from '@material-ui/core/styles'; |
|
|
|
import { makeStyles } from '@material-ui/core/styles'; |
|
|
|
import { HeaderText } from '../Text'; |
|
|
|
import { HeaderText } from '../Text'; |
|
|
|
import { BLUE } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
import { BLUE, PURPLE_OFF, RED_ON } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
import anvilState from './CONSTS'; |
|
|
|
|
|
|
|
|
|
|
|
const useStyles = makeStyles(() => ({ |
|
|
|
const useStyles = makeStyles(() => ({ |
|
|
|
root: { |
|
|
|
root: { |
|
|
@ -17,11 +19,34 @@ const useStyles = makeStyles(() => ({ |
|
|
|
decorator: { |
|
|
|
decorator: { |
|
|
|
width: '20px', |
|
|
|
width: '20px', |
|
|
|
height: '100%', |
|
|
|
height: '100%', |
|
|
|
backgroundColor: BLUE, |
|
|
|
|
|
|
|
borderRadius: 2, |
|
|
|
borderRadius: 2, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
optimal: { |
|
|
|
|
|
|
|
backgroundColor: BLUE, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
notReady: { |
|
|
|
|
|
|
|
backgroundColor: PURPLE_OFF, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
degraded: { |
|
|
|
|
|
|
|
backgroundColor: RED_ON, |
|
|
|
|
|
|
|
}, |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const selectDecorator = ( |
|
|
|
|
|
|
|
state: string, |
|
|
|
|
|
|
|
): keyof ClassNameMap<'optimal' | 'notReady' | 'degraded'> => { |
|
|
|
|
|
|
|
switch (state) { |
|
|
|
|
|
|
|
case 'optimal': |
|
|
|
|
|
|
|
return 'optimal'; |
|
|
|
|
|
|
|
case 'not_ready': |
|
|
|
|
|
|
|
return 'notReady'; |
|
|
|
|
|
|
|
case 'degraded': |
|
|
|
|
|
|
|
return 'degraded'; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return 'optimal'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const SelectedAnvil = ({ anvil }: { anvil: AnvilListItem }): JSX.Element => { |
|
|
|
const SelectedAnvil = ({ anvil }: { anvil: AnvilListItem }): JSX.Element => { |
|
|
|
const classes = useStyles(); |
|
|
|
const classes = useStyles(); |
|
|
|
const [checked, setChecked] = useState<boolean>(true); |
|
|
|
const [checked, setChecked] = useState<boolean>(true); |
|
|
@ -29,11 +54,17 @@ const SelectedAnvil = ({ anvil }: { anvil: AnvilListItem }): JSX.Element => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Box display="flex" flexDirection="row" width="100%"> |
|
|
|
<Box display="flex" flexDirection="row" width="100%"> |
|
|
|
<Box p={1}> |
|
|
|
<Box p={1}> |
|
|
|
<div className={classes.decorator} /> |
|
|
|
<div |
|
|
|
|
|
|
|
className={`${classes.decorator} ${ |
|
|
|
|
|
|
|
classes[selectDecorator(anvil.anvil_state)] |
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
/> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
<Box p={1} flexGrow={1} className={classes.anvilName}> |
|
|
|
<Box p={1} flexGrow={1} className={classes.anvilName}> |
|
|
|
<HeaderText text={anvil?.anvil_name} /> |
|
|
|
<HeaderText text={anvil?.anvil_name} /> |
|
|
|
<HeaderText text={anvil?.anvil_state || 'State unavailable'} /> |
|
|
|
<HeaderText |
|
|
|
|
|
|
|
text={anvilState.get(anvil.anvil_state) || 'State unavailable'} |
|
|
|
|
|
|
|
/> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
<Box p={1}> |
|
|
|
<Box p={1}> |
|
|
|
<Switch checked={checked} onChange={() => setChecked(!checked)} /> |
|
|
|
<Switch checked={checked} onChange={() => setChecked(!checked)} /> |
|
|
|