import { useState, useEffect } from 'react';
import { Container } from 'react-bootstrap';
import {
IconBrandTabler,
IconWorld,
IconNetwork,
IconSettings,
IconHome,
IconFileText,
IconCloud,
IconShield,
IconActivity,
IconBell,
IconChevronDown,
IconUser,
IconDatabase,
IconAlertTriangle,
IconAlertCircle,
IconServer,
IconFilter,
IconDownload,
IconCreditCard,
IconMoon,
IconHeart,
IconCode
} from '@tabler/icons-react';
import DataManager from './DataManager';
import ServerManager from './ServerManager';
import FilterManager from './FilterManager';
import DomainsNewManager from './DomainsNewManager';
import IPRangesManager from './IPRangesManager';
import ASNsNewManager from './ASNsNewManager';
import AutoUrlManager from './AutoUrlManager';
import BillingManager from './BillingManager';
import './App.css';
import axios from 'axios';
import {
BrowserRouter as Router,
Routes,
Route,
Link,
useLocation,
Navigate
} from 'react-router-dom';
function App() {
return (
);
}
function MainLayout() {
const location = useLocation();
const [notifications] = useState([
{ id: 1, title: 'Новый домен добавлен', message: 'example.com был добавлен в список', time: '2 мин назад' },
{ id: 2, title: 'Изменения сохранены', message: 'Список AS обновлен в S3', time: '5 мин назад' }
]);
// Состояние для управления выпадающими меню
const [dropdownStates, setDropdownStates] = useState({
data: false,
management: false,
tools: false,
settings: false
});
const toggleDropdown = (dropdown) => {
setDropdownStates(prev => ({
...prev,
[dropdown]: !prev[dropdown]
}));
};
const navCategories = [
{
id: 'home',
title: 'Главная',
icon: IconHome,
path: '/',
single: true
},
{
id: 'data',
title: 'Данные',
icon: IconDatabase,
items: [
{ id: 'domains', title: 'Домены', path: '/domains', icon: IconWorld },
{ id: 'domains-new', title: 'Домены New', path: '/domains-new', icon: IconWorld },
{ id: 'ip-ranges', title: 'IP-диапазоны', path: '/ip-ranges', icon: IconNetwork },
{ id: 'asns', title: 'AS', path: '/asns', icon: IconNetwork }
]
},
{
id: 'management',
title: 'Управление',
icon: IconServer,
items: [
{ id: 'servers', title: 'Серверы', path: '/servers', icon: IconServer },
{ id: 'filters', title: 'Фильтры', path: '/filters', icon: IconFilter },
{ id: 'billing', title: 'Биллинг', path: '/billing', icon: IconCreditCard }
]
},
{
id: 'tools',
title: 'Инструменты',
icon: IconSettings,
items: [
{ id: 'auto-urls', title: 'Авто URL', path: '/auto-urls', icon: IconDownload },
{ id: 'files', title: 'Файлы', path: '/files', icon: IconFileText },
{ id: 'cloud', title: 'Облако', path: '/cloud', icon: IconCloud },
{ id: 'security', title: 'Безопасность', path: '/security', icon: IconShield },
{ id: 'activity', title: 'Активность', path: '/activity', icon: IconActivity }
]
},
{
id: 'settings',
title: 'Настройки',
icon: IconSettings,
path: '/settings',
single: true
}
];
// Определяем активную вкладку по адресу
const getActiveTab = () => {
for (const category of navCategories) {
if (category.single && location.pathname === category.path) {
return category.id;
}
if (category.items) {
for (const item of category.items) {
if (location.pathname.startsWith(item.path)) {
return item.id;
}
}
}
}
return 'home';
};
const activeTab = getActiveTab();
return (
{/* Верхнее меню Tabler Admin */}
} />
} />
} />
} />
} />
} />
} />
} />
} />
);
}
function StatCard({ icon: Icon, color, value, title, subtitle }) {
return (
{value} {title}
{subtitle}
);
}
function Dashboard() {
const [stats, setStats] = useState({ domainsCount: null, asnsCount: null, serversCount: null, lastModified: null });
const [loading, setLoading] = useState(true);
useEffect(() => {
async function fetchStats() {
setLoading(true);
try {
const [domainsRes, asnsRes, serversRes, s3Res] = await Promise.all([
axios.get('/api/domains'),
axios.get('/api/asns'),
axios.get('/api/servers'),
axios.get('/api/s3/last-modified')
]);
setStats({
domainsCount: domainsRes.data.length,
asnsCount: asnsRes.data.length,
serversCount: serversRes.data.length,
lastModified: s3Res.data.domainsLastModified
});
} catch (e) {
setStats({ domainsCount: null, asnsCount: null, serversCount: null, lastModified: null });
} finally {
setLoading(false);
}
}
fetchStats();
}, []);
return (
Dashboard
Главная / Dashboard
);
}
export default App;