Can view from web UI XML definition of domains
This commit is contained in:
virtweb_backend/src
virtweb_frontend
@ -5,7 +5,10 @@ import { AsyncWidget } from "../widgets/AsyncWidget";
|
||||
import { VirtWebRouteContainer } from "../widgets/VirtWebRouteContainer";
|
||||
import { VMDetails } from "../widgets/vms/VMDetails";
|
||||
import { VMStatusWidget } from "../widgets/vms/VMStatusWidget";
|
||||
import { Button } from "@mui/material";
|
||||
import { Button, IconButton } from "@mui/material";
|
||||
import Icon from "@mdi/react";
|
||||
import { mdiXml } from "@mdi/js";
|
||||
import { RouterLink } from "../widgets/RouterLink";
|
||||
|
||||
export function VMRoute(): React.ReactElement {
|
||||
const { uuid } = useParams();
|
||||
@ -35,9 +38,15 @@ function VMRouteBody(p: { vm: VMInfo }): React.ReactElement {
|
||||
<VirtWebRouteContainer
|
||||
label={`VM ${p.vm.name}`}
|
||||
actions={
|
||||
<span>
|
||||
<span style={{ display: "inline-flex", alignItems: "center" }}>
|
||||
<VMStatusWidget vm={p.vm} onChange={setState} />
|
||||
|
||||
<RouterLink to={p.vm.XMLURL}>
|
||||
<IconButton size="small">
|
||||
<Icon path={mdiXml} style={{ width: "1rem" }} />
|
||||
</IconButton>
|
||||
</RouterLink>
|
||||
|
||||
{(state === "Shutdown" || state === "Shutoff") && (
|
||||
<Button
|
||||
variant="contained"
|
||||
|
60
virtweb_frontend/src/routes/VMXMLRoute.tsx
Normal file
60
virtweb_frontend/src/routes/VMXMLRoute.tsx
Normal file
@ -0,0 +1,60 @@
|
||||
import React from "react";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Light as SyntaxHighlighter } from "react-syntax-highlighter";
|
||||
import xml from "react-syntax-highlighter/dist/esm/languages/hljs/xml";
|
||||
import { dracula } from "react-syntax-highlighter/dist/esm/styles/hljs";
|
||||
import xmlFormat from "xml-formatter";
|
||||
import { VMApi, VMInfo } from "../api/VMApi";
|
||||
import { AsyncWidget } from "../widgets/AsyncWidget";
|
||||
import { VirtWebRouteContainer } from "../widgets/VirtWebRouteContainer";
|
||||
import { IconButton } from "@mui/material";
|
||||
import { RouterLink } from "../widgets/RouterLink";
|
||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||
|
||||
SyntaxHighlighter.registerLanguage("xml", xml);
|
||||
|
||||
export function VMXMLRoute(): React.ReactElement {
|
||||
const { uuid } = useParams();
|
||||
|
||||
const [vm, setVM] = React.useState<VMInfo | undefined>();
|
||||
const [src, setSrc] = React.useState<string | undefined>();
|
||||
|
||||
const load = async () => {
|
||||
setVM(await VMApi.GetSingle(uuid!));
|
||||
setSrc(await VMApi.GetSingleXML(uuid!));
|
||||
};
|
||||
|
||||
return (
|
||||
<AsyncWidget
|
||||
loadKey={uuid}
|
||||
load={load}
|
||||
errMsg="Failed to load VM information!"
|
||||
build={() => <XMLRouteInner vm={vm!} src={src!} />}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function XMLRouteInner(p: { vm: VMInfo; src: string }): React.ReactElement {
|
||||
const xml = xmlFormat(p.src);
|
||||
|
||||
return (
|
||||
<VirtWebRouteContainer
|
||||
label={`XML definition of ${p.vm.name}`}
|
||||
actions={
|
||||
<RouterLink to={p.vm.ViewURL}>
|
||||
<IconButton>
|
||||
<ArrowBackIcon />
|
||||
</IconButton>
|
||||
</RouterLink>
|
||||
}
|
||||
>
|
||||
<SyntaxHighlighter
|
||||
language="xml"
|
||||
style={dracula}
|
||||
customStyle={{ fontSize: "120%" }}
|
||||
>
|
||||
{xml}
|
||||
</SyntaxHighlighter>
|
||||
</VirtWebRouteContainer>
|
||||
);
|
||||
}
|
@ -94,7 +94,7 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement {
|
||||
return <p>Please wait, connecting to the machine...</p>;
|
||||
|
||||
return (
|
||||
<div ref={vncRef}>
|
||||
<div ref={vncRef} style={{ display: "flex" }}>
|
||||
{/* Controls */}
|
||||
<div>
|
||||
<IconButton onClick={goBack}>
|
||||
|
Reference in New Issue
Block a user