2024-07-26 16:45:10 +02:00
|
|
|
import {Badge, Layout, Menu, theme} from "antd";
|
|
|
|
|
import {
|
|
|
|
|
ApiOutlined,
|
|
|
|
|
BankOutlined,
|
|
|
|
|
CloudServerOutlined,
|
2024-07-27 12:59:40 +02:00
|
|
|
CompassOutlined,
|
2024-07-26 16:45:10 +02:00
|
|
|
FileProtectOutlined,
|
|
|
|
|
FileSearchOutlined,
|
2024-07-27 12:59:40 +02:00
|
|
|
HomeOutlined,
|
2024-07-26 16:45:10 +02:00
|
|
|
InfoCircleOutlined,
|
|
|
|
|
LineChartOutlined,
|
2024-07-26 18:31:47 +02:00
|
|
|
LoginOutlined,
|
|
|
|
|
LogoutOutlined,
|
2024-07-26 16:45:10 +02:00
|
|
|
QuestionCircleOutlined,
|
|
|
|
|
SearchOutlined,
|
|
|
|
|
TeamOutlined,
|
|
|
|
|
UserOutlined
|
|
|
|
|
} from "@ant-design/icons";
|
2024-07-26 23:55:12 +02:00
|
|
|
import {Link, Navigate, Route, Routes, useLocation, useNavigate} from "react-router-dom";
|
2024-07-26 16:45:10 +02:00
|
|
|
import TextPage from "./pages/TextPage";
|
|
|
|
|
import DomainSearchPage from "./pages/search/DomainSearchPage";
|
|
|
|
|
import EntitySearchPage from "./pages/search/EntitySearchPage";
|
|
|
|
|
import NameserverSearchPage from "./pages/search/NameserverSearchPage";
|
|
|
|
|
import TldPage from "./pages/info/TldPage";
|
|
|
|
|
import StatisticsPage from "./pages/info/StatisticsPage";
|
2024-07-27 17:19:25 +02:00
|
|
|
import WatchlistPage from "./pages/tracking/WatchlistPage";
|
2024-07-26 23:55:12 +02:00
|
|
|
import UserPage from "./pages/watchdog/UserPage";
|
2024-07-26 18:31:47 +02:00
|
|
|
import React, {useCallback, useEffect, useMemo, useState} from "react";
|
2024-07-26 16:45:10 +02:00
|
|
|
import {getUser} from "./utils/api";
|
2024-07-26 18:31:47 +02:00
|
|
|
import LoginPage, {AuthenticatedContext} from "./pages/LoginPage";
|
|
|
|
|
import ConnectorsPage from "./pages/tracking/ConnectorsPage";
|
|
|
|
|
import NotFoundPage from "./pages/NotFoundPage";
|
2024-07-27 17:19:25 +02:00
|
|
|
import {ItemType, MenuItemType} from "antd/lib/menu/interface";
|
2024-07-28 15:36:22 +02:00
|
|
|
import {t} from 'ttag'
|
2024-07-30 06:13:31 +02:00
|
|
|
import useBreakpoint from "./hooks/useBreakpoint";
|
2024-07-26 16:45:10 +02:00
|
|
|
|
|
|
|
|
export default function App() {
|
|
|
|
|
const {
|
|
|
|
|
token: {colorBgContainer, borderRadiusLG},
|
|
|
|
|
} = theme.useToken()
|
2024-07-26 18:31:47 +02:00
|
|
|
|
2024-07-26 16:45:10 +02:00
|
|
|
const navigate = useNavigate()
|
2024-07-26 18:31:47 +02:00
|
|
|
const location = useLocation()
|
2024-07-30 06:13:31 +02:00
|
|
|
const sm = useBreakpoint('sm')
|
2024-07-26 18:31:47 +02:00
|
|
|
|
2024-07-26 23:55:12 +02:00
|
|
|
|
|
|
|
|
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
|
|
|
|
|
|
|
|
|
|
2024-07-26 18:31:47 +02:00
|
|
|
const authenticated = useCallback((authenticated: boolean) => {
|
|
|
|
|
setIsAuthenticated(authenticated)
|
|
|
|
|
}, []);
|
2024-07-26 16:45:10 +02:00
|
|
|
|
2024-07-26 18:31:47 +02:00
|
|
|
const contextValue = useMemo(() => ({
|
|
|
|
|
authenticated,
|
|
|
|
|
setIsAuthenticated
|
|
|
|
|
}), [authenticated, setIsAuthenticated]);
|
2024-07-26 16:45:10 +02:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-07-26 18:31:47 +02:00
|
|
|
getUser().then(() => {
|
|
|
|
|
setIsAuthenticated(true)
|
|
|
|
|
if (location.pathname === '/login') navigate('/search/domain')
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
setIsAuthenticated(false)
|
2024-07-27 12:59:40 +02:00
|
|
|
navigate('/home')
|
2024-07-26 18:31:47 +02:00
|
|
|
})
|
2024-07-26 16:45:10 +02:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
2024-07-27 12:59:40 +02:00
|
|
|
const menuItems: ItemType<MenuItemType>[] = [
|
|
|
|
|
{
|
|
|
|
|
key: 'home',
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Home`,
|
2024-07-27 12:59:40 +02:00
|
|
|
icon: <HomeOutlined/>,
|
|
|
|
|
onClick: () => navigate('/home')
|
|
|
|
|
},
|
2024-07-26 18:31:47 +02:00
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'search',
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Search`,
|
2024-07-27 12:59:40 +02:00
|
|
|
icon: <SearchOutlined/>,
|
2024-07-26 18:31:47 +02:00
|
|
|
children: [
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'domain-finder',
|
2024-07-27 01:35:00 +02:00
|
|
|
icon: <CompassOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Domain`,
|
|
|
|
|
title: t`Domain Finder`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/search/domain')
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'entity-finder',
|
2024-07-26 18:31:47 +02:00
|
|
|
icon: <TeamOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Entity`,
|
|
|
|
|
title: t`Entity Finder`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/search/entity')
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'ns-finder',
|
2024-07-26 18:31:47 +02:00
|
|
|
icon: <CloudServerOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Nameserver`,
|
|
|
|
|
title: t`Nameserver Finder`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/search/nameserver')
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'info',
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Information`,
|
2024-07-26 23:55:12 +02:00
|
|
|
icon: <InfoCircleOutlined/>,
|
2024-07-26 18:31:47 +02:00
|
|
|
children: [
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'tld-list',
|
2024-07-26 18:31:47 +02:00
|
|
|
icon: <BankOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`TLD`,
|
|
|
|
|
title: t`TLD list`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/info/tld')
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'stats',
|
2024-07-26 18:31:47 +02:00
|
|
|
icon: <LineChartOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Statistics`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/info/stats')
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'tracking',
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Tracking`,
|
2024-07-26 23:55:12 +02:00
|
|
|
icon: <FileSearchOutlined/>,
|
2024-07-26 18:31:47 +02:00
|
|
|
children: [
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'watchlist',
|
2024-07-26 23:55:12 +02:00
|
|
|
icon: <Badge count={0} size="small"><FileSearchOutlined/></Badge>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`My Watchlists`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/tracking/watchlist')
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'connectors',
|
2024-07-26 18:31:47 +02:00
|
|
|
icon: <ApiOutlined/>,
|
2024-07-30 18:32:02 +02:00
|
|
|
label: t`My Connectors`,
|
2024-07-26 18:31:47 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/tracking/connectors')
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'watchdog',
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`My Watchdog`,
|
2024-07-26 18:31:47 +02:00
|
|
|
icon: <UserOutlined/>,
|
2024-07-26 23:55:12 +02:00
|
|
|
children: [
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'account',
|
2024-07-26 23:55:12 +02:00
|
|
|
icon: <UserOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`My Account`,
|
2024-07-26 23:55:12 +02:00
|
|
|
disabled: !isAuthenticated,
|
|
|
|
|
onClick: () => navigate('/user')
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'tos',
|
2024-07-26 23:55:12 +02:00
|
|
|
icon: <InfoCircleOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`TOS`,
|
2024-07-26 23:55:12 +02:00
|
|
|
onClick: () => navigate('/tos')
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-07-27 12:59:40 +02:00
|
|
|
key: 'privacy',
|
2024-07-26 23:55:12 +02:00
|
|
|
icon: <FileProtectOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Privacy Policy`,
|
2024-07-26 23:55:12 +02:00
|
|
|
onClick: () => navigate('/privacy')
|
|
|
|
|
}
|
|
|
|
|
]
|
2024-07-26 18:31:47 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: '5',
|
|
|
|
|
icon: <QuestionCircleOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`FAQ`,
|
2024-07-26 18:31:47 +02:00
|
|
|
onClick: () => navigate('/faq')
|
|
|
|
|
},
|
2024-07-26 23:55:12 +02:00
|
|
|
|
2024-07-26 18:31:47 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return <AuthenticatedContext.Provider value={contextValue}>
|
|
|
|
|
<Layout hasSider style={{minHeight: '100vh'}}>
|
2024-07-30 06:13:31 +02:00
|
|
|
{/* Ant will use a break-off tab to toggle the collapse of the sider when collapseWidth = 0*/}
|
|
|
|
|
<Layout.Sider collapsible breakpoint="sm" {...(sm ? {collapsedWidth: 0} : {})}>
|
2024-07-26 18:31:47 +02:00
|
|
|
<Menu
|
2024-07-27 12:59:40 +02:00
|
|
|
defaultSelectedKeys={['home']}
|
|
|
|
|
defaultOpenKeys={['search', 'info', 'tracking', 'watchdog']}
|
2024-07-26 18:31:47 +02:00
|
|
|
mode="inline"
|
|
|
|
|
theme="dark"
|
|
|
|
|
items={[...menuItems, isAuthenticated ? {
|
|
|
|
|
key: '8',
|
|
|
|
|
icon: <LogoutOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Log out`,
|
2024-07-26 18:31:47 +02:00
|
|
|
danger: true,
|
|
|
|
|
onClick: () => window.location.replace("/logout")
|
|
|
|
|
} : {
|
|
|
|
|
key: '8',
|
|
|
|
|
icon: <LoginOutlined/>,
|
2024-07-28 15:36:22 +02:00
|
|
|
label: t`Log in`,
|
2024-07-26 18:31:47 +02:00
|
|
|
onClick: () => navigate('/login')
|
|
|
|
|
}]}
|
|
|
|
|
/>
|
|
|
|
|
</Layout.Sider>
|
|
|
|
|
<Layout>
|
|
|
|
|
<Layout.Header style={{padding: 0, background: colorBgContainer}}/>
|
2024-07-30 06:21:37 +02:00
|
|
|
<Layout.Content style={sm ? {margin: '24px 0'} : {margin: '24px 16px 0'}}>
|
2024-07-26 18:31:47 +02:00
|
|
|
<div style={{
|
|
|
|
|
padding: 24,
|
|
|
|
|
minHeight: 360,
|
|
|
|
|
background: colorBgContainer,
|
|
|
|
|
borderRadius: borderRadiusLG,
|
|
|
|
|
}}>
|
|
|
|
|
|
|
|
|
|
<Routes>
|
2024-07-27 12:59:40 +02:00
|
|
|
<Route path="/" element={<Navigate to="/login"/>}/>
|
2024-07-28 01:04:08 +02:00
|
|
|
<Route path="/home" element={<TextPage resource='home.md'/>}/>
|
2024-07-26 18:31:47 +02:00
|
|
|
|
|
|
|
|
<Route path="/search/domain" element={<DomainSearchPage/>}/>
|
|
|
|
|
<Route path="/search/entity" element={<EntitySearchPage/>}/>
|
|
|
|
|
<Route path="/search/nameserver" element={<NameserverSearchPage/>}/>
|
|
|
|
|
|
|
|
|
|
<Route path="/info/tld" element={<TldPage/>}/>
|
|
|
|
|
<Route path="/info/stats" element={<StatisticsPage/>}/>
|
|
|
|
|
|
2024-07-27 17:19:25 +02:00
|
|
|
<Route path="/tracking/watchlist" element={<WatchlistPage/>}/>
|
2024-07-26 18:31:47 +02:00
|
|
|
<Route path="/tracking/connectors" element={<ConnectorsPage/>}/>
|
|
|
|
|
|
|
|
|
|
<Route path="/user" element={<UserPage/>}/>
|
|
|
|
|
|
2024-07-28 01:04:08 +02:00
|
|
|
<Route path="/faq" element={<TextPage resource='faq.md'/>}/>
|
|
|
|
|
<Route path="/tos" element={<TextPage resource='tos.md'/>}/>
|
|
|
|
|
<Route path="/privacy" element={<TextPage resource='privacy.md'/>}/>
|
2024-07-26 18:31:47 +02:00
|
|
|
|
|
|
|
|
<Route path="/login" element={<LoginPage/>}/>
|
|
|
|
|
|
|
|
|
|
<Route path="*" element={<NotFoundPage/>}/>
|
|
|
|
|
</Routes>
|
|
|
|
|
</div>
|
|
|
|
|
</Layout.Content>
|
|
|
|
|
<Layout.Footer style={{textAlign: 'center'}}>
|
2024-07-26 23:55:12 +02:00
|
|
|
<Link to='https://github.com/maelgangloff/domain-watchdog'>Domain
|
2024-08-02 01:16:16 +02:00
|
|
|
Watchdog</Link> © {new Date().getFullYear()} Maël Gangloff
|
2024-07-26 18:31:47 +02:00
|
|
|
</Layout.Footer>
|
|
|
|
|
</Layout>
|
2024-07-26 16:45:10 +02:00
|
|
|
</Layout>
|
2024-07-26 18:31:47 +02:00
|
|
|
</AuthenticatedContext.Provider>
|
2024-07-26 16:45:10 +02:00
|
|
|
}
|