2022-02-23 15:20:23 +01:00
|
|
|
import Alert from "@mui/lab/Alert";
|
2022-01-28 20:20:15 +01:00
|
|
|
import { Box, Grid, Paper, CircularProgress } from "@mui/material";
|
2020-09-20 22:30:17 +02:00
|
|
|
|
|
|
|
import RequestDetail from "./RequestDetail";
|
2022-02-23 15:20:23 +01:00
|
|
|
import ResponseDetail from "./ResponseDetail";
|
2020-09-20 22:30:17 +02:00
|
|
|
|
2022-02-23 15:20:23 +01:00
|
|
|
import { useHttpRequestLogQuery } from "lib/graphql/generated";
|
2020-09-20 22:30:17 +02:00
|
|
|
|
|
|
|
interface Props {
|
2022-01-21 11:45:54 +01:00
|
|
|
requestId: string;
|
2020-09-20 22:30:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function LogDetail({ requestId: id }: Props): JSX.Element {
|
2022-02-23 15:20:23 +01:00
|
|
|
const { loading, error, data } = useHttpRequestLogQuery({
|
2020-09-20 22:30:17 +02:00
|
|
|
variables: { id },
|
|
|
|
});
|
|
|
|
|
2020-09-23 18:10:32 +02:00
|
|
|
if (loading) {
|
|
|
|
return <CircularProgress />;
|
|
|
|
}
|
|
|
|
if (error) {
|
2022-01-28 20:20:15 +01:00
|
|
|
return <Alert severity="error">Error fetching logs details: {error.message}</Alert>;
|
2020-09-23 18:10:32 +02:00
|
|
|
}
|
2020-09-20 22:30:17 +02:00
|
|
|
|
2022-02-23 15:20:23 +01:00
|
|
|
if (data && !data.httpRequestLog) {
|
2020-09-23 23:43:20 +02:00
|
|
|
return (
|
|
|
|
<Alert severity="warning">
|
|
|
|
Request <strong>{id}</strong> was not found.
|
|
|
|
</Alert>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-23 15:20:23 +01:00
|
|
|
if (!data?.httpRequestLog) {
|
|
|
|
return <div></div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
const httpRequestLog = data.httpRequestLog;
|
2020-09-20 22:30:17 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Grid container item spacing={2}>
|
|
|
|
<Grid item xs={6}>
|
2020-09-27 18:59:38 +02:00
|
|
|
<Box component={Paper}>
|
2022-02-23 15:20:23 +01:00
|
|
|
<RequestDetail request={httpRequestLog} />
|
2020-09-20 22:30:17 +02:00
|
|
|
</Box>
|
|
|
|
</Grid>
|
|
|
|
<Grid item xs={6}>
|
2022-02-23 15:20:23 +01:00
|
|
|
{httpRequestLog.response && (
|
2020-09-27 18:59:38 +02:00
|
|
|
<Box component={Paper}>
|
2022-02-23 15:20:23 +01:00
|
|
|
<ResponseDetail response={httpRequestLog.response} />
|
2020-09-21 21:46:44 +02:00
|
|
|
</Box>
|
|
|
|
)}
|
2020-09-20 22:30:17 +02:00
|
|
|
</Grid>
|
|
|
|
</Grid>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default LogDetail;
|