fix(striker-ui): link server name to server detail page

main
Tsu-ba-me 3 years ago
parent 9cd1ffb3ae
commit e3b5688779
  1. 10
      striker-ui/components/Display/FullSize.tsx
  2. 21
      striker-ui/components/Display/Preview.tsx
  3. 14
      striker-ui/pages/index.tsx
  4. 17
      striker-ui/pages/server/index.tsx

@ -94,7 +94,7 @@ const VncDisplay = dynamic(() => import('./VncDisplay'), { ssr: false });
interface FullSizeProps { interface FullSizeProps {
setMode: Dispatch<SetStateAction<boolean>>; setMode: Dispatch<SetStateAction<boolean>>;
uuid: string; serverUUID: string;
serverName: string | string[] | undefined; serverName: string | string[] | undefined;
} }
@ -105,7 +105,7 @@ interface VncConnectionProps {
const FullSize = ({ const FullSize = ({
setMode, setMode,
uuid, serverUUID,
serverName, serverName,
}: FullSizeProps): JSX.Element => { }: FullSizeProps): JSX.Element => {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
@ -127,7 +127,7 @@ const FullSize = ({
const res = await putFetchWithTimeout( const res = await putFetchWithTimeout(
`${process.env.NEXT_PUBLIC_API_URL}/manage_vnc_pipes`, `${process.env.NEXT_PUBLIC_API_URL}/manage_vnc_pipes`,
{ {
server_uuid: uuid, server_uuid: serverUUID,
is_open: true, is_open: true,
}, },
120000, 120000,
@ -137,7 +137,7 @@ const FullSize = ({
setIsError(true); setIsError(true);
} }
})(); })();
}, [uuid, vncConnection, isError]); }, [serverUUID, vncConnection, isError]);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => { const handleClick = (event: React.MouseEvent<HTMLButtonElement>): void => {
setAnchorEl(event.currentTarget); setAnchorEl(event.currentTarget);
@ -145,7 +145,7 @@ const FullSize = ({
const handleClickClose = async () => { const handleClickClose = async () => {
await putFetch(`${process.env.NEXT_PUBLIC_API_URL}/manage_vnc_pipes`, { await putFetch(`${process.env.NEXT_PUBLIC_API_URL}/manage_vnc_pipes`, {
server_uuid: uuid, server_uuid: serverUUID,
is_open: false, is_open: false,
}); });
}; };

@ -26,11 +26,11 @@ type PreviewOptionalProps = {
isFetchPreview?: boolean; isFetchPreview?: boolean;
isShowControls?: boolean; isShowControls?: boolean;
isUseInnerPanel?: boolean; isUseInnerPanel?: boolean;
serverName?: string;
setMode?: Dispatch<SetStateAction<boolean>> | null; setMode?: Dispatch<SetStateAction<boolean>> | null;
}; };
type PreviewProps = PreviewOptionalProps & { type PreviewProps = PreviewOptionalProps & {
serverName: string | string[] | undefined;
serverUUID: string; serverUUID: string;
}; };
@ -41,6 +41,7 @@ const PREVIEW_DEFAULT_PROPS: Required<PreviewOptionalProps> = {
isFetchPreview: true, isFetchPreview: true,
isShowControls: true, isShowControls: true,
isUseInnerPanel: false, isUseInnerPanel: false,
serverName: '',
setMode: null, setMode: null,
}; };
@ -54,19 +55,18 @@ const PreviewPanel: FC<{ isUseInnerPanel: boolean }> = ({
<Panel>{children}</Panel> <Panel>{children}</Panel>
); );
const PreviewPanelHeader: FC<{ isUseInnerPanel: boolean; text: string }> = ({ const PreviewPanelHeader: FC<{
children, isUseInnerPanel: boolean;
isUseInnerPanel, text: string | undefined;
text, }> = ({ children, isUseInnerPanel, text }) =>
}) =>
isUseInnerPanel ? ( isUseInnerPanel ? (
<InnerPanelHeader> <InnerPanelHeader>
<BodyText text={text} /> {text ? <BodyText text={text} /> : <></>}
{children} {children}
</InnerPanelHeader> </InnerPanelHeader>
) : ( ) : (
<PanelHeader> <PanelHeader>
<HeaderText text={text} /> {text ? <HeaderText text={text} /> : <></>}
{children} {children}
</PanelHeader> </PanelHeader>
); );
@ -114,10 +114,7 @@ const Preview: FC<PreviewProps> = ({
return ( return (
<PreviewPanel isUseInnerPanel={isUseInnerPanel}> <PreviewPanel isUseInnerPanel={isUseInnerPanel}>
<PreviewPanelHeader <PreviewPanelHeader isUseInnerPanel={isUseInnerPanel} text={serverName}>
isUseInnerPanel={isUseInnerPanel}
text={`${serverName}`}
>
{headerEndAdornment} {headerEndAdornment}
</PreviewPanelHeader> </PreviewPanelHeader>
<Box <Box

@ -53,22 +53,28 @@ const createServerPreviewContainer = (
}) => ( }) => (
<Preview <Preview
externalPreview={screenshot} externalPreview={screenshot}
headerEndAdornment={ headerEndAdornment={[
<Link
href={`/server?uuid=${serverUUID}&server_name=${serverName}`}
key={`server_list_to_server_${serverUUID}`}
>
{serverName}
</Link>,
<Link <Link
href={`/anvil?anvil_uuid=${anvilUUID}`} href={`/anvil?anvil_uuid=${anvilUUID}`}
key={`server_list_server_${serverUUID}_to_anvil_${anvilUUID}`}
sx={{ sx={{
opacity: 0.7, opacity: 0.7,
}} }}
> >
{anvilName} {anvilName}
</Link> </Link>,
} ]}
isExternalPreviewStale={isScreenshotStale} isExternalPreviewStale={isScreenshotStale}
isFetchPreview={false} isFetchPreview={false}
isShowControls={false} isShowControls={false}
isUseInnerPanel isUseInnerPanel
key={`server-preview-${serverUUID}`} key={`server-preview-${serverUUID}`}
serverName={serverName}
serverUUID={serverUUID} serverUUID={serverUUID}
setMode={() => { setMode={() => {
router.push(`/server?uuid=${serverUUID}&server_name=${serverName}`); router.push(`/server?uuid=${serverUUID}&server_name=${serverName}`);

@ -36,31 +36,32 @@ const Server = (): JSX.Element => {
const router = useRouter(); const router = useRouter();
const { uuid, server_name } = router.query; const { uuid, server_name } = router.query;
const serverUUID: string = uuid?.toString() || '';
const serverName: string = server_name?.toString() || '';
return ( return (
<StyledDiv> <StyledDiv>
<Head> <Head>
<title>{server_name}</title> <title>{serverName}</title>
</Head> </Head>
<Header /> <Header />
{typeof uuid === 'string' && {previewMode ? (
(previewMode ? (
<Box className={classes.preview}> <Box className={classes.preview}>
<Preview <Preview
setMode={setPreviewMode} setMode={setPreviewMode}
serverName={server_name} serverName={serverName}
serverUUID={uuid} serverUUID={serverUUID}
/> />
</Box> </Box>
) : ( ) : (
<Box className={classes.fullView}> <Box className={classes.fullView}>
<FullSize <FullSize
setMode={setPreviewMode} setMode={setPreviewMode}
uuid={uuid} serverUUID={serverUUID}
serverName={server_name} serverName={serverName}
/> />
</Box> </Box>
))} )}
</StyledDiv> </StyledDiv>
); );
}; };

Loading…
Cancel
Save