|
|
|
@ -73,84 +73,89 @@ const AnvilHost = ({ |
|
|
|
|
return ( |
|
|
|
|
<Box className={classes.root}> |
|
|
|
|
{hosts && |
|
|
|
|
hosts.map((host): JSX.Element => { |
|
|
|
|
return ( |
|
|
|
|
<InnerPanel key={host.host_uuid}> |
|
|
|
|
<PanelHeader> |
|
|
|
|
<Box display="flex" width="100%" className={classes.header}> |
|
|
|
|
hosts.map( |
|
|
|
|
(host): JSX.Element => { |
|
|
|
|
return ( |
|
|
|
|
<InnerPanel key={host.host_uuid}> |
|
|
|
|
<PanelHeader> |
|
|
|
|
<Box display="flex" width="100%" className={classes.header}> |
|
|
|
|
<Box flexGrow={1}> |
|
|
|
|
<BodyText text={host.host_name} /> |
|
|
|
|
</Box> |
|
|
|
|
<Box className={classes.decoratorBox}> |
|
|
|
|
<Decorator colour={selectDecorator(host.state)} /> |
|
|
|
|
</Box> |
|
|
|
|
<Box> |
|
|
|
|
<BodyText |
|
|
|
|
text={ |
|
|
|
|
host?.state?.replace(stateRegex, (c) => |
|
|
|
|
c.toUpperCase(), |
|
|
|
|
) || 'Not Available' |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
</PanelHeader> |
|
|
|
|
<Box display="flex" className={classes.state}> |
|
|
|
|
<Box className={classes.label}> |
|
|
|
|
<BodyText text="Power: " /> |
|
|
|
|
</Box> |
|
|
|
|
<Box flexGrow={1}> |
|
|
|
|
<BodyText text={host.host_name} /> |
|
|
|
|
<Switch |
|
|
|
|
checked={host.state === 'online'} |
|
|
|
|
onChange={() => |
|
|
|
|
putFetch( |
|
|
|
|
`${process.env.NEXT_PUBLIC_API_URL}/set_power`, |
|
|
|
|
{ |
|
|
|
|
host_uuid: host.host_uuid, |
|
|
|
|
is_on: !(host.state === 'online'), |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
<Box className={classes.decoratorBox}> |
|
|
|
|
<Decorator colour={selectDecorator(host.state)} /> |
|
|
|
|
<Box className={classes.label}> |
|
|
|
|
<BodyText text="Member: " /> |
|
|
|
|
</Box> |
|
|
|
|
<Box> |
|
|
|
|
<BodyText |
|
|
|
|
text={ |
|
|
|
|
host?.state?.replace(stateRegex, (c) => |
|
|
|
|
c.toUpperCase(), |
|
|
|
|
) || 'Not Available' |
|
|
|
|
<Switch |
|
|
|
|
checked={host.state === 'online'} |
|
|
|
|
disabled={!(host.state === 'online')} |
|
|
|
|
onChange={() => |
|
|
|
|
putFetch( |
|
|
|
|
`${process.env.NEXT_PUBLIC_API_URL}/set_membership`, |
|
|
|
|
{ |
|
|
|
|
host_uuid: host.host_uuid, |
|
|
|
|
is_member: !(host.state === 'online'), |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
</PanelHeader> |
|
|
|
|
<Box display="flex" className={classes.state}> |
|
|
|
|
<Box className={classes.label}> |
|
|
|
|
<BodyText text="Power: " /> |
|
|
|
|
</Box> |
|
|
|
|
<Box flexGrow={1}> |
|
|
|
|
<Switch |
|
|
|
|
checked={host.state === 'online'} |
|
|
|
|
onChange={() => |
|
|
|
|
putFetch(`${process.env.NEXT_PUBLIC_API_URL}/set_power`, { |
|
|
|
|
host_uuid: host.host_uuid, |
|
|
|
|
is_on: !(host.state === 'online'), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
<Box className={classes.label}> |
|
|
|
|
<BodyText text="Member: " /> |
|
|
|
|
</Box> |
|
|
|
|
<Box> |
|
|
|
|
<Switch |
|
|
|
|
checked={host.state === 'online'} |
|
|
|
|
disabled={!(host.state === 'online')} |
|
|
|
|
onChange={() => |
|
|
|
|
putFetch( |
|
|
|
|
`${process.env.NEXT_PUBLIC_API_URL}/set_membership`, |
|
|
|
|
{ |
|
|
|
|
host_uuid: host.host_uuid, |
|
|
|
|
is_member: !(host.state === 'online'), |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
{host.state !== 'online' && host.state !== 'offline' && ( |
|
|
|
|
<> |
|
|
|
|
<Box display="flex" width="100%" className={classes.state}> |
|
|
|
|
<Box> |
|
|
|
|
<BodyText |
|
|
|
|
text={selectStateMessage( |
|
|
|
|
messageRegex, |
|
|
|
|
host.state_message, |
|
|
|
|
)} |
|
|
|
|
/> |
|
|
|
|
{host.state !== 'online' && host.state !== 'offline' && ( |
|
|
|
|
<> |
|
|
|
|
<Box display="flex" width="100%" className={classes.state}> |
|
|
|
|
<Box> |
|
|
|
|
<BodyText |
|
|
|
|
text={selectStateMessage( |
|
|
|
|
messageRegex, |
|
|
|
|
host.state_message, |
|
|
|
|
)} |
|
|
|
|
/> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
<Box display="flex" width="100%" className={classes.bar}> |
|
|
|
|
<Box flexGrow={1}> |
|
|
|
|
<ProgressBar progressPercentage={host.state_percent} /> |
|
|
|
|
<Box display="flex" width="100%" className={classes.bar}> |
|
|
|
|
<Box flexGrow={1}> |
|
|
|
|
<ProgressBar progressPercentage={host.state_percent} /> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
</InnerPanel> |
|
|
|
|
); |
|
|
|
|
})} |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
</InnerPanel> |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
)} |
|
|
|
|
</Box> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|