diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/_reset.scss | 48 | ||||
| -rw-r--r-- | src/components/App/App.module.scss | 55 | ||||
| -rw-r--r-- | src/components/App/App.tsx | 68 | ||||
| -rw-r--r-- | src/components/Content/Content.module.scss | 51 | ||||
| -rw-r--r-- | src/components/Content/Content.tsx | 100 | ||||
| -rw-r--r-- | src/components/Details/Details.module.scss | 84 | ||||
| -rw-r--r-- | src/components/Details/Details.tsx | 148 | ||||
| -rw-r--r-- | src/components/RequestSummary/RequestSummary.module.scss | 24 | ||||
| -rw-r--r-- | src/components/RequestSummary/RequestSummary.tsx | 33 | ||||
| -rw-r--r-- | src/hooks/useRequests.tsx | 77 | ||||
| -rw-r--r-- | src/index.scss | 16 | ||||
| -rw-r--r-- | src/index.tsx | 7 | ||||
| -rw-r--r-- | src/utils.ts | 4 |
13 files changed, 715 insertions, 0 deletions
diff --git a/src/_reset.scss b/src/_reset.scss new file mode 100644 index 0000000..ed11813 --- /dev/null +++ b/src/_reset.scss | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* http://meyerweb.com/eric/tools/css/reset/ | ||
| 2 | v2.0 | 20110126 | ||
| 3 | License: none (public domain) | ||
| 4 | */ | ||
| 5 | |||
| 6 | html, body, div, span, applet, object, iframe, | ||
| 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
| 8 | a, abbr, acronym, address, big, cite, code, | ||
| 9 | del, dfn, em, img, ins, kbd, q, s, samp, | ||
| 10 | small, strike, strong, sub, sup, tt, var, | ||
| 11 | b, u, i, center, | ||
| 12 | dl, dt, dd, ol, ul, li, | ||
| 13 | fieldset, form, label, legend, | ||
| 14 | table, caption, tbody, tfoot, thead, tr, th, td, | ||
| 15 | article, aside, canvas, details, embed, | ||
| 16 | figure, figcaption, footer, header, hgroup, | ||
| 17 | menu, nav, output, ruby, section, summary, | ||
| 18 | time, mark, audio, video { | ||
| 19 | margin: 0; | ||
| 20 | padding: 0; | ||
| 21 | border: 0; | ||
| 22 | font-size: 100%; | ||
| 23 | font: inherit; | ||
| 24 | vertical-align: baseline; | ||
| 25 | } | ||
| 26 | /* HTML5 display-role reset for older browsers */ | ||
| 27 | article, aside, details, figcaption, figure, | ||
| 28 | footer, header, hgroup, menu, nav, section { | ||
| 29 | display: block; | ||
| 30 | } | ||
| 31 | body { | ||
| 32 | line-height: 1; | ||
| 33 | } | ||
| 34 | ol, ul { | ||
| 35 | list-style: none; | ||
| 36 | } | ||
| 37 | blockquote, q { | ||
| 38 | quotes: none; | ||
| 39 | } | ||
| 40 | blockquote:before, blockquote:after, | ||
| 41 | q:before, q:after { | ||
| 42 | content: ''; | ||
| 43 | content: none; | ||
| 44 | } | ||
| 45 | table { | ||
| 46 | border-collapse: collapse; | ||
| 47 | border-spacing: 0; | ||
| 48 | } | ||
diff --git a/src/components/App/App.module.scss b/src/components/App/App.module.scss new file mode 100644 index 0000000..2036eb9 --- /dev/null +++ b/src/components/App/App.module.scss | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | .app { | ||
| 2 | display: flex; | ||
| 3 | flex-flow: column nowrap; | ||
| 4 | grid-template-rows: auto 1fr; | ||
| 5 | height: 100vh; | ||
| 6 | overflow: hidden; | ||
| 7 | } | ||
| 8 | |||
| 9 | .main { | ||
| 10 | display: flex; | ||
| 11 | flex-flow: row nowrap; | ||
| 12 | flex-grow: 1; | ||
| 13 | overflow: hidden; | ||
| 14 | } | ||
| 15 | |||
| 16 | .header { | ||
| 17 | font-size: 1.2em; | ||
| 18 | display: flex; | ||
| 19 | flex-flow: row nowrap; | ||
| 20 | align-items: center; | ||
| 21 | justify-content: space-between; | ||
| 22 | background: black; | ||
| 23 | color: white; | ||
| 24 | padding: 1em; | ||
| 25 | |||
| 26 | a { | ||
| 27 | color: white; | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | .sidebar { | ||
| 32 | width: calc((6 / 16) * 100%); | ||
| 33 | height: 100%; | ||
| 34 | grid-area: sidebar; | ||
| 35 | border-right: 1px solid black; | ||
| 36 | overflow-y: auto; | ||
| 37 | |||
| 38 | li { | ||
| 39 | border-bottom: 1px solid gray; | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | .details { | ||
| 44 | width: calc((10 / 16) * 100%); | ||
| 45 | overflow: hidden; | ||
| 46 | height: 100%; | ||
| 47 | } | ||
| 48 | |||
| 49 | .noRequest, .noRequestSelected { | ||
| 50 | width: 100%; | ||
| 51 | height: 100%; | ||
| 52 | display: flex; | ||
| 53 | justify-content: center; | ||
| 54 | align-items: center; | ||
| 55 | } | ||
diff --git a/src/components/App/App.tsx b/src/components/App/App.tsx new file mode 100644 index 0000000..3a7fe9b --- /dev/null +++ b/src/components/App/App.tsx | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | import * as React from "react"; | ||
| 2 | import useRequests, {RequestResponse} from "../../hooks/useRequests"; | ||
| 3 | import {useEffect, useMemo, useState} from "react"; | ||
| 4 | |||
| 5 | import styles from './App.module.scss'; | ||
| 6 | import Details from "../Details/Details"; | ||
| 7 | import RequestSummary from "../RequestSummary/RequestSummary"; | ||
| 8 | import {getHost} from "../../utils"; | ||
| 9 | |||
| 10 | interface Config { | ||
| 11 | url: string | ||
| 12 | } | ||
| 13 | |||
| 14 | export default function App() { | ||
| 15 | const [config, setConfig]= useState<Config | null>(null) | ||
| 16 | useEffect(() => { | ||
| 17 | fetch(`http://${getHost()}/config/`) | ||
| 18 | .then(response => response.json() as Promise<Config>) | ||
| 19 | .then(setConfig) | ||
| 20 | }, []) | ||
| 21 | |||
| 22 | const requests = useRequests(); | ||
| 23 | const [selectedRequestIndex, setSelectedRequestIndex] = useState<number | null>(null); | ||
| 24 | const selectedRequest = useMemo<RequestResponse | null>(() => ( | ||
| 25 | selectedRequestIndex === null | ||
| 26 | ? null | ||
| 27 | : requests[selectedRequestIndex] | ||
| 28 | ), [selectedRequestIndex, requests]); | ||
| 29 | |||
| 30 | return config && ( | ||
| 31 | <div className={styles.app}> | ||
| 32 | <header className={styles.header}> | ||
| 33 | TTUN | ||
| 34 | <a href={config.url} target="_blank">{config.url}</a> | ||
| 35 | </header> | ||
| 36 | <main className={styles.main}> | ||
| 37 | <ul className={styles.sidebar}> | ||
| 38 | { | ||
| 39 | requests.length > 0 | ||
| 40 | ? requests.slice(0).reverse().map((requestResponse, index) => ( | ||
| 41 | <li onClick={() => setSelectedRequestIndex(requests.length - index - 1)} key={`request-${index}`}> | ||
| 42 | <RequestSummary requestResponse={requestResponse} /> | ||
| 43 | </li> | ||
| 44 | )) | ||
| 45 | : ( | ||
| 46 | <div className={styles.noRequest}> | ||
| 47 | <p>No requests</p> | ||
| 48 | </div> | ||
| 49 | ) | ||
| 50 | } | ||
| 51 | </ul> | ||
| 52 | |||
| 53 | <div className={styles.details}> | ||
| 54 | { | ||
| 55 | selectedRequest !== null | ||
| 56 | ? ( | ||
| 57 | <Details requestResponse={selectedRequest} /> | ||
| 58 | ) : ( | ||
| 59 | <div className={styles.noRequestSelected}> | ||
| 60 | <p>Select a request to inspect it</p> | ||
| 61 | </div> | ||
| 62 | ) | ||
| 63 | } | ||
| 64 | </div> | ||
| 65 | </main> | ||
| 66 | </div> | ||
| 67 | ); | ||
| 68 | } | ||
diff --git a/src/components/Content/Content.module.scss b/src/components/Content/Content.module.scss new file mode 100644 index 0000000..8908516 --- /dev/null +++ b/src/components/Content/Content.module.scss | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | .content { | ||
| 2 | width: 100%; | ||
| 3 | height: 100%; | ||
| 4 | display: flex; | ||
| 5 | flex-flow: column nowrap; | ||
| 6 | overflow: hidden; | ||
| 7 | } | ||
| 8 | |||
| 9 | .header { | ||
| 10 | flex-shrink: 0; | ||
| 11 | flex-grow: 0; | ||
| 12 | width: 100%; | ||
| 13 | display: flex; | ||
| 14 | padding: 0.5em; | ||
| 15 | background-color: black; | ||
| 16 | color: white; | ||
| 17 | } | ||
| 18 | |||
| 19 | .body { | ||
| 20 | flex-grow: 1; | ||
| 21 | flex-shrink: 1; | ||
| 22 | overflow-y: auto; | ||
| 23 | |||
| 24 | pre { | ||
| 25 | width: 100%; | ||
| 26 | height: 100%; | ||
| 27 | padding: 1em; | ||
| 28 | font-family: monospace; | ||
| 29 | overflow: auto; | ||
| 30 | } | ||
| 31 | |||
| 32 | iframe { | ||
| 33 | height: 100%; | ||
| 34 | width: 100%; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | .renderError { | ||
| 39 | width: 100%; | ||
| 40 | height: 100%; | ||
| 41 | display: flex; | ||
| 42 | flex-flow: column nowrap; | ||
| 43 | justify-content: center; | ||
| 44 | align-items: center; | ||
| 45 | |||
| 46 | a { | ||
| 47 | margin-top: 1em; | ||
| 48 | text-decoration: underline; | ||
| 49 | color: blue; | ||
| 50 | } | ||
