Add groups VM configuration
This commit is contained in:
parent
1c6ca2d76a
commit
1278a178f4
@ -2,6 +2,7 @@ import { Button } from "@mui/material";
|
|||||||
import Grid from "@mui/material/Grid2";
|
import Grid from "@mui/material/Grid2";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { GroupApi } from "../../api/GroupApi";
|
||||||
import { NWFilter, NWFilterApi } from "../../api/NWFilterApi";
|
import { NWFilter, NWFilterApi } from "../../api/NWFilterApi";
|
||||||
import { NetworkApi, NetworkInfo } from "../../api/NetworksApi";
|
import { NetworkApi, NetworkInfo } from "../../api/NetworksApi";
|
||||||
import { ServerApi } from "../../api/ServerApi";
|
import { ServerApi } from "../../api/ServerApi";
|
||||||
@ -35,12 +36,14 @@ interface DetailsProps {
|
|||||||
|
|
||||||
export function APITokenDetails(p: DetailsProps): React.ReactElement {
|
export function APITokenDetails(p: DetailsProps): React.ReactElement {
|
||||||
const [vms, setVMs] = React.useState<VMInfo[]>();
|
const [vms, setVMs] = React.useState<VMInfo[]>();
|
||||||
|
const [groups, setGroups] = React.useState<string[]>();
|
||||||
const [networks, setNetworks] = React.useState<NetworkInfo[]>();
|
const [networks, setNetworks] = React.useState<NetworkInfo[]>();
|
||||||
const [nwFilters, setNetworkFilters] = React.useState<NWFilter[]>();
|
const [nwFilters, setNetworkFilters] = React.useState<NWFilter[]>();
|
||||||
const [tokens, setTokens] = React.useState<APIToken[]>();
|
const [tokens, setTokens] = React.useState<APIToken[]>();
|
||||||
|
|
||||||
const load = async () => {
|
const load = async () => {
|
||||||
setVMs(await VMApi.GetList());
|
setVMs(await VMApi.GetList());
|
||||||
|
setGroups(await GroupApi.GetList());
|
||||||
setNetworks(await NetworkApi.GetList());
|
setNetworks(await NetworkApi.GetList());
|
||||||
setNetworkFilters(await NWFilterApi.GetList());
|
setNetworkFilters(await NWFilterApi.GetList());
|
||||||
setTokens(await TokensApi.GetList());
|
setTokens(await TokensApi.GetList());
|
||||||
@ -54,6 +57,7 @@ export function APITokenDetails(p: DetailsProps): React.ReactElement {
|
|||||||
build={() => (
|
build={() => (
|
||||||
<APITokenDetailsInner
|
<APITokenDetailsInner
|
||||||
vms={vms!}
|
vms={vms!}
|
||||||
|
groups={groups!}
|
||||||
networks={networks!}
|
networks={networks!}
|
||||||
nwFilters={nwFilters!}
|
nwFilters={nwFilters!}
|
||||||
tokens={tokens!}
|
tokens={tokens!}
|
||||||
@ -73,6 +77,7 @@ enum TokenTab {
|
|||||||
|
|
||||||
type DetailsInnerProps = DetailsProps & {
|
type DetailsInnerProps = DetailsProps & {
|
||||||
vms: VMInfo[];
|
vms: VMInfo[];
|
||||||
|
groups: string[];
|
||||||
networks: NetworkInfo[];
|
networks: NetworkInfo[];
|
||||||
nwFilters: NWFilter[];
|
nwFilters: NWFilter[];
|
||||||
tokens: APIToken[];
|
tokens: APIToken[];
|
||||||
|
@ -22,6 +22,7 @@ export function TokenRightsEditor(p: {
|
|||||||
editable: boolean;
|
editable: boolean;
|
||||||
onChange?: () => void;
|
onChange?: () => void;
|
||||||
vms: VMInfo[];
|
vms: VMInfo[];
|
||||||
|
groups: string[];
|
||||||
networks: NetworkInfo[];
|
networks: NetworkInfo[];
|
||||||
nwFilters: NWFilter[];
|
nwFilters: NWFilter[];
|
||||||
tokens: APIToken[];
|
tokens: APIToken[];
|
||||||
@ -238,6 +239,139 @@ export function TokenRightsEditor(p: {
|
|||||||
</Table>
|
</Table>
|
||||||
</RightsSection>
|
</RightsSection>
|
||||||
|
|
||||||
|
<RightsSection label="VM groups">
|
||||||
|
<RouteRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "POST", path: "/api/group/list" }}
|
||||||
|
label="Get the list of groups"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Table size="small">
|
||||||
|
<TableHead>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>Group name</TableCell>
|
||||||
|
<TableCell align="center">Get VM info</TableCell>
|
||||||
|
<TableCell align="center">Start VM</TableCell>
|
||||||
|
<TableCell align="center">Shutdown VM</TableCell>
|
||||||
|
<TableCell align="center">Suspend VM</TableCell>
|
||||||
|
<TableCell align="center">Resume VM</TableCell>
|
||||||
|
<TableCell align="center">Kill VM</TableCell>
|
||||||
|
<TableCell align="center">Reset VM</TableCell>
|
||||||
|
<TableCell align="center">Screenshot VM</TableCell>
|
||||||
|
<TableCell align="center">Get VM State</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{/* All Group operations */}
|
||||||
|
<TableRow hover>
|
||||||
|
<TableCell>
|
||||||
|
<i>All</i>
|
||||||
|
</TableCell>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/info" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/start" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/shutdown" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/suspend" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/resume" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/kill" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/reset" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/screenshot" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: "/api/group/*/vm/state" }}
|
||||||
|
/>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
{/* Per VM operations */}
|
||||||
|
{p.groups.map((v, n) => (
|
||||||
|
<TableRow hover key={n}>
|
||||||
|
<TableCell>{v}</TableCell>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: `/api/group/${v}/vm/info` }}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/info" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: `/api/group/${v}/vm/start` }}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/start" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{
|
||||||
|
verb: "GET",
|
||||||
|
path: `/api/group/${v}/vm/shutdown`,
|
||||||
|
}}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/shutdown" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{
|
||||||
|
verb: "GET",
|
||||||
|
path: `/api/group/${v}/vm/suspend`,
|
||||||
|
}}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/suspend" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{
|
||||||
|
verb: "GET",
|
||||||
|
path: `/api/group/${v}/vm/resume`,
|
||||||
|
}}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/resume" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: `/api/group/${v}/vm/kill` }}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/kill" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: `/api/group/${v}/vm/reset` }}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/reset" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{
|
||||||
|
verb: "GET",
|
||||||
|
path: `/api/group/${v}/vm/screenshot`,
|
||||||
|
}}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/screenshot" }}
|
||||||
|
/>
|
||||||
|
<CellRight
|
||||||
|
{...p}
|
||||||
|
right={{ verb: "GET", path: `/api/group/${v}/vm/state` }}
|
||||||
|
parent={{ verb: "GET", path: "/api/group/*/vm/state" }}
|
||||||
|
/>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</RightsSection>
|
||||||
|
|
||||||
{/* Networks */}
|
{/* Networks */}
|
||||||
<RightsSection label="Networks">
|
<RightsSection label="Networks">
|
||||||
<RouteRight
|
<RouteRight
|
||||||
|
Loading…
Reference in New Issue
Block a user