feat: Introduce quick capture widget configuration and validation
Deploy Development / deploy (push) Successful in 55s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Added support for the "quick_capture" widget, allowing users to configure visibility for weight and baseline vitals (resting HR, HRV, VO₂max).
- Implemented validation logic to ensure correct configuration input and prevent errors.
- Updated the widget catalog and dashboard layout to reflect the new quick capture features.
- Removed the "training_type_distribution" widget from the catalog as part of the refactor.
- Bumped app_dashboard version to 1.6.2 to incorporate these enhancements.
This commit is contained in:
Lars committed 2026-04-07 18:02:18 +02:00
1 parent 3d498d03c1
commit 7f833b2cb1
9 files changed
+267 -107

No files matched your search

@@ -0,0 +1,67 @@
/**
* Sichtbarkeit der Teile im Schnelleingabe-Widget (Dashboard-Lab).
* Default: alle sichtbar (leeres config).
*/
const KEYS = [
{ key: 'show_weight', label: 'Gewicht' },
{ key: 'show_resting_hr', label: 'Ruhepuls' },
{ key: 'show_hrv', label: 'HRV' },
{ key: 'show_vo2_max', label: 'VO₂max' },
]
function mergeFromConfig(config) {
const c = config || {}
return {
show_weight: c.show_weight !== false,
show_resting_hr: c.show_resting_hr !== false,
show_hrv: c.show_hrv !== false,
show_vo2_max: c.show_vo2_max !== false,
}
}
/** @param {{ config: Record<string, unknown>, onChange: (next: Record<string, boolean>) => void }} props */
export default function QuickCaptureConfigEditor({ config, onChange }) {
const vis = mergeFromConfig(config)
const setKey = (k, checked) => {
const next = { ...vis, [k]: checked }
if (!next.show_weight && !next.show_resting_hr && !next.show_hrv && !next.show_vo2_max) {
return
}
const stored = {}
for (const { key } of KEYS) {
if (!next[key]) stored[key] = false
}
onChange(stored)
}
const resetAllVisible = () => onChange({})
return (
<div style={{ marginTop: 10, marginLeft: 28 }}>
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 8, lineHeight: 1.5 }}>
<strong>Schnelleingabe:</strong> welche Bereiche angezeigt werden. Ohne Eintrag = alles sichtbar.
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{KEYS.map(({ key, label }) => (
<label key={key} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' }}>
<input
type="checkbox"
checked={vis[key]}
onChange={(e) => setKey(key, e.target.checked)}
/>
<span>{label}</span>
</label>
))}
</div>
<button
type="button"
className="btn btn-secondary"
style={{ marginTop: 10, fontSize: 12, padding: '6px 12px' }}
onClick={resetAllVisible}
>
Alle einblenden (Standard)
</button>
</div>
)
}
@@ -14,7 +14,6 @@ import ProfileGoalsProgressWidget from '../components/dashboard-widgets/ProfileG
import TrendKcalWeightWidget from '../components/dashboard-widgets/TrendKcalWeightWidget'
import NutritionActivitySummaryWidget from '../components/dashboard-widgets/NutritionActivitySummaryWidget'
import RecoverySleepRestWidget from '../components/dashboard-widgets/RecoverySleepRestWidget'
import TrainingTypeDistributionWidget from '../components/dashboard-widgets/TrainingTypeDistributionWidget'
import GoalsFocusTeaserWidget from '../components/dashboard-widgets/GoalsFocusTeaserWidget'
import AiPipelineInsightWidget from '../components/dashboard-widgets/AiPipelineInsightWidget'
import { normalizeBodyChartDays } from './bodyChartDays'
@@ -34,7 +33,10 @@ export function ensurePilotLabWidgetsRegistered() {
registerDashboardWidget({
id: 'quick_capture',
Component: PilotQuickCapture,
mapProps: (ctx) => ({ onSaved: ctx.requestRefresh }),
mapProps: (ctx) => ({
onSaved: ctx.requestRefresh,
captureConfig: ctx.layoutEntry?.config || {},
}),
})
registerDashboardWidget({
id: 'kpi_board',
@@ -104,17 +106,6 @@ export function ensurePilotLabWidgetsRegistered() {
Component: RecoverySleepRestWidget,
mapProps: () => ({}),
})
registerDashboardWidget({
id: 'training_type_distribution',
Component: TrainingTypeDistributionWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
distributionDays:
ctx.layoutEntry?.config?.distribution_days != null
? Number(ctx.layoutEntry.config.distribution_days)
: 28,
}),
})
registerDashboardWidget({
id: 'goals_focus_teaser',
Component: GoalsFocusTeaserWidget,