feat(11-02): add optional ReportBranding parameter to all 5 HTML export services
- Added ReportBranding? branding = null to BuildHtml on all 5 services - Added ReportBranding? branding = null after CancellationToken ct on all WriteAsync overloads - Injected BrandingHtmlHelper.BuildBrandingHeader(branding) between <body> and <h1> in each - StorageHtmlExportService both overloads updated (nodes-only and nodes+fileTypeMetrics) - HtmlExportService both overloads updated (PermissionEntry and SimplifiedPermissionEntry) - Build passes with 0 warnings — all existing callers compile unchanged via default null
This commit is contained in:
@@ -10,7 +10,7 @@ namespace SharepointToolbox.Services.Export;
|
||||
/// </summary>
|
||||
public class DuplicatesHtmlExportService
|
||||
{
|
||||
public string BuildHtml(IReadOnlyList<DuplicateGroup> groups)
|
||||
public string BuildHtml(IReadOnlyList<DuplicateGroup> groups, ReportBranding? branding = null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
@@ -52,6 +52,9 @@ public class DuplicatesHtmlExportService
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
""");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("""
|
||||
<h1>Duplicate Detection Report</h1>
|
||||
""");
|
||||
|
||||
@@ -117,9 +120,9 @@ public class DuplicatesHtmlExportService
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public async Task WriteAsync(IReadOnlyList<DuplicateGroup> groups, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<DuplicateGroup> groups, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(groups);
|
||||
var html = BuildHtml(groups, branding);
|
||||
await System.IO.File.WriteAllTextAsync(filePath, html, Encoding.UTF8, ct);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class HtmlExportService
|
||||
/// Builds a self-contained HTML string from the supplied permission entries.
|
||||
/// Includes inline CSS, inline JS filter, stats cards, type badges, unique/inherited badges, and user pills.
|
||||
/// </summary>
|
||||
public string BuildHtml(IReadOnlyList<PermissionEntry> entries)
|
||||
public string BuildHtml(IReadOnlyList<PermissionEntry> entries, ReportBranding? branding = null)
|
||||
{
|
||||
// Compute stats
|
||||
var totalEntries = entries.Count;
|
||||
@@ -73,6 +73,7 @@ a:hover { text-decoration: underline; }
|
||||
|
||||
// ── BODY ───────────────────────────────────────────────────────────────
|
||||
sb.AppendLine("<body>");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("<h1>SharePoint Permissions Report</h1>");
|
||||
|
||||
// Stats cards
|
||||
@@ -148,9 +149,9 @@ a:hover { text-decoration: underline; }
|
||||
/// <summary>
|
||||
/// Writes the HTML report to the specified file path using UTF-8 without BOM.
|
||||
/// </summary>
|
||||
public async Task WriteAsync(IReadOnlyList<PermissionEntry> entries, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<PermissionEntry> entries, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(entries);
|
||||
var html = BuildHtml(entries, branding);
|
||||
await File.WriteAllTextAsync(filePath, html, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), ct);
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ a:hover { text-decoration: underline; }
|
||||
/// Builds a self-contained HTML string from simplified permission entries.
|
||||
/// Includes risk-level summary cards, color-coded rows, and simplified labels column.
|
||||
/// </summary>
|
||||
public string BuildHtml(IReadOnlyList<SimplifiedPermissionEntry> entries)
|
||||
public string BuildHtml(IReadOnlyList<SimplifiedPermissionEntry> entries, ReportBranding? branding = null)
|
||||
{
|
||||
var summaries = PermissionSummaryBuilder.Build(entries);
|
||||
|
||||
@@ -228,6 +229,7 @@ a:hover { text-decoration: underline; }
|
||||
sb.AppendLine("</head>");
|
||||
|
||||
sb.AppendLine("<body>");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("<h1>SharePoint Permissions Report (Simplified)</h1>");
|
||||
|
||||
// Stats cards
|
||||
@@ -317,9 +319,9 @@ a:hover { text-decoration: underline; }
|
||||
/// <summary>
|
||||
/// Writes the simplified HTML report to the specified file path.
|
||||
/// </summary>
|
||||
public async Task WriteAsync(IReadOnlyList<SimplifiedPermissionEntry> entries, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<SimplifiedPermissionEntry> entries, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(entries);
|
||||
var html = BuildHtml(entries, branding);
|
||||
await File.WriteAllTextAsync(filePath, html, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), ct);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace SharepointToolbox.Services.Export;
|
||||
/// </summary>
|
||||
public class SearchHtmlExportService
|
||||
{
|
||||
public string BuildHtml(IReadOnlyList<SearchResult> results)
|
||||
public string BuildHtml(IReadOnlyList<SearchResult> results, ReportBranding? branding = null)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
@@ -43,6 +43,9 @@ public class SearchHtmlExportService
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
""");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("""
|
||||
<h1>File Search Results</h1>
|
||||
<div class="toolbar">
|
||||
<label for="filterInput">Filter:</label>
|
||||
@@ -135,9 +138,9 @@ public class SearchHtmlExportService
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public async Task WriteAsync(IReadOnlyList<SearchResult> results, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<SearchResult> results, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(results);
|
||||
var html = BuildHtml(results, branding);
|
||||
await System.IO.File.WriteAllTextAsync(filePath, html, Encoding.UTF8, ct);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class StorageHtmlExportService
|
||||
{
|
||||
private int _togIdx;
|
||||
|
||||
public string BuildHtml(IReadOnlyList<StorageNode> nodes)
|
||||
public string BuildHtml(IReadOnlyList<StorageNode> nodes, ReportBranding? branding = null)
|
||||
{
|
||||
_togIdx = 0;
|
||||
var sb = new StringBuilder();
|
||||
@@ -48,6 +48,9 @@ public class StorageHtmlExportService
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
""");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("""
|
||||
<h1>SharePoint Storage Metrics</h1>
|
||||
""");
|
||||
|
||||
@@ -99,7 +102,7 @@ public class StorageHtmlExportService
|
||||
/// <summary>
|
||||
/// Builds an HTML report including a file-type breakdown chart section.
|
||||
/// </summary>
|
||||
public string BuildHtml(IReadOnlyList<StorageNode> nodes, IReadOnlyList<FileTypeMetric> fileTypeMetrics)
|
||||
public string BuildHtml(IReadOnlyList<StorageNode> nodes, IReadOnlyList<FileTypeMetric> fileTypeMetrics, ReportBranding? branding = null)
|
||||
{
|
||||
_togIdx = 0;
|
||||
var sb = new StringBuilder();
|
||||
@@ -145,6 +148,9 @@ public class StorageHtmlExportService
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
""");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("""
|
||||
<h1>SharePoint Storage Metrics</h1>
|
||||
""");
|
||||
|
||||
@@ -227,15 +233,15 @@ public class StorageHtmlExportService
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public async Task WriteAsync(IReadOnlyList<StorageNode> nodes, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<StorageNode> nodes, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(nodes);
|
||||
var html = BuildHtml(nodes, branding);
|
||||
await File.WriteAllTextAsync(filePath, html, Encoding.UTF8, ct);
|
||||
}
|
||||
|
||||
public async Task WriteAsync(IReadOnlyList<StorageNode> nodes, IReadOnlyList<FileTypeMetric> fileTypeMetrics, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<StorageNode> nodes, IReadOnlyList<FileTypeMetric> fileTypeMetrics, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(nodes, fileTypeMetrics);
|
||||
var html = BuildHtml(nodes, fileTypeMetrics, branding);
|
||||
await File.WriteAllTextAsync(filePath, html, Encoding.UTF8, ct);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class UserAccessHtmlExportService
|
||||
/// <summary>
|
||||
/// Builds a self-contained HTML string from the supplied user access entries.
|
||||
/// </summary>
|
||||
public string BuildHtml(IReadOnlyList<UserAccessEntry> entries)
|
||||
public string BuildHtml(IReadOnlyList<UserAccessEntry> entries, ReportBranding? branding = null)
|
||||
{
|
||||
// Compute stats
|
||||
var totalAccesses = entries.Count;
|
||||
@@ -88,6 +88,7 @@ a:hover { text-decoration: underline; }
|
||||
|
||||
// ── BODY ───────────────────────────────────────────────────────────────
|
||||
sb.AppendLine("<body>");
|
||||
sb.Append(BrandingHtmlHelper.BuildBrandingHeader(branding));
|
||||
sb.AppendLine("<h1>User Access Audit Report</h1>");
|
||||
|
||||
// Stats cards
|
||||
@@ -320,9 +321,9 @@ function sortTable(view, col) {
|
||||
/// <summary>
|
||||
/// Writes the HTML report to the specified file path using UTF-8 without BOM.
|
||||
/// </summary>
|
||||
public async Task WriteAsync(IReadOnlyList<UserAccessEntry> entries, string filePath, CancellationToken ct)
|
||||
public async Task WriteAsync(IReadOnlyList<UserAccessEntry> entries, string filePath, CancellationToken ct, ReportBranding? branding = null)
|
||||
{
|
||||
var html = BuildHtml(entries);
|
||||
var html = BuildHtml(entries, branding);
|
||||
await File.WriteAllTextAsync(filePath, html, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), ct);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user