- 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.
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
/**
|
|
* 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
|
|
}
|