|
|
|
@ -5,7 +5,7 @@ import { makeStyles } from '@material-ui/core/styles'; |
|
|
|
|
import CloseIcon from '@material-ui/icons/Close'; |
|
|
|
|
import KeyboardIcon from '@material-ui/icons/Keyboard'; |
|
|
|
|
import IconButton from '@material-ui/core/IconButton'; |
|
|
|
|
import RFB from './noVNC/core/rfb'; |
|
|
|
|
import RFB from '@novnc/novnc/core/rfb'; |
|
|
|
|
import { Panel } from '../Panels'; |
|
|
|
|
import { BLACK, RED, TEXT } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
|
import keyCombinations from './keyCombinations'; |
|
|
|
@ -18,6 +18,8 @@ const VncDisplay = dynamic(() => import('./VncDisplay'), { ssr: false }); |
|
|
|
|
|
|
|
|
|
const useStyles = makeStyles(() => ({ |
|
|
|
|
displayBox: { |
|
|
|
|
width: '75vw', |
|
|
|
|
height: '75vh', |
|
|
|
|
paddingTop: '1em', |
|
|
|
|
paddingBottom: 0, |
|
|
|
|
paddingLeft: 0, |
|
|
|
@ -77,16 +79,12 @@ interface VncConnectionProps { |
|
|
|
|
|
|
|
|
|
const FullSize = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => { |
|
|
|
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); |
|
|
|
|
const rfb = useRef<RFB>(); |
|
|
|
|
const rfb = useRef<typeof RFB>(); |
|
|
|
|
const hostname = useRef<string | undefined>(undefined); |
|
|
|
|
const [vncConnection, setVncConnection] = useState< |
|
|
|
|
VncConnectionProps | undefined |
|
|
|
|
>(undefined); |
|
|
|
|
const [isError, setIsError] = useState<boolean>(false); |
|
|
|
|
const [displaySize] = useState<{ |
|
|
|
|
width: string; |
|
|
|
|
height: string; |
|
|
|
|
}>({ width: '100%', height: '75vh' }); |
|
|
|
|
const classes = useStyles(); |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
@ -146,103 +144,94 @@ const FullSize = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => { |
|
|
|
|
<Box flexGrow={1}> |
|
|
|
|
<HeaderText text={`Server: ${serverName}`} /> |
|
|
|
|
</Box> |
|
|
|
|
|
|
|
|
|
<Box display="flex" className={classes.displayBox}> |
|
|
|
|
{vncConnection ? ( |
|
|
|
|
<> |
|
|
|
|
<VncDisplay |
|
|
|
|
rfb={rfb} |
|
|
|
|
url={`${vncConnection.protocol}://${hostname.current}:${vncConnection.forward_port}`} |
|
|
|
|
style={displaySize} |
|
|
|
|
viewOnly={false} |
|
|
|
|
focusOnClick={false} |
|
|
|
|
clipViewport={false} |
|
|
|
|
dragViewport={false} |
|
|
|
|
scaleViewport |
|
|
|
|
resizeSession |
|
|
|
|
showDotCursor={false} |
|
|
|
|
background="" |
|
|
|
|
qualityLevel={6} |
|
|
|
|
compressionLevel={2} |
|
|
|
|
/> |
|
|
|
|
<Box> |
|
|
|
|
<Box className={classes.closeBox}> |
|
|
|
|
<IconButton |
|
|
|
|
className={classes.closeButton} |
|
|
|
|
style={{ color: TEXT }} |
|
|
|
|
component="span" |
|
|
|
|
onClick={() => { |
|
|
|
|
handleClickClose(); |
|
|
|
|
setMode(true); |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<CloseIcon /> |
|
|
|
|
</IconButton> |
|
|
|
|
</Box> |
|
|
|
|
<Box className={classes.closeBox}> |
|
|
|
|
<IconButton |
|
|
|
|
className={classes.keyboardButton} |
|
|
|
|
style={{ color: BLACK }} |
|
|
|
|
component="span" |
|
|
|
|
onClick={handleClick} |
|
|
|
|
> |
|
|
|
|
<KeyboardIcon /> |
|
|
|
|
</IconButton> |
|
|
|
|
<Menu |
|
|
|
|
anchorEl={anchorEl} |
|
|
|
|
keepMounted |
|
|
|
|
open={Boolean(anchorEl)} |
|
|
|
|
onClose={() => setAnchorEl(null)} |
|
|
|
|
> |
|
|
|
|
{keyCombinations.map(({ keys, scans }) => { |
|
|
|
|
return ( |
|
|
|
|
<MenuItem |
|
|
|
|
onClick={() => handleSendKeys(scans)} |
|
|
|
|
className={classes.keysItem} |
|
|
|
|
key={keys} |
|
|
|
|
> |
|
|
|
|
<Typography variant="subtitle1">{keys}</Typography> |
|
|
|
|
</MenuItem> |
|
|
|
|
); |
|
|
|
|
})} |
|
|
|
|
</Menu> |
|
|
|
|
</Box> |
|
|
|
|
{vncConnection ? ( |
|
|
|
|
<Box display="flex" className={classes.displayBox}> |
|
|
|
|
<VncDisplay |
|
|
|
|
rfb={rfb} |
|
|
|
|
url={`${vncConnection.protocol}://${hostname.current}:${vncConnection.forward_port}`} |
|
|
|
|
viewOnly={false} |
|
|
|
|
focusOnClick={false} |
|
|
|
|
clipViewport={false} |
|
|
|
|
dragViewport={false} |
|
|
|
|
scaleViewport |
|
|
|
|
resizeSession |
|
|
|
|
showDotCursor={false} |
|
|
|
|
background="" |
|
|
|
|
qualityLevel={6} |
|
|
|
|
compressionLevel={2} |
|
|
|
|
/> |
|
|
|
|
<Box> |
|
|
|
|
<Box className={classes.closeBox}> |
|
|
|
|
<IconButton |
|
|
|
|
className={classes.closeButton} |
|
|
|
|
style={{ color: TEXT }} |
|
|
|
|
component="span" |
|
|
|
|
onClick={() => { |
|
|
|
|
handleClickClose(); |
|
|
|
|
setMode(true); |
|
|
|
|
}} |
|
|
|
|
> |
|
|
|
|
<CloseIcon /> |
|
|
|
|
</IconButton> |
|
|
|
|
</Box> |
|
|
|
|
<Box className={classes.closeBox}> |
|
|
|
|
<IconButton |
|
|
|
|
className={classes.keyboardButton} |
|
|
|
|
style={{ color: BLACK }} |
|
|
|
|
component="span" |
|
|
|
|
onClick={handleClick} |
|
|
|
|
> |
|
|
|
|
<KeyboardIcon /> |
|
|
|
|
</IconButton> |
|
|
|
|
<Menu |
|
|
|
|
anchorEl={anchorEl} |
|
|
|
|
keepMounted |
|
|
|
|
open={Boolean(anchorEl)} |
|
|
|
|
onClose={() => setAnchorEl(null)} |
|
|
|
|
> |
|
|
|
|
{keyCombinations.map(({ keys, scans }) => { |
|
|
|
|
return ( |
|
|
|
|
<MenuItem |
|
|
|
|
onClick={() => handleSendKeys(scans)} |
|
|
|
|
className={classes.keysItem} |
|
|
|
|
key={keys} |
|
|
|
|
> |
|
|
|
|
<Typography variant="subtitle1">{keys}</Typography> |
|
|
|
|
</MenuItem> |
|
|
|
|
); |
|
|
|
|
})} |
|
|
|
|
</Menu> |
|
|
|
|
</Box> |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
<Box display="flex" className={classes.spinnerBox}> |
|
|
|
|
{!isError ? ( |
|
|
|
|
<> |
|
|
|
|
<HeaderText |
|
|
|
|
text={`Establishing connection with ${serverName}`} |
|
|
|
|
/> |
|
|
|
|
<HeaderText text="This may take a few minutes" /> |
|
|
|
|
<Spinner /> |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
<> |
|
|
|
|
<Box style={{ paddingBottom: '2em' }}> |
|
|
|
|
<HeaderText text="There was a problem connecting to the server, please try again" /> |
|
|
|
|
</Box> |
|
|
|
|
<Button |
|
|
|
|
variant="contained" |
|
|
|
|
onClick={() => { |
|
|
|
|
setIsError(false); |
|
|
|
|
}} |
|
|
|
|
style={{ textTransform: 'none' }} |
|
|
|
|
> |
|
|
|
|
<Typography |
|
|
|
|
className={classes.buttonText} |
|
|
|
|
variant="subtitle1" |
|
|
|
|
> |
|
|
|
|
Reconnect |
|
|
|
|
</Typography> |
|
|
|
|
</Button> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
</Box> |
|
|
|
|
)} |
|
|
|
|
</Box> |
|
|
|
|
</Box> |
|
|
|
|
) : ( |
|
|
|
|
<Box display="flex" className={classes.spinnerBox}> |
|
|
|
|
{!isError ? ( |
|
|
|
|
<> |
|
|
|
|
<HeaderText text={`Establishing connection with ${serverName}`} /> |
|
|
|
|
<HeaderText text="This may take a few minutes" /> |
|
|
|
|
<Spinner /> |
|
|
|
|
</> |
|
|
|
|
) : ( |
|
|
|
|
<> |
|
|
|
|
<Box style={{ paddingBottom: '2em' }}> |
|
|
|
|
<HeaderText text="There was a problem connecting to the server, please try again" /> |
|
|
|
|
</Box> |
|
|
|
|
<Button |
|
|
|
|
variant="contained" |
|
|
|
|
onClick={() => { |
|
|
|
|
setIsError(false); |
|
|
|
|
}} |
|
|
|
|
style={{ textTransform: 'none' }} |
|
|
|
|
> |
|
|
|
|
<Typography className={classes.buttonText} variant="subtitle1"> |
|
|
|
|
Reconnect |
|
|
|
|
</Typography> |
|
|
|
|
</Button> |
|
|
|
|
</> |
|
|
|
|
)} |
|
|
|
|
</Box> |
|
|
|
|
)} |
|
|
|
|
</Panel> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|