diff --git a/striker-ui/components/Display/FullSize.tsx b/striker-ui/components/Display/FullSize.tsx index fa1aa24f..8584dfe0 100644 --- a/striker-ui/components/Display/FullSize.tsx +++ b/striker-ui/components/Display/FullSize.tsx @@ -60,10 +60,9 @@ interface VncConnectionProps { const FullSize = ({ setMode, uuid }: PreviewProps): JSX.Element => { const [anchorEl, setAnchorEl] = useState(null); const rfb = useRef(undefined); - const vncConnection = useRef({ - protocol: '', - forward_port: 0, - }); + const [vncConnection, setVncConnection] = useState< + VncConnectionProps | undefined + >(undefined); const [displaySize, setDisplaySize] = useState< | { width: string | number; @@ -79,18 +78,18 @@ const FullSize = ({ setMode, uuid }: PreviewProps): JSX.Element => { height: '80vh', }); - (async () => { - const res = await putJSON( - 'http://108.168.17.168/cgi-bin/manage_vnc_pipes', - { - server_uuid: uuid, - is_open: true, - }, - ); - // console.log(res); - vncConnection.current = res.json(); - })(); - }, [uuid]); + if (!vncConnection) + (async () => { + const res = await putJSON( + `${process.env.NEXT_PUBLIC_API_URL}/manage_vnc_pipes`, + { + server_uuid: uuid, + is_open: true, + }, + ); + setVncConnection(await res.json()); + })(); + }, [uuid, vncConnection]); const handleClick = (event: React.MouseEvent): void => { setAnchorEl(event.currentTarget); @@ -117,13 +116,15 @@ const FullSize = ({ setMode, uuid }: PreviewProps): JSX.Element => { return ( - - - + {vncConnection && ( + + + + )} { className={classes.button} key={server.server_uuid} component="a" - href={`/server/${server.server_uuid}`} + href={`/server?uuid=${server.server_uuid}`} > {showCheckbox && ( diff --git a/striker-ui/pages/server/[uuid].tsx b/striker-ui/pages/server/index.tsx similarity index 100% rename from striker-ui/pages/server/[uuid].tsx rename to striker-ui/pages/server/index.tsx