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