mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: user can force domain refresh
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
import {Form, Input} from 'antd'
|
||||
import {t} from 'ttag'
|
||||
import {SearchOutlined} from '@ant-design/icons'
|
||||
import React from 'react'
|
||||
import React, {useState} from 'react'
|
||||
|
||||
export interface FieldType {
|
||||
ldhName: string
|
||||
isRefreshForced: boolean
|
||||
}
|
||||
|
||||
export function DomainSearchBar({onFinish, initialValue}: {
|
||||
onFinish: (values: FieldType) => void,
|
||||
initialValue?: string
|
||||
}) {
|
||||
const [isRefreshForced, setRefreshForced] = useState(false)
|
||||
|
||||
return (
|
||||
<Form
|
||||
onFinish={onFinish}
|
||||
onFinish={({ldhName}: FieldType) => onFinish({ldhName, isRefreshForced})}
|
||||
autoComplete='off'
|
||||
style={{width: '100%'}}
|
||||
>
|
||||
@@ -33,6 +36,8 @@ export function DomainSearchBar({onFinish, initialValue}: {
|
||||
<Input
|
||||
style={{textAlign: 'center'}}
|
||||
size='large'
|
||||
onKeyDown={e => setRefreshForced(e.shiftKey)}
|
||||
onKeyUp={e => setRefreshForced(e.shiftKey)}
|
||||
prefix={<SearchOutlined/>}
|
||||
placeholder='example.com'
|
||||
autoComplete='off'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Col, List, Tag, Tooltip, Typography} from 'antd'
|
||||
import {List, Tag, Tooltip, Typography} from 'antd'
|
||||
import React from 'react'
|
||||
import type {Domain} from '../../utils/api'
|
||||
import {rdapRoleDetailTranslation, rdapRoleTranslation} from '../../utils/functions/rdapTranslation'
|
||||
@@ -29,19 +29,15 @@ export function EntitiesList({domain}: { domain: Domain }) {
|
||||
const details = extractDetailsFromJCard(e)
|
||||
|
||||
return <List.Item>
|
||||
<Col span={14}>
|
||||
<List.Item.Meta
|
||||
avatar={roleToAvatar(e)}
|
||||
title={<Typography.Text code>{e.entity.handle}</Typography.Text>}
|
||||
description={<>
|
||||
{details.fn && <div>👤 {details.fn}</div>}
|
||||
{details.organization && <div>🏢 {details.organization}</div>}
|
||||
</>}
|
||||
/>
|
||||
</Col>
|
||||
<Col span={10} flex='none'>
|
||||
{e.roles.map(roleToTag)}
|
||||
</Col>
|
||||
<List.Item.Meta
|
||||
avatar={roleToAvatar(e)}
|
||||
title={<Typography.Text code>{e.entity.handle}</Typography.Text>}
|
||||
description={<>
|
||||
{details.fn && <div>👤 {details.fn}</div>}
|
||||
{details.organization && <div>🏢 {details.organization}</div>}
|
||||
</>}
|
||||
/>
|
||||
{e.roles.map(roleToTag)}
|
||||
</List.Item>
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -19,13 +19,15 @@ export default function DomainSearchPage() {
|
||||
const [messageApi, contextHolder] = message.useMessage()
|
||||
const navigate = useNavigate()
|
||||
|
||||
|
||||
|
||||
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
||||
navigate('/search/domain/' + values.ldhName)
|
||||
|
||||
if (loading) return
|
||||
setLoading(true)
|
||||
setDomain(null)
|
||||
getDomain(values.ldhName).then(d => {
|
||||
getDomain(values.ldhName, values.isRefreshForced).then(d => {
|
||||
setDomain(d)
|
||||
messageApi.success(t`Found !`)
|
||||
}).catch((e: AxiosError) => {
|
||||
@@ -36,7 +38,7 @@ export default function DomainSearchPage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (query === undefined) return
|
||||
onFinish({ldhName: query})
|
||||
onFinish({ldhName: query, isRefreshForced: false})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import type {Domain} from '.'
|
||||
import { request} from '.'
|
||||
import {request} from '.'
|
||||
|
||||
export async function getDomain(ldhName: string): Promise<Domain> {
|
||||
export async function getDomain(ldhName: string, forced = false): Promise<Domain> {
|
||||
const response = await request<Domain>({
|
||||
url: 'domains/' + ldhName
|
||||
url: 'domains/' + ldhName,
|
||||
params: {forced}
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Service\RDAPService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Random\Randomizer;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Messenger\Exception\ExceptionInterface;
|
||||
@@ -37,7 +38,7 @@ class DomainRefreshController extends AbstractController
|
||||
* @throws HttpExceptionInterface
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function __invoke(string $ldhName, KernelInterface $kernel): Domain
|
||||
public function __invoke(string $ldhName, KernelInterface $kernel, Request $request): Domain
|
||||
{
|
||||
$idnDomain = strtolower(idn_to_ascii($ldhName));
|
||||
$userId = $this->getUser()->getUserIdentifier();
|
||||
@@ -49,12 +50,12 @@ class DomainRefreshController extends AbstractController
|
||||
|
||||
/** @var ?Domain $domain */
|
||||
$domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]);
|
||||
|
||||
// If the domain name exists in the database, recently updated and not important, we return the stored Domain
|
||||
if (null !== $domain
|
||||
&& !$domain->getDeleted()
|
||||
&& !$domain->isToBeUpdated()
|
||||
&& !$this->kernel->isDebug()
|
||||
&& true !== filter_var($request->get('forced', false), FILTER_VALIDATE_BOOLEAN)
|
||||
) {
|
||||
$this->logger->info('It is not necessary to update the information of the domain name {idnDomain} with the RDAP protocol.', [
|
||||
'idnDomain' => $idnDomain,
|
||||
|
||||
Reference in New Issue
Block a user