From fcf66e3e93cda5791af896cc98121cfb613b6d01 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Mon, 16 Oct 2023 19:25:00 +0200 Subject: [PATCH] Show VM settings in grid --- virtweb_frontend/src/routes/EditVMRoute.tsx | 224 ++++++++++---------- 1 file changed, 114 insertions(+), 110 deletions(-) diff --git a/virtweb_frontend/src/routes/EditVMRoute.tsx b/virtweb_frontend/src/routes/EditVMRoute.tsx index 38e5c29..ec6abfb 100644 --- a/virtweb_frontend/src/routes/EditVMRoute.tsx +++ b/virtweb_frontend/src/routes/EditVMRoute.tsx @@ -1,16 +1,16 @@ +import { Button, Grid, Paper, Typography } from "@mui/material"; import React, { PropsWithChildren } from "react"; import { useNavigate, useParams } from "react-router-dom"; -import { VMApi, VMInfo } from "../api/VMApi"; -import { useSnackbar } from "../hooks/providers/SnackbarProvider"; -import { VirtWebRouteContainer } from "../widgets/VirtWebRouteContainer"; -import { Button, Paper, Typography } from "@mui/material"; -import { TextInput } from "../widgets/forms/TextInput"; -import { ServerApi } from "../api/ServerApi"; import { validate as validateUUID } from "uuid"; -import { SelectInput } from "../widgets/forms/SelectInput"; -import { CheckboxInput } from "../widgets/forms/CheckboxInput"; +import { ServerApi } from "../api/ServerApi"; +import { VMApi, VMInfo } from "../api/VMApi"; import { useAlert } from "../hooks/providers/AlertDialogProvider"; +import { useSnackbar } from "../hooks/providers/SnackbarProvider"; import { AsyncWidget } from "../widgets/AsyncWidget"; +import { VirtWebRouteContainer } from "../widgets/VirtWebRouteContainer"; +import { CheckboxInput } from "../widgets/forms/CheckboxInput"; +import { SelectInput } from "../widgets/forms/SelectInput"; +import { TextInput } from "../widgets/forms/TextInput"; export function CreateVMRoute(): React.ReactElement { const snackbar = useSnackbar(); @@ -126,110 +126,112 @@ function EditVMInner(p: { } > - {/* Metadata section */} - - { - p.vm.name = v ?? ""; - valueChanged(); - }} - size={ServerApi.Config.constraints.name_size} - /> + + {/* Metadata section */} + + { + p.vm.name = v ?? ""; + valueChanged(); + }} + size={ServerApi.Config.constraints.name_size} + /> - + - { - p.vm.genid = v; - valueChanged(); - }} - checkValue={(v) => validateUUID(v)} - /> + { + p.vm.genid = v; + valueChanged(); + }} + checkValue={(v) => validateUUID(v)} + /> - { - p.vm.title = v; - valueChanged(); - }} - size={ServerApi.Config.constraints.title_size} - /> + { + p.vm.title = v; + valueChanged(); + }} + size={ServerApi.Config.constraints.title_size} + /> - { - p.vm.description = v; - valueChanged(); - }} - multiline={true} - /> - + { + p.vm.description = v; + valueChanged(); + }} + multiline={true} + /> + - {/* General section */} - - { - p.vm.architecture = v! as any; - valueChanged(); - }} - value={p.vm.architecture} - options={[ - { label: "i686", value: "i686" }, - { label: "x86_64", value: "x86_64" }, - ]} - /> + {/* General section */} + + { + p.vm.architecture = v! as any; + valueChanged(); + }} + value={p.vm.architecture} + options={[ + { label: "i686", value: "i686" }, + { label: "x86_64", value: "x86_64" }, + ]} + /> - { - p.vm.boot_type = v! as any; - valueChanged(); - }} - value={p.vm.boot_type} - options={[ - { label: "UEFI with Secure Boot", value: "UEFISecureBoot" }, - { label: "UEFI", value: "UEFI" }, - ]} - /> + { + p.vm.boot_type = v! as any; + valueChanged(); + }} + value={p.vm.boot_type} + options={[ + { label: "UEFI with Secure Boot", value: "UEFISecureBoot" }, + { label: "UEFI", value: "UEFI" }, + ]} + /> - { - p.vm.memory = Number(v ?? "0"); - valueChanged(); - }} - checkValue={(v) => - Number(v) > ServerApi.Config.constraints.memory_size.min && - Number(v) < ServerApi.Config.constraints.memory_size.max - } - /> + { + p.vm.memory = Number(v ?? "0"); + valueChanged(); + }} + checkValue={(v) => + Number(v) > ServerApi.Config.constraints.memory_size.min && + Number(v) < ServerApi.Config.constraints.memory_size.max + } + /> - { - p.vm.vnc_access = v; - valueChanged(); - }} - /> - + { + p.vm.vnc_access = v; + valueChanged(); + }} + /> + + ); } @@ -238,11 +240,13 @@ function EditSection( p: { title: string } & PropsWithChildren ): React.ReactElement { return ( - - - {p.title} - - {p.children} - + + + + {p.title} + + {p.children} + + ); }