Re-structured result components to use re-usable card

This commit is contained in:
Alicia Sykes 2023-07-05 01:46:59 +01:00
parent a6ecbd3406
commit fd7feada3a
17 changed files with 171 additions and 203 deletions

View File

@ -23,16 +23,6 @@ const Row = styled.div`
} }
`; `;
const DataRow = (props: { lbl: string, val: string }) => {
const { lbl, val } = props;
return (
<Row>
<span className="lbl">{lbl}</span>
<span className="val" title={val}>{val}</span>
</Row>
);
};
const ListRow = (props: { list: Technology[], title: string }) => { const ListRow = (props: { list: Technology[], title: string }) => {
const { list, title } = props; const { list, title } = props;
return ( return (
@ -44,15 +34,15 @@ const ListRow = (props: { list: Technology[], title: string }) => {
)} )}
)} )}
</> </>
); );
} }
const BuiltWithCard = (technologies: TechnologyGroup[]): JSX.Element => { const BuiltWithCard = (props: { data: TechnologyGroup[]}): JSX.Element => {
// const { created, updated, expires, nameservers } = whois; // const { created, updated, expires, nameservers } = whois;
return ( return (
<Outer> <Outer>
<Heading as="h3" align="left" color={colors.primary}>Technologies</Heading> <Heading as="h3" align="left" color={colors.primary}>Technologies</Heading>
{ technologies.map((group: TechnologyGroup) => { { props.data.map((group: TechnologyGroup) => {
return ( return (
<ListRow key={group.tag} title={group.tag} list={group.technologies} /> <ListRow key={group.tag} title={group.tag} list={group.technologies} />
); );

View File

@ -1,21 +1,13 @@
import { Card } from 'components/Form/Card';
import styled from 'styled-components';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import { ExpandableRow } from 'components/Form/Row'; import { ExpandableRow } from 'components/Form/Row';
const Outer = styled(Card)``; const CookiesCard = (props: { data: any, title: string, actionButtons: any}): JSX.Element => {
const cookies = props.data.cookies;
const CookiesCard = (cookies: { cookies: any }): JSX.Element => {
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>Cookies</Heading> { cookies.length === 0 && <p>No cookies found.</p> }
{ {
cookies.cookies.length === 0 && <p>No cookies found.</p> cookies.map((cookie: any, index: number) => {
}
{
cookies.cookies.map((cookie: any, index: number) => {
const attributes = Object.keys(cookie.attributes).map((key: string) => { const attributes = Object.keys(cookie.attributes).map((key: string) => {
return { lbl: key, val: cookie.attributes[key] } return { lbl: key, val: cookie.attributes[key] }
}); });
@ -24,7 +16,7 @@ const CookiesCard = (cookies: { cookies: any }): JSX.Element => {
) )
}) })
} }
</Outer> </Card>
); );
} }

View File

@ -1,21 +1,17 @@
import { Card } from 'components/Form/Card';
import styled from 'styled-components';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row, { ListRow } from 'components/Form/Row'; import Row, { ListRow } from 'components/Form/Row';
const Outer = styled(Card)` const styles = `
.content { .content {
max-height: 28rem; max-height: 28rem;
overflow-y: auto; overflow-y: auto;
} }
`; `;
const DnsRecordsCard = (dnsRecords: any): JSX.Element => { const DnsRecordsCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const dnsRecords = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={styles}>
<Heading as="h3" align="left" color={colors.primary}>DNS Records</Heading>
<div className="content"> <div className="content">
{ dnsRecords.A && <Row lbl="A" val={dnsRecords.A.address} /> } { dnsRecords.A && <Row lbl="A" val={dnsRecords.A.address} /> }
{ dnsRecords.AAAA?.length > 0 && <ListRow title="AAAA" list={dnsRecords.AAAA} /> } { dnsRecords.AAAA?.length > 0 && <ListRow title="AAAA" list={dnsRecords.AAAA} /> }
@ -25,9 +21,8 @@ const DnsRecordsCard = (dnsRecords: any): JSX.Element => {
{ dnsRecords.PTR?.length > 0 && <ListRow title="PTR" list={dnsRecords.PTR} /> } { dnsRecords.PTR?.length > 0 && <ListRow title="PTR" list={dnsRecords.PTR} /> }
{ dnsRecords.SOA?.length > 0 && <ListRow title="SOA" list={dnsRecords.SOA} /> } { dnsRecords.SOA?.length > 0 && <ListRow title="SOA" list={dnsRecords.SOA} /> }
</div> </div>
</Outer> </Card>
); );
} }
export default DnsRecordsCard; export default DnsRecordsCard;

View File

@ -1,18 +1,11 @@
import { Card } from 'components/Form/Card';
import styled from 'styled-components';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row'; import Row from 'components/Form/Row';
import { ReactNode } from 'react';
const Outer = styled(Card)` const HeadersCard = (props: { data: any, title: string, actionButtons: ReactNode }): JSX.Element => {
grid-row: span 2; const headers = props.data;
`;
const HeadersCard = (headers: any): JSX.Element => {
return ( return (
<Outer> <Card heading={props.title} styles="grid-row: span 2;" actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>Headers</Heading>
{ {
Object.keys(headers).map((header: string, index: number) => { Object.keys(headers).map((header: string, index: number) => {
return ( return (
@ -20,7 +13,7 @@ const HeadersCard = (headers: any): JSX.Element => {
) )
}) })
} }
</Outer> </Card>
); );
} }

View File

@ -2,14 +2,9 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { HostNames } from 'utils/result-processor'; import { HostNames } from 'utils/result-processor';
import colors from 'styles/colors'; import colors from 'styles/colors';
import Card from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Heading from 'components/Form/Heading'; import Heading from 'components/Form/Heading';
const Outer = styled(Card)`
max-height: 28rem;
overflow: auto;
`;
const Row = styled.div` const Row = styled.div`
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -22,7 +17,7 @@ const HostListSection = (props: { list: string[], title: string }) => {
const { list, title } = props; const { list, title } = props;
return ( return (
<> <>
<Heading as="h3" align="left" color={colors.primary}>{title}</Heading> <Heading as="h4" size="small" align="left" color={colors.primary}>{title}</Heading>
{ list.map((entry: string, index: number) => { { list.map((entry: string, index: number) => {
return ( return (
<Row key={`${title.toLocaleLowerCase()}-${index}`}><span>{ entry }</span></Row> <Row key={`${title.toLocaleLowerCase()}-${index}`}><span>{ entry }</span></Row>
@ -32,16 +27,22 @@ const HostListSection = (props: { list: string[], title: string }) => {
); );
} }
const HostNamesCard = (hosts: HostNames): JSX.Element => { const cardStyles = `
max-height: 28rem;
overflow: auto;
`;
const HostNamesCard = (props: { data: HostNames, title: string, actionButtons: any }): JSX.Element => {
const hosts = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
{ hosts.domains.length > 0 && { hosts.domains.length > 0 &&
<HostListSection list={hosts.domains} title="Domain Names" /> <HostListSection list={hosts.domains} title="Domains" />
} }
{ hosts.hostnames.length > 0 && { hosts.hostnames.length > 0 &&
<HostListSection list={hosts.hostnames} title="Hostnames" /> <HostListSection list={hosts.hostnames} title="Hosts" />
} }
</Outer> </Card>
); );
} }

View File

@ -1,17 +1,10 @@
import { Card } from 'components/Form/Card';
import styled from 'styled-components';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import { ExpandableRow } from 'components/Form/Row'; import { ExpandableRow } from 'components/Form/Row';
const processScore = (percentile: number) => { const processScore = (percentile: number) => {
return `${Math.round(percentile * 100)}%`; return `${Math.round(percentile * 100)}%`;
} }
const Outer = styled(Card)``;
interface Audit { interface Audit {
id: string, id: string,
score?: number | string, score?: number | string,
@ -31,13 +24,13 @@ const makeValue = (audit: Audit) => {
return score; return score;
}; };
const LighthouseCard = (lighthouse: any): JSX.Element => { const LighthouseCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const lighthouse = props.data;
const categories = lighthouse?.categories || {}; const categories = lighthouse?.categories || {};
const audits = lighthouse?.audits || []; const audits = lighthouse?.audits || [];
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>Performance</Heading>
{ Object.keys(categories).map((title: string, index: number) => { { Object.keys(categories).map((title: string, index: number) => {
const scoreIds = categories[title].auditRefs.map((ref: { id: string }) => ref.id); const scoreIds = categories[title].auditRefs.map((ref: { id: string }) => ref.id);
const scoreList = scoreIds.map((id: string) => { const scoreList = scoreIds.map((id: string) => {
@ -52,7 +45,7 @@ const LighthouseCard = (lighthouse: any): JSX.Element => {
/> />
); );
}) } }) }
</Outer> </Card>
); );
} }

View File

@ -1,23 +1,14 @@
import { Card } from 'components/Form/Card';
import styled from 'styled-components';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row'; import Row from 'components/Form/Row';
const Outer = styled(Card)` const cardStyles = `
small { margin-top: 1rem; opacity: 0.5; }
small {
margin-top: 1rem;
opacity: 0.5;
}
`; `;
const OpenPortsCard = (portData: any): JSX.Element => { const OpenPortsCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const portData = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>Open Ports</Heading>
{portData.openPorts.map((port: any) => ( {portData.openPorts.map((port: any) => (
<Row key={port} lbl="" val=""> <Row key={port} lbl="" val="">
<span>{port}</span> <span>{port}</span>
@ -29,7 +20,7 @@ const OpenPortsCard = (portData: any): JSX.Element => {
Unable to establish connections to:<br /> Unable to establish connections to:<br />
{portData.failedPorts.join(', ')} {portData.failedPorts.join(', ')}
</small> </small>
</Outer> </Card>
); );
} }

View File

@ -1,11 +1,8 @@
import styled from 'styled-components';
import colors from 'styles/colors'; import colors from 'styles/colors';
import Card from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row'; import Row from 'components/Form/Row';
const Outer = styled(Card)` const cardStyles = `
div { div {
justify-content: flex-start; justify-content: flex-start;
align-items: baseline; align-items: baseline;
@ -16,13 +13,21 @@ const Outer = styled(Card)`
font-weight: bold; font-weight: bold;
margin-right: 0.5rem; margin-right: 0.5rem;
} }
.redirect-count {
color: ${colors.textColorSecondary};
margin: 0;
}
`; `;
const RedirectsCard = (redirects: any): JSX.Element => { const RedirectsCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const redirects = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>Redirects</Heading>
{ !redirects?.redirects.length && <Row lbl="" val="No redirects" />} { !redirects?.redirects.length && <Row lbl="" val="No redirects" />}
<p className="redirect-count">
Followed {redirects.redirects.length}{' '}
redirect{redirects.redirects.length === 1 ? '' : 's'} when contacting host
</p>
{redirects.redirects.map((redirect: any, index: number) => { {redirects.redirects.map((redirect: any, index: number) => {
return ( return (
<Row lbl="" val="" key={index}> <Row lbl="" val="" key={index}>
@ -30,7 +35,7 @@ const RedirectsCard = (redirects: any): JSX.Element => {
</Row> </Row>
); );
})} })}
</Outer> </Card>
); );
} }

View File

@ -1,21 +1,18 @@
import styled from 'styled-components'; import { Card } from 'components/Form/Card';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row, { RowProps } from 'components/Form/Row'; import Row, { RowProps } from 'components/Form/Row';
const Outer = styled(Card)` const cardStyles = `
.content { .content {
max-height: 28rem; max-height: 28rem;
overflow-y: auto; overflow-y: auto;
} }
`; `;
const RobotsTxtCard = ( robots: { robots: RowProps[]}): JSX.Element => { const RobotsTxtCard = ( props: { data: { robots: RowProps[]}, title: string, actionButtons: any}): JSX.Element => {
const robots = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>Crawl Rules</Heading>
<div className="content"> <div className="content">
{ {
robots.robots.length === 0 && <p>No crawl rules found.</p> robots.robots.length === 0 && <p>No crawl rules found.</p>
@ -28,7 +25,7 @@ const RobotsTxtCard = ( robots: { robots: RowProps[]}): JSX.Element => {
}) })
} }
</div> </div>
</Outer> </Card>
); );
} }

View File

@ -1,25 +1,21 @@
import { Card } from 'components/Form/Card';
import styled from 'styled-components'; const cardStyles = `
import colors from 'styles/colors'; overflow: auto;
import Card from 'components/Form/Card'; max-height: 32rem;
import Heading from 'components/Form/Heading'; img {
const Outer = styled(Card)`
overflow: auto;
max-height: 28rem;
img {
border-radius: 6px; border-radius: 6px;
width: 100%; width: 100%;
margin 0.5rem 0;; margin 0.5rem 0;;
} }
`; `;
const ScreenshotCard = (screenshot: { data: string }): JSX.Element => { const ScreenshotCard = (props: { data: { data: string }, title: string, actionButtons: any }): JSX.Element => {
const screenshot = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>Screenshot</Heading>
<img src={screenshot.data} alt="Full page screenshot" /> <img src={screenshot.data} alt="Full page screenshot" />
</Outer> </Card>
); );
} }

View File

@ -1,18 +1,12 @@
import styled from 'styled-components';
import { ServerInfo } from 'utils/result-processor'; import { ServerInfo } from 'utils/result-processor';
import colors from 'styles/colors'; import { Card } from 'components/Form/Card';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row'; import Row from 'components/Form/Row';
const Outer = styled(Card)``; const ServerInfoCard = (props: { data: ServerInfo, title: string, actionButtons: any }): JSX.Element => {
const info = props.data;
const ServerInfoCard = (info: ServerInfo): JSX.Element => {
const { org, asn, isp, os, ports, ip, loc, type } = info; const { org, asn, isp, os, ports, ip, loc, type } = info;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>Server Info</Heading>
{ org && <Row lbl="Organization" val={org} /> } { org && <Row lbl="Organization" val={org} /> }
{ (isp && isp !== org) && <Row lbl="Service Provider" val={isp} /> } { (isp && isp !== org) && <Row lbl="Service Provider" val={isp} /> }
{ os && <Row lbl="Operating System" val={os} /> } { os && <Row lbl="Operating System" val={os} /> }
@ -21,7 +15,7 @@ const ServerInfoCard = (info: ServerInfo): JSX.Element => {
{ ip && <Row lbl="IP" val={ip} /> } { ip && <Row lbl="IP" val={ip} /> }
{ type && <Row lbl="Type" val={type} /> } { type && <Row lbl="Type" val={type} /> }
{ loc && <Row lbl="Location" val={loc} /> } { loc && <Row lbl="Location" val={loc} /> }
</Outer> </Card>
); );
} }

View File

@ -1,17 +1,13 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { ServerLocation } from 'utils/result-processor'; import { ServerLocation } from 'utils/result-processor';
import colors from 'styles/colors'; import { Card } from 'components/Form/Card';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import LocationMap from 'components/misc/LocationMap'; import LocationMap from 'components/misc/LocationMap';
import Flag from 'components/misc/Flag'; import Flag from 'components/misc/Flag';
import { TextSizes } from 'styles/typography'; import { TextSizes } from 'styles/typography';
import Row, { StyledRow } from 'components/Form/Row'; import Row, { StyledRow } from 'components/Form/Row';
const Outer = styled(Card)` const cardStyles = 'grid-row: span 2';
grid-row: span 2
`;
const SmallText = styled.span` const SmallText = styled.span`
opacity: 0.5; opacity: 0.5;
@ -30,8 +26,8 @@ const CountryValue = styled.span`
gap: 0.5rem; gap: 0.5rem;
`; `;
const ServerLocationCard = (location: ServerLocation): JSX.Element => { const ServerLocationCard = (props: { data: ServerLocation, title: string, actionButtons: any }): JSX.Element => {
const location = props.data;
const { const {
city, region, country, city, region, country,
postCode, countryCode, coords, postCode, countryCode, coords,
@ -39,8 +35,7 @@ const ServerLocationCard = (location: ServerLocation): JSX.Element => {
} = location; } = location;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>Location</Heading>
<Row lbl="City" val={`${postCode}, ${city}, ${region}`} /> <Row lbl="City" val={`${postCode}, ${city}, ${region}`} />
<Row lbl="" val=""> <Row lbl="" val="">
<b>Country</b> <b>Country</b>
@ -56,7 +51,7 @@ const ServerLocationCard = (location: ServerLocation): JSX.Element => {
<LocationMap lat={coords.latitude} lon={coords.longitude} label={`Server (${isp})`} /> <LocationMap lat={coords.latitude} lon={coords.longitude} label={`Server (${isp})`} />
<SmallText>Latitude: {coords.latitude}, Longitude: {coords.longitude} </SmallText> <SmallText>Latitude: {coords.latitude}, Longitude: {coords.longitude} </SmallText>
</MapRow> </MapRow>
</Outer> </Card>
); );
} }

View File

@ -1,28 +1,26 @@
import styled from 'styled-components';
import colors from 'styles/colors'; import colors from 'styles/colors';
import Card from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row'; import Row from 'components/Form/Row';
const Outer = styled(Card)` const cardStyles = `
span.val { span.val {
&.up { color: ${colors.success}; } &.up { color: ${colors.success}; }
&.down { color: ${colors.danger}; } &.down { color: ${colors.danger}; }
} }
`; `;
const ServerStatusCard = (serverStatus: any): JSX.Element => { const ServerStatusCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const serverStatus = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>Server Status</Heading>
<Row lbl="" val=""> <Row lbl="" val="">
<span className="lbl">Is Up?</span> <span className="lbl">Is Up?</span>
{ serverStatus.isUp ? <span className="val up"> Online</span> : <span className="val down"> Offline</span>} { serverStatus.isUp ? <span className="val up"> Online</span> : <span className="val down"> Offline</span>}
</Row> </Row>
<Row lbl="Status Code" val={serverStatus.responseCode} /> <Row lbl="Status Code" val={serverStatus.responseCode} />
{ serverStatus.responseTime && <Row lbl="Response Time" val={`${Math.round(serverStatus.responseTime)}ms`} /> } { serverStatus.responseTime && <Row lbl="Response Time" val={`${Math.round(serverStatus.responseTime)}ms`} /> }
</Outer> </Card>
); );
} }

View File

@ -1,11 +1,9 @@
import styled from 'styled-components'; import styled from 'styled-components';
import colors from 'styles/colors'; import colors from 'styles/colors';
import Card from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Heading from 'components/Form/Heading'; import Heading from 'components/Form/Heading';
const Outer = styled(Card)``;
const Row = styled.div` const Row = styled.div`
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -79,14 +77,13 @@ const ListRow = (props: { list: string[], title: string }) => {
); );
} }
const SslCertCard = (sslCert: any): JSX.Element => { const SslCertCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const sslCert = props.data;
const { subject, issuer, fingerprint, serialNumber, asn1Curve, nistCurve, valid_to, valid_from, ext_key_usage } = sslCert; const { subject, issuer, fingerprint, serialNumber, asn1Curve, nistCurve, valid_to, valid_from, ext_key_usage } = sslCert;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>SSL Info</Heading>
{ subject && <DataRow lbl="Subject" val={subject?.CN} /> } { subject && <DataRow lbl="Subject" val={subject?.CN} /> }
{ issuer?.O && <DataRow lbl="Issuer" val={issuer.O} /> } { issuer?.O && <DataRow lbl="Issuer" val={issuer.O} /> }
{ asn1Curve && <DataRow lbl="ASN1 Curve" val={asn1Curve} /> } { asn1Curve && <DataRow lbl="ASN1 Curve" val={asn1Curve} /> }
{ nistCurve && <DataRow lbl="NIST Curve" val={nistCurve} /> } { nistCurve && <DataRow lbl="NIST Curve" val={nistCurve} /> }
{ valid_to && <DataRow lbl="Expires" val={formatDate(valid_to)} /> } { valid_to && <DataRow lbl="Expires" val={formatDate(valid_to)} /> }
@ -96,7 +93,7 @@ const SslCertCard = (sslCert: any): JSX.Element => {
{ fingerprint && <DataRow lbl="Fingerprint" val={fingerprint} /> } { fingerprint && <DataRow lbl="Fingerprint" val={fingerprint} /> }
{ ext_key_usage && <ListRow title="Extended Key Usage" list={getExtendedKeyUsage(ext_key_usage)} /> } { ext_key_usage && <ListRow title="Extended Key Usage" list={getExtendedKeyUsage(ext_key_usage)} /> }
</Outer> </Card>
); );
} }

View File

@ -1,27 +1,63 @@
import styled from 'styled-components'; import styled from 'styled-components';
import colors from 'styles/colors'; import colors from 'styles/colors';
import Card from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Heading from 'components/Form/Heading'; import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row';
const Outer = styled(Card)``; const RouteRow = styled.div`
text-align: center;
width: fit-content;
margin: 0 auto;
.ipName {
font-size: 1rem;
}
`;
const TraceRouteCard = (traceRouteResponse: any): JSX.Element => { const RouteTimings = styled.div`
console.log(traceRouteResponse.result); p {
margin: 0 auto;
}
.arrow {
font-size: 2.5rem;
color: ${colors.primary};
margin-top: -1rem;
}
.times {
font-size: 0.85rem;
color: ${colors.textColorSecondary};
}
.completed {
text-align: center;
font-weight: bold;
}
`;
const TraceRouteCard = (props: { data: any, title: string, actionButtons: any }): JSX.Element => {
const traceRouteResponse = props.data;
const routes = traceRouteResponse.result; const routes = traceRouteResponse.result;
console.log(Object.keys(routes));
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>Trace Route</Heading> {routes.filter((x: any) => x).map((route: any, index: number) => (
{routes.map((route: any) => ( <RouteRow key={index}>
<Row lbl="" val="">
{/* <span>{route}</span> */} {/* <span>{route}</span> */}
<span>{Object.keys(route)[0]}</span> <span className="ipName">{Object.keys(route)[0]}</span>
</Row> <RouteTimings>
{route[Object.keys(route)[0]].map((time: any, packetIndex: number) => (
<p className="times" key={`timing-${packetIndex}-${time}`}>
{ route[Object.keys(route)[0]].length > 1 && (<>Packet #{packetIndex + 1}:</>) }
Took {time} ms
</p>
))}
<p className="arrow"></p>
</RouteTimings>
</RouteRow>
) )
)} )}
</Outer> <RouteTimings>
<p className="completed">
Round trip completed in {traceRouteResponse.timeTaken} ms
</p>
</RouteTimings>
</Card>
); );
} }

View File

@ -1,23 +1,20 @@
import styled from 'styled-components'; import { Card } from 'components/Form/Card';
import colors from 'styles/colors';
import Card from 'components/Form/Card';
import Heading from 'components/Form/Heading';
import Row from 'components/Form/Row'; import Row from 'components/Form/Row';
const Outer = styled(Card)``; const cardStyles = '';
const TxtRecordCard = (records: any): JSX.Element => { const TxtRecordCard = (props: {data: any, title: string, actionButtons: any }): JSX.Element => {
const records = props.data;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
<Heading as="h3" align="left" color={colors.primary}>TXT Config</Heading>
{ !records && <Row lbl="" val="No TXT Records" />} { !records && <Row lbl="" val="No TXT Records" />}
{Object.keys(records).map((recordName: any, index: number) => { {Object.keys(records).map((recordName: any, index: number) => {
return ( return (
<Row lbl={recordName} val={records[recordName]} key={`${recordName}-${index}`} /> <Row lbl={recordName} val={records[recordName]} key={`${recordName}-${index}`} />
); );
})} })}
</Outer> </Card>
); );
} }

View File

@ -2,11 +2,9 @@
import styled from 'styled-components'; import styled from 'styled-components';
import { Whois } from 'utils/result-processor'; import { Whois } from 'utils/result-processor';
import colors from 'styles/colors'; import colors from 'styles/colors';
import Card from 'components/Form/Card'; import { Card } from 'components/Form/Card';
import Heading from 'components/Form/Heading'; import Heading from 'components/Form/Heading';
const Outer = styled(Card)``;
const Row = styled.div` const Row = styled.div`
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -55,17 +53,17 @@ const ListRow = (props: { list: string[], title: string }) => {
); );
} }
const ServerInfoCard = (whois: Whois): JSX.Element => { const WhoIsCard = (props: { data: Whois, title: string, actionButtons: any }): JSX.Element => {
const whois = props.data;
const { created, updated, expires, nameservers } = whois; const { created, updated, expires, nameservers } = whois;
return ( return (
<Outer> <Card heading={props.title} actionButtons={props.actionButtons}>
<Heading as="h3" align="left" color={colors.primary}>Who Is Info</Heading>
{ created && <DataRow lbl="Created" val={formatDate(created)} /> } { created && <DataRow lbl="Created" val={formatDate(created)} /> }
{ updated && <DataRow lbl="Updated" val={formatDate(updated)} /> } { updated && <DataRow lbl="Updated" val={formatDate(updated)} /> }
{ expires && <DataRow lbl="Expires" val={formatDate(expires)} /> } { expires && <DataRow lbl="Expires" val={formatDate(expires)} /> }
{ nameservers && <ListRow title="Name Servers" list={nameservers} /> } { nameservers && <ListRow title="Name Servers" list={nameservers} /> }
</Outer> </Card>
); );
} }
export default ServerInfoCard; export default WhoIsCard;