From 3e3e7fba12ba289c279e3634e6ea83b6b6e13a62 Mon Sep 17 00:00:00 2001 From: Josue Date: Mon, 19 Jul 2021 18:34:57 -0400 Subject: [PATCH] fix(front-end): get domain from window and add spinner --- striker-ui/components/Display/FullSize.tsx | 47 ++++++++++++++-------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/striker-ui/components/Display/FullSize.tsx b/striker-ui/components/Display/FullSize.tsx index 45df321d..df8d69fc 100644 --- a/striker-ui/components/Display/FullSize.tsx +++ b/striker-ui/components/Display/FullSize.tsx @@ -11,11 +11,18 @@ import { BLACK, RED, TEXT } from '../../lib/consts/DEFAULT_THEME'; import keyCombinations from './keyCombinations'; import putJSON from '../../lib/fetchers/putJSON'; import { HeaderText } from '../Text'; +import Spinner from '../Spinner'; const useStyles = makeStyles(() => ({ displayBox: { paddingTop: '1em', paddingBottom: 0, + width: '75%', + height: '80%', + }, + vncBox: { + width: '75%', + height: '80%', }, closeButton: { borderRadius: 8, @@ -74,23 +81,20 @@ const extractDomain = (url: string | undefined): string | undefined => { const FullSize = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => { const [anchorEl, setAnchorEl] = useState(null); const rfb = useRef(undefined); + const hostname = useRef(undefined); const [vncConnection, setVncConnection] = useState< VncConnectionProps | undefined >(undefined); - const [displaySize, setDisplaySize] = useState< - | { - width: string | number; - height: string | number; - } - | undefined - >(undefined); + const [displaySize] = useState<{ + width: string; + height: string; + }>({ width: '75%', height: '80%' }); const classes = useStyles(); useEffect(() => { - setDisplaySize({ - width: '75vw', - height: '80vh', - }); + if (typeof window !== 'undefined') { + hostname.current = window.location.hostname; + } if (!vncConnection) (async () => { @@ -109,6 +113,13 @@ const FullSize = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => { setAnchorEl(event.currentTarget); }; + const handleClickClose = async () => { + await putJSON(`${process.env.NEXT_PUBLIC_API_URL}/manage_vnc_pipes`, { + server_uuid: uuid, + is_open: false, + }); + }; + const handleSendKeys = (scans: string[]) => { if (rfb.current) { if (!scans.length) rfb.current.sendCtrlAltDel(); @@ -135,23 +146,27 @@ const FullSize = ({ setMode, uuid, serverName }: PreviewProps): JSX.Element => { - {vncConnection && extractedDomain && ( - + {vncConnection && extractedDomain ? ( + + ) : ( + )} setMode(true)} + onClick={() => { + handleClickClose(); + setMode(true); + }} >