feat: add recovery_history_viz widget and enhance configuration handling
- Introduced the `recovery_history_viz` widget to the dashboard, enabling users to visualize recovery history data. - Updated widget configuration to include `recovery_history_viz` in the allowed widgets and added validation for its configuration. - Enhanced the widget catalog with details for the new `recovery_history_viz` entry. - Implemented default values and validation logic for the widget's configuration, ensuring proper handling of user inputs. - Added tests to ensure proper validation of the `recovery_history_viz` widget configuration. - Bumped application version to reflect the addition of the new widget.
This commit is contained in:
1 parent
d22e0ba0a7
commit
e20b321b64
16 files changed
+735
-258
No files matched your search
@@ -1,8 +1,8 @@
|
||||
import RecoveryDashboardOverview from './RecoveryDashboardOverview'
|
||||
|
||||
/**
|
||||
* @deprecated Nutze direkt {@link RecoveryDashboardOverview}. Wrapper für Dashboard-Widgets (days → period).
|
||||
* @deprecated Nutze direkt {@link RecoveryDashboardOverview}. Wrapper (days → externalPeriod).
|
||||
*/
|
||||
export default function RecoveryCharts({ days = 28 }) {
|
||||
return <RecoveryDashboardOverview period={days} hidePeriodSelector />
|
||||
return <RecoveryDashboardOverview externalPeriod={days} hidePeriodSelector />
|
||||
}
|
||||
@@ -4,6 +4,11 @@ import { LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianG
|
||||
import { api } from '../utils/api'
|
||||
import KpiTilesOverview from './KpiTilesOverview'
|
||||
import { getStatusColor, getStatusBg } from '../utils/interpret'
|
||||
import {
|
||||
RECOVERY_HISTORY_VIZ_HISTORY_FULL,
|
||||
filterRecoveryHistoryKpiTiles,
|
||||
normalizeRecoveryHistoryVizConfig,
|
||||
} from '../widgetSystem/recoveryHistoryVizConfig'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const fmtDate = (d) => dayjs(d).format('DD.MM.')
|
||||
@@ -194,17 +199,32 @@ function ChartCard({ title, loading, error, children, description }) {
|
||||
|
||||
/**
|
||||
* Layer 2b: Erholung — ein Request GET /api/charts/recovery-dashboard-viz (recovery_metrics).
|
||||
* @param {number} [props.externalPeriod] — Widget: feste Tage (7–90)
|
||||
* @param {boolean} [props.embedded]
|
||||
* @param {Record<string, unknown>} [props.visibility] — Dashboard-Config; undefined = voller Verlauf
|
||||
* @param {import('react').ReactNode} [props.footer]
|
||||
*/
|
||||
export default function RecoveryDashboardOverview({
|
||||
period: periodProp,
|
||||
onPeriodChange,
|
||||
hidePeriodSelector = false,
|
||||
externalPeriod,
|
||||
embedded = false,
|
||||
visibility,
|
||||
footer = null,
|
||||
}) {
|
||||
const nav = useNavigate()
|
||||
const [internalPeriod, setInternalPeriod] = useState(28)
|
||||
const controlled = periodProp !== undefined && typeof onPeriodChange === 'function'
|
||||
const period = controlled ? periodProp : internalPeriod
|
||||
const setPeriod = controlled ? onPeriodChange : setInternalPeriod
|
||||
const period =
|
||||
externalPeriod !== undefined ? externalPeriod : controlled ? periodProp : internalPeriod
|
||||
const setPeriod =
|
||||
externalPeriod !== undefined ? () => {} : controlled ? onPeriodChange : setInternalPeriod
|
||||
|
||||
const display =
|
||||
visibility === undefined ? RECOVERY_HISTORY_VIZ_HISTORY_FULL : normalizeRecoveryHistoryVizConfig(visibility)
|
||||
const chartH = embedded ? 176 : 200
|
||||
const chartHVitals = embedded ? 200 : 220
|
||||
|
||||
const [viz, setViz] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
@@ -230,10 +250,13 @@ export default function RecoveryDashboardOverview({
|
||||
}
|
||||
}, [period])
|
||||
|
||||
const outerClass = embedded ? '' : 'card section-gap'
|
||||
const showPeriodDropdown = !hidePeriodSelector && externalPeriod === undefined && !controlled
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="card section-gap">
|
||||
<div className="card-title">Erholung & Vitalwerte</div>
|
||||
<div className={outerClass || undefined}>
|
||||
{!embedded && <div className="card-title">Erholung & Vitalwerte</div>}
|
||||
<div className="spinner" style={{ margin: 24 }} />
|
||||
</div>
|
||||
)
|
||||
@@ -241,8 +264,8 @@ export default function RecoveryDashboardOverview({
|
||||
|
||||
if (err) {
|
||||
return (
|
||||
<div className="card section-gap">
|
||||
<div className="card-title">Erholung & Vitalwerte</div>
|
||||
<div className={outerClass || undefined}>
|
||||
{!embedded && <div className="card-title">Erholung & Vitalwerte</div>}
|
||||
<div style={{ color: 'var(--danger)' }}>{err}</div>
|
||||
</div>
|
||||
)
|
||||
@@ -250,8 +273,8 @@ export default function RecoveryDashboardOverview({
|
||||
|
||||
if (!viz?.has_recovery_data) {
|
||||
return (
|
||||
<div className="card section-gap">
|
||||
<div className="card-title">Erholung & Vitalwerte</div>
|
||||
<div className={outerClass || undefined}>
|
||||
{!embedded && <div className="card-title">Erholung & Vitalwerte</div>}
|
||||
<p style={{ fontSize: 12, color: 'var(--text3)', lineHeight: 1.45, marginBottom: 14 }}>
|
||||
{viz?.message || 'Noch keine Schlaf- oder Vitaldaten.'} Sobald du Schlaf oder morgendliche Vitalwerte erfasst
|
||||
oder importierst, erscheinen Auswertungen hier.
|
||||
@@ -280,18 +303,19 @@ export default function RecoveryDashboardOverview({
|
||||
const vo2SectionInsights = sectionInsights.filter((s) => s.section === 'vo2')
|
||||
const heartSnapshotItems = ['resting_hr', 'hrv', 'blood_pressure'].map((k) => vitalItemsByKey[k]).filter(Boolean)
|
||||
|
||||
const kpiTiles = (viz.kpi_tiles || []).map((t) => ({
|
||||
const kpiTilesRaw = (viz.kpi_tiles || []).map((t) => ({
|
||||
...t,
|
||||
sublabel:
|
||||
typeof t.sublabel === 'string' && t.sublabel.length > 42 ? `${t.sublabel.slice(0, 40)}…` : t.sublabel,
|
||||
}))
|
||||
const kpiTilesShown = display.show_kpis
|
||||
? filterRecoveryHistoryKpiTiles(kpiTilesRaw, display.kpi_detail || 'full')
|
||||
: []
|
||||
const insights = viz.progress_insights || []
|
||||
const eff = viz.effective_window_days
|
||||
const cDays = viz.chart_days_used
|
||||
const vDays = viz.vital_matrix_days_used
|
||||
|
||||
const showPeriodDropdown = !hidePeriodSelector && !controlled
|
||||
|
||||
const renderRecoveryScore = () => {
|
||||
if (!recoveryData || recoveryData.metadata?.confidence === 'insufficient') {
|
||||
return (
|
||||
@@ -306,41 +330,43 @@ export default function RecoveryDashboardOverview({
|
||||
}))
|
||||
return (
|
||||
<>
|
||||
<ResponsiveContainer width="100%" height={200}>
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
domain={[0, 100]}
|
||||
tickFormatter={(v) => (Number.isFinite(Number(v)) ? String(Math.round(Number(v))) : '')}
|
||||
tickCount={6}
|
||||
width={36}
|
||||
/>
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="score"
|
||||
stroke="#1D9E75"
|
||||
strokeWidth={2}
|
||||
name={recoveryData.data?.datasets?.[0]?.label || 'HRV (Proxy)'}
|
||||
dot={{ r: 2 }}
|
||||
/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
<div style={{ width: '100%', minWidth: 0, height: chartH }}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
domain={[0, 100]}
|
||||
tickFormatter={(v) => (Number.isFinite(Number(v)) ? String(Math.round(Number(v))) : '')}
|
||||
tickCount={6}
|
||||
width={36}
|
||||
/>
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="score"
|
||||
stroke="#1D9E75"
|
||||
strokeWidth={2}
|
||||
name={recoveryData.data?.datasets?.[0]?.label || 'HRV (Proxy)'}
|
||||
dot={{ r: 2 }}
|
||||
/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
<div style={{ marginTop: 8, fontSize: 10, color: 'var(--text3)', textAlign: 'center', lineHeight: 1.45 }}>
|
||||
KPI Recovery-Score (aktuell): <strong>{recoveryData.metadata.current_score}/100</strong> · Datenpunkte Kurve:{' '}
|
||||
{recoveryData.metadata.data_points}
|
||||
@@ -364,44 +390,46 @@ export default function RecoveryDashboardOverview({
|
||||
}))
|
||||
return (
|
||||
<>
|
||||
<ResponsiveContainer width="100%" height={200}>
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis
|
||||
yAxisId="left"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
tickFormatter={formatAxisTick}
|
||||
tickCount={6}
|
||||
width={44}
|
||||
/>
|
||||
<YAxis
|
||||
yAxisId="right"
|
||||
orientation="right"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
tickFormatter={formatAxisTick}
|
||||
tickCount={6}
|
||||
width={44}
|
||||
/>
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line yAxisId="left" type="monotone" dataKey="hrv" stroke="#1D9E75" strokeWidth={2} name="HRV (ms)" dot={{ r: 2 }} />
|
||||
<Line yAxisId="right" type="monotone" dataKey="rhr" stroke="#3B82F6" strokeWidth={2} name="RHR (bpm)" dot={{ r: 2 }} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
<div style={{ width: '100%', minWidth: 0, height: chartH }}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis
|
||||
yAxisId="left"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
tickFormatter={formatAxisTick}
|
||||
tickCount={6}
|
||||
width={44}
|
||||
/>
|
||||
<YAxis
|
||||
yAxisId="right"
|
||||
orientation="right"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
tickFormatter={formatAxisTick}
|
||||
tickCount={6}
|
||||
width={44}
|
||||
/>
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line yAxisId="left" type="monotone" dataKey="hrv" stroke="#1D9E75" strokeWidth={2} name="HRV (ms)" dot={{ r: 2 }} />
|
||||
<Line yAxisId="right" type="monotone" dataKey="rhr" stroke="#3B82F6" strokeWidth={2} name="RHR (bpm)" dot={{ r: 2 }} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
<div style={{ marginTop: 8, fontSize: 10, color: 'var(--text3)', textAlign: 'center' }}>
|
||||
HRV Ø {hrvRhrData.metadata.avg_hrv}ms · RHR Ø {hrvRhrData.metadata.avg_rhr}bpm
|
||||
</div>
|
||||
@@ -424,29 +452,31 @@ export default function RecoveryDashboardOverview({
|
||||
}))
|
||||
return (
|
||||
<>
|
||||
<ResponsiveContainer width="100%" height={200}>
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis yAxisId="left" tick={{ fontSize: 9, fill: 'var(--text3)' }} tickLine={false} />
|
||||
<YAxis yAxisId="right" orientation="right" tick={{ fontSize: 9, fill: 'var(--text3)' }} tickLine={false} domain={[0, 100]} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line yAxisId="left" type="monotone" dataKey="duration" stroke="#3B82F6" strokeWidth={2} name="Dauer (h)" dot={{ r: 2 }} />
|
||||
<Line yAxisId="right" type="monotone" dataKey="quality" stroke="#1D9E75" strokeWidth={2} name="Qualität (%)" dot={{ r: 2 }} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
<div style={{ width: '100%', minWidth: 0, height: chartH }}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis yAxisId="left" tick={{ fontSize: 9, fill: 'var(--text3)' }} tickLine={false} />
|
||||
<YAxis yAxisId="right" orientation="right" tick={{ fontSize: 9, fill: 'var(--text3)' }} tickLine={false} domain={[0, 100]} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line yAxisId="left" type="monotone" dataKey="duration" stroke="#3B82F6" strokeWidth={2} name="Dauer (h)" dot={{ r: 2 }} />
|
||||
<Line yAxisId="right" type="monotone" dataKey="quality" stroke="#1D9E75" strokeWidth={2} name="Qualität (%)" dot={{ r: 2 }} />
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
<div style={{ marginTop: 8, fontSize: 10, color: 'var(--text3)', textAlign: 'center' }}>
|
||||
Ø {sleepData.metadata.avg_duration_hours}h Schlaf
|
||||
</div>
|
||||
@@ -469,35 +499,37 @@ export default function RecoveryDashboardOverview({
|
||||
const curDebt = debtData.metadata?.current_debt_hours
|
||||
return (
|
||||
<>
|
||||
<ResponsiveContainer width="100%" height={200}>
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis tick={{ fontSize: 9, fill: 'var(--text3)' }} tickLine={false} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="debt"
|
||||
stroke="#EF4444"
|
||||
strokeWidth={2}
|
||||
name={debtData.data?.datasets?.[0]?.label || 'Schlafschuld (h)'}
|
||||
dot={{ r: 2 }}
|
||||
connectNulls
|
||||
/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
<div style={{ width: '100%', minWidth: 0, height: chartH }}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 8, bottom: 0, left: -20 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
<XAxis
|
||||
dataKey="date"
|
||||
tick={{ fontSize: 9, fill: 'var(--text3)' }}
|
||||
tickLine={false}
|
||||
interval={Math.max(0, Math.floor(chartData.length / 6) - 1)}
|
||||
/>
|
||||
<YAxis tick={{ fontSize: 9, fill: 'var(--text3)' }} tickLine={false} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
borderRadius: 8,
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="debt"
|
||||
stroke="#EF4444"
|
||||
strokeWidth={2}
|
||||
name={debtData.data?.datasets?.[0]?.label || 'Schlafschuld (h)'}
|
||||
dot={{ r: 2 }}
|
||||
connectNulls
|
||||
/>
|
||||
</LineChart>
|
||||
</ResponsiveContainer>
|
||||
</div>
|
||||
<div style={{ marginTop: 8, fontSize: 10, color: 'var(--text3)', textAlign: 'center' }}>
|
||||
Aktuelle Schuld: {curDebt != null ? Number(curDebt).toFixed(1) : '—'}h
|
||||
</div>
|
||||
@@ -577,7 +609,7 @@ export default function RecoveryDashboardOverview({
|
||||
Ein Messpunkt ({formatAxisTick(m.last)}) — weiter erfassen, um einen Verlauf zu sehen.
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ width: '100%', height: hasMa ? 220 : 200, minHeight: hasMa ? 220 : 200 }}>
|
||||
<div style={{ width: '100%', minWidth: 0, height: hasMa ? chartHVitals : chartH, minHeight: hasMa ? chartHVitals : chartH }}>
|
||||
<ResponsiveContainer width="100%" height="100%">
|
||||
<LineChart data={chartData} margin={{ top: 4, right: 12, bottom: 0, left: 0 }}>
|
||||
<CartesianGrid stroke="var(--border)" strokeDasharray="3 3" />
|
||||
@@ -632,37 +664,43 @@ export default function RecoveryDashboardOverview({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="card section-gap">
|
||||
<div className="card-title" style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 12 }}>
|
||||
<span>Erholung & Vitalwerte</span>
|
||||
{showPeriodDropdown ? (
|
||||
<label
|
||||
style={{ fontSize: 12, fontWeight: 500, color: 'var(--text3)', display: 'flex', alignItems: 'center', gap: 8 }}
|
||||
>
|
||||
Zeitraum
|
||||
<select
|
||||
className="form-input"
|
||||
style={{ maxWidth: 140, padding: '6px 10px', fontSize: 13 }}
|
||||
value={period}
|
||||
onChange={(e) => setPeriod(Number(e.target.value))}
|
||||
<div className={outerClass || undefined}>
|
||||
{!embedded && (
|
||||
<div className="card-title" style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 12 }}>
|
||||
<span>Erholung & Vitalwerte</span>
|
||||
{showPeriodDropdown ? (
|
||||
<label
|
||||
style={{ fontSize: 12, fontWeight: 500, color: 'var(--text3)', display: 'flex', alignItems: 'center', gap: 8 }}
|
||||
>
|
||||
<option value={7}>7 Tage</option>
|
||||
<option value={28}>28 Tage</option>
|
||||
<option value={90}>90 Tage</option>
|
||||
<option value={9999}>Gesamt</option>
|
||||
</select>
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
Zeitraum
|
||||
<select
|
||||
className="form-input"
|
||||
style={{ maxWidth: 140, padding: '6px 10px', fontSize: 13 }}
|
||||
value={period}
|
||||
onChange={(e) => setPeriod(Number(e.target.value))}
|
||||
>
|
||||
<option value={7}>7 Tage</option>
|
||||
<option value={28}>28 Tage</option>
|
||||
<option value={90}>90 Tage</option>
|
||||
<option value={9999}>Gesamt</option>
|
||||
</select>
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<p style={{ fontSize: 11, color: 'var(--text3)', lineHeight: 1.45, marginBottom: 12 }}>
|
||||
Daten-Layer Auswertung · Fenster ca. <strong>{eff}</strong> Tage · Chart-Horizont <strong>{cDays}</strong> Tage ·
|
||||
Vital-Snapshot <strong>{vDays}</strong> Tage.
|
||||
</p>
|
||||
{display.show_layer_meta ? (
|
||||
<p style={{ fontSize: 11, color: 'var(--text3)', lineHeight: 1.45, marginBottom: 12 }}>
|
||||
Daten-Layer Auswertung · Fenster ca. <strong>{eff}</strong> Tage · Chart-Horizont <strong>{cDays}</strong> Tage ·
|
||||
Vital-Snapshot <strong>{vDays}</strong> Tage.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<KpiTilesOverview tiles={kpiTiles} heading="Kennzahlen" marginBottom={16} />
|
||||
{kpiTilesShown.length > 0 ? (
|
||||
<KpiTilesOverview tiles={kpiTilesShown} heading="Kennzahlen" marginBottom={16} />
|
||||
) : null}
|
||||
|
||||
{insights.length > 0 ? (
|
||||
{display.show_progress_insights && insights.length > 0 ? (
|
||||
<div style={{ marginBottom: 18 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>
|
||||
Überblick: Recovery & Schlaf
|
||||
@@ -690,93 +728,113 @@ export default function RecoveryDashboardOverview({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<SectionHeading
|
||||
compactTop
|
||||
title="Schlaf & Erholung"
|
||||
hint="Recovery-Score und Schlaf im gleichen Zeitraum wie die Kennzahlen oben."
|
||||
/>
|
||||
<ChartCard
|
||||
title="HRV-Verlauf (kein Recovery-Score)"
|
||||
description={
|
||||
'Kurve = HRV-Rohwert (ms), auf 0–100 begrenzt — nur zur Einordnung des Verlaufs. ' +
|
||||
'Die KPI-Kachel «Recovery-Score» oben nutzt calculate_recovery_score_v2 (HRV, RHR, Schlaf, Last, …).'
|
||||
}
|
||||
>
|
||||
{renderRecoveryScore()}
|
||||
</ChartCard>
|
||||
<ChartCard
|
||||
title="Schlaf: Dauer & Qualität"
|
||||
description={
|
||||
sleepData && sleepData.metadata?.confidence !== 'insufficient' && sleepData.metadata?.avg_duration_hours != null
|
||||
? `Dauer (h) und Qualitätsanteil (%). Mittlere Schlafdauer im Chart-Fenster: ${sleepData.metadata.avg_duration_hours} h — gleiche Information wie früher in der KPI «Ø Schlafdauer», jetzt hier im Schlaf-Kontext.`
|
||||
: 'Dauer (h) und Qualitätsanteil (%). Sobald genug Daten vorliegen, siehst du die mittlere Schlafdauer unter dem Diagramm.'
|
||||
}
|
||||
>
|
||||
{renderSleepQuality()}
|
||||
</ChartCard>
|
||||
<ChartCard
|
||||
title="Schlafschuld"
|
||||
description={
|
||||
'Gleiche Berechnung wie die KPI: Summe der nächtlichen Defizite gegenüber 7,5 h/Nacht im rollierenden 14-Tage-Fenster ' +
|
||||
'(Ziel derzeit fest im Code, nicht in den Einstellungen). Jeder Punkt = Schlafschuld mit Fensterende an diesem Datum — ' +
|
||||
'entspricht der KPI, wenn der letzte Punkt die letzte erfasste Nacht ist.'
|
||||
}
|
||||
>
|
||||
{renderSleepDebt()}
|
||||
</ChartCard>
|
||||
{display.show_sleep_section_heading ? (
|
||||
<SectionHeading
|
||||
compactTop
|
||||
title="Schlaf & Erholung"
|
||||
hint="Recovery-Score und Schlaf im gleichen Zeitraum wie die Kennzahlen oben."
|
||||
/>
|
||||
) : null}
|
||||
{display.show_chart_recovery_score ? (
|
||||
<ChartCard
|
||||
title="HRV-Verlauf (kein Recovery-Score)"
|
||||
description={
|
||||
'Kurve = HRV-Rohwert (ms), auf 0–100 begrenzt — nur zur Einordnung des Verlaufs. ' +
|
||||
'Die KPI-Kachel «Recovery-Score» oben nutzt calculate_recovery_score_v2 (HRV, RHR, Schlaf, Last, …).'
|
||||
}
|
||||
>
|
||||
{renderRecoveryScore()}
|
||||
</ChartCard>
|
||||
) : null}
|
||||
{display.show_chart_sleep_quality ? (
|
||||
<ChartCard
|
||||
title="Schlaf: Dauer & Qualität"
|
||||
description={
|
||||
sleepData && sleepData.metadata?.confidence !== 'insufficient' && sleepData.metadata?.avg_duration_hours != null
|
||||
? `Dauer (h) und Qualitätsanteil (%). Mittlere Schlafdauer im Chart-Fenster: ${sleepData.metadata.avg_duration_hours} h — gleiche Information wie früher in der KPI «Ø Schlafdauer», jetzt hier im Schlaf-Kontext.`
|
||||
: 'Dauer (h) und Qualitätsanteil (%). Sobald genug Daten vorliegen, siehst du die mittlere Schlafdauer unter dem Diagramm.'
|
||||
}
|
||||
>
|
||||
{renderSleepQuality()}
|
||||
</ChartCard>
|
||||
) : null}
|
||||
{display.show_chart_sleep_debt ? (
|
||||
<ChartCard
|
||||
title="Schlafschuld"
|
||||
description={
|
||||
'Gleiche Berechnung wie die KPI: Summe der nächtlichen Defizite gegenüber 7,5 h/Nacht im rollierenden 14-Tage-Fenster ' +
|
||||
'(Ziel derzeit fest im Code, nicht in den Einstellungen). Jeder Punkt = Schlafschuld mit Fensterende an diesem Datum — ' +
|
||||
'entspricht der KPI, wenn der letzte Punkt die letzte erfasste Nacht ist.'
|
||||
}
|
||||
>
|
||||
{renderSleepDebt()}
|
||||
</ChartCard>
|
||||
) : null}
|
||||
|
||||
<SectionHeading
|
||||
title="Herz & Kreislauf"
|
||||
hint="Text-Hinweise und Zonen-Snapshots zu Ruhepuls, HRV und Blutdruck; Verlauf nur im kombinierten Diagramm (keine zweite RHR/HRV-Linie unten)."
|
||||
/>
|
||||
<div className="card" style={{ marginBottom: 12 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>Einordnung & Kontext</div>
|
||||
<HeartAutonomicGuide />
|
||||
{heartSectionInsights.length > 0 ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 12 }}>
|
||||
{heartSectionInsights.map((ins) => (
|
||||
<SectionInsightCard key={ins.key} ins={ins} />
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text3)', marginBottom: 6 }}>Letzte Messwerte (Zonen)</div>
|
||||
<SnapshotCards items={heartSnapshotItems} />
|
||||
{vitalsData?.metadata?.vitals_measured_at || vitalsData?.metadata?.blood_pressure_measured_at ? (
|
||||
<div style={{ fontSize: 10, color: 'var(--text3)', marginBottom: 8, lineHeight: 1.45 }}>
|
||||
{vitalsData?.metadata?.vitals_measured_at ? (
|
||||
<>
|
||||
Baseline-Vitals: <strong>{fmtDate(vitalsData.metadata.vitals_measured_at)}</strong>
|
||||
</>
|
||||
) : null}
|
||||
{vitalsData?.metadata?.vitals_measured_at && vitalsData?.metadata?.blood_pressure_measured_at ? ' · ' : null}
|
||||
{vitalsData?.metadata?.blood_pressure_measured_at ? (
|
||||
<>
|
||||
Blutdruck: <strong>{fmtDate(vitalsData.metadata.blood_pressure_measured_at)}</strong>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{vitalsData?.metadata?.disclaimer_de ? (
|
||||
<div style={{ fontSize: 10, color: 'var(--text3)', fontStyle: 'italic', marginBottom: 10 }}>
|
||||
{vitalsData.metadata.disclaimer_de}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<ChartCard
|
||||
title="HRV & Ruhepuls — Zeitverlauf"
|
||||
description="Zwei Y-Achsen: HRV (ms, links), Ruhepuls (bpm, rechts). Gleicher Zeitraum wie die Charts oben."
|
||||
>
|
||||
{renderHrvRhr()}
|
||||
</ChartCard>
|
||||
{display.show_heart_section_heading ? (
|
||||
<SectionHeading
|
||||
title="Herz & Kreislauf"
|
||||
hint="Text-Hinweise und Zonen-Snapshots zu Ruhepuls, HRV und Blutdruck; Verlauf nur im kombinierten Diagramm (keine zweite RHR/HRV-Linie unten)."
|
||||
/>
|
||||
) : null}
|
||||
{display.show_heart_context_card ? (
|
||||
<div className="card" style={{ marginBottom: 12 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>Einordnung & Kontext</div>
|
||||
<HeartAutonomicGuide />
|
||||
{heartSectionInsights.length > 0 ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 12 }}>
|
||||
{heartSectionInsights.map((ins) => (
|
||||
<SectionInsightCard key={ins.key} ins={ins} />
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<div style={{ fontSize: 11, fontWeight: 600, color: 'var(--text3)', marginBottom: 6 }}>Letzte Messwerte (Zonen)</div>
|
||||
<SnapshotCards items={heartSnapshotItems} />
|
||||
{vitalsData?.metadata?.vitals_measured_at || vitalsData?.metadata?.blood_pressure_measured_at ? (
|
||||
<div style={{ fontSize: 10, color: 'var(--text3)', marginBottom: 8, lineHeight: 1.45 }}>
|
||||
{vitalsData?.metadata?.vitals_measured_at ? (
|
||||
<>
|
||||
Baseline-Vitals: <strong>{fmtDate(vitalsData.metadata.vitals_measured_at)}</strong>
|
||||
</>
|
||||
) : null}
|
||||
{vitalsData?.metadata?.vitals_measured_at && vitalsData?.metadata?.blood_pressure_measured_at ? ' · ' : null}
|
||||
{vitalsData?.metadata?.blood_pressure_measured_at ? (
|
||||
<>
|
||||
Blutdruck: <strong>{fmtDate(vitalsData.metadata.blood_pressure_measured_at)}</strong>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{vitalsData?.metadata?.disclaimer_de ? (
|
||||
<div style={{ fontSize: 10, color: 'var(--text3)', fontStyle: 'italic', marginBottom: 10 }}>
|
||||
{vitalsData.metadata.disclaimer_de}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
{display.show_chart_hrv_rhr ? (
|
||||
<ChartCard
|
||||
title="HRV & Ruhepuls — Zeitverlauf"
|
||||
description="Zwei Y-Achsen: HRV (ms, links), Ruhepuls (bpm, rechts). Gleicher Zeitraum wie die Charts oben."
|
||||
>
|
||||
{renderHrvRhr()}
|
||||
</ChartCard>
|
||||
) : null}
|
||||
|
||||
<SectionHeading
|
||||
title="Weitere Vitalparameter (Verlauf)"
|
||||
hint="VO2max-Trendtexte erscheinen oberhalb des Diagramms. SpO2 und Atemfrequenz: Zonen zum letzten Snapshot unter dem Titel."
|
||||
/>
|
||||
<div className="card" style={{ marginBottom: 12 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>Verläufe</div>
|
||||
{renderWeitereVitalVerlaeufe(vo2SectionInsights, vitalItemsByKey)}
|
||||
</div>
|
||||
{display.show_vitals_extra_heading ? (
|
||||
<SectionHeading
|
||||
title="Weitere Vitalparameter (Verlauf)"
|
||||
hint="VO2max-Trendtexte erscheinen oberhalb des Diagramms. SpO2 und Atemfrequenz: Zonen zum letzten Snapshot unter dem Titel."
|
||||
/>
|
||||
) : null}
|
||||
{display.show_vitals_extra_trends ? (
|
||||
<div className="card" style={{ marginBottom: 12 }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--text3)', marginBottom: 8 }}>Verläufe</div>
|
||||
{renderWeitereVitalVerlaeufe(vo2SectionInsights, vitalItemsByKey)}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{footer}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export default function RecoveryChartsPanelWidget({ refreshTick = 0, chartDays }
|
||||
Verlauf →
|
||||
</button>
|
||||
</div>
|
||||
<RecoveryDashboardOverview key={`${refreshTick}-${days}`} period={days} hidePeriodSelector />
|
||||
<RecoveryDashboardOverview key={`${refreshTick}-${days}`} externalPeriod={days} hidePeriodSelector />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import RecoveryHistoryVizSection from '../history/RecoveryHistoryVizSection'
|
||||
import { normalizeBodyChartDays } from '../../widgetSystem/bodyChartDays'
|
||||
import { normalizeRecoveryHistoryVizConfig } from '../../widgetSystem/recoveryHistoryVizConfig'
|
||||
|
||||
/**
|
||||
* Verlauf → Erholung als Dashboard-Widget: GET /charts/recovery-dashboard-viz (Layer 2b), Umfang über Layout-Config.
|
||||
* @param {{ refreshTick?: number, recoveryHistoryVizConfig?: Record<string, unknown> }} props
|
||||
*/
|
||||
export default function RecoveryHistoryVizWidget({ refreshTick = 0, recoveryHistoryVizConfig }) {
|
||||
const nav = useNavigate()
|
||||
const cfg = normalizeRecoveryHistoryVizConfig(recoveryHistoryVizConfig)
|
||||
const days = normalizeBodyChartDays(cfg.chart_days)
|
||||
|
||||
return (
|
||||
<div className="card section-gap" style={{ marginBottom: 16 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
|
||||
<div>
|
||||
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text1)' }}>Erholung (Verlauf-Bundle)</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--text3)' }}>recovery-dashboard-viz · {days} Tage</div>
|
||||
</div>
|
||||
<button type="button" className="btn btn-secondary" style={{ fontSize: 12, padding: '6px 12px' }} onClick={() => nav('/history', { state: { tab: 'activity' } })}>
|
||||
Verlauf →
|
||||
</button>
|
||||
</div>
|
||||
<RecoveryHistoryVizSection key={`${refreshTick}-${days}`} externalPeriod={days} embedded visibility={cfg} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import RecoveryDashboardOverview from '../RecoveryDashboardOverview'
|
||||
|
||||
/**
|
||||
* Verlauf → Erholung bzw. Dashboard-Widget: GET /charts/recovery-dashboard-viz (Layer 2b).
|
||||
*/
|
||||
export default function RecoveryHistoryVizSection({
|
||||
externalPeriod,
|
||||
period,
|
||||
onPeriodChange,
|
||||
hidePeriodSelector,
|
||||
embedded,
|
||||
visibility,
|
||||
footer,
|
||||
}) {
|
||||
return (
|
||||
<RecoveryDashboardOverview
|
||||
period={period}
|
||||
onPeriodChange={onPeriodChange}
|
||||
hidePeriodSelector={hidePeriodSelector}
|
||||
externalPeriod={externalPeriod}
|
||||
embedded={embedded}
|
||||
visibility={visibility}
|
||||
footer={footer}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user