feat: Add server management functionality with new API endpoints and update UI to include server statistics
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 14m34s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 14m34s
This commit is contained in:
+23
-7
@@ -15,9 +15,11 @@ import {
|
||||
IconUser,
|
||||
IconDatabase,
|
||||
IconAlertTriangle,
|
||||
IconAlertCircle
|
||||
IconAlertCircle,
|
||||
IconServer
|
||||
} from '@tabler/icons-react';
|
||||
import DataManager from './DataManager';
|
||||
import ServerManager from './ServerManager';
|
||||
import './App.css';
|
||||
import axios from 'axios';
|
||||
|
||||
@@ -32,6 +34,7 @@ function App() {
|
||||
{ id: 'dashboard', title: 'Dashboard', icon: IconHome },
|
||||
{ id: 'domains', title: 'Домены', icon: IconWorld },
|
||||
{ id: 'asns', title: 'AS', icon: IconNetwork },
|
||||
{ id: 'servers', title: 'Серверы', icon: IconServer },
|
||||
{ id: 'files', title: 'Файлы', icon: IconFileText },
|
||||
{ id: 'cloud', title: 'Облако', icon: IconCloud },
|
||||
{ id: 'security', title: 'Безопасность', icon: IconShield },
|
||||
@@ -59,6 +62,8 @@ function App() {
|
||||
placeholder="AS12345"
|
||||
/>
|
||||
);
|
||||
case 'servers':
|
||||
return <ServerManager />;
|
||||
default:
|
||||
return <Dashboard />;
|
||||
}
|
||||
@@ -172,25 +177,27 @@ function StatCard({ icon: Icon, color, value, title, subtitle }) {
|
||||
}
|
||||
|
||||
function Dashboard() {
|
||||
const [stats, setStats] = useState({ domainsCount: null, asnsCount: null, lastModified: null });
|
||||
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, s3Res] = await Promise.all([
|
||||
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, lastModified: null });
|
||||
setStats({ domainsCount: null, asnsCount: null, serversCount: null, lastModified: null });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -201,7 +208,7 @@ function Dashboard() {
|
||||
return (
|
||||
<div>
|
||||
<div className="row g-3 mb-4">
|
||||
<div className="col-md-4">
|
||||
<div className="col-md-3">
|
||||
<StatCard
|
||||
icon={IconWorld}
|
||||
color="blue"
|
||||
@@ -210,7 +217,7 @@ function Dashboard() {
|
||||
subtitle="Всего доменов"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<div className="col-md-3">
|
||||
<StatCard
|
||||
icon={IconNetwork}
|
||||
color="green"
|
||||
@@ -219,7 +226,16 @@ function Dashboard() {
|
||||
subtitle="Всего AS"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<div className="col-md-3">
|
||||
<StatCard
|
||||
icon={IconServer}
|
||||
color="purple"
|
||||
value={loading ? '...' : stats.serversCount ?? '—'}
|
||||
title="Серверов"
|
||||
subtitle="Всего серверов"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
<StatCard
|
||||
icon={IconDatabase}
|
||||
color="orange"
|
||||
|
||||
Reference in New Issue
Block a user