feat: Add new widgets and enhance configuration validation
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

- Introduced "nutrition_detail_charts", "recovery_charts_panel", and "progress_photos" widgets to the dashboard.
- Updated widget configuration validation to support new widgets, including chart days for nutrition and recovery charts.
- Enhanced the widget catalog and dashboard layout to include the new features.
- Bumped app_dashboard version to 1.7.0 to reflect these additions and improvements.
This commit is contained in:
Lars committed 2026-04-07 20:58:44 +02:00
1 parent 7f833b2cb1
commit bc91396885
9 files changed
+226 -4

No files matched your search

@@ -0,0 +1,32 @@
import { useNavigate } from 'react-router-dom'
import NutritionCharts from '../NutritionCharts'
import { normalizeBodyChartDays } from '../../widgetSystem/bodyChartDays'
/**
* Phase-0c-Ernährungscharts (wie „Detaillierte Charts“ im Verlauf).
* @param {{ refreshTick?: number, chartDays?: number }} props
*/
export default function NutritionDetailChartsWidget({ refreshTick = 0, chartDays }) {
const nav = useNavigate()
const days = chartDays != null ? normalizeBodyChartDays(chartDays) : 30
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)' }}>Ernährung — Charts</div>
<div style={{ fontSize: 12, color: 'var(--text3)' }}>API-Charts · {days} Tage</div>
</div>
<button
type="button"
className="btn btn-secondary"
style={{ fontSize: 12, padding: '6px 12px' }}
onClick={() => nav('/history', { state: { tab: 'nutrition' } })}
>
Verlauf →
</button>
</div>
<NutritionCharts key={`${refreshTick}-${days}`} days={days} />
</div>
)
}
@@ -0,0 +1,86 @@
import { useState, useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import { api } from '../../utils/api'
/**
* Fortschrittsfotos (Galerie wie Verlauf-Tab Fotos).
*/
export default function ProgressPhotosWidget({ refreshTick = 0 }) {
const nav = useNavigate()
const [photos, setPhotos] = useState([])
const [big, setBig] = useState(null)
useEffect(() => {
api.listPhotos().then(setPhotos).catch(() => setPhotos([]))
}, [refreshTick])
if (!photos.length) {
return (
<div className="card section-gap" style={{ marginBottom: 16, textAlign: 'center', padding: 24 }}>
<div style={{ fontSize: 13, color: 'var(--text3)', marginBottom: 12 }}>Noch keine Fotos.</div>
<button type="button" className="btn btn-primary" onClick={() => nav('/capture')}>
Zur Erfassung
</button>
</div>
)
}
return (
<div className="card section-gap" style={{ marginBottom: 16 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 10 }}>
<div style={{ fontSize: 14, fontWeight: 700, color: 'var(--text1)' }}>Fortschrittsfotos</div>
<button
type="button"
className="btn btn-secondary"
style={{ fontSize: 12, padding: '6px 12px' }}
onClick={() => nav('/history', { state: { tab: 'photos' } })}
>
Verlauf →
</button>
</div>
{big && (
<div
role="presentation"
style={{
position: 'fixed',
inset: 0,
background: 'rgba(0,0,0,0.9)',
zIndex: 100,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
onClick={() => setBig(null)}
>
<img src={api.photoUrl(big)} style={{ maxWidth: '100%', maxHeight: '100%', borderRadius: 8 }} alt="" />
</div>
)}
<div className="photo-grid">
{photos.map((p) => (
<div key={p.id} style={{ position: 'relative' }}>
<img
src={api.photoUrl(p.id)}
className="photo-thumb"
alt=""
onClick={() => setBig(p.id)}
/>
<div
style={{
position: 'absolute',
bottom: 4,
left: 4,
fontSize: 9,
background: 'rgba(0,0,0,0.6)',
color: 'white',
padding: '1px 4px',
borderRadius: 3,
}}
>
{p.date?.slice(0, 10) || p.created?.slice(0, 10)}
</div>
</div>
))}
</div>
</div>
)
}
@@ -0,0 +1,32 @@
import { useNavigate } from 'react-router-dom'
import RecoveryCharts from '../RecoveryCharts'
import { normalizeBodyChartDays } from '../../widgetSystem/bodyChartDays'
/**
* Erholung R1–R5 (wie Verlauf Erholung).
* @param {{ refreshTick?: number, chartDays?: number }} props
*/
export default function RecoveryChartsPanelWidget({ refreshTick = 0, chartDays }) {
const nav = useNavigate()
const days = chartDays != null ? normalizeBodyChartDays(chartDays) : 28
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 — Charts</div>
<div style={{ fontSize: 12, color: 'var(--text3)' }}>Schlaf, Recovery, Vitalwerte · {days} Tage</div>
</div>
<button
type="button"
className="btn btn-secondary"
style={{ fontSize: 12, padding: '6px 12px' }}
onClick={() => nav('/history', { state: { tab: 'recovery' } })}
>
Verlauf →
</button>
</div>
<RecoveryCharts key={`${refreshTick}-${days}`} days={days} />
</div>
)
}