Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

reporting: fit and wrap operator-controlled cover title and brand lines

rcourtman4c37a8c33239
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 7ca4b7a59b..5ec8f69bc5 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -104,7 +104,6 @@ work extends shared components instead of creating new local variants.
71. `frontend-modern/src/utils/systemLogsPresentation.ts`
72. `frontend-modern/src/components/Settings/__tests__/SystemLogsPanel.test.tsx`
73. `frontend-modern/src/components/Settings/ResourcePicker.tsx`
-74. `frontend-modern/src/components/Settings/reportingResourceTypes.ts`
75. `frontend-modern/src/utils/reportableResourceTypes.ts`
76. `frontend-modern/src/utils/reportingResourceTypes.ts`
77. `frontend-modern/src/utils/workloadEmptyStatePresentation.ts`
@@ -3886,9 +3885,9 @@ request/range/filename model and reporting-type API mapping,
`frontend-modern/src/utils/reportableResourceTypes.ts` own the reportable
resource selection, filter, sort, and empty-state contract, and
`frontend-modern/src/utils/reportingPresentation.ts` owns the user-facing
-range/status copy. The compatibility re-export in
-`frontend-modern/src/components/Settings/reportingResourceTypes.ts` stays part
-of that same reporting boundary. Native Kubernetes inventory-only resource
+range/status copy. Consumers import `@/utils/reportingResourceTypes` directly;
+the former one-line compatibility re-export under `components/Settings/` was
+removed as dead code once its last importer moved. Native Kubernetes inventory-only resource
types, including ReplicaSets, EndpointSlices, NetworkPolicies, StorageClasses,
ConfigMaps, Secrets, ServiceAccounts, Roles, ClusterRoles, RoleBindings,
ClusterRoleBindings, ResourceQuotas, LimitRanges, PodDisruptionBudgets, and
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index c41d127557..bc4160a58f 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -3761,7 +3761,6 @@
"frontend-modern/src/components/Settings/RecoverySettingsPanel.tsx",
"frontend-modern/src/components/Settings/ReportingPanel.tsx",
"frontend-modern/src/components/Settings/reportingPanelModel.ts",
- "frontend-modern/src/components/Settings/reportingResourceTypes.ts",
"frontend-modern/src/components/Settings/ResourcePicker.tsx",
"frontend-modern/src/components/Settings/SecurityAuthPanel.tsx",
"frontend-modern/src/components/Settings/SecurityOverviewPanel.tsx",
@@ -4034,7 +4033,6 @@
"frontend-modern/scripts/header-audit.mjs",
"frontend-modern/src/components/Settings/ReportingPanel.tsx",
"frontend-modern/src/components/Settings/reportingPanelModel.ts",
- "frontend-modern/src/components/Settings/reportingResourceTypes.ts",
"frontend-modern/src/components/Settings/ResourcePicker.tsx",
"frontend-modern/src/components/Settings/SystemLogsPanel.tsx",
"frontend-modern/src/components/Settings/useReportingPanelState.ts",
diff --git a/pkg/reporting/pdf.go b/pkg/reporting/pdf.go
index ac6c009e6e..b1db00fdc1 100644
--- a/pkg/reporting/pdf.go
+++ b/pkg/reporting/pdf.go
@@ -46,6 +46,32 @@ func reportCoverBrandName(brand *ReportBrand) string {
return "PULSE"
}
+// setCoverFontToFit sets an Arial font at baseSize, then shrinks it until
+// text fits within maxWidth or minSize is reached. Cover title and brand
+// lines carry operator-controlled text, so they cannot assume a width.
+func setCoverFontToFit(pdf *fpdf.Fpdf, style, text string, baseSize, minSize, maxWidth float64) {
+ size := baseSize
+ pdf.SetFont("Arial", style, size)
+ for size > minSize && pdf.GetStringWidth(text) > maxWidth {
+ size--
+ pdf.SetFontSize(size)
+ }
+}
+
+// writeCoverLine draws one centered cover line, shrinking the font to fit
+// and wrapping onto extra lines when the minimum size still overflows.
+func writeCoverLine(pdf *fpdf.Fpdf, text string, lineHeight, baseSize, minSize float64, style string) {
+ pageWidth, _ := pdf.GetPageSize()
+ left, _, right, _ := pdf.GetMargins()
+ maxWidth := pageWidth - left - right
+ setCoverFontToFit(pdf, style, text, baseSize, minSize, maxWidth)
+ if pdf.GetStringWidth(text) > maxWidth {
+ pdf.MultiCell(0, lineHeight*0.8, text, "", "C", false)
+ return
+ }
+ pdf.CellFormat(0, lineHeight, text, "", 1, "C", false, 0, "")
+}
+
func reportHeaderBrandName(brand *ReportBrand, fallback string) string {
if brand != nil && strings.TrimSpace(brand.DisplayName) != "" {
return strings.ToUpper(strings.TrimSpace(brand.DisplayName))
@@ -363,9 +389,8 @@ func (g *PDFGenerator) writeCoverPage(pdf *fpdf.Fpdf, data *ReportData) {
} else {
pdf.SetY(50)
}
- pdf.SetFont("Arial", "B", 32)
pdf.SetTextColor(colorPrimary[0], colorPrimary[1], colorPrimary[2])
- pdf.CellFormat(0, 15, reportCoverBrandName(data.Brand), "", 1, "C", false, 0, "")
+ writeCoverLine(pdf, reportCoverBrandName(data.Brand), 15, 32, 20, "B")
pdf.SetFont("Arial", "", 12)
pdf.SetTextColor(colorTextMuted[0], colorTextMuted[1], colorTextMuted[2])
@@ -1849,9 +1874,8 @@ func (g *PDFGenerator) writeMultiCoverPage(pdf *fpdf.Fpdf, data *MultiReportData
} else {
pdf.SetY(50)
}
- pdf.SetFont("Arial", "B", 32)
pdf.SetTextColor(colorPrimary[0], colorPrimary[1], colorPrimary[2])
- pdf.CellFormat(0, 15, reportCoverBrandName(data.Brand), "", 1, "C", false, 0, "")
+ writeCoverLine(pdf, reportCoverBrandName(data.Brand), 15, 32, 20, "B")
pdf.SetFont("Arial", "", 12)
pdf.SetTextColor(colorTextMuted[0], colorTextMuted[1], colorTextMuted[2])
@@ -1859,12 +1883,16 @@ func (g *PDFGenerator) writeMultiCoverPage(pdf *fpdf.Fpdf, data *MultiReportData
// Main title
pdf.SetY(100)
- pdf.SetFont("Arial", "B", 28)
pdf.SetTextColor(colorTextDark[0], colorTextDark[1], colorTextDark[2])
- pdf.CellFormat(0, 12, data.Title, "", 1, "C", false, 0, "")
+ writeCoverLine(pdf, data.Title, 12, 28, 16, "B")
- // Subtitle with counts
- pdf.SetY(120)
+ // Subtitle with counts. A wrapped title can run past the fixed band, so
+ // keep the subtitle below whatever the title actually used.
+ subtitleY := 120.0
+ if y := pdf.GetY() + 4; y > subtitleY {
+ subtitleY = y
+ }
+ pdf.SetY(subtitleY)
pdf.SetFont("Arial", "", 14)
pdf.SetTextColor(colorTextMuted[0], colorTextMuted[1], colorTextMuted[2])
@@ -1874,8 +1902,12 @@ func (g *PDFGenerator) writeMultiCoverPage(pdf *fpdf.Fpdf, data *MultiReportData
subtitle := fmt.Sprintf("%d Resources | %s", len(data.Resources), durationStr)
pdf.CellFormat(0, 8, subtitle, "", 1, "C", false, 0, "")
- // Scope box
- pdf.SetY(140)
+ // Scope box, kept below the flexible title/subtitle block
+ scopeY := 140.0
+ if y := pdf.GetY() + 8; y > scopeY {
+ scopeY = y
+ }
+ pdf.SetY(scopeY)
boxX := 40.0
boxWidth := pageWidth - 80
boxHeight := 40.0