feat(dashboard): enhance widget availability and initialization
All checks were successful
Deploy to production / deploy (push) Successful in 3m2s

- Updated `getAvailableWidgets` method in `DashboardService` to merge default widget types with database entries, ensuring immediate visibility of new widgets post-deployment.
- Introduced `DASHBOARD_WIDGET_TYPE_DEFAULTS` in `initializeWidgetTypes` for canonical widget types, facilitating API merging when database entries are absent.
- Modified `StatusBar.vue` to utilize a computed property for quick access children, improving menu item handling and visibility based on user context.
- Enhanced `LoggedInView.vue` to dynamically return localized widget labels, improving user experience with accurate translations.
This commit is contained in:
Torsten Schulz (local)
2026-04-02 15:19:08 +02:00
parent 5fcd55be43
commit 49713d957d
5 changed files with 95 additions and 20 deletions

View File

@@ -4,7 +4,8 @@ import WidgetType from '../models/type/widget_type.js';
* Default rows for type.widget_type. Labels/descriptions are German for DB/admin readability;
* the web app maps known `endpoint` values to localized strings (see LoggedInView / home.dashboard.widgetLabels).
*/
const DEFAULT_WIDGET_TYPES = [
/** Kanonische Widget-Typen (auch für API-Merge, falls DB noch keine Zeile hat) */
export const DASHBOARD_WIDGET_TYPE_DEFAULTS = [
{ label: 'Termine', endpoint: '/api/termine', description: 'Bevorstehende Termine', orderId: 1 },
{ label: 'Falukant', endpoint: '/api/falukant/dashboard-widget', description: 'Charakter, Geld, Nachrichten, Kinder', orderId: 2 },
{ label: 'News', endpoint: '/api/news?language=de&category=top', description: 'Nachrichten (newsdata.io), Counter für Pagination', orderId: 3 },
@@ -17,9 +18,12 @@ const DEFAULT_WIDGET_TYPES = [
/**
* Stellt die Standard-Widget-Typen in type.widget_type bereit.
* Idempotent: vorhandene Einträge werden nicht verändert.
*
* Produktion ohne Sync/Init: manuell backend/sql/seed_dashboard_widget_types.sql ausführen
* (muss dieselben Endpoints wie DASHBOARD_WIDGET_TYPE_DEFAULTS enthalten).
*/
const initializeWidgetTypes = async () => {
for (const row of DEFAULT_WIDGET_TYPES) {
for (const row of DASHBOARD_WIDGET_TYPE_DEFAULTS) {
await WidgetType.findOrCreate({
where: { endpoint: row.endpoint },
defaults: {