feat: add viz_bundle support to report generation and enhance schema
Deploy Development / deploy (push) Successful in 1m1s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 20s

- Introduced the `viz_bundle` block type to the report profile schema, allowing for the inclusion of bundled visualizations in PDF reports.
- Updated the `build_structured_report_pdf` function to handle `VizBundleBlock` and append its content to the report.
- Enhanced the report catalog API to include details for the new `viz_bundle` block type.
- Added configuration editors for various visualization bundles in the frontend settings page.
- Updated tests to validate the new `viz_bundle` functionality and ensure proper handling of report profiles.
- Bumped application version to reflect these enhancements.
This commit is contained in:
Lars committed 2026-04-29 11:46:34 +02:00
1 parent 62729d0648
commit 3ab5dae130
7 files changed
+682 -104

No files matched your search

+119 -5
View File
@@ -5,6 +5,11 @@ import { useProfile } from '../context/ProfileContext'
import { useAuth } from '../context/AuthContext'
import { Avatar } from './ProfileSelect'
import { api } from '../utils/api'
import BodyHistoryVizConfigEditor from '../widgetSystem/BodyHistoryVizConfigEditor'
import NutritionHistoryVizConfigEditor from '../widgetSystem/NutritionHistoryVizConfigEditor'
import FitnessHistoryVizConfigEditor from '../widgetSystem/FitnessHistoryVizConfigEditor'
import RecoveryHistoryVizConfigEditor from '../widgetSystem/RecoveryHistoryVizConfigEditor'
import HistoryOverviewVizConfigEditor from '../widgetSystem/HistoryOverviewVizConfigEditor'
import FeatureUsageOverview from '../components/FeatureUsageOverview'
import UsageBadge from '../components/UsageBadge'
@@ -57,7 +62,10 @@ export default function SettingsPage() {
const reportNewBlock = (kind) => {
const charts = reportCatalog?.charts || []
const first = charts[0]
const bundles = reportCatalog?.viz_bundles || []
const firstBundleId = bundles[0]?.id || 'body_history_viz'
if (kind === 'section') return { type: 'section', title: 'Neue Überschrift' }
if (kind === 'viz_bundle') return { type: 'viz_bundle', bundle_id: firstBundleId, config: {} }
if (kind === 'chart')
return {
type: 'chart',
@@ -586,10 +594,13 @@ export default function SettingsPage() {
PDF-Bericht (strukturiert)
</div>
<p style={{ fontSize: 13, color: 'var(--text2)', marginBottom: 12, lineHeight: 1.65 }}>
<strong>Eigenes Berichtsprofil:</strong> Reihenfolge, Überschriften und Diagramme — unabhängig von der
Startübersicht. Die PDF-Datei wird <strong>serverseitig</strong> aus denselben Datenquellen wie die
Chart-API erzeugt (kein Screenshot). Das unterscheidet sich vom optionalen Widget „Übersicht als
Bild-PDF“ auf der Startseite.
<strong>Eigenes Berichtsprofil:</strong> Überschriften, <strong>Verlauf-Bundles</strong> (KPIs,
Einschätzungen und Diagramme wie im Bereich Verlauf) und optional einzelne Legacy-Diagramme. Gleiche
Schalter wie unter{' '}
<Link to="/settings/dashboard-layout" style={{ color: 'var(--accent)' }}>
Übersicht anpassen
</Link>
. PDF wird serverseitig aus dem Datenlayer erzeugt — kein Screenshot der Widgets.
</p>
{!canExport && (
<div
@@ -755,6 +766,108 @@ export default function SettingsPage() {
/>
</div>
)}
{b.type === 'viz_bundle' && (
<div style={{ marginTop: 8, display: 'flex', flexDirection: 'column', gap: 10 }}>
<div>
<label style={{ fontSize: 11, color: 'var(--text3)', display: 'block', marginBottom: 4 }}>
Verlauf-Bundle
</label>
<select
className="form-input"
value={b.bundle_id}
onChange={(e) =>
setReportDraft((d) => {
const blocks = d.blocks.map((x, j) =>
j === idx ? { ...x, bundle_id: e.target.value, config: {} } : x
)
return { ...d, blocks }
})
}
>
{(reportCatalog.viz_bundles || []).map((vb) => (
<option key={vb.id} value={vb.id}>
{vb.title}
</option>
))}
</select>
</div>
{b.bundle_id === 'body_history_viz' && (
<BodyHistoryVizConfigEditor
config={b.config || {}}
onChange={(next) =>
setReportDraft((d) => {
const blocks = d.blocks.map((x, j) => {
if (j !== idx) return x
if (Object.keys(next).length === 0) return { ...x, config: {} }
return { ...x, config: { ...(x.config || {}), ...next } }
})
return { ...d, blocks }
})
}
/>
)}
{b.bundle_id === 'nutrition_history_viz' && (
<NutritionHistoryVizConfigEditor
config={b.config || {}}
onChange={(next) =>
setReportDraft((d) => {
const blocks = d.blocks.map((x, j) => {
if (j !== idx) return x
if (Object.keys(next).length === 0) return { ...x, config: {} }
return { ...x, config: { ...(x.config || {}), ...next } }
})
return { ...d, blocks }
})
}
/>
)}
{b.bundle_id === 'fitness_history_viz' && (
<FitnessHistoryVizConfigEditor
config={b.config || {}}
onChange={(next) =>
setReportDraft((d) => {
const blocks = d.blocks.map((x, j) => {
if (j !== idx) return x
if (Object.keys(next).length === 0) return { ...x, config: {} }
return { ...x, config: { ...(x.config || {}), ...next } }
})
return { ...d, blocks }
})
}
/>
)}
{b.bundle_id === 'recovery_history_viz' && (
<RecoveryHistoryVizConfigEditor
config={b.config || {}}
onChange={(next) =>
setReportDraft((d) => {
const blocks = d.blocks.map((x, j) => {
if (j !== idx) return x
if (Object.keys(next).length === 0) return { ...x, config: {} }
return { ...x, config: { ...(x.config || {}), ...next } }
})
return { ...d, blocks }
})
}
/>
)}
{b.bundle_id === 'history_overview_viz' && (
<HistoryOverviewVizConfigEditor
config={b.config || {}}
onChange={(next) =>
setReportDraft((d) => {
const blocks = d.blocks.map((x, j) => {
if (j !== idx) return x
if (Object.keys(next).length === 0) return { ...x, config: {} }
return { ...x, config: { ...(x.config || {}), ...next } }
})
return { ...d, blocks }
})
}
/>
)}
</div>
)}
</li>
))}
</ul>
@@ -772,7 +885,8 @@ export default function SettingsPage() {
>
<option value="">+ Block hinzufügen…</option>
<option value="section">Überschrift</option>
<option value="chart">Diagramm</option>
<option value="viz_bundle">Verlauf-Bundle (KPIs &amp; Diagramme)</option>
<option value="chart">Einzel-Diagramm (Legacy)</option>
<option value="ai_insight">KI-Auswertung</option>
</select>
</div>