mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 10:15:41 +00:00
feat: add registrar in diagram
This commit is contained in:
parent
aa1d9818e6
commit
c8953078ad
@ -14,11 +14,11 @@ export function DomainDiagram({domain}: { domain: Domain }) {
|
||||
useEffect(() => {
|
||||
const e = getLayoutedElements([
|
||||
domainToNode(domain),
|
||||
...domainEntitiesToNode(domain),
|
||||
...domainEntitiesToNode(domain, true),
|
||||
tldToNode(domain.tld),
|
||||
...domain.nameservers.map(nsToNode)
|
||||
].flat(), [
|
||||
domainEntitiesToEdges(domain),
|
||||
domainEntitiesToEdges(domain, true),
|
||||
tldToEdge(domain),
|
||||
...domainNSToEdges(domain)
|
||||
].flat())
|
||||
@ -30,7 +30,7 @@ export function DomainDiagram({domain}: { domain: Domain }) {
|
||||
return <Flex style={{width: '80vw', height: '80vh'}}>
|
||||
<ReactFlow
|
||||
fitView
|
||||
colorMode='system'
|
||||
colorMode='dark'
|
||||
nodesConnectable={false}
|
||||
edgesReconnectable={false}
|
||||
nodes={nodes}
|
||||
|
||||
@ -4,16 +4,17 @@ import {t} from "ttag";
|
||||
|
||||
const rolesToColor = (roles: string[]) => roles.includes('registrant') ? 'green' :
|
||||
roles.includes('administrative') ? 'blue' :
|
||||
roles.includes('technical') ? 'orange' : 'violet'
|
||||
roles.includes('technical') ? 'orange' :
|
||||
roles.includes('registrar') ? 'violet' : 'white'
|
||||
|
||||
export function domainEntitiesToEdges(d: Domain) {
|
||||
export function domainEntitiesToEdges(d: Domain, withRegistrar = false) {
|
||||
const domainRole = translateRoles()
|
||||
return d.entities
|
||||
.filter(e => !e.roles.includes('registrar')) //
|
||||
.filter(e => !withRegistrar ? !e.roles.includes('registrar') : true)
|
||||
.map(e => ({
|
||||
id: `e-${d.ldhName}-${e.entity.handle}`,
|
||||
source: e.roles.includes('registrant') ? e.entity.handle : d.ldhName,
|
||||
target: e.roles.includes('registrant') ? d.ldhName : e.entity.handle,
|
||||
source: e.roles.includes('registrant') || e.roles.includes('registrar') ? e.entity.handle : d.ldhName,
|
||||
target: e.roles.includes('registrant') || e.roles.includes('registrar') ? d.ldhName : e.entity.handle,
|
||||
style: {stroke: rolesToColor(e.roles), strokeWidth: 3},
|
||||
label: e.roles
|
||||
.map(r => Object.keys(domainRole).includes(r) ? domainRole[r as keyof typeof domainRole] : r)
|
||||
@ -40,7 +41,7 @@ export const tldToEdge = (d: Domain) => ({
|
||||
})
|
||||
|
||||
export function watchlistToEdges(watchlist: Watchlist) {
|
||||
const entitiesEdges = watchlist.domains.map(domainEntitiesToEdges).flat()
|
||||
const entitiesEdges = watchlist.domains.map(d => domainEntitiesToEdges(d)).flat()
|
||||
const nameserversEdges = watchlist.domains.map(domainNSToEdges).flat()
|
||||
|
||||
return [...entitiesEdges, ...nameserversEdges]
|
||||
|
||||
@ -11,8 +11,8 @@ export const domainToNode = (d: Domain) => ({
|
||||
}
|
||||
})
|
||||
|
||||
export const domainEntitiesToNode = (d: Domain) => d.entities
|
||||
.filter(e => !e.roles.includes('registrar')) //
|
||||
export const domainEntitiesToNode = (d: Domain, withRegistrar = false) => d.entities
|
||||
.filter(e => !withRegistrar ? !e.roles.includes('registrar') : true)
|
||||
.map(e => {
|
||||
const jCard = vCard.fromJSON(e.entity.jCard)
|
||||
let label = e.entity.handle
|
||||
@ -46,7 +46,7 @@ export const nsToNode = (ns: Nameserver) => ({
|
||||
export function watchlistToNodes(watchlist: Watchlist) {
|
||||
|
||||
const domains = watchlist.domains.map(domainToNode)
|
||||
const entities = [...new Set(watchlist.domains.map(domainEntitiesToNode).flat())]
|
||||
const entities = [...new Set(watchlist.domains.map(d => domainEntitiesToNode(d)).flat())]
|
||||
const tlds = [...new Set(watchlist.domains.map(d => d.tld))].map(tldToNode)
|
||||
const nameservers = [...new Set(watchlist.domains.map(d => d.nameservers))].flat().map(nsToNode)
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ export function showErrorAPI(e: AxiosError, messageApi: MessageInstance): Messag
|
||||
|
||||
if (response.status === 429) {
|
||||
const duration = response.headers['retry-after']
|
||||
return messageApi.error(t`Please retry after ${duration} seconds`)
|
||||
return messageApi.error(t`Please retry after ${duration} minutes`)
|
||||
}
|
||||
|
||||
if (response.status.toString()[0] === '4') {
|
||||
|
||||
@ -325,7 +325,7 @@ msgstr ""
|
||||
msgid "Watchlist Entity Diagram"
|
||||
msgstr ""
|
||||
|
||||
#: assets/components/tracking/watchlist/diagram/watchlistToEdges.tsx:39
|
||||
#: assets/components/tracking/watchlist/diagram/watchlistToEdges.tsx:40
|
||||
msgid "Registry"
|
||||
msgstr ""
|
||||
|
||||
@ -607,7 +607,7 @@ msgstr ""
|
||||
|
||||
#: assets/utils/index.ts:19
|
||||
#, javascript-format
|
||||
msgid "Please retry after ${ duration } seconds"
|
||||
msgid "Please retry after ${ duration } minutes"
|
||||
msgstr ""
|
||||
|
||||
#: assets/utils/index.ts:23
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user