Can send Ctrl+Alt+Del from VNC viewer
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
				
			|||||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
 | 
					import ArrowBackIcon from "@mui/icons-material/ArrowBack";
 | 
				
			||||||
import FullscreenIcon from "@mui/icons-material/Fullscreen";
 | 
					import FullscreenIcon from "@mui/icons-material/Fullscreen";
 | 
				
			||||||
import FullscreenExitIcon from "@mui/icons-material/FullscreenExit";
 | 
					import FullscreenExitIcon from "@mui/icons-material/FullscreenExit";
 | 
				
			||||||
import { IconButton } from "@mui/material";
 | 
					import { IconButton, Tooltip } from "@mui/material";
 | 
				
			||||||
import React, { useEffect } from "react";
 | 
					import React, { useEffect } from "react";
 | 
				
			||||||
import { useNavigate, useParams } from "react-router-dom";
 | 
					import { useNavigate, useParams } from "react-router-dom";
 | 
				
			||||||
import { VncScreen } from "react-vnc";
 | 
					import { VncScreen } from "react-vnc";
 | 
				
			||||||
@@ -10,6 +10,8 @@ import { VMApi, VMInfo } from "../api/VMApi";
 | 
				
			|||||||
import { useSnackbar } from "../hooks/providers/SnackbarProvider";
 | 
					import { useSnackbar } from "../hooks/providers/SnackbarProvider";
 | 
				
			||||||
import { time } from "../utils/DateUtils";
 | 
					import { time } from "../utils/DateUtils";
 | 
				
			||||||
import { AsyncWidget } from "../widgets/AsyncWidget";
 | 
					import { AsyncWidget } from "../widgets/AsyncWidget";
 | 
				
			||||||
 | 
					import RFB from "react-vnc/dist/types/noVNC/core/rfb";
 | 
				
			||||||
 | 
					import KeyboardAltIcon from "@mui/icons-material/KeyboardAlt";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface VNCTokenInfo {
 | 
					interface VNCTokenInfo {
 | 
				
			||||||
  url: string;
 | 
					  url: string;
 | 
				
			||||||
@@ -41,6 +43,7 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const [token, setToken] = React.useState<VNCTokenInfo | undefined>();
 | 
					  const [token, setToken] = React.useState<VNCTokenInfo | undefined>();
 | 
				
			||||||
  const [counter, setCounter] = React.useState(1);
 | 
					  const [counter, setCounter] = React.useState(1);
 | 
				
			||||||
 | 
					  const [rfb, setRFB] = React.useState<RFB | undefined>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const vncRef = React.createRef<HTMLDivElement>();
 | 
					  const vncRef = React.createRef<HTMLDivElement>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -67,6 +70,7 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement {
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const disconnected = () => {
 | 
					  const disconnected = () => {
 | 
				
			||||||
 | 
					    setRFB(undefined);
 | 
				
			||||||
    connect(true);
 | 
					    connect(true);
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -96,10 +100,12 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement {
 | 
				
			|||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <div ref={vncRef} style={{ display: "flex" }}>
 | 
					    <div ref={vncRef} style={{ display: "flex" }}>
 | 
				
			||||||
      {/* Controls */}
 | 
					      {/* Controls */}
 | 
				
			||||||
      <div>
 | 
					      <div style={{ display: "flex", flexDirection: "column" }}>
 | 
				
			||||||
        <IconButton onClick={goBack}>
 | 
					        <IconButton onClick={goBack}>
 | 
				
			||||||
          <ArrowBackIcon />
 | 
					          <ArrowBackIcon />
 | 
				
			||||||
        </IconButton>
 | 
					        </IconButton>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        {/* Toggle fullscreen */}
 | 
				
			||||||
        {!document.fullscreenElement ? (
 | 
					        {!document.fullscreenElement ? (
 | 
				
			||||||
          <IconButton onClick={goFullScreen}>
 | 
					          <IconButton onClick={goFullScreen}>
 | 
				
			||||||
            <FullscreenIcon />
 | 
					            <FullscreenIcon />
 | 
				
			||||||
@@ -109,6 +115,15 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement {
 | 
				
			|||||||
            <FullscreenExitIcon />
 | 
					            <FullscreenExitIcon />
 | 
				
			||||||
          </IconButton>
 | 
					          </IconButton>
 | 
				
			||||||
        )}
 | 
					        )}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        {/* Keystrokes */}
 | 
				
			||||||
 | 
					        {rfb && (
 | 
				
			||||||
 | 
					          <Tooltip title="Send Ctrl+Alt+Del">
 | 
				
			||||||
 | 
					            <IconButton onClick={() => rfb?.sendCtrlAltDel()}>
 | 
				
			||||||
 | 
					              <KeyboardAltIcon />
 | 
				
			||||||
 | 
					            </IconButton>
 | 
				
			||||||
 | 
					          </Tooltip>
 | 
				
			||||||
 | 
					        )}
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      {/* Screen */}
 | 
					      {/* Screen */}
 | 
				
			||||||
@@ -126,6 +141,7 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement {
 | 
				
			|||||||
            console.info("VNC disconnected " + token?.url);
 | 
					            console.info("VNC disconnected " + token?.url);
 | 
				
			||||||
            disconnected();
 | 
					            disconnected();
 | 
				
			||||||
          }}
 | 
					          }}
 | 
				
			||||||
 | 
					          onConnect={(rfb) => setRFB(rfb)}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
      </div>
 | 
					      </div>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user