mirror of
https://github.com/dstotijn/hetty.git
synced 2025-07-01 18:47:29 -04:00
Add Proto
to request detail, update theme
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { green, orange, red } from "@material-ui/core/colors";
|
||||
import { teal, orange, red } from "@material-ui/core/colors";
|
||||
import FiberManualRecordIcon from "@material-ui/icons/FiberManualRecord";
|
||||
|
||||
function HttpStatusIcon({ status }: { status: number }): JSX.Element {
|
||||
@ -6,7 +6,7 @@ function HttpStatusIcon({ status }: { status: number }): JSX.Element {
|
||||
switch (Math.floor(status / 100)) {
|
||||
case 2:
|
||||
case 3:
|
||||
return <FiberManualRecordIcon style={{ ...style, color: green[400] }} />;
|
||||
return <FiberManualRecordIcon style={{ ...style, color: teal[400] }} />;
|
||||
case 4:
|
||||
return <FiberManualRecordIcon style={{ ...style, color: orange[400] }} />;
|
||||
case 5:
|
||||
|
@ -10,6 +10,7 @@ const HTTP_REQUEST_LOG = gql`
|
||||
id
|
||||
method
|
||||
url
|
||||
proto
|
||||
body
|
||||
response {
|
||||
proto
|
||||
@ -30,17 +31,17 @@ function LogDetail({ requestId: id }: Props): JSX.Element {
|
||||
variables: { id },
|
||||
});
|
||||
|
||||
if (loading) return "Loading...";
|
||||
if (error) return `Error: ${error.message}`;
|
||||
if (loading) return <div>"Loading..."</div>;
|
||||
if (error) return <div>`Error: ${error.message}`</div>;
|
||||
|
||||
const { method, url, body, response } = data.httpRequestLog;
|
||||
const { method, url, proto, body, response } = data.httpRequestLog;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Grid container item spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Box component={Paper} maxHeight="60vh" overflow="scroll">
|
||||
<RequestDetail request={{ method, url, body }} />
|
||||
<RequestDetail request={{ method, url, proto, body }} />
|
||||
</Box>
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
|
@ -6,12 +6,13 @@ interface Props {
|
||||
request: {
|
||||
method: string;
|
||||
url: string;
|
||||
proto: string;
|
||||
body?: string;
|
||||
};
|
||||
}
|
||||
|
||||
function RequestDetail({ request }: Props): JSX.Element {
|
||||
const { method, url, body } = request;
|
||||
const { method, url, proto, body } = request;
|
||||
|
||||
const parsedUrl = new URL(url);
|
||||
console.log(parsedUrl);
|
||||
@ -24,7 +25,7 @@ function RequestDetail({ request }: Props): JSX.Element {
|
||||
style={{ fontSize: "1rem", whiteSpace: "nowrap" }}
|
||||
>
|
||||
{request.method}{" "}
|
||||
{decodeURIComponent(parsedUrl.pathname + parsedUrl.search)}
|
||||
{decodeURIComponent(parsedUrl.pathname + parsedUrl.search)} {proto}
|
||||
</Typography>
|
||||
</Box>
|
||||
<Box>
|
||||
|
@ -34,8 +34,8 @@ interface Props {
|
||||
function RequestList({ onLogClick }: Props): JSX.Element {
|
||||
const { loading, error, data } = useQuery(HTTP_REQUEST_LOGS);
|
||||
|
||||
if (loading) return "Loading...";
|
||||
if (error) return `Error: ${error.message}`;
|
||||
if (loading) return <div>"Loading..."</div>;
|
||||
if (error) return <div>`Error: ${error.message}`</div>;
|
||||
|
||||
const { httpRequestLogs: logs } = data;
|
||||
|
||||
|
@ -1,7 +1,16 @@
|
||||
import { createMuiTheme } from "@material-ui/core/styles";
|
||||
import { red } from "@material-ui/core/colors";
|
||||
import teal from "@material-ui/core/colors/teal";
|
||||
import green from "@material-ui/core/colors/green";
|
||||
|
||||
// Create a theme instance.
|
||||
const theme = createMuiTheme({});
|
||||
const theme = createMuiTheme({
|
||||
palette: {
|
||||
primary: {
|
||||
main: teal[500],
|
||||
},
|
||||
secondary: {
|
||||
main: green[500],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default theme;
|
||||
|
@ -46,6 +46,7 @@ type ComplexityRoot struct {
|
||||
Body func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Method func(childComplexity int) int
|
||||
Proto func(childComplexity int) int
|
||||
Response func(childComplexity int) int
|
||||
Timestamp func(childComplexity int) int
|
||||
URL func(childComplexity int) int
|
||||
@ -106,6 +107,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||
|
||||
return e.complexity.HTTPRequestLog.Method(childComplexity), true
|
||||
|
||||
case "HttpRequestLog.proto":
|
||||
if e.complexity.HTTPRequestLog.Proto == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.HTTPRequestLog.Proto(childComplexity), true
|
||||
|
||||
case "HttpRequestLog.response":
|
||||
if e.complexity.HTTPRequestLog.Response == nil {
|
||||
break
|
||||
@ -235,6 +243,7 @@ var sources = []*ast.Source{
|
||||
id: ID!
|
||||
url: String!
|
||||
method: HttpMethod!
|
||||
proto: String!
|
||||
body: String
|
||||
timestamp: Time!
|
||||
response: HttpResponseLog
|
||||
@ -440,6 +449,40 @@ func (ec *executionContext) _HttpRequestLog_method(ctx context.Context, field gr
|
||||
return ec.marshalNHttpMethod2githubᚗcomᚋdstotijnᚋgurpᚋpkgᚋapiᚐHTTPMethod(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _HttpRequestLog_proto(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
fc := &graphql.FieldContext{
|
||||
Object: "HttpRequestLog",
|
||||
Field: field,
|
||||
Args: nil,
|
||||
IsMethod: false,
|
||||
}
|
||||
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.Proto, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(string)
|
||||
fc.Result = res
|
||||
return ec.marshalNString2string(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) _HttpRequestLog_body(ctx context.Context, field graphql.CollectedField, obj *HTTPRequestLog) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@ -1933,6 +1976,11 @@ func (ec *executionContext) _HttpRequestLog(ctx context.Context, sel ast.Selecti
|
||||
if out.Values[i] == graphql.Null {
|
||||
invalids++
|
||||
}
|
||||
case "proto":
|
||||
out.Values[i] = ec._HttpRequestLog_proto(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
invalids++
|
||||
}
|
||||
case "body":
|
||||
out.Values[i] = ec._HttpRequestLog_body(ctx, field, obj)
|
||||
case "timestamp":
|
||||
|
@ -13,6 +13,7 @@ type HTTPRequestLog struct {
|
||||
ID string `json:"id"`
|
||||
URL string `json:"url"`
|
||||
Method HTTPMethod `json:"method"`
|
||||
Proto string `json:"proto"`
|
||||
Body *string `json:"body"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Response *HTTPResponseLog `json:"response"`
|
||||
|
@ -58,6 +58,7 @@ func parseRequestLog(req reqlog.Request) (HTTPRequestLog, error) {
|
||||
log := HTTPRequestLog{
|
||||
ID: req.ID.String(),
|
||||
URL: req.Request.URL.String(),
|
||||
Proto: req.Request.Proto,
|
||||
Method: method,
|
||||
Timestamp: req.Timestamp,
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ type HttpRequestLog {
|
||||
id: ID!
|
||||
url: String!
|
||||
method: HttpMethod!
|
||||
proto: String!
|
||||
body: String
|
||||
timestamp: Time!
|
||||
response: HttpResponseLog
|
||||
|
Reference in New Issue
Block a user