feat: attachments panel, file previews, print preview and history (#34)

Documents need to show, upload and generate their files from the interface,
and users need to see who changed a record. This adds the attachment list
(upload, preview, download, lock, trash and restore, older versions, ZIP,
generate/regenerate), in-app previews for PDF, images, XML, text, CSV and
XLSX, an A4 print preview with "save as attachment", and an audit history
list read through a permission-checked AuditTrailService.

Files are served by /files endpoints that require a signed-in user and the
company permissions; only PDF and images open inline, with their own CSP
that allows framing by this site only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 19:59:37 +01:00
1 parent f415dc37a8
commit 8198e0a754
20 files changed
+1786 -24

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
using System.Globalization;
namespace Khaemhat.Web.Ui;
/// <summary>File sizes as people read them: <c>840 B</c>, <c>184 KB</c>, <c>1,2 MB</c>.</summary>
public static class FileSizes
{
private static readonly string[] Units = ["B", "KB", "MB", "GB", "TB"];
/// <summary>Formats a size in bytes (1 KB = 1024 B).</summary>
/// <param name="bytes">The size.</param>
/// <param name="culture">The culture of the decimal separator.</param>
/// <returns>The text.</returns>
public static string Format(long bytes, CultureInfo culture)
{
ArgumentNullException.ThrowIfNull(culture);
double value = Math.Max(0, bytes);
var unit = 0;
while (value >= 1024 && unit < Units.Length - 1)
{
value /= 1024;
unit++;
}
var format = unit == 0 || value >= 10 ? "0" : "0.#";
return value.ToString(format, culture) + " " + Units[unit];
}
}