summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2022-02-16 21:10:39 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2022-02-16 21:10:39 +0100
commita86f0a804bf8d1ff37d9027930aad1fdcbde3ad6 (patch)
treef9c8eff30e1f38cf7f3320590eadbdbe2af5291f
parente2aed74b7a9807bf87a9bf337c8a2e84a4bcbfde (diff)
downloadclient-1.4.0.post1.tar.gz
client-1.4.0.post1.tar.bz2
client-1.4.0.post1.zip
Added a timestampv1.4.0.post1v1.4.0
-rw-r--r--package.json1
-rw-r--r--src/components/RequestList/RequestList.tsx6
-rw-r--r--src/components/RequestSummary/RequestSummary.tsx15
-rw-r--r--src/hooks/useRequests.tsx1
-rw-r--r--src/index.tsx4
-rw-r--r--ttun/client.py10
-rw-r--r--yarn.lock5
7 files changed, 38 insertions, 4 deletions
diff --git a/package.json b/package.json
index 28b664f..51a2660 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
14 "bootstrap-darkmode": "5.0.0-beta.1", 14 "bootstrap-darkmode": "5.0.0-beta.1",
15 "bootstrap-icons": "^1.7.2", 15 "bootstrap-icons": "^1.7.2",
16 "classnames": "^2.3.1", 16 "classnames": "^2.3.1",
17 "dayjs": "^1.10.7",
17 "react": "^17.0.2", 18 "react": "^17.0.2",
18 "react-bootstrap": "^2.1.1", 19 "react-bootstrap": "^2.1.1",
19 "react-dom": "^17.0.2", 20 "react-dom": "^17.0.2",
diff --git a/src/components/RequestList/RequestList.tsx b/src/components/RequestList/RequestList.tsx
index 06a78a3..acef47a 100644
--- a/src/components/RequestList/RequestList.tsx
+++ b/src/components/RequestList/RequestList.tsx
@@ -106,8 +106,7 @@ export default function RequestList({
106 ) 106 )
107 .filter( 107 .filter(
108 ([index, request]) => 108 ([index, request]) =>
109 search === "" || 109 search === "" || searchRegex.test(request.request.path)
110 searchRegex.test(`${request.request.method} ${request.request.path}`)
111 ); 110 );
112 }, [requests, search, enabledMethods, enableRegex]); 111 }, [requests, search, enabledMethods, enableRegex]);
113 112
@@ -168,6 +167,7 @@ export default function RequestList({
168 <RequestSummary 167 <RequestSummary
169 requestResponse={requestResponse} 168 requestResponse={requestResponse}
170 selected={selected} 169 selected={selected}
170 showTime
171 /> 171 />
172 </ListGroup.Item> 172 </ListGroup.Item>
173 ); 173 );
@@ -205,7 +205,7 @@ export default function RequestList({
205 onChange={() => setEnableRegex(!enableRegex)} 205 onChange={() => setEnableRegex(!enableRegex)}
206 /> 206 />
207 </Form.Group> 207 </Form.Group>
208 <Form.Group> 208 <Form.Group className="mb-4">
209 <Form.Label className="fw-bold">Method</Form.Label> 209 <Form.Label className="fw-bold">Method</Form.Label>
210 {Object.entries(methods).map(([method, enabled]) => ( 210 {Object.entries(methods).map(([method, enabled]) => (
211 <Form.Check 211 <Form.Check
diff --git a/src/components/RequestSummary/RequestSummary.tsx b/src/components/RequestSummary/RequestSummary.tsx
index 44254d0..49e6086 100644
--- a/src/components/RequestSummary/RequestSummary.tsx
+++ b/src/components/RequestSummary/RequestSummary.tsx
@@ -3,10 +3,12 @@ import * as React from "react";
3import classNames from "classnames"; 3import classNames from "classnames";
4 4
5import { Badge, Col, Row } from "react-bootstrap"; 5import { Badge, Col, Row } from "react-bootstrap";
6import dayjs from "dayjs";
6 7
7interface RequestSummaryProps { 8interface RequestSummaryProps {
8 selected?: boolean; 9 selected?: boolean;
9 requestResponse: RequestResponse; 10 requestResponse: RequestResponse;
11 showTime?: boolean;
10} 12}
11 13
12function isBetween(value: number, min: number, max: number) { 14function isBetween(value: number, min: number, max: number) {
@@ -32,9 +34,22 @@ function calcBadgeVariant(statusCode: number | undefined): string {
32export default function RequestSummary({ 34export default function RequestSummary({
33 requestResponse: { request, response }, 35 requestResponse: { request, response },
34 selected = false, 36 selected = false,
37 showTime = false,
35}: RequestSummaryProps) { 38}: RequestSummaryProps) {
36 return ( 39 return (
37 <Row> 40 <Row>
41 {showTime && (
42 <Col
43 className={classNames(
44 "flex-grow-0 d-flex align-items-center text-nowrap",
45 {
46 "text-muted": !selected,
47 }
48 )}
49 >
50 {dayjs(request.timestamp).format("LTS")}
51 </Col>
52 )}
38 <Col className="flex-grow-0 d-flex align-items-center"> 53 <Col className="flex-grow-0 d-flex align-items-center">
39 {request.method} 54 {request.method}
40 </Col> 55 </Col>
diff --git a/src/hooks/useRequests.tsx b/src/hooks/useRequests.tsx
index feba4fa..1361949 100644
--- a/src/hooks/useRequests.tsx
+++ b/src/hooks/useRequests.tsx
@@ -15,6 +15,7 @@ export type Method =
15 15
16export interface RequestPayload { 16export interface RequestPayload {
17 id: string; 17 id: string;
18 timestamp: string;
18 body: string; 19 body: string;
19 headers: Headers; 20 headers: Headers;
20 method: Method; 21 method: Method;
diff --git a/src/index.tsx b/src/index.tsx
index 83f8970..d83fd38 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -5,6 +5,10 @@ import App from "~/components/App/App";
5import "~/index.scss"; 5import "~/index.scss";
6import DarkModeProvider from "./contexts/DarkMode"; 6import DarkModeProvider from "./contexts/DarkMode";
7 7
8import dayjs from "dayjs";
9import localizedFormat from "dayjs/plugin/localizedFormat";
10dayjs.extend(localizedFormat);
11
8ReactDOM.render( 12ReactDOM.render(
9 <DarkModeProvider> 13 <DarkModeProvider>
10 <App /> 14 <App />
diff --git a/ttun/client.py b/ttun/client.py
index fe51b1a..671ac59 100644
--- a/ttun/client.py
+++ b/ttun/client.py
@@ -2,6 +2,7 @@ import asyncio
2import json 2import json
3from base64 import b64decode 3from base64 import b64decode
4from base64 import b64encode 4from base64 import b64encode
5from datetime import datetime
5from time import perf_counter 6from time import perf_counter
6from typing import Awaitable 7from typing import Awaitable
7from typing import Callable 8from typing import Callable
@@ -80,7 +81,14 @@ class Client:
80 async with ClientSession(cookie_jar=DummyCookieJar()) as session: 81 async with ClientSession(cookie_jar=DummyCookieJar()) as session:
81 request_id = uuid4() 82 request_id = uuid4()
82 await PubSub.publish( 83 await PubSub.publish(
83 {"type": "request", "payload": {"id": request_id.hex, **request}} 84 {
85 "type": "request",
86 "payload": {
87 "id": request_id.hex,
88 "timestamp": datetime.now().isoformat(),
89 **request,
90 },
91 }
84 ) 92 )
85 93
86 start = perf_counter() 94 start = perf_counter()
diff --git a/yarn.lock b/yarn.lock
index 371732f..83f0506 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -688,6 +688,11 @@ csstype@^3.0.2:
688 resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.10.tgz#2ad3a7bed70f35b965707c092e5f30b327c290e5" 688 resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.10.tgz#2ad3a7bed70f35b965707c092e5f30b327c290e5"
689 integrity sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA== 689 integrity sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA==
690 690
691dayjs@^1.10.7:
692 version "1.10.7"
693 resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.7.tgz#2cf5f91add28116748440866a0a1d26f3a6ce468"
694 integrity sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==
695
691debug@^4.1.0, debug@^4.1.1: 696debug@^4.1.0, debug@^4.1.1:
692 version "4.3.3" 697 version "4.3.3"
693 resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" 698 resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"