-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1241683
commit 0e96404
Showing
12 changed files
with
201 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
assets/components/tracking/watchlist/TrackedDomainTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, {useEffect, useState} from "react"; | ||
import {Domain, getTrackedDomainList} from "../../../utils/api"; | ||
import {Table, Tag, Tooltip} from "antd"; | ||
import {t} from "ttag"; | ||
import useBreakpoint from "../../../hooks/useBreakpoint"; | ||
import {ColumnType} from "antd/es/table"; | ||
import {rdapStatusCodeDetailTranslation} from "../../../utils/functions/rdapTranslation"; | ||
import {eppStatusCodeToColor} from "../../../utils/functions/eppStatusCodeToColor"; | ||
|
||
export function TrackedDomainTable() { | ||
const sm = useBreakpoint('sm') | ||
const [dataTable, setDataTable] = useState<Domain[]>([]) | ||
const [total, setTotal] = useState() | ||
|
||
|
||
const rdapStatusCodeDetailTranslated = rdapStatusCodeDetailTranslation() | ||
|
||
const fetchData = (params: { page: number, itemsPerPage: number }) => { | ||
getTrackedDomainList(params).then(data => { | ||
setTotal(data['hydra:totalItems']) | ||
setDataTable(data['hydra:member'].map((d: Domain) => { | ||
const expirationDate = d.events.find(e => e.action === 'expiration' && !e.deleted)?.date | ||
|
||
return { | ||
key: d.ldhName, | ||
ldhName: d.ldhName, | ||
expirationDate: expirationDate ? new Date(expirationDate).toLocaleString() : '-', | ||
status: d.status.map(s => <Tooltip | ||
placement='bottomLeft' | ||
title={s in rdapStatusCodeDetailTranslated ? rdapStatusCodeDetailTranslated[s as keyof typeof rdapStatusCodeDetailTranslated] : undefined}> | ||
<Tag color={eppStatusCodeToColor(s)}>{s}</Tag> | ||
</Tooltip> | ||
), | ||
updatedAt: new Date(d.updatedAt).toLocaleString() | ||
} | ||
})) | ||
}) | ||
} | ||
|
||
useEffect(() => { | ||
fetchData({page: 1, itemsPerPage: 30}) | ||
}, []) | ||
|
||
const columns: ColumnType<any>[] = [ | ||
{ | ||
title: t`Domain`, | ||
dataIndex: "ldhName" | ||
}, | ||
{ | ||
title: t`Expiration date`, | ||
dataIndex: 'expirationDate' | ||
}, | ||
{ | ||
title: t`Status`, | ||
dataIndex: 'status' | ||
}, | ||
{ | ||
title: t`Updated at`, | ||
dataIndex: 'updatedAt' | ||
} | ||
] | ||
|
||
|
||
return <Table | ||
loading={total === undefined} | ||
columns={columns} | ||
dataSource={dataTable} | ||
pagination={{ | ||
total, | ||
hideOnSinglePage: true, | ||
defaultPageSize: 30, | ||
onChange: (page, itemsPerPage) => { | ||
fetchData({page, itemsPerPage}) | ||
} | ||
}} | ||
|
||
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})} | ||
/> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const eppStatusCodeToColor = (s: string) => | ||
['active', 'ok'].includes(s) ? 'green' : | ||
s.startsWith('client') ? 'purple' : | ||
s.startsWith('server') ? 'geekblue' : | ||
s.includes('prohibited') ? 'red' : 'blue' | ||
['pending delete', 'redemption period'].includes(s) ? 'red' : | ||
s.startsWith('client') ? 'purple' : | ||
s.startsWith('server') ? 'geekblue' : 'blue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters