From 2a7a5fa0f9659ea20f7b2826b1b1757860066af3 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Wed, 21 Jun 2023 14:29:20 +0100 Subject: [PATCH] Components to show cookie and header results --- src/components/Results/Cookies.tsx | 31 ++++++++++++++++ src/components/Results/Headers.tsx | 51 +++++++++++++++++++++++++++ src/components/Results/Lighthouse.tsx | 2 -- src/components/Results/Screenshot.tsx | 1 - src/components/Results/ServerInfo.tsx | 40 ++++++--------------- 5 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 src/components/Results/Cookies.tsx create mode 100644 src/components/Results/Headers.tsx diff --git a/src/components/Results/Cookies.tsx b/src/components/Results/Cookies.tsx new file mode 100644 index 0000000..d910289 --- /dev/null +++ b/src/components/Results/Cookies.tsx @@ -0,0 +1,31 @@ + +import styled from 'styled-components'; +import colors from 'styles/colors'; +import Card from 'components/Form/Card'; +import Heading from 'components/Form/Heading'; +import Row, { ExpandableRow } from 'components/Form/Row'; + +const Outer = styled(Card)``; + +const CookiesCard = (props: { cookies: any }): JSX.Element => { + const cookies = props.cookies; + console.log('COOKIES: ', cookies); + return ( + + Cookies + {/* { subject && } */} + { + cookies.map((cookie: any, index: number) => { + const attributes = Object.keys(cookie.attributes).map((key: string) => { + return { lbl: key, val: cookie.attributes[key] } + }); + return ( + + ) + }) + } + + ); +} + +export default CookiesCard; diff --git a/src/components/Results/Headers.tsx b/src/components/Results/Headers.tsx new file mode 100644 index 0000000..38c6511 --- /dev/null +++ b/src/components/Results/Headers.tsx @@ -0,0 +1,51 @@ + +import styled from 'styled-components'; +import colors from 'styles/colors'; +import Card from 'components/Form/Card'; +import Heading from 'components/Form/Heading'; + +const Outer = styled(Card)` + grid-row: span 2; +`; + +const Row = styled.div` + display: flex; + justify-content: space-between; + padding: 0.25rem; + &:not(:last-child) { border-bottom: 1px solid ${colors.primary}; } + span.lbl { font-weight: bold; } + span.val { + max-width: 200px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } +`; + +const DataRow = (props: { lbl: string, val: string }) => { + const { lbl, val } = props; + return ( + + {lbl} + {val} + + ); +}; + +const HeadersCard = (props: { headers: any }): JSX.Element => { + const headers = props.headers; + return ( + + Headers + { + Object.keys(headers).map((header: string, index: number) => { + return ( + + ) + }) + } + + ); +} + +export default HeadersCard; diff --git a/src/components/Results/Lighthouse.tsx b/src/components/Results/Lighthouse.tsx index 7e78626..733cef4 100644 --- a/src/components/Results/Lighthouse.tsx +++ b/src/components/Results/Lighthouse.tsx @@ -60,7 +60,6 @@ interface Audit { const ScoreItem = (props: { scoreId: any, audits: Audit[] }) => { const { scoreId, audits } = props; - console.log('Audits: ', props.audits) const audit = audits[scoreId]; if (!audit.score) return null; @@ -99,7 +98,6 @@ const ExpandableRow = (props: { lbl: string, val: string, list: string[], audits }; const LighthouseCard = (props: { lighthouse: any }): JSX.Element => { - console.log('Props:', props.lighthouse); const categories = props.lighthouse?.categories || {}; const audits = props.lighthouse?.audits || []; diff --git a/src/components/Results/Screenshot.tsx b/src/components/Results/Screenshot.tsx index ff21812..a84b88e 100644 --- a/src/components/Results/Screenshot.tsx +++ b/src/components/Results/Screenshot.tsx @@ -10,7 +10,6 @@ max-height: 20rem; `; const ScreenshotCard = (props: { screenshot: string }): JSX.Element => { - console.log('Props:', props.screenshot); return ( Screenshot diff --git a/src/components/Results/ServerInfo.tsx b/src/components/Results/ServerInfo.tsx index ddac52e..ccb16a2 100644 --- a/src/components/Results/ServerInfo.tsx +++ b/src/components/Results/ServerInfo.tsx @@ -4,43 +4,23 @@ import { ServerInfo } from 'utils/result-processor'; import colors from 'styles/colors'; import Card from 'components/Form/Card'; import Heading from 'components/Form/Heading'; +import Row from 'components/Form/Row'; const Outer = styled(Card)``; -const Row = styled.div` - display: flex; - justify-content: space-between; - padding: 0.25rem; - &:not(:last-child) { border-bottom: 1px solid ${colors.primary}; } - span.lbl { font-weight: bold; } - span.val { - max-width: 200px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } -`; - -const DataRow = (props: { lbl: string, val: string }) => { - const { lbl, val } = props; - return ( - - {lbl} - {val} - - ); -}; - const ServerInfoCard = (info: ServerInfo): JSX.Element => { - const { org, asn, isp, os, ports } = info; + const { org, asn, isp, os, ports, ip, loc, type } = info; return ( Server Info - { org && } - { (isp && isp !== org) && } - { os && } - { asn && } - { ports && } + { org && } + { (isp && isp !== org) && } + { os && } + { asn && } + { ports && } + { ip && } + { type && } + { loc && } ); }