Networks management
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2024-04-20 11:17:49 +02:00
parent c0b50c75fd
commit f404018392

View File

@ -51,12 +51,12 @@ export function TokenRightsEditor(p: {
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell>VM name</TableCell> <TableCell>VM name</TableCell>
<TableCell>Get definition</TableCell> <TableCell align="center">Get definition</TableCell>
<TableCell>Update</TableCell> <TableCell align="center">Update</TableCell>
<TableCell>Delete</TableCell> <TableCell align="center">Delete</TableCell>
<TableCell>Get XML definition</TableCell> <TableCell align="center">Get XML definition</TableCell>
<TableCell>Get autostart</TableCell> <TableCell align="center">Get autostart</TableCell>
<TableCell>Set autostart</TableCell> <TableCell align="center">Set autostart</TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
@ -127,15 +127,15 @@ export function TokenRightsEditor(p: {
<TableHead> <TableHead>
<TableRow> <TableRow>
<TableCell>VM name</TableCell> <TableCell>VM name</TableCell>
<TableCell>Get state</TableCell> <TableCell align="center">Get state</TableCell>
<TableCell>Start</TableCell> <TableCell align="center">Start</TableCell>
<TableCell>Shutdown</TableCell> <TableCell align="center">Shutdown</TableCell>
<TableCell>Kill</TableCell> <TableCell align="center">Kill</TableCell>
<TableCell>Reset</TableCell> <TableCell align="center">Reset</TableCell>
<TableCell>Suspend</TableCell> <TableCell align="center">Suspend</TableCell>
<TableCell>Resume</TableCell> <TableCell align="center">Resume</TableCell>
<TableCell>Screenshot</TableCell> <TableCell align="center">Screenshot</TableCell>
<TableCell>VNC token</TableCell> <TableCell align="center">VNC token</TableCell>
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
@ -236,6 +236,152 @@ export function TokenRightsEditor(p: {
</TableBody> </TableBody>
</Table> </Table>
</RightsSection> </RightsSection>
{/* Networks */}
<RightsSection label="Networks">
<RouteRight
{...p}
right={{ verb: "POST", path: "/api/network/create" }}
label="Create a new network"
/>
<RouteRight
{...p}
right={{ verb: "GET", path: "/api/network/list" }}
label="Get list of networks"
/>
</RightsSection>
{/* Networks management */}
<RightsSection label="Networks management">
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Network name</TableCell>
<TableCell align="center">Get definition</TableCell>
<TableCell align="center">Update</TableCell>
<TableCell align="center">Delete</TableCell>
<TableCell align="center">Get XML definition</TableCell>
<TableCell align="center">Get autostart</TableCell>
<TableCell align="center">Set autostart</TableCell>
<TableCell align="center">Get status</TableCell>
<TableCell align="center">Start</TableCell>
<TableCell align="center">Stop</TableCell>
</TableRow>
</TableHead>
<TableBody>
{/* All networks operations */}
<TableRow hover>
<TableCell>
<i>All</i>
</TableCell>
<CellRight
{...p}
right={{ verb: "GET", path: "/api/network/*" }}
/>
<CellRight
{...p}
right={{ verb: "PUT", path: "/api/network/*" }}
/>
<CellRight
{...p}
right={{ verb: "DELETE", path: "/api/network/*" }}
/>
<CellRight
{...p}
right={{ verb: "GET", path: "/api/network/*/src" }}
/>
<CellRight
{...p}
right={{ verb: "GET", path: "/api/network/*/autostart" }}
/>
<CellRight
{...p}
right={{ verb: "PUT", path: "/api/network/*/autostart" }}
/>
<CellRight
{...p}
right={{ verb: "GET", path: "/api/network/*/status" }}
/>
<CellRight
{...p}
right={{ verb: "GET", path: "/api/network/*/start" }}
/>
<CellRight
{...p}
right={{ verb: "GET", path: "/api/network/*/stop" }}
/>
</TableRow>
{/* Per network operations */}
{p.networks.map((v, n) => (
<TableRow hover key={n}>
<TableCell>{v.name}</TableCell>
<CellRight
{...p}
right={{ verb: "GET", path: `/api/network/${v.uuid}` }}
parent={{ verb: "GET", path: "/api/network/*" }}
/>
<CellRight
{...p}
right={{ verb: "PUT", path: `/api/network/${v.uuid}` }}
parent={{ verb: "PUT", path: "/api/network/*" }}
/>
<CellRight
{...p}
right={{ verb: "DELETE", path: `/api/network/${v.uuid}` }}
parent={{ verb: "DELETE", path: "/api/network/*" }}
/>
<CellRight
{...p}
right={{ verb: "GET", path: `/api/network/${v.uuid}/src` }}
parent={{ verb: "GET", path: "/api/network/*/src" }}
/>
<CellRight
{...p}
right={{
verb: "GET",
path: `/api/network/${v.uuid}/autostart`,
}}
parent={{ verb: "GET", path: "/api/network/*/autostart" }}
/>
<CellRight
{...p}
right={{
verb: "PUT",
path: `/api/network/${v.uuid}/autostart`,
}}
parent={{ verb: "PUT", path: "/api/network/*/autostart" }}
/>
<CellRight
{...p}
right={{
verb: "GET",
path: `/api/network/${v.uuid}/status`,
}}
parent={{ verb: "GET", path: "/api/network/*/status" }}
/>
<CellRight
{...p}
right={{
verb: "GET",
path: `/api/network/${v.uuid}/start`,
}}
parent={{ verb: "GET", path: "/api/network/*/start" }}
/>
<CellRight
{...p}
right={{
verb: "GET",
path: `/api/network/${v.uuid}/stop`,
}}
parent={{ verb: "GET", path: "/api/network/*/stop" }}
/>
</TableRow>
))}
</TableBody>
</Table>
</RightsSection>
{/* ISO files */} {/* ISO files */}
<RightsSection label="ISO files"> <RightsSection label="ISO files">
<RouteRight <RouteRight
@ -365,6 +511,7 @@ function RouteRight(p: RightOpts): React.ReactElement {
}, },
}} }}
> >
{p.label ? (
<FormControlLabel <FormControlLabel
control={ control={
<Checkbox <Checkbox
@ -375,6 +522,15 @@ function RouteRight(p: RightOpts): React.ReactElement {
} }
label={p.label} label={p.label}
/> />
) : (
<span>
<Checkbox
checked={activated || parentActivated}
disabled={!p.editable || parentActivated}
onChange={(_e, a) => toggle(a)}
/>
</span>
)}
</Tooltip> </Tooltip>
</div> </div>
); );