From 4c98d143527b388a1211d7e4fe747355b20c6680 Mon Sep 17 00:00:00 2001 From: Philipp Date: Thu, 21 May 2026 09:20:10 +0200 Subject: [PATCH] added frontent viewer for snapshot --- .../src/components/SnapshotFilesPanel.jsx | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 frontend/src/components/SnapshotFilesPanel.jsx diff --git a/frontend/src/components/SnapshotFilesPanel.jsx b/frontend/src/components/SnapshotFilesPanel.jsx new file mode 100644 index 0000000..660b5eb --- /dev/null +++ b/frontend/src/components/SnapshotFilesPanel.jsx @@ -0,0 +1,74 @@ +import { File, Folder } from 'lucide-react'; + +export function SnapshotFilesPanel({ files, loading, onClose, snapshot }) { + if (!snapshot) return null; + + return ( +
+
+
+

Snapshot Contents

+

{snapshot.id.slice(0, 8)}

+
+ +
+
+ + + + + + + + + + + {files.map((entry) => ( + + + + + + + ))} + {!files.length ? ( + + + + ) : null} + +
PathTypeSizeModified
+ + {entry.type === 'dir' ? : } + {entry.path} + + {entry.type}{entry.type === 'dir' ? '-' : formatBytes(entry.size)}{formatTime(entry.mtime)}
+ {loading ? 'Loading snapshot contents...' : 'No files found.'} +
+
+
+ ); +} + +function formatBytes(value) { + if (!value) return '0 B'; + const units = ['B', 'KiB', 'MiB', 'GiB', 'TiB']; + let size = Number(value); + let unitIndex = 0; + while (size >= 1024 && unitIndex < units.length - 1) { + size /= 1024; + unitIndex += 1; + } + return `${size.toFixed(unitIndex === 0 ? 0 : 1)} ${units[unitIndex]}`; +} + +function formatTime(value) { + if (!value) return '-'; + return new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'medium' }).format(new Date(value)); +}