feat: add report_export widget and enhance report generation capabilities
Deploy Development / deploy (push) Successful in 1m4s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 19s

- Introduced the `report_export` widget to the dashboard, allowing users to generate structured PDF reports.
- Updated widget configuration to include `report_export` in the allowed widgets and added validation for its configuration.
- Enhanced the widget catalog with details for the new `report_export` entry.
- Implemented API endpoints for managing report profiles and generating PDFs.
- Added frontend components for configuring and displaying report settings.
- Updated tests to ensure proper validation and functionality of the new report generation features.
- Bumped application version to reflect the addition of the new widget and related functionalities.
This commit is contained in:
Lars committed 2026-04-29 11:28:04 +02:00
1 parent 141df021c1
commit 62729d0648
22 files changed
+1389 -7

No files matched your search

@@ -0,0 +1,66 @@
import { normalizeReportExportConfig } from './reportExportConfig'
function buildStoredConfig(n) {
const out = {}
if (n.document_title) out.document_title = n.document_title
if (n.subtitle) out.subtitle = n.subtitle
if (n.capture_scale !== 2) out.capture_scale = n.capture_scale
return out
}
/**
* @param {{
* config: Record<string, unknown>,
* onChange: (next: Record<string, unknown>) => void
* }} props
*/
export default function ReportExportConfigEditor({ config, onChange }) {
const n = normalizeReportExportConfig(config)
const push = (partial) => {
const merged = normalizeReportExportConfig({ ...(config || {}), ...partial })
onChange(buildStoredConfig(merged))
}
return (
<div style={{ marginTop: 12, marginLeft: 28, maxWidth: 440 }}>
<label style={{ fontSize: 12, color: 'var(--text2)', display: 'block', marginBottom: 4 }}>
Dokumenttitel (optional, max. 120 Zeichen)
</label>
<input
type="text"
className="form-input"
maxLength={120}
placeholder="Leer = Profilname + „Übersicht“"
value={n.document_title}
onChange={(e) => push({ document_title: e.target.value })}
/>
<label
style={{ fontSize: 12, color: 'var(--text2)', display: 'block', marginTop: 10, marginBottom: 4 }}
>
Untertitel (optional, max. 240 Zeichen)
</label>
<input
type="text"
className="form-input"
maxLength={240}
placeholder="Leer = Datum/Uhrzeit"
value={n.subtitle}
onChange={(e) => push({ subtitle: e.target.value })}
/>
<label style={{ fontSize: 12, color: 'var(--text2)', display: 'block', marginTop: 10, marginBottom: 4 }}>
PDF-Auflösung (1 = schneller/kleiner, 3 = schärfere Grafiken)
</label>
<select
className="form-input"
style={{ maxWidth: 120 }}
value={String(n.capture_scale)}
onChange={(e) => push({ capture_scale: Number(e.target.value) })}
>
<option value="1">1×</option>
<option value="2">2× (Standard)</option>
<option value="3">3×</option>
</select>
</div>
)
}
@@ -29,7 +29,9 @@ import ProgressPhotosWidget from '../components/dashboard-widgets/ProgressPhotos
import RecoverySleepRestWidget from '../components/dashboard-widgets/RecoverySleepRestWidget'
import GoalsFocusTeaserWidget from '../components/dashboard-widgets/GoalsFocusTeaserWidget'
import AiPipelineInsightWidget from '../components/dashboard-widgets/AiPipelineInsightWidget'
import ReportExportWidget from '../components/dashboard-widgets/ReportExportWidget'
import { normalizeBodyChartDays } from './bodyChartDays'
import { normalizeReportExportConfig } from './reportExportConfig'
import { registerDashboardWidget } from './dashboardWidgetRegistry'
let _registered = false
@@ -190,6 +192,13 @@ export function ensureDashboardWidgetsRegistered() {
Component: AiPipelineInsightWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'report_export',
Component: ReportExportWidget,
mapProps: (ctx) => ({
reportExportConfig: normalizeReportExportConfig(ctx.layoutEntry?.config),
}),
})
}
/** @internal Nur für Tests */
@@ -0,0 +1,15 @@
/**
* @param {Record<string, unknown> | null | undefined} raw
* @returns {{ document_title: string, subtitle: string, capture_scale: number }}
*/
export function normalizeReportExportConfig(raw) {
const c = raw && typeof raw === 'object' ? raw : {}
let capture_scale = 2
if (c.capture_scale != null && c.capture_scale !== '') {
const n = Number(c.capture_scale)
if (Number.isFinite(n)) capture_scale = Math.min(3, Math.max(1, Math.round(n)))
}
const dt = typeof c.document_title === 'string' ? c.document_title.trim().slice(0, 120) : ''
const st = typeof c.subtitle === 'string' ? c.subtitle.trim().slice(0, 240) : ''
return { document_title: dt, subtitle: st, capture_scale }
}