feat: add history_overview_viz widget and enhance configuration handling
- Introduced the `history_overview_viz` widget to the dashboard, allowing users to visualize consolidated history data across various metrics. - Updated widget configuration to include `history_overview_viz` in the allowed widgets and added validation for its configuration. - Enhanced the widget catalog with details for the new `history_overview_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 `history_overview_viz` widget configuration. - Bumped application version to reflect the addition of the new widget.
This commit is contained in:
1 parent
e20b321b64
commit
97dbb0f80b
15 files changed
+1105
-727
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS,
|
||||
normalizeHistoryOverviewVizConfig,
|
||||
} from './historyOverviewVizConfig'
|
||||
|
||||
const TOGGLES = [
|
||||
{ key: 'show_confidence_banner', label: 'Banner «Datenlage»' },
|
||||
{ key: 'show_intro_blurb', label: 'Hinweistext (Ernährung / API)' },
|
||||
{ key: 'show_area_summaries', label: 'Kacheln Körper · Ernährung · Fitness · Erholung' },
|
||||
{ key: 'show_correlation_c1_c3', label: 'Lag-Korrelationen C1–C3 (Charts)' },
|
||||
{ key: 'show_drivers_c4', label: 'Einflussfaktoren C4' },
|
||||
]
|
||||
|
||||
/**
|
||||
* @param {{ config: Record<string, unknown>, onChange: (next: Record<string, unknown>) => void }} props
|
||||
*/
|
||||
export default function HistoryOverviewVizConfigEditor({ config, onChange }) {
|
||||
const merged = normalizeHistoryOverviewVizConfig(config)
|
||||
|
||||
const patch = (partial) => {
|
||||
const next = { ...merged, ...partial }
|
||||
const def = HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS
|
||||
const stored = {}
|
||||
for (const k of Object.keys(def)) {
|
||||
if (next[k] !== def[k]) stored[k] = next[k]
|
||||
}
|
||||
onChange(stored)
|
||||
}
|
||||
|
||||
const setBool = (key, checked) => {
|
||||
patch({ [key]: checked })
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ marginTop: 10, marginLeft: 28 }}>
|
||||
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 8, lineHeight: 1.5 }}>
|
||||
<strong>Gesamtübersicht (Verlauf-Bundle):</strong> konsolidierte Kurzinfos und Korrelations-Kacheln — wie im Verlauf-Reiter «Gesamt».
|
||||
</div>
|
||||
<div style={{ fontSize: 12, color: 'var(--text2)', marginBottom: 6 }}>Bereiche</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||
{TOGGLES.map(({ key, label }) => (
|
||||
<label key={key} style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' }}>
|
||||
<input type="checkbox" checked={merged[key]} onChange={(e) => setBool(key, e.target.checked)} />
|
||||
<span>{label}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Sichtbarkeit für history_overview_viz (sync mit backend dashboard_widget_config).
|
||||
* `visibility === undefined` → Verlauf-Tab: volle Gesamtübersicht (wie bisher).
|
||||
*/
|
||||
|
||||
export const HISTORY_OVERVIEW_VIZ_PAGE_FULL = {
|
||||
chart_days: 30,
|
||||
show_confidence_banner: true,
|
||||
show_intro_blurb: true,
|
||||
show_area_summaries: true,
|
||||
show_correlation_c1_c3: true,
|
||||
show_drivers_c4: true,
|
||||
}
|
||||
|
||||
export const HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS = {
|
||||
chart_days: 30,
|
||||
show_confidence_banner: true,
|
||||
show_intro_blurb: true,
|
||||
show_area_summaries: true,
|
||||
show_correlation_c1_c3: true,
|
||||
show_drivers_c4: true,
|
||||
}
|
||||
|
||||
const BOOL_KEYS = [
|
||||
'show_confidence_banner',
|
||||
'show_intro_blurb',
|
||||
'show_area_summaries',
|
||||
'show_correlation_c1_c3',
|
||||
'show_drivers_c4',
|
||||
]
|
||||
|
||||
/**
|
||||
* @param {Record<string, unknown>|null|undefined} raw
|
||||
*/
|
||||
export function normalizeHistoryOverviewVizConfig(raw) {
|
||||
const base = { ...HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS }
|
||||
if (!raw || typeof raw !== 'object') return base
|
||||
for (const k of BOOL_KEYS) {
|
||||
if (Object.prototype.hasOwnProperty.call(raw, k)) {
|
||||
base[k] = raw[k] === true
|
||||
}
|
||||
}
|
||||
if (raw.chart_days != null) {
|
||||
const n = Number(raw.chart_days)
|
||||
if (Number.isFinite(n)) {
|
||||
base.chart_days = Math.min(90, Math.max(7, Math.round(n)))
|
||||
}
|
||||
}
|
||||
return base
|
||||
}
|
||||
@@ -18,10 +18,12 @@ import BodyHistoryVizWidget from '../components/dashboard-widgets/BodyHistoryViz
|
||||
import NutritionHistoryVizWidget from '../components/dashboard-widgets/NutritionHistoryVizWidget'
|
||||
import FitnessHistoryVizWidget from '../components/dashboard-widgets/FitnessHistoryVizWidget'
|
||||
import RecoveryHistoryVizWidget from '../components/dashboard-widgets/RecoveryHistoryVizWidget'
|
||||
import HistoryOverviewVizWidget from '../components/dashboard-widgets/HistoryOverviewVizWidget'
|
||||
import { normalizeBodyHistoryVizConfig } from './bodyHistoryVizConfig'
|
||||
import { normalizeNutritionHistoryVizConfig } from './nutritionHistoryVizConfig'
|
||||
import { normalizeFitnessHistoryVizConfig } from './fitnessHistoryVizConfig'
|
||||
import { normalizeRecoveryHistoryVizConfig } from './recoveryHistoryVizConfig'
|
||||
import { normalizeHistoryOverviewVizConfig } from './historyOverviewVizConfig'
|
||||
import RecoveryChartsPanelWidget from '../components/dashboard-widgets/RecoveryChartsPanelWidget'
|
||||
import ProgressPhotosWidget from '../components/dashboard-widgets/ProgressPhotosWidget'
|
||||
import RecoverySleepRestWidget from '../components/dashboard-widgets/RecoverySleepRestWidget'
|
||||
@@ -152,6 +154,14 @@ export function ensurePilotLabWidgetsRegistered() {
|
||||
recoveryHistoryVizConfig: normalizeRecoveryHistoryVizConfig(ctx.layoutEntry?.config),
|
||||
}),
|
||||
})
|
||||
registerDashboardWidget({
|
||||
id: 'history_overview_viz',
|
||||
Component: HistoryOverviewVizWidget,
|
||||
mapProps: (ctx) => ({
|
||||
refreshTick: ctx.refreshTick,
|
||||
historyOverviewVizConfig: normalizeHistoryOverviewVizConfig(ctx.layoutEntry?.config),
|
||||
}),
|
||||
})
|
||||
registerDashboardWidget({
|
||||
id: 'recovery_charts_panel',
|
||||
Component: RecoveryChartsPanelWidget,
|
||||
|
||||
Reference in new issue
Block a user