From 97a75c0f84b5729c4cf9c4eafa79c6d487786677 Mon Sep 17 00:00:00 2001 From: zorex <109388690+notzorexlol@users.noreply.github.com> Date: Wed, 3 Jun 2026 05:19:22 +0300 Subject: [PATCH] feat: add user activity chart on home page (#1092) Co-authored-by: dicedtomato also adds settings to hide the recents, activity graph, and file type table --- src/components/pages/dashboard/index.tsx | 228 +++++++++--------- .../pages/dashboard/parts/ActivityChart.tsx | 204 ++++++++++++++++ .../pages/dashboard/parts/Recents.tsx | 36 +++ .../settings/parts/SettingsDashboard.tsx | 20 ++ src/lib/api/response.ts | 2 + src/lib/client/store/settings.ts | 6 + src/server/routes/api/user/activity.ts | 126 ++++++++++ 7 files changed, 514 insertions(+), 108 deletions(-) create mode 100644 src/components/pages/dashboard/parts/ActivityChart.tsx create mode 100644 src/components/pages/dashboard/parts/Recents.tsx create mode 100644 src/server/routes/api/user/activity.ts diff --git a/src/components/pages/dashboard/index.tsx b/src/components/pages/dashboard/index.tsx index 3b431307..ca144260 100644 --- a/src/components/pages/dashboard/index.tsx +++ b/src/components/pages/dashboard/index.tsx @@ -3,6 +3,7 @@ import Stat from '@/components/Stat'; import type { Response } from '@/lib/api/response'; import { bytes } from '@/lib/bytes'; import useLogin from '@/lib/client/hooks/useLogin'; +import { useSettingsStore } from '@/lib/client/store/settings'; import { isAdministrator } from '@/lib/role'; import { Button, Group, Paper, ScrollArea, SimpleGrid, Skeleton, Table, Text, Title } from '@mantine/core'; import { @@ -17,11 +18,12 @@ import { lazy, Suspense } from 'react'; import { Link } from 'react-router-dom'; import useSWR from 'swr'; -const DashboardFile = lazy(() => import('@/components/file/DashboardFile')); +const ActivityChart = lazy(() => import('./parts/ActivityChart')); +const Recents = lazy(() => import('./parts/Recents')); export default function DashboardHome() { const { user } = useLogin(); - const { data: recent, isLoading: recentLoading } = useSWR('/api/user/recent'); + const { homeShowActivity, homeShowRecents, homeShowTypes } = useSettingsStore((state) => state.settings); const { data: stats, isLoading: statsLoading } = useSWR('/api/user/stats'); const config = useConfig(); @@ -38,6 +40,32 @@ export default function DashboardHome() { + {homeShowRecents && ( + + + + + } + > + + Recent files + + + + + + )} + {user?.quota && (user.quota.maxBytes || user.quota.maxFiles) ? ( {user.quota.filesQuota === 'BY_BYTES' ? ( @@ -60,41 +88,9 @@ export default function DashboardHome() { ) : null} - - Recent files - - - - {recentLoading ? ( - - {[...Array(3)].map((_, i) => ( - - ))} - - ) : recent?.length !== 0 ? ( - - {recent!.map((file, i) => ( - } key={i}> - - - ))} - - ) : ( - - You have no recent files. The last three files you uploaded will appear here. - - )} - Stats + {(!config.features?.metrics?.adminOnly || isAdministrator(user?.role)) && (