feat: Extend widget configuration for activity overview and improve validation
Deploy Development / deploy (push) Successful in 55s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 16s

- Added support for the "activity_overview" widget in the dashboard configuration, allowing for chart_days validation.
- Refactored validation logic to streamline error handling for both "body_overview" and "activity_overview" widgets.
- Updated the widget catalog description to reflect the new configuration options.
- Enhanced the DashboardLabPage to manage chart_days input for both widgets, improving user experience.
- Bumped app_dashboard version to 1.3.0 to reflect these enhancements.
This commit is contained in:
Lars committed 2026-04-07 12:20:23 +02:00
1 parent 4493b140bd
commit b617212145
9 files changed
+164 -60

No files matched your search

@@ -0,0 +1,51 @@
import { Component } from 'react'
/**
* Verhindert, dass ein fehlerhaftes Dashboard-Widget die ganze Seite mitreißt.
*/
export default class WidgetErrorBoundary extends Component {
constructor(props) {
super(props)
this.state = { error: null }
}
static getDerivedStateFromError(error) {
return { error }
}
render() {
if (this.state.error) {
const msg =
this.state.error && typeof this.state.error === 'object' && 'message' in this.state.error
? String(this.state.error.message)
: String(this.state.error)
return (
<div
className="card section-gap"
style={{ marginBottom: 16, borderColor: 'var(--danger, #D85A30)' }}
>
<div className="card-title" style={{ color: 'var(--danger, #D85A30)' }}>
Widget-Fehler
</div>
<p style={{ fontSize: 12, color: 'var(--text2)', margin: '4px 0 8px' }}>
<code>{this.props.widgetId}</code>
</p>
<pre
style={{
fontSize: 11,
overflow: 'auto',
margin: 0,
padding: 8,
background: 'var(--surface2)',
borderRadius: 8,
color: 'var(--text2)',
}}
>
{msg}
</pre>
</div>
)
}
return this.props.children
}
}
@@ -1,3 +1,5 @@
import WidgetErrorBoundary from './WidgetErrorBoundary'
/**
* @typedef {object} LayoutWidgetEntry
* @property {string} id
@@ -52,7 +54,11 @@ export function renderRegisteredWidget(id, ctx) {
}
const { Component } = spec
const props = spec.mapProps ? spec.mapProps(ctx) : {}
return <Component key={id} {...props} />
return (
<WidgetErrorBoundary key={id} widgetId={id}>
<Component {...props} />
</WidgetErrorBoundary>
)
}
/**
@@ -41,7 +41,10 @@ export function ensurePilotLabWidgetsRegistered() {
registerDashboardWidget({
id: 'activity_overview',
Component: PilotActivitySection,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: normalizeBodyChartDays(ctx.layoutEntry?.config?.chart_days),
}),
})
}