This commit is contained in:
		@@ -315,7 +315,7 @@ impl VMInfo {
 | 
				
			|||||||
                    ),
 | 
					                    ),
 | 
				
			||||||
                    bus: match disk.bus {
 | 
					                    bus: match disk.bus {
 | 
				
			||||||
                        VMDiskBus::Virtio => "virtio",
 | 
					                        VMDiskBus::Virtio => "virtio",
 | 
				
			||||||
                        VMDiskBus::Sata => "sata",
 | 
					                        VMDiskBus::SATA => "sata",
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    .to_string(),
 | 
					                    .to_string(),
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ enum VMDisksError {
 | 
				
			|||||||
#[derive(serde::Serialize, serde::Deserialize)]
 | 
					#[derive(serde::Serialize, serde::Deserialize)]
 | 
				
			||||||
pub enum VMDiskBus {
 | 
					pub enum VMDiskBus {
 | 
				
			||||||
    Virtio,
 | 
					    Virtio,
 | 
				
			||||||
    Sata,
 | 
					    SATA,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Disk allocation type
 | 
					/// Disk allocation type
 | 
				
			||||||
@@ -72,7 +72,7 @@ impl VMFileDisk {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            bus: match bus {
 | 
					            bus: match bus {
 | 
				
			||||||
                "virtio" => VMDiskBus::Virtio,
 | 
					                "virtio" => VMDiskBus::Virtio,
 | 
				
			||||||
                "sata" => VMDiskBus::Sata,
 | 
					                "sata" => VMDiskBus::SATA,
 | 
				
			||||||
                _ => anyhow::bail!("Unsupported disk bus type: {bus}"),
 | 
					                _ => anyhow::bail!("Unsupported disk bus type: {bus}"),
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,7 @@ export type VMState =
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export type VMFileDisk = BaseFileVMDisk & (RawVMDisk | QCow2Disk);
 | 
					export type VMFileDisk = BaseFileVMDisk & (RawVMDisk | QCow2Disk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type DiskBusType = "Virtio" | "Sata";
 | 
					export type DiskBusType = "Virtio" | "SATA";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface BaseFileVMDisk {
 | 
					export interface BaseFileVMDisk {
 | 
				
			||||||
  size: number;
 | 
					  size: number;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ export function DiskBusSelect(p: {
 | 
				
			|||||||
      label="Disk bus type"
 | 
					      label="Disk bus type"
 | 
				
			||||||
      options={[
 | 
					      options={[
 | 
				
			||||||
        { label: "virtio", value: "Virtio" },
 | 
					        { label: "virtio", value: "Virtio" },
 | 
				
			||||||
        { label: "sata", value: "Sata" },
 | 
					        { label: "sata", value: "SATA" },
 | 
				
			||||||
      ]}
 | 
					      ]}
 | 
				
			||||||
      onValueChange={(v) => p.onValueChange(v as any)}
 | 
					      onValueChange={(v) => p.onValueChange(v as any)}
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ import { TextInput } from "./TextInput";
 | 
				
			|||||||
import { DiskImageSelect } from "./DiskImageSelect";
 | 
					import { DiskImageSelect } from "./DiskImageSelect";
 | 
				
			||||||
import { DiskImage } from "../../api/DiskImageApi";
 | 
					import { DiskImage } from "../../api/DiskImageApi";
 | 
				
			||||||
import { DiskBusSelect } from "./DiskBusSelect";
 | 
					import { DiskBusSelect } from "./DiskBusSelect";
 | 
				
			||||||
 | 
					import { VMDiskFileWidget } from "../vms/VMDiskFileWidget";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function VMDisksList(p: {
 | 
					export function VMDisksList(p: {
 | 
				
			||||||
  vm: VMInfo;
 | 
					  vm: VMInfo;
 | 
				
			||||||
@@ -124,7 +125,8 @@ function DiskInfo(p: {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  if (!p.editable || !p.disk.new)
 | 
					  if (!p.editable || !p.disk.new)
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
      <ListItem
 | 
					      <VMDiskFileWidget
 | 
				
			||||||
 | 
					        disk={p.disk}
 | 
				
			||||||
        secondaryAction={
 | 
					        secondaryAction={
 | 
				
			||||||
          <>
 | 
					          <>
 | 
				
			||||||
            {p.editable && (
 | 
					            {p.editable && (
 | 
				
			||||||
@@ -158,32 +160,7 @@ function DiskInfo(p: {
 | 
				
			|||||||
            )}
 | 
					            )}
 | 
				
			||||||
          </>
 | 
					          </>
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      >
 | 
					      />
 | 
				
			||||||
        <ListItemAvatar>
 | 
					 | 
				
			||||||
          <Avatar>
 | 
					 | 
				
			||||||
            <Icon path={mdiHarddisk} />
 | 
					 | 
				
			||||||
          </Avatar>
 | 
					 | 
				
			||||||
        </ListItemAvatar>
 | 
					 | 
				
			||||||
        <ListItemText
 | 
					 | 
				
			||||||
          primary={
 | 
					 | 
				
			||||||
            <>
 | 
					 | 
				
			||||||
              {p.disk.name}{" "}
 | 
					 | 
				
			||||||
              {p.disk.deleteType && (
 | 
					 | 
				
			||||||
                <span style={{ color: "red" }}>
 | 
					 | 
				
			||||||
                  {p.disk.deleteType === "deletefile"
 | 
					 | 
				
			||||||
                    ? "Remove, DELETING block file"
 | 
					 | 
				
			||||||
                    : "Remove, keeping block file"}
 | 
					 | 
				
			||||||
                </span>
 | 
					 | 
				
			||||||
              )}
 | 
					 | 
				
			||||||
            </>
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          secondary={`${filesize(p.disk.size)} - ${p.disk.format}${
 | 
					 | 
				
			||||||
            p.disk.format == "Raw"
 | 
					 | 
				
			||||||
              ? " - " + (p.disk.is_sparse ? "Sparse" : "Fixed")
 | 
					 | 
				
			||||||
              : ""
 | 
					 | 
				
			||||||
          }`}
 | 
					 | 
				
			||||||
        />
 | 
					 | 
				
			||||||
      </ListItem>
 | 
					 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,17 +4,35 @@ import { Avatar, ListItem, ListItemAvatar, ListItemText } from "@mui/material";
 | 
				
			|||||||
import { filesize } from "filesize";
 | 
					import { filesize } from "filesize";
 | 
				
			||||||
import { VMFileDisk } from "../../api/VMApi";
 | 
					import { VMFileDisk } from "../../api/VMApi";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function VMDiskFileWidget(p: { disk: VMFileDisk }): React.ReactElement {
 | 
					export function VMDiskFileWidget(p: {
 | 
				
			||||||
 | 
					  disk: VMFileDisk;
 | 
				
			||||||
 | 
					  secondaryAction?: React.ReactElement;
 | 
				
			||||||
 | 
					}): React.ReactElement {
 | 
				
			||||||
 | 
					  const info = [p.disk.bus, filesize(p.disk.size), p.disk.format];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (p.disk.format === "Raw") info.push(p.disk.is_sparse ? "Sparse" : "Fixed");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <ListItem>
 | 
					    <ListItem secondaryAction={p.secondaryAction}>
 | 
				
			||||||
      <ListItemAvatar>
 | 
					      <ListItemAvatar>
 | 
				
			||||||
        <Avatar>
 | 
					        <Avatar>
 | 
				
			||||||
          <Icon path={mdiHarddisk} />
 | 
					          <Icon path={mdiHarddisk} />
 | 
				
			||||||
        </Avatar>
 | 
					        </Avatar>
 | 
				
			||||||
      </ListItemAvatar>
 | 
					      </ListItemAvatar>
 | 
				
			||||||
      <ListItemText
 | 
					      <ListItemText
 | 
				
			||||||
        primary={p.disk.name}
 | 
					        primary={
 | 
				
			||||||
        secondary={`${p.disk.format} - ${filesize(p.disk.size)}`}
 | 
					          <>
 | 
				
			||||||
 | 
					            {p.disk.name}{" "}
 | 
				
			||||||
 | 
					            {p.disk.deleteType && (
 | 
				
			||||||
 | 
					              <span style={{ color: "red" }}>
 | 
				
			||||||
 | 
					                {p.disk.deleteType === "deletefile"
 | 
				
			||||||
 | 
					                  ? "Remove, DELETING block file"
 | 
				
			||||||
 | 
					                  : "Remove, keeping block file"}
 | 
				
			||||||
 | 
					              </span>
 | 
				
			||||||
 | 
					            )}
 | 
				
			||||||
 | 
					          </>
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        secondary={info.join(" - ")}
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
    </ListItem>
 | 
					    </ListItem>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user