Reapply "Add missing admin action files and navigation links"
This reverts commit 4d515bc400.
This commit is contained in:
1 parent
96ed768f14
commit
5b4228261a
338 files changed
+28143
-5948
No files matched your search
+69
-18
@@ -25,8 +25,7 @@ export default async function AdminDashboard() {
|
||||
prisma.websiteArticles.count(),
|
||||
prisma.ban.count({ where: { banExpire: { gt: Math.floor(Date.now() / 1000) } } }),
|
||||
]);
|
||||
} catch {
|
||||
}
|
||||
} catch {}
|
||||
const dbOk = users >= 0;
|
||||
|
||||
const rankGroups = await prisma.user
|
||||
@@ -62,26 +61,64 @@ export default async function AdminDashboard() {
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-8">
|
||||
<StatusCard label={t("playersOnline")} value={online} hint={dbOk ? t("totalAccounts", { count: users }) : t("databaseDown")} state={dbOk ? "neutral" : "danger"} icon={<Users size={18} />} />
|
||||
<StatusCard label={t("articles")} value={dbOk ? articles : "—"} state="neutral" icon={<Newspaper size={18} />} />
|
||||
<StatusCard label={t("activeBans")} value={dbOk ? bans : "—"} state={bans > 0 ? "warn" : "neutral"} icon={<Ban size={18} />} />
|
||||
<StatusCard label={t("database")} value={dbOk ? t("databaseConnected") : t("databaseDown")} state={dbOk ? "ok" : "danger"} icon={<Database size={18} />} />
|
||||
<StatusCard
|
||||
label={t("playersOnline")}
|
||||
value={online}
|
||||
hint={dbOk ? t("totalAccounts", { count: users }) : t("databaseDown")}
|
||||
state={dbOk ? "neutral" : "danger"}
|
||||
icon={<Users size={18} />}
|
||||
/>
|
||||
<StatusCard
|
||||
label={t("articles")}
|
||||
value={dbOk ? articles : "—"}
|
||||
state="neutral"
|
||||
icon={<Newspaper size={18} />}
|
||||
/>
|
||||
<StatusCard
|
||||
label={t("activeBans")}
|
||||
value={dbOk ? bans : "—"}
|
||||
state={bans > 0 ? "warn" : "neutral"}
|
||||
icon={<Ban size={18} />}
|
||||
/>
|
||||
<StatusCard
|
||||
label={t("database")}
|
||||
value={dbOk ? t("databaseConnected") : t("databaseDown")}
|
||||
state={dbOk ? "ok" : "danger"}
|
||||
icon={<Database size={18} />}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<section className="admin-card p-5">
|
||||
<h2 className="text-sm font-bold text-[var(--color-text)] mb-4 admin-section-title">{t("usersByRank")}</h2>
|
||||
<h2 className="text-sm font-bold text-[var(--color-text)] mb-4 admin-section-title">
|
||||
{t("usersByRank")}
|
||||
</h2>
|
||||
{rankCounts.length === 0 ? (
|
||||
<p className="text-xs text-[var(--color-text-muted)]">{dbOk ? t("noAccountsToBreakDown") : t("databaseDown")}</p>
|
||||
<p className="text-xs text-[var(--color-text-muted)]">
|
||||
{dbOk ? t("noAccountsToBreakDown") : t("databaseDown")}
|
||||
</p>
|
||||
) : (
|
||||
<div className="space-y-2.5">
|
||||
{rankCounts.map((r) => {
|
||||
const pct = maxRankCount > 0 ? Math.round((r.count / maxRankCount) * 100) : 0;
|
||||
return (
|
||||
<div key={r.rank} className="grid items-center gap-3" style={{ gridTemplateColumns: "5rem 1fr 2.5rem" }}>
|
||||
<span className="text-xs font-medium text-[var(--color-text-muted)]">{t("rankLabel", { rank: r.rank })}</span>
|
||||
<div className="h-3 rounded-md overflow-hidden bg-[var(--color-primary)]/10" role="img" aria-label={t("rankWithCount", { rank: r.rank, count: r.count })}>
|
||||
<div className="h-full rounded-md bg-gradient-to-r from-[var(--color-primary)] to-[var(--color-primary-hover)] transition-all duration-500" style={{ width: `${Math.max(pct, r.count > 0 ? 4 : 0)}%` }} />
|
||||
<div
|
||||
key={r.rank}
|
||||
className="grid items-center gap-3"
|
||||
style={{ gridTemplateColumns: "5rem 1fr 2.5rem" }}
|
||||
>
|
||||
<span className="text-xs font-medium text-[var(--color-text-muted)]">
|
||||
{t("rankLabel", { rank: r.rank })}
|
||||
</span>
|
||||
<div
|
||||
className="h-3 rounded-md overflow-hidden bg-[var(--color-primary)]/10"
|
||||
role="img"
|
||||
aria-label={t("rankWithCount", { rank: r.rank, count: r.count })}
|
||||
>
|
||||
<div
|
||||
className="h-full rounded-md bg-gradient-to-r from-[var(--color-primary)] to-[var(--color-primary-hover)] transition-all duration-500"
|
||||
style={{ width: `${Math.max(pct, r.count > 0 ? 4 : 0)}%` }}
|
||||
/>
|
||||
</div>
|
||||
<strong className="text-xs text-right text-[var(--color-text-muted)]">{r.count}</strong>
|
||||
</div>
|
||||
@@ -93,8 +130,13 @@ export default async function AdminDashboard() {
|
||||
|
||||
<section className="admin-card p-5">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h2 className="text-sm font-bold text-[var(--color-text)] admin-section-title">{t("recentStaffActivity")}</h2>
|
||||
<Link href="/admin/commandocentrum" className="text-xs font-medium text-[var(--color-primary)] hover:text-[var(--color-primary-hover)] flex items-center gap-1 no-underline">
|
||||
<h2 className="text-sm font-bold text-[var(--color-text)] admin-section-title">
|
||||
{t("recentStaffActivity")}
|
||||
</h2>
|
||||
<Link
|
||||
href="/admin/commandocentrum"
|
||||
className="text-xs font-medium text-[var(--color-primary)] hover:text-[var(--color-primary-hover)] flex items-center gap-1 no-underline"
|
||||
>
|
||||
{t("viewAll")} <ArrowRight size={12} />
|
||||
</Link>
|
||||
</div>
|
||||
@@ -103,17 +145,26 @@ export default async function AdminDashboard() {
|
||||
) : (
|
||||
<div className="space-y-0">
|
||||
{activity.map((a, i) => (
|
||||
<div key={String(a.id)} className={`flex items-center gap-3 py-2.5 ${i > 0 ? "border-t border-[var(--border-subtle)]" : ""}`}>
|
||||
<div
|
||||
key={String(a.id)}
|
||||
className={`flex items-center gap-3 py-2.5 ${i > 0 ? "border-t border-[var(--border-subtle)]" : ""}`}
|
||||
>
|
||||
<div className="w-7 h-7 rounded-full bg-[var(--color-primary)]/10 grid place-items-center flex-none">
|
||||
<Activity size={12} className="text-[var(--color-primary)]" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="text-sm font-medium text-[var(--color-text)] truncate">{nameById.get(Number(a.userId)) ?? `#${a.userId}`}</div>
|
||||
<div className="text-sm font-medium text-[var(--color-text)] truncate">
|
||||
{nameById.get(Number(a.userId)) ?? `#${a.userId}`}
|
||||
</div>
|
||||
<div className="text-xs text-[var(--color-text-muted)] truncate">{a.description}</div>
|
||||
</div>
|
||||
<div className="text-right flex-none">
|
||||
<span className="inline-block text-[0.6rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)] admin-card inline-flex items-center justify-center min-w-[60px]">{a.action}</span>
|
||||
<div className="text-[0.6rem] text-[var(--color-text-muted)] mt-0.5">{fromDate(a.createdAt)}</div>
|
||||
<span className="inline-block text-[0.6rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)] admin-card inline-flex items-center justify-center min-w-[60px]">
|
||||
{a.action}
|
||||
</span>
|
||||
<div className="text-[0.6rem] text-[var(--color-text-muted)] mt-0.5">
|
||||
{fromDate(a.createdAt)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in new issue
Block a user