Improve media manager UI: search, delete, drag-and-drop, file meta
Local Build and Deploy / deploy (push) Successful in 1m21s

Add a richer media manager with filename search, per-file delete with
confirmation, drag-and-drop uploads, copy-URL feedback, file size/type/date
metadata, and server-side upload validation that returns errors to the UI.
Extend the /api/media listing with size and uploaded timestamps.
This commit is contained in:
openhands committed 2026-07-18 17:29:01 +02:00
1 parent 6a20ccda5c
commit a07d438987
4 files changed
+214 -70

No files matched your search

+7 -9
View File
@@ -1,4 +1,3 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { AdminMediaGrid } from "@/components/admin/media-grid";
import { redirect } from "next/navigation";
@@ -14,14 +13,13 @@ export default async function AdminMediaPage() {
return (
<main>
<div className="flex justify-end mb-6">
<Link
href="/admin/articles"
className="text-sm theme-text-muted dark:theme-text-muted"
style={{ fontSize: "0.88rem" }}
>
← {t("articles")}
</Link>
<div className="mb-6">
<h1 className="m-0 text-2xl font-extrabold text-[var(--admin-text)]">
{t("title")}
</h1>
<p className="m-0 text-sm text-[var(--admin-text-muted)] mt-1">
{t("subtitle")}
</p>
</div>
<AdminMediaGrid />
</main>
+12 -7
View File
@@ -1,5 +1,5 @@
import { existsSync, readdirSync } from "node:fs";
import path from "node:path";
import { existsSync, readdirSync, statSync } from "node:fs";
import { resolve } from "node:path";
import { NextResponse } from "next/server";
import { MEDIA_ROOT } from "@/lib/media-storage";
@@ -14,11 +14,16 @@ export async function GET() {
// eslint-disable-next-line security/detect-non-literal-fs-filename
const files = readdirSync(dir)
.filter((f) => /\.(png|jpg|jpeg|gif|webp|svg|bmp)$/i.test(f))
.map((f) => ({
name: f,
url: `/api/media/${f}`,
}))
.sort((a, b) => a.name.localeCompare(b.name));
.map((f) => {
const stat = statSync(resolve(dir, f));
return {
name: f,
url: `/api/media/${f}`,
size: stat.size,
uploaded: stat.mtimeMs,
};
})
.sort((a, b) => b.uploaded - a.uploaded);
return NextResponse.json({ files });
}