Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat(web): polish usage statistics page (#3182)

Mohamed Bassemff5e253f7909
diff --git a/apps/web/app/settings/stats/page.tsx b/apps/web/app/settings/stats/page.tsx
index 9820e1ea..4de69a75 100644
--- a/apps/web/app/settings/stats/page.tsx
+++ b/apps/web/app/settings/stats/page.tsx
@@ -1,16 +1,14 @@
"use client";
-import { useMemo } from "react";
import { SettingsPage } from "@/components/settings/SettingsPage";
-import { Badge } from "@/components/ui/badge";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
-import { Progress } from "@/components/ui/progress";
import { Skeleton } from "@/components/ui/skeleton";
+import { normalizeI18nLanguage } from "@/lib/date-format";
import { useTranslation } from "@/lib/i18n/client";
+import { cn } from "@/lib/utils";
import { useQuery } from "@tanstack/react-query";
import {
Archive,
- BarChart3,
BookOpen,
Chrome,
Clock,
@@ -25,6 +23,7 @@ import {
Image,
Link,
List,
+ PieChart,
Rss,
Smartphone,
TrendingUp,
@@ -56,10 +55,26 @@ function formatNumber(num: number): string {
return num.toString();
}
-const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
-const hourLabels = Array.from({ length: 24 }, (_, i) =>
- i === 0 ? "12 AM" : i < 12 ? `${i} AM` : i === 12 ? "12 PM" : `${i - 12} PM`,
-);
+function getDayNames(locale: string | undefined): string[] {
+ const formatter = new Intl.DateTimeFormat(locale, {
+ weekday: "short",
+ timeZone: "UTC",
+ });
+ // 2023-01-01 was a Sunday, matching the stats API's day 0.
+ return Array.from({ length: 7 }, (_, day) =>
+ formatter.format(Date.UTC(2023, 0, 1 + day)),
+ );
+}
+
+function getHourLabels(locale: string | undefined): string[] {
+ const formatter = new Intl.DateTimeFormat(locale, {
+ hour: "numeric",
+ timeZone: "UTC",
+ });
+ return Array.from({ length: 24 }, (_, hour) =>
+ formatter.format(Date.UTC(2023, 0, 1, hour)),
+ );
+}
function formatSourceName(source: BookmarkSource | null): string {
if (!source) return "Unknown";
@@ -100,39 +115,132 @@ function getSourceIcon(source: BookmarkSource | null): React.ReactNode {
}
}
-function SimpleBarChart({
+function ColumnChart({
+ title,
data,
- maxValue,
labels,
+ axisLabels,
+ summary,
}: {
+ title: string;
data: number[];
- maxValue: number;
labels: string[];
+ axisLabels: string[];
+ summary?: string;
}) {
+ const maxValue = Math.max(...data, 0);
return (
- <div className="space-y-2">
- {data.map((value, index) => (
- <div key={index} className="flex items-center gap-3">
- <div className="w-12 text-right text-xs text-muted-foreground">
- {labels[index]}
- </div>
- <div className="relative h-2 flex-1 overflow-hidden rounded-full bg-muted">
+ <div className="space-y-3">
+ <div className="flex items-baseline justify-between gap-3">
+ <h4 className="text-sm font-medium">{title}</h4>
+ {summary && (
+ <span className="text-xs text-muted-foreground">{summary}</span>
+ )}
+ </div>
+ <div
+ role="img"
+ aria-label={`${title}: ${data.map((value, index) => `${labels[index]} ${value}`).join(", ")}`}
+ className={cn(
+ "flex h-32 items-end",
+ data.length > 12 ? "gap-1" : "gap-3",
+ )}
+ >
+ {data.map((value, index) => (
+ <div
+ key={index}
+ className="flex h-full flex-1 items-end justify-center"
+ >
<div
- className="h-full rounded-full bg-primary transition-all duration-300"
+ className={cn(
+ "w-full max-w-8 rounded-t-sm",
+ value > 0 ? "bg-primary" : "bg-muted",
+ )}
style={{
- width: `${maxValue > 0 ? (value / maxValue) * 100 : 0}%`,
+ height: `${maxValue > 0 ? Math.max(2, (value / maxValue) * 100) : 2}%`,
}}
/>
</div>
- <div className="w-8 text-right text-xs text-muted-foreground">
- {value}
- </div>
- </div>
- ))}
+ ))}
+ </div>
+ <div
+ className={cn(
+ "grid text-xs text-muted-foreground",
+ axisLabels.length === data.length ? "gap-3 text-center" : "",
+ )}
+ style={{ gridTemplateColumns: `repeat(${axisLabels.length}, 1fr)` }}
+ >
+ {axisLabels.map((label) => (
+ <span key={label}>{label}</span>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+function BarRow({
+ label,
+ value,
+ maxValue,
+ icon,
+ rank,
+}: {
+ label: string;
+ value: number;
+ maxValue: number;
+ icon?: React.ReactNode;
+ rank?: number;
+}) {
+ return (
+ <div className="space-y-1.5">
+ <div className="flex items-center gap-2 text-sm">
+ {rank !== undefined && (
+ <span className="w-4 text-xs tabular-nums text-muted-foreground">
+ {rank}
+ </span>
+ )}
+ {icon}
+ <span className="min-w-0 flex-1 truncate" title={label}>
+ {label}
+ </span>
+ <span className="tabular-nums text-muted-foreground">{value}</span>
+ </div>
+ <div className="h-1 overflow-hidden rounded-full bg-muted">
+ <div
+ className="h-full rounded-full bg-primary/40"
+ style={{
+ width: `${maxValue > 0 ? (value / maxValue) * 100 : 0}%`,
+ }}
+ />
+ </div>
</div>
);
}
+function SectionCard({
+ title,
+ icon,
+ action,
+ className,
+ children,
+}: {
+ title: string;
+ icon: React.ReactNode;
+ action?: React.ReactNode;
+ className?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <Card className={className}>
+ <CardHeader className="flex flex-row items-center gap-2 space-y-0 pb-4">
+ {icon}
+ <CardTitle className="text-base">{title}</CardTitle>
+ {action && <div className="ml-auto">{action}</div>}
+ </CardHeader>
+ <CardContent>{children}</CardContent>
+ </Card>
+ );
+}
+
function StatCard({
title,
value,
@@ -147,43 +255,31 @@ function StatCard({
return (
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
- <CardTitle className="text-sm font-medium">{title}</CardTitle>
+ <CardTitle className="text-sm font-medium text-muted-foreground">
+ {title}
+ </CardTitle>
{icon}
</CardHeader>
<CardContent>
- <div className="text-2xl font-bold">{value}</div>
+ <div className="text-3xl font-semibold tabular-nums tracking-tight">
+ {value}
+ </div>
{description && (
- <p className="text-xs text-muted-foreground">{description}</p>
+ <p className="mt-1 text-xs text-muted-foreground">{description}</p>
)}
</CardContent>
</Card>
);
}
+const sectionIconClass = "h-4 w-4 text-muted-foreground";
+
export default function StatsPage() {
const api = useTRPC();
- const { t } = useTranslation();
+ const { t, i18n } = useTranslation();
const { data: stats, isLoading } = useQuery(api.users.stats.queryOptions());
const { data: userSettings } = useQuery(api.users.settings.queryOptions());
- const maxHourlyActivity = useMemo(() => {
- if (!stats) return 0;
- return Math.max(
- ...stats.bookmarkingActivity.byHour.map(
- (h: { hour: number; count: number }) => h.count,
- ),
- );
- }, [stats]);
-
- const maxDailyActivity = useMemo(() => {
- if (!stats) return 0;
- return Math.max(
- ...stats.bookmarkingActivity.byDayOfWeek.map(
- (d: { day: number; count: number }) => d.count,
- ),
- );
- }, [stats]);
-
if (isLoading) {
return (
<SettingsPage
@@ -217,391 +313,290 @@ export default function StatsPage() {
);
}
+ const locale = normalizeI18nLanguage(i18n.language);
+ const dayNames = getDayNames(locale);
+ const hourLabels = getHourLabels(locale);
+ const activityByDay = dayNames.map(
+ (_, day) =>
+ stats.bookmarkingActivity.byDayOfWeek.find((d) => d.day === day)?.count ??
+ 0,
+ );
+ const activityByHour = hourLabels.map(
+ (_, hour) =>
+ stats.bookmarkingActivity.byHour.find((h) => h.hour === hour)?.count ?? 0,
+ );
+ const maxHourCount = Math.max(...activityByHour);
+ const busiestHour =
+ maxHourCount > 0 ? activityByHour.indexOf(maxHourCount) : undefined;
+ const typeCounts = [
+ {
+ label: t("settings.stats.bookmark_types.links"),
+ value: stats.bookmarksByType.link,
+ icon: <Link className={sectionIconClass} />,
+ },
+ {
+ label: t("settings.stats.bookmark_types.text_notes"),
+ value: stats.bookmarksByType.text,
+ icon: <FileText className={sectionIconClass} />,
+ },
+ {
+ label: t("settings.stats.bookmark_types.assets"),
+ value: stats.bookmarksByType.asset,
+ icon: <Image className={sectionIconClass} />,
+ },
+ ];
+ const maxSourceCount = Math.max(
+ ...stats.bookmarksBySource.map((s) => s.count),
+ 0,
+ );
+ const topDomains = stats.topDomains.slice(0, 8);
+ const topTags = stats.tagUsage.slice(0, 8);
+ const timezoneNote = userSettings?.timezone &&
+ userSettings.timezone !== "UTC" && (
+ <span className="text-xs text-muted-foreground">
+ {userSettings.timezone}
+ </span>
+ );
+
return (
<SettingsPage
title={t("settings.stats.usage_statistics")}
- description="Insights into your bookmarking habits and collection"
+ description={t("settings.stats.insights_description")}
>
{/* Overview Stats */}
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<StatCard
title={t("settings.stats.overview.total_bookmarks")}
value={formatNumber(stats.numBookmarks)}
- icon={<BookOpen className="h-4 w-4 text-muted-foreground" />}
+ icon={<BookOpen className={sectionIconClass} />}
description={t("settings.stats.overview.all_saved_items")}
/>
<StatCard
title={t("settings.stats.overview.favorites")}
value={formatNumber(stats.numFavorites)}
- icon={<Heart className="h-4 w-4 text-muted-foreground" />}
+ icon={<Heart className={sectionIconClass} />}
description={t("settings.stats.overview.starred_bookmarks")}
/>
<StatCard
title={t("settings.stats.overview.archived")}
value={formatNumber(stats.numArchived)}
- icon={<Archive className="h-4 w-4 text-muted-foreground" />}
+ icon={<Archive className={sectionIconClass} />}
description={t("settings.stats.overview.archived_items")}
/>
<StatCard
title={t("settings.stats.overview.tags")}
value={formatNumber(stats.numTags)}
- icon={<Hash className="h-4 w-4 text-muted-foreground" />}
+ icon={<Hash className={sectionIconClass} />}
description={t("settings.stats.overview.unique_tags_created")}
/>
<StatCard
title={t("settings.stats.overview.lists")}
value={formatNumber(stats.numLists)}
- icon={<List className="h-4 w-4 text-muted-foreground" />}
+ icon={<List className={sectionIconClass} />}
description={t("settings.stats.overview.bookmark_collections")}
/>
<StatCard
title={t("settings.stats.overview.highlights")}
value={formatNumber(stats.numHighlights)}
- icon={<Highlighter className="h-4 w-4 text-muted-foreground" />}
+ icon={<Highlighter className={sectionIconClass} />}
description={t("settings.stats.overview.text_highlights")}
/>
<StatCard
title={t("settings.stats.overview.storage_used")}
value={formatBytes(stats.totalAssetSize)}
- icon={<Database className="h-4 w-4 text-muted-foreground" />}
+ icon={<Database className={sectionIconClass} />}
description={t("settings.stats.overview.total_asset_storage")}
/>
<StatCard
title={t("settings.stats.overview.this_month")}
value={formatNumber(stats.bookmarkingActivity.thisMonth)}
- icon={<TrendingUp className="h-4 w-4 text-muted-foreground" />}
+ icon={<TrendingUp className={sectionIconClass} />}
description={t("settings.stats.overview.bookmarks_added")}
/>
</div>
- <div className="grid gap-6 md:grid-cols-2">
- {/* Bookmark Types */}
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <BarChart3 className="h-5 w-5" />
- {t("settings.stats.bookmark_types.title")}
- </CardTitle>
- </CardHeader>
- <CardContent className="space-y-4">
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
- <Link className="h-4 w-4 text-blue-500" />
- <span className="text-sm">
- {t("settings.stats.bookmark_types.links")}
- </span>
+
+ {/* Recent Activity */}
+ <SectionCard
+ title={t("settings.stats.recent_activity.title")}
+ icon={<Clock className={sectionIconClass} />}
+ action={timezoneNote}
+ >
+ <div className="space-y-8">
+ <div className="grid grid-cols-3 divide-x rounded-lg border">
+ {[
+ {
+ label: t("settings.stats.recent_activity.this_week"),
+ value: stats.bookmarkingActivity.thisWeek,
+ },
+ {
+ label: t("settings.stats.recent_activity.this_month"),
+ value: stats.bookmarkingActivity.thisMonth,
+ },
+ {
+ label: t("settings.stats.recent_activity.this_year"),
+ value: stats.bookmarkingActivity.thisYear,
+ },
+ ].map(({ label, value }) => (
+ <div key={label} className="px-4 py-3">
+ <div className="text-2xl font-semibold tabular-nums tracking-tight">
+ {formatNumber(value)}
</div>
- <span className="text-sm font-medium">
- {stats.bookmarksByType.link}
- </span>
+ <div className="text-xs text-muted-foreground">{label}</div>
</div>
- <Progress
- value={
- stats.numBookmarks > 0
- ? (stats.bookmarksByType.link / stats.numBookmarks) * 100
- : 0
- }
- className="h-2"
+ ))}
+ </div>
+ <div className="grid gap-8 md:grid-cols-5">
+ <div className="md:col-span-2">
+ <ColumnChart
+ title={t("settings.stats.activity_patterns.activity_by_day")}
+ data={activityByDay}
+ labels={dayNames}
+ axisLabels={dayNames}
/>
</div>
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
- <FileText className="h-4 w-4 text-green-500" />
- <span className="text-sm">
- {t("settings.stats.bookmark_types.text_notes")}
- </span>
- </div>
- <span className="text-sm font-medium">
- {stats.bookmarksByType.text}
- </span>
- </div>
- <Progress
- value={
- stats.numBookmarks > 0
- ? (stats.bookmarksByType.text / stats.numBookmarks) * 100
- : 0
+ <div className="md:col-span-3">
+ <ColumnChart
+ title={t("settings.stats.activity_patterns.activity_by_hour")}
+ data={activityByHour}
+ labels={hourLabels}
+ axisLabels={[0, 6, 12, 18].map((hour) => hourLabels[hour])}
+ summary={
+ busiestHour !== undefined
+ ? t("settings.stats.activity_patterns.busiest_around", {
+ hour: hourLabels[busiestHour],
+ })
+ : undefined
}
- className="h-2"
/>
</div>
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <div className="flex items-center gap-2">
- <Image className="h-4 w-4 text-purple-500" />
- <span className="text-sm">
- {t("settings.stats.bookmark_types.assets")}
- </span>
- </div>
- <span className="text-sm font-medium">
- {stats.bookmarksByType.asset}
- </span>
- </div>
- <Progress
- value={
- stats.numBookmarks > 0
- ? (stats.bookmarksByType.asset / stats.numBookmarks) * 100
- : 0
- }
- className="h-2"
+ </div>
+ </div>
+ </SectionCard>
+
+ <div className="grid gap-4 md:grid-cols-2">
+ {/* Bookmark Types */}
+ <SectionCard
+ title={t("settings.stats.bookmark_types.title")}
+ icon={<PieChart className={sectionIconClass} />}
+ >
+ <div className="space-y-4">
+ {typeCounts.map((type) => (
+ <BarRow
+ key={type.label}
+ label={type.label}
+ value={type.value}
+ maxValue={stats.numBookmarks}
+ icon={type.icon}
/>
- </div>
- </CardContent>
- </Card>
+ ))}
+ </div>
+ </SectionCard>
- {/* Recent Activity */}
- <Card className="flex flex-col">
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Clock className="h-5 w-5" />
- {t("settings.stats.recent_activity.title")}
- </CardTitle>
- </CardHeader>
- <CardContent className="flex flex-1 items-center">
- <div className="grid w-full grid-cols-3 gap-4 text-center">
- <div>
- <div className="text-2xl font-bold text-green-600">
- {stats.bookmarkingActivity.thisWeek}
- </div>
- <div className="text-xs text-muted-foreground">
- {t("settings.stats.recent_activity.this_week")}
- </div>
- </div>
- <div>
- <div className="text-2xl font-bold text-blue-600">
- {stats.bookmarkingActivity.thisMonth}
- </div>
- <div className="text-xs text-muted-foreground">
- {t("settings.stats.recent_activity.this_month")}
- </div>
- </div>
- <div>
- <div className="text-2xl font-bold text-purple-600">
- {stats.bookmarkingActivity.thisYear}
- </div>
- <div className="text-xs text-muted-foreground">
- {t("settings.stats.recent_activity.this_year")}
- </div>
- </div>
+ {/* Bookmark Sources */}
+ <SectionCard
+ title={t("settings.stats.bookmark_sources.title")}
+ icon={<Zap className={sectionIconClass} />}
+ >
+ {stats.bookmarksBySource.length > 0 ? (
+ <div className="space-y-4">
+ {stats.bookmarksBySource.map((source) => (
+ <BarRow
+ key={source.source || "unknown"}
+ label={formatSourceName(source.source)}
+ value={source.count}
+ maxValue={maxSourceCount}
+ icon={getSourceIcon(source.source)}
+ />
+ ))}
</div>
- </CardContent>
- </Card>
+ ) : (
+ <p className="text-sm text-muted-foreground">
+ {t("settings.stats.bookmark_sources.empty")}
+ </p>
+ )}
+ </SectionCard>
{/* Top Domains */}
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Globe className="h-5 w-5" />
- {t("settings.stats.top_domains.title")}
- </CardTitle>
- </CardHeader>
- <CardContent>
- {stats.topDomains.length > 0 ? (
- <div className="space-y-3">
- {stats.topDomains
- .slice(0, 8)
- .map(
- (
- domain: { domain: string; count: number },
- index: number,
- ) => (
- <div
- key={domain.domain}
- className="flex items-center justify-between"
- >
- <div className="flex items-center gap-2">
- <div className="flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium">
- {index + 1}
- </div>
- <span
- className="max-w-[200px] truncate text-sm"
- title={domain.domain}
- >
- {domain.domain}
- </span>
- </div>
- <Badge variant="secondary">{domain.count}</Badge>
- </div>
- ),
- )}
- </div>
- ) : (
- <p className="text-sm text-muted-foreground">
- {t("settings.stats.top_domains.no_domains_found")}
- </p>
- )}
- </CardContent>
- </Card>
+ <SectionCard
+ title={t("settings.stats.top_domains.title")}
+ icon={<Globe className={sectionIconClass} />}
+ >
+ {topDomains.length > 0 ? (
+ <div className="space-y-4">
+ {topDomains.map((domain, index) => (
+ <BarRow
+ key={domain.domain}
+ rank={index + 1}
+ label={domain.domain}
+ value={domain.count}
+ maxValue={topDomains[0].count}
+ />
+ ))}
+ </div>
+ ) : (
+ <p className="text-sm text-muted-foreground">
+ {t("settings.stats.top_domains.no_domains_found")}
+ </p>
+ )}
+ </SectionCard>
{/* Top Tags */}
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Hash className="h-5 w-5" />
- {t("settings.stats.most_used_tags.title")}
- </CardTitle>
- </CardHeader>
- <CardContent>
- {stats.tagUsage.length > 0 ? (
- <div className="space-y-3">
- {stats.tagUsage
- .slice(0, 8)
- .map(
- (tag: { name: string; count: number }, index: number) => (
- <div
- key={tag.name}
- className="flex items-center justify-between"
- >
- <div className="flex items-center gap-2">
- <div className="flex h-6 w-6 items-center justify-center rounded-full bg-muted text-xs font-medium">
- {index + 1}
- </div>
- <span
- className="max-w-[200px] truncate text-sm"
- title={tag.name}
- >
- {tag.name}
- </span>
- </div>
- <Badge variant="secondary">{tag.count}</Badge>
- </div>
- ),
- )}
- </div>
- ) : (
- <p className="text-sm text-muted-foreground">
- {t("settings.stats.most_used_tags.no_tags_found")}
- </p>
- )}
- </CardContent>
- </Card>
-
- {/* Bookmark Sources */}
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Zap className="h-5 w-5" />
- {t("settings.stats.bookmark_sources.title")}
- </CardTitle>
- </CardHeader>
- <CardContent>
- {stats.bookmarksBySource.length > 0 ? (
- <div className="space-y-3">
- {stats.bookmarksBySource.map(
- (source: {
- source: BookmarkSource | null;
- count: number;
- }) => (
- <div
- key={source.source || "unknown"}
- className="flex items-center justify-between"
- >
- <div className="flex items-center gap-2">
- {getSourceIcon(source.source)}
- <span className="max-w-[200px] truncate text-sm">
- {formatSourceName(source.source)}
- </span>
- </div>
- <Badge variant="secondary">{source.count}</Badge>
- </div>
- ),
- )}
- </div>
- ) : (
- <p className="text-sm text-muted-foreground">
- {t("settings.stats.bookmark_sources.empty")}
- </p>
- )}
- </CardContent>
- </Card>
+ <SectionCard
+ title={t("settings.stats.most_used_tags.title")}
+ icon={<Hash className={sectionIconClass} />}
+ >
+ {topTags.length > 0 ? (
+ <div className="space-y-4">
+ {topTags.map((tag, index) => (
+ <BarRow
+ key={tag.name}
+ rank={index + 1}
+ label={tag.name}
+ value={tag.count}
+ maxValue={topTags[0].count}
+ />
+ ))}
+ </div>
+ ) : (
+ <p className="text-sm text-muted-foreground">
+ {t("settings.stats.most_used_tags.no_tags_found")}
+ </p>
+ )}
+ </SectionCard>
</div>
- {/* Activity Patterns */}
- <div className="grid gap-6 md:grid-cols-2">
- {/* Hourly Activity */}
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Clock className="h-5 w-5" />
- {t("settings.stats.activity_patterns.activity_by_hour")}
- {userSettings?.timezone && userSettings.timezone !== "UTC" && (
- <span className="text-xs font-normal text-muted-foreground">
- ({userSettings.timezone})
- </span>
- )}
- </CardTitle>
- </CardHeader>
- <CardContent>
- <SimpleBarChart
- data={stats.bookmarkingActivity.byHour.map(
- (h: { hour: number; count: number }) => h.count,
- )}
- maxValue={maxHourlyActivity}
- labels={hourLabels}
- />
- </CardContent>
- </Card>
- {/* Daily Activity */}
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <BarChart3 className="h-5 w-5" />
- {t("settings.stats.activity_patterns.activity_by_day")}
- {userSettings?.timezone && userSettings.timezone !== "UTC" && (
- <span className="text-xs font-normal text-muted-foreground">
- ({userSettings.timezone})
- </span>
- )}
- </CardTitle>
- </CardHeader>
- <CardContent>
- <SimpleBarChart
- data={stats.bookmarkingActivity.byDayOfWeek.map(
- (d: { day: number; count: number }) => d.count,
- )}
- maxValue={maxDailyActivity}
- labels={dayNames}
- />
- </CardContent>
- </Card>
- </div>
{/* Asset Storage */}
{stats.assetsByType.length > 0 && (
- <Card>
- <CardHeader>
- <CardTitle className="flex items-center gap-2">
- <Database className="h-5 w-5" />
- {t("settings.stats.storage_breakdown.title")}
- </CardTitle>
- </CardHeader>
- <CardContent>
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
- {stats.assetsByType.map(
- (asset: { type: string; count: number; totalSize: number }) => (
- <div key={asset.type} className="space-y-2">
- <div className="flex items-center justify-between">
- <span className="text-sm font-medium capitalize">
- {asset.type.replace(/([A-Z])/g, " $1").trim()}
- </span>
- <Badge variant="outline">{asset.count}</Badge>
- </div>
- <div className="text-xs text-muted-foreground">
- {formatBytes(asset.totalSize)}
- </div>
- <Progress
- value={
- stats.totalAssetSize > 0
- ? (asset.totalSize / stats.totalAssetSize) * 100
- : 0
- }
- className="h-2"
- />
- </div>
- ),
- )}
- </div>
- </CardContent>
- </Card>
+ <SectionCard
+ title={t("settings.stats.storage_breakdown.title")}
+ icon={<Database className={sectionIconClass} />}
+ >
+ <div className="grid gap-x-8 gap-y-4 md:grid-cols-2 lg:grid-cols-3">
+ {stats.assetsByType.map((asset) => (
+ <div key={asset.type} className="space-y-1.5">
+ <div className="flex items-center justify-between gap-3 text-sm">
+ <span className="truncate capitalize">
+ {asset.type.replace(/([A-Z])/g, " $1").trim()}
+ <span className="ml-2 text-xs tabular-nums text-muted-foreground">
+ {asset.count}
+ </span>
+ </span>
+ <span className="font-medium tabular-nums">
+ {formatBytes(asset.totalSize)}
+ </span>
+ </div>
+ <div className="h-1 overflow-hidden rounded-full bg-muted">
+ <div
+ className="h-full rounded-full bg-primary/40"
+ style={{
+ width: `${stats.totalAssetSize > 0 ? (asset.totalSize / stats.totalAssetSize) * 100 : 0}%`,
+ }}
+ />
+ </div>
+ </div>
+ ))}
+ </div>
+ </SectionCard>
)}
</SettingsPage>
);
diff --git a/apps/web/lib/i18n/locales/en/translation.json b/apps/web/lib/i18n/locales/en/translation.json
index 19ef81fb..66a8df6d 100644
--- a/apps/web/lib/i18n/locales/en/translation.json
+++ b/apps/web/lib/i18n/locales/en/translation.json
@@ -236,7 +236,8 @@
},
"activity_patterns": {
"activity_by_hour": "Activity by Hour",
- "activity_by_day": "Activity by Day"
+ "activity_by_day": "Activity by Day",
+ "busiest_around": "Busiest around {{hour}}"
},
"storage_breakdown": {
"title": "Storage Breakdown"