From 5b3f4b493fcd1e706548a4b072b460277ad2c645 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Wed, 27 Nov 2024 17:35:54 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(dashboard):=20Optimization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/admin/app/dashboard/page.tsx | 1206 ++++++++++++++++------------- 1 file changed, 685 insertions(+), 521 deletions(-) diff --git a/apps/admin/app/dashboard/page.tsx b/apps/admin/app/dashboard/page.tsx index 83c4f9b..34fd6db 100644 --- a/apps/admin/app/dashboard/page.tsx +++ b/apps/admin/app/dashboard/page.tsx @@ -1,8 +1,15 @@ 'use client'; -import { formatBytes } from '@repo/ui/utils'; -import { Badge } from '@shadcn/ui/badge'; -import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@shadcn/ui/card'; +import { Icon } from '@iconify/react'; +import { formatBytes, unitConversion } from '@repo/ui/utils'; +import { + Card, + CardContent, + CardDescription, + CardFooter, + CardHeader, + CardTitle, +} from '@shadcn/ui/card'; import { ChartConfig, ChartContainer, @@ -18,13 +25,17 @@ import { BarChart, CartesianGrid, Label, + LabelList, Pie, PieChart, XAxis, + YAxis, } from '@shadcn/ui/lib/recharts'; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@shadcn/ui/select'; import { Separator } from '@shadcn/ui/separator'; -import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@shadcn/ui/table'; +import { Tabs, TabsContent, TabsList, TabsTrigger } from '@shadcn/ui/tabs'; import { useLocale } from 'next-intl'; +import { useState } from 'react'; const UserStatisticsConfig = { register: { @@ -52,541 +63,694 @@ const IncomeStatisticsConfig = { }, }; +// Sample data - replace with actual data +const trafficData = { + nodes: { + today: [ + { name: 'Node 1', traffic: 1000, type: 'Trojan', address: '127.0.0.1:443' }, + { name: 'Node 2', traffic: 800, type: 'Trojan', address: '127.0.0.1:444' }, + { name: 'Node 3', traffic: 600, type: 'Trojan', address: '127.0.0.1:445' }, + { name: 'Node 4', traffic: 400, type: 'Trojan', address: '127.0.0.1:446' }, + { name: 'Node 5', traffic: 200, type: 'Trojan', address: '127.0.0.1:447' }, + { name: 'Node 6', traffic: 1000, type: 'Trojan', address: '127.0.0.1:443' }, + { name: 'Node 7', traffic: 800, type: 'Trojan', address: '127.0.0.1:444' }, + { name: 'Node 8', traffic: 600, type: 'Trojan', address: '127.0.0.1:445' }, + { name: 'Node 9', traffic: 400, type: 'Trojan', address: '127.0.0.1:446' }, + { name: 'Node 10', traffic: 200, type: 'Trojan', address: '127.0.0.1:447' }, + ], + yesterday: [ + { name: 'Node 1', traffic: 900, type: 'Trojan', address: '127.0.0.1:443' }, + { name: 'Node 2', traffic: 750, type: 'Trojan', address: '127.0.0.1:444' }, + { name: 'Node 3', traffic: 550, type: 'Trojan', address: '127.0.0.1:445' }, + { name: 'Node 4', traffic: 350, type: 'Trojan', address: '127.0.0.1:446' }, + { name: 'Node 5', traffic: 150, type: 'Trojan', address: '127.0.0.1:447' }, + ], + }, + users: { + today: [ + { name: 'olivia.martin@email.com', traffic: 100, email: 'olivia.martin@email.com' }, + { name: 'jackson.lee@email.com', traffic: 90, email: 'jackson.lee@email.com' }, + { name: 'isabella.nguyen@email.com', traffic: 80, email: 'isabella.nguyen@email.com' }, + { name: 'william.chen@email.com', traffic: 70, email: 'william.chen@email.com' }, + { name: 'sophia.rodriguez@email.com', traffic: 60, email: 'sophia.rodriguez@email.com' }, + { name: 'olivia.martin@email.com', traffic: 100, email: 'olivia.martin@email.com' }, + { name: 'jackson.lee@email.com', traffic: 90, email: 'jackson.lee@email.com' }, + { name: 'isabella.nguyen@email.com', traffic: 80, email: 'isabella.nguyen@email.com' }, + { name: 'william.chen@email.com', traffic: 70, email: 'william.chen@email.com' }, + { name: 'sophia.rodriguez@email.com', traffic: 60, email: 'sophia.rodriguez@email.com' }, + ], + yesterday: [ + { name: 'olivia.martin@email.com', traffic: 95, email: 'olivia.martin@email.com' }, + { name: 'jackson.lee@email.com', traffic: 85, email: 'jackson.lee@email.com' }, + { name: 'isabella.nguyen@email.com', traffic: 75, email: 'isabella.nguyen@email.com' }, + { name: 'william.chen@email.com', traffic: 65, email: 'william.chen@email.com' }, + { name: 'sophia.rodriguez@email.com', traffic: 55, email: 'sophia.rodriguez@email.com' }, + ], + }, +}; + export default function Dashboard() { const locale = useLocale(); + + const [dataType, setDataType] = useState('nodes'); + const [timeFrame, setTimeFrame] = useState('today'); + + const currentData = trafficData[dataType][timeFrame]; + return ( -
- - - 统计 - - -
-
在线IP数
-
666
-
-
-
在线节点数
-
99
-
-
-
离线节点数
-
1
-
- -
-
待处理工单
-
1
-
-
-
今日上传流量
-
- {formatBytes(99999999999999)} -
-
-
-
今日下载流量
-
- {formatBytes(99999999999999)} -
-
-
-
总上传流量
-
- {formatBytes(99999999999999)} -
-
-
-
总下载流量
-
- {formatBytes(99999999999999)} -
-
-
-
-
- - - 今日收入统计 - - - - - } /> - } /> - -