diff --git a/striker-ui/components/Anvils/SelectedAnvil.tsx b/striker-ui/components/Anvils/SelectedAnvil.tsx index 7c1130fb..b159c8a3 100644 --- a/striker-ui/components/Anvils/SelectedAnvil.tsx +++ b/striker-ui/components/Anvils/SelectedAnvil.tsx @@ -67,7 +67,7 @@ const SelectedAnvil = ({ list }: { list: AnvilListItem[] }): JSX.Element => { - putJSON('/set_power', { + putJSON(`${process.env.NEXT_PUBLIC_API_URL}/set_power`, { anvil_uuid: list[index].anvil_uuid, is_on: !isAnvilOn(list[index]), }) diff --git a/striker-ui/components/Display/FullSize.tsx b/striker-ui/components/Display/FullSize.tsx index 0efd3a3b..fa1aa24f 100644 --- a/striker-ui/components/Display/FullSize.tsx +++ b/striker-ui/components/Display/FullSize.tsx @@ -9,6 +9,7 @@ import VncDisplay from './VncDisplay'; import { Panel } from '../Panels'; import { BLACK, RED, TEXT } from '../../lib/consts/DEFAULT_THEME'; import keyCombinations from './keyCombinations'; +import putJSON from '../../lib/fetchers/putJSON'; const useStyles = makeStyles(() => ({ displayBox: { @@ -48,11 +49,21 @@ const useStyles = makeStyles(() => ({ interface PreviewProps { setMode: Dispatch>; + uuid: string; } -const FullSize = ({ setMode }: PreviewProps): JSX.Element => { +interface VncConnectionProps { + protocol: string; + forward_port: number; +} + +const FullSize = ({ setMode, uuid }: PreviewProps): JSX.Element => { const [anchorEl, setAnchorEl] = useState(null); const rfb = useRef(undefined); + const vncConnection = useRef({ + protocol: '', + forward_port: 0, + }); const [displaySize, setDisplaySize] = useState< | { width: string | number; @@ -67,7 +78,19 @@ const FullSize = ({ setMode }: PreviewProps): JSX.Element => { width: '75vw', 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]); const handleClick = (event: React.MouseEvent): void => { setAnchorEl(event.currentTarget); @@ -97,7 +120,7 @@ const FullSize = ({ setMode }: PreviewProps): JSX.Element => { diff --git a/striker-ui/components/Hosts/AnvilHost.tsx b/striker-ui/components/Hosts/AnvilHost.tsx index e0678247..c1adfa04 100644 --- a/striker-ui/components/Hosts/AnvilHost.tsx +++ b/striker-ui/components/Hosts/AnvilHost.tsx @@ -104,10 +104,13 @@ const AnvilHost = ({ - putJSON('/set_power', { - host_uuid: host.host_uuid, - is_on: !(host.state === 'online'), - }) + putJSON( + `${process.env.NEXT_PUBLIC_API_URL}/set_power`, + { + host_uuid: host.host_uuid, + is_on: !(host.state === 'online'), + }, + ) } /> @@ -119,10 +122,13 @@ const AnvilHost = ({ checked={host.state === 'online'} disabled={!(host.state === 'online')} onChange={() => - putJSON('/set_membership', { - host_uuid: host.host_uuid, - is_member: !(host.state === 'online'), - }) + putJSON( + `${process.env.NEXT_PUBLIC_API_URL}/set_membership`, + { + host_uuid: host.host_uuid, + is_member: !(host.state === 'online'), + }, + ) } /> diff --git a/striker-ui/components/Servers.tsx b/striker-ui/components/Servers.tsx index 1d63ba87..30a6e841 100644 --- a/striker-ui/components/Servers.tsx +++ b/striker-ui/components/Servers.tsx @@ -145,7 +145,7 @@ const Servers = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { const handlePower = (label: ButtonLabels) => { setAnchorEl(null); if (selected.length) { - putJSON('/set_power', { + putJSON(`${process.env.NEXT_PUBLIC_API_URL}/set_power`, { server_uuid_list: selected, is_on: label === 'on', }); diff --git a/striker-ui/lib/fetchers/putJSON.ts b/striker-ui/lib/fetchers/putJSON.ts index 472f9ded..bace43fc 100644 --- a/striker-ui/lib/fetchers/putJSON.ts +++ b/striker-ui/lib/fetchers/putJSON.ts @@ -1,5 +1,6 @@ -const putJSON = (uri: string, data: T): void => { - fetch(`${process.env.NEXT_PUBLIC_API_URL}${uri}`, { +/* eslint-disable @typescript-eslint/no-explicit-any */ +const putJSON = (uri: string, data: T): Promise => { + return fetch(uri, { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/striker-ui/pages/server/[uuid].tsx b/striker-ui/pages/server/[uuid].tsx index ac2d700d..27390069 100644 --- a/striker-ui/pages/server/[uuid].tsx +++ b/striker-ui/pages/server/[uuid].tsx @@ -74,7 +74,7 @@ const Server = (): JSX.Element => { ) : ( - + ))}