diff --git a/expressjs/src/server.js b/expressjs/src/server.js index 287d873..09c53f7 100644 --- a/expressjs/src/server.js +++ b/expressjs/src/server.js @@ -317,7 +317,7 @@ function renderFileManagerPage(title, body) { ${title} @@ -743,8 +754,8 @@ app.get(`${basePath}/admin/dashboard`, requireAdminPage, async (req, res) => {
Systemstatistiken und Logs
- Dateimanager - Benutzer verwalten + Dateimanager + Benutzer verwalten
${csrfField(res.locals.csrfToken)} @@ -937,11 +948,31 @@ app.get(`${basePath}/admin/files`, requireAdminPage, async (req, res) => { const parentPath = relativePath ? relativePath.split('/').slice(0, -1).join('/') : ''; - const dirs = entries.filter((entry) => entry.isDirectory() && entry.name !== '_share'); - const files = entries.filter((entry) => !entry.isDirectory() && entry.name !== '_share'); + const filtered = entries.filter((entry) => entry.name !== '_share'); + const details = await Promise.all( + filtered.map(async (entry) => { + const childPath = relativePath ? `${relativePath}/${entry.name}` : entry.name; + let stat = null; + try { + stat = await fs.promises.stat(path.join(resolved, entry.name)); + } catch (err) { + stat = null; + } + return { + entry, + childPath, + isDir: entry.isDirectory(), + size: stat && stat.isFile() ? stat.size : null, + modifiedAt: stat ? stat.mtimeMs : null, + }; + }) + ); - const rowForEntry = (entry, isDir) => { - const childPath = relativePath ? `${relativePath}/${entry.name}` : entry.name; + const dirs = details.filter((item) => item.isDir); + const files = details.filter((item) => !item.isDir); + + const rowForEntry = (item) => { + const { entry, childPath, isDir, size, modifiedAt } = item; const href = baseUrl(`/admin/files?path=${encodeURIComponent(childPath)}`); const escapedName = escapeHtml(entry.name); const escapedPath = escapeHtml(childPath); @@ -954,26 +985,19 @@ app.get(`${basePath}/admin/files`, requireAdminPage, async (req, res) => { ${isDir ? 'Ordner' : 'Datei'} + ${size ? formatBytes(size) : '—'} + ${modifiedAt ? formatTimestamp(modifiedAt) : '—'} - - ${csrfField(res.locals.csrfToken)} - - - -
-
- ${csrfField(res.locals.csrfToken)} - - -
+ + `; }; const tableRows = [ - ...dirs.map((entry) => rowForEntry(entry, true)), - ...files.map((entry) => rowForEntry(entry, false)), + ...dirs.map((entry) => rowForEntry(entry)), + ...files.map((entry) => rowForEntry(entry)), ].join(''); const body = ` @@ -991,37 +1015,43 @@ app.get(`${basePath}/admin/files`, requireAdminPage, async (req, res) => {
-
-
+
+
Pfad /${escapeHtml(relativePath || '')} - ${relativePath ? `← Zurück` : ''} + ${relativePath ? `← Zurück` : ''} +
+ Position: + ${relativePath ? relativePath.split('/').map((segment, idx, parts) => { + const crumbPath = parts.slice(0, idx + 1).join('/'); + return `${escapeHtml(segment)}`; + }).join('/') : 'Root'} +
-
- -
-
-

Ordner erstellen

-
- ${csrfField(res.locals.csrfToken)} - - - -
-
-
-

Datei hochladen

-
- ${csrfField(res.locals.csrfToken)} - - - -
+
+
+

Ordner erstellen

+
+ ${csrfField(res.locals.csrfToken)} + + + +
+
+
+

Datei hochladen

+
+ ${csrfField(res.locals.csrfToken)} + + + +
+
@@ -1033,6 +1063,8 @@ app.get(`${basePath}/admin/files`, requireAdminPage, async (req, res) => { Name Typ + Größe + Geändert Aktionen @@ -1042,6 +1074,70 @@ app.get(`${basePath}/admin/files`, requireAdminPage, async (req, res) => { ` : '
Keine Eintraege in diesem Ordner.
'}
+ + +
+ ${csrfField(res.locals.csrfToken)} + +

Umbenennen

+
+ +
+ + +
+
+
+ + +
+ ${csrfField(res.locals.csrfToken)} + +

Löschen

+
+
+ + +
+
+
+ + `; res.send(renderFileManagerPage('Admin-Dateien', body));