Skip to content

Commit

Permalink
headerを表示できるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
cateiru committed Feb 19, 2024
1 parent ede1f7d commit a51fc4d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 81 deletions.
177 changes: 97 additions & 80 deletions components/Staff/DeployData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import {
Badge,
Flex,
Heading,
Link,
Skeleton,
Table,
Expand All @@ -25,7 +27,7 @@ export const DeployData = () => {
DeployDataType | undefined | null
>();

const {request} = useRequest('/debug');
const {request} = useRequest('/admin/debug');

React.useEffect(() => {
const f = async () => {
Expand All @@ -46,86 +48,101 @@ export const DeployData = () => {
}, []);

return (
<TableContainer>
<Table variant="simple">
<Tbody>
<Tr>
<Td fontWeight="bold">モード</Td>
<Td>{config.mode}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">APIモード</Td>
<Td>
{apiData === null ? (
<>No Connected</>
) : apiData ? (
apiData.mode
) : (
<Skeleton h="1.2rem" w="3rem" />
)}
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">クライアントIPアドレス</Td>
<Td>
{apiData === null ? (
<>No Connected</>
) : apiData ? (
apiData.ip_address
) : (
<Skeleton h="1.2rem" w="3rem" />
)}
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">X-Forwarded-For</Td>
<Td>
{apiData === null ? (
<>No Connected</>
) : apiData ? (
apiData.xff
) : (
<Skeleton h="1.2rem" w="3rem" />
)}
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">リビジョン</Td>
<Td>{config.revision}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">ブランチ名</Td>
<Td>{config.branchName ?? ''}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">APIホスト</Td>
<Td>
<Link isExternal href={config.apiHost ?? config.apiPathPrefix}>
{config.apiHost ?? config.apiPathPrefix}
</Link>
<Text ml="1rem" as="span">
{apiConnectOk ? (
<Badge colorScheme="green" verticalAlign="top">
Connected
</Badge>
<>
<TableContainer>
<Table variant="simple">
<Tbody>
<Tr>
<Td fontWeight="bold">モード</Td>
<Td>{config.mode}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">APIモード</Td>
<Td>
{apiData === null ? (
<>No Connected</>
) : apiData ? (
apiData.mode
) : (
<Badge colorScheme="red" verticalAlign="top">
No Connect
</Badge>
<Skeleton h="1.2rem" w="3rem" />
)}
</Text>
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">CORS設定</Td>
<Td>{config.apiCors ? '有効' : '無効'}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">タイトル</Td>
<Td>{config.title}</Td>
</Tr>
</Tbody>
</Table>
</TableContainer>
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">クライアントIPアドレス</Td>
<Td>
{apiData === null ? (
<>No Connected</>
) : apiData ? (
apiData.ip_address
) : (
<Skeleton h="1.2rem" w="3rem" />
)}
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">リビジョン</Td>
<Td>{config.revision}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">ブランチ名</Td>
<Td>{config.branchName ?? ''}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">APIホスト</Td>
<Td>
<Link isExternal href={config.apiHost ?? config.apiPathPrefix}>
{config.apiHost ?? config.apiPathPrefix}
</Link>
<Text ml="1rem" as="span">
{apiConnectOk ? (
<Badge colorScheme="green" verticalAlign="top">
Connected
</Badge>
) : (
<Badge colorScheme="red" verticalAlign="top">
No Connect
</Badge>
)}
</Text>
</Td>
</Tr>
<Tr>
<Td fontWeight="bold">CORS設定</Td>
<Td>{config.apiCors ? '有効' : '無効'}</Td>
</Tr>
<Tr>
<Td fontWeight="bold">タイトル</Td>
<Td>{config.title}</Td>
</Tr>
</Tbody>
</Table>
</TableContainer>

<Flex mt="2rem">
<Heading as="h2" fontSize="1.3rem" fontWeight="bold">
リクエストヘッダー
</Heading>
</Flex>
<TableContainer mt="1rem">
<Table variant="simple">
<Tbody>
{apiData &&
Object.keys(apiData.headers).map(key => {
return (
<Tr key={`header-${key}`}>
<Td fontWeight="bold">{key}</Td>
<Td>
<Text as="pre" maxW="350px" whiteSpace="pre-wrap">
{apiData.headers[key].join(', ')}
</Text>
</Td>
</Tr>
);
})}
</Tbody>
</Table>
</TableContainer>
</>
);
};
2 changes: 1 addition & 1 deletion utils/types/staff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export type UserNames = z.infer<typeof UsernamesSchema>;

export const DeployDataSchema = z.object({
mode: z.string(),
xff: z.string(),
ip_address: z.string(),
headers: z.record(z.string(), z.array(z.string())),
});
export type DeployData = z.infer<typeof DeployDataSchema>;

0 comments on commit a51fc4d

Please sign in to comment.