feat: add nutrition_history_viz widget and enhance configuration handling
- Introduced the `nutrition_history_viz` widget to the dashboard, allowing users to visualize nutrition history data. - Updated widget configuration to include `nutrition_history_viz` in the allowed widgets and added validation for its configuration. - Enhanced the widget catalog with details for the new `nutrition_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 `nutrition_history_viz` widget configuration. - Bumped application version to reflect the addition of the new widget.
This commit is contained in:
1 parent
20f195aca1
commit
db5557e4aa
12 files changed
+993
-509
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import NutritionHistoryVizSection from '../history/NutritionHistoryVizSection'
|
||||
import { normalizeBodyChartDays } from '../../widgetSystem/bodyChartDays'
|
||||
import { normalizeNutritionHistoryVizConfig } from '../../widgetSystem/nutritionHistoryVizConfig'
|
||||
|
||||
/**
|
||||
* Verlauf → Ernährung als Dashboard-Widget: GET /charts/nutrition-history-viz (Layer 2b), Umfang über Layout-Config.
|
||||
* @param {{ refreshTick?: number, nutritionHistoryVizConfig?: Record<string, unknown> }} props
|
||||
*/
|
||||
export default function NutritionHistoryVizWidget({ refreshTick = 0, nutritionHistoryVizConfig }) {
|
||||
const nav = useNavigate()
|
||||
const cfg = normalizeNutritionHistoryVizConfig(nutritionHistoryVizConfig)
|
||||
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)' }}>Ernährung (Verlauf-Bundle)</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--text3)' }}>nutrition-history-viz · {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>
|
||||
<NutritionHistoryVizSection
|
||||
key={`${refreshTick}-${days}`}
|
||||
externalPeriod={days}
|
||||
embedded
|
||||
visibility={cfg}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user