feat: Remove deprecated pilot widgets and layout management
- Deleted unused components: GoalsSnapshotWidget, ReferenceValuesSummaryWidget, WeightKpiWidget, and PilotVizAdminCard. - Removed associated layout storage and widget registry logic to streamline the pilot visualization module. - Updated PilotVizPage to integrate new components for improved user experience and functionality.
This commit is contained in:
1 parent
8c8f595385
commit
c0cb995a7b
15 files changed
+837
-504
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
/** Gleiche Logik wie History.jsx für rollierende Mittel */
|
||||
export function rollingAvg(arr, key, window = 7) {
|
||||
return arr.map((d, i) => {
|
||||
const s = arr
|
||||
.slice(Math.max(0, i - window + 1), i + 1)
|
||||
.map((x) => x[key])
|
||||
.filter((v) => v != null)
|
||||
return s.length
|
||||
? { ...d, [`${key}_avg`]: Math.round((s.reduce((a, b) => a + b, 0) / s.length) * 10) / 10 }
|
||||
: d
|
||||
})
|
||||
}
|
||||
|
||||
export const fmtDate = (d) => dayjs(d).format('DD.MM')
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Pilot-Layout: nur lokal (localStorage), kein Server.
|
||||
* Dient zum Testen von Sichtbarkeit und Reihenfolge vor einer DB-Lösung.
|
||||
*/
|
||||
|
||||
import { PILOT_WIDGET_DEFS, PILOT_WIDGET_IDS_DEFAULT_ORDER } from './widgetRegistry'
|
||||
|
||||
const STORAGE_KEY = 'mitai_pilot_viz_layout_v1'
|
||||
|
||||
function defaultLayout() {
|
||||
const order = [...PILOT_WIDGET_IDS_DEFAULT_ORDER]
|
||||
const enabled = Object.fromEntries(order.map((id) => [id, true]))
|
||||
return { version: 1, order, enabled}
|
||||
}
|
||||
|
||||
function mergeWithRegistry(saved) {
|
||||
if (!saved || typeof saved !== 'object') return defaultLayout()
|
||||
const known = new Set(Object.keys(PILOT_WIDGET_DEFS))
|
||||
let order = Array.isArray(saved.order) ? saved.order.filter((id) => known.has(id)) : []
|
||||
for (const id of PILOT_WIDGET_IDS_DEFAULT_ORDER) {
|
||||
if (!order.includes(id)) order.push(id)
|
||||
}
|
||||
const enabled = { ...defaultLayout().enabled, ...(saved.enabled && typeof saved.enabled === 'object' ? saved.enabled : {}) }
|
||||
for (const id of Object.keys(PILOT_WIDGET_DEFS)) {
|
||||
if (typeof enabled[id] !== 'boolean') enabled[id] = true
|
||||
}
|
||||
return { version: 1, order, enabled }
|
||||
}
|
||||
|
||||
export function loadPilotLayout() {
|
||||
try {
|
||||
const raw = localStorage.getItem(STORAGE_KEY)
|
||||
if (!raw) return defaultLayout()
|
||||
return mergeWithRegistry(JSON.parse(raw))
|
||||
} catch {
|
||||
return defaultLayout()
|
||||
}
|
||||
}
|
||||
|
||||
export function savePilotLayout(layout) {
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(layout))
|
||||
} catch {
|
||||
/* ignore quota */
|
||||
}
|
||||
}
|
||||
|
||||
export function resetPilotLayout() {
|
||||
const d = defaultLayout()
|
||||
savePilotLayout(d)
|
||||
return d
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import ReferenceValuesSummaryWidget from '../components/pilot/ReferenceValuesSummaryWidget'
|
||||
import GoalsSnapshotWidget from '../components/pilot/GoalsSnapshotWidget'
|
||||
import WeightKpiWidget from '../components/pilot/WeightKpiWidget'
|
||||
|
||||
/**
|
||||
* Pilot: Widget-Registry (Layer 3b-Vorspiel).
|
||||
* Reihenfolge-Default: PILOT_WIDGET_IDS_DEFAULT_ORDER
|
||||
*/
|
||||
export const PILOT_WIDGET_IDS_DEFAULT_ORDER = ['weight_kpi', 'goals_teaser', 'reference_values_summary']
|
||||
|
||||
export const PILOT_WIDGET_DEFS = {
|
||||
weight_kpi: {
|
||||
id: 'weight_kpi',
|
||||
title: 'Gewicht (KPI)',
|
||||
description: 'Letzter Eintrag und Delta zum vorherigen Messwert (API weight/stats).',
|
||||
Component: WeightKpiWidget,
|
||||
},
|
||||
goals_teaser: {
|
||||
id: 'goals_teaser',
|
||||
title: 'Strategische Ziele',
|
||||
description: 'Anzahl aktiver Ziele, Link zur Ziele-Seite (API goals/list).',
|
||||
Component: GoalsSnapshotWidget,
|
||||
},
|
||||
reference_values_summary: {
|
||||
id: 'reference_values_summary',
|
||||
title: 'Referenzwerte',
|
||||
description: 'Aktuellste Kennwerte pro Typ (Layer 1 → /profile-reference-values/summary).',
|
||||
Component: ReferenceValuesSummaryWidget,
|
||||
},
|
||||
}
|
||||
|
||||
/** Sichtbare Widgets in gespeicherter Reihenfolge (für Render). */
|
||||
export function resolvePilotWidgetsForRender(layout) {
|
||||
if (!layout?.order) return []
|
||||
return layout.order
|
||||
.filter((id) => layout.enabled[id] && PILOT_WIDGET_DEFS[id])
|
||||
.map((id) => PILOT_WIDGET_DEFS[id])
|
||||
}
|
||||
Reference in new issue
Block a user