Add widget management functionality: Implement getAvailableWidgets method in dashboardService to retrieve widget types, and create corresponding API endpoint in dashboardRouter. Update LoggedInView to allow users to select and add widgets dynamically, enhancing dashboard customization options.
This commit is contained in:
@@ -1,7 +1,26 @@
|
||||
import BaseService from './BaseService.js';
|
||||
import UserDashboard from '../models/community/user_dashboard.js';
|
||||
import WidgetType from '../models/type/widget_type.js';
|
||||
|
||||
class DashboardService extends BaseService {
|
||||
/**
|
||||
* Liste aller möglichen (verfügbaren) Widget-Typen.
|
||||
* @returns {Promise<Array<{ id: number, label: string, endpoint: string, description: string|null, orderId: number }>>}
|
||||
*/
|
||||
async getAvailableWidgets() {
|
||||
const rows = await WidgetType.findAll({
|
||||
order: [['orderId', 'ASC'], ['id', 'ASC']],
|
||||
attributes: ['id', 'label', 'endpoint', 'description', 'orderId']
|
||||
});
|
||||
return rows.map(r => ({
|
||||
id: r.id,
|
||||
label: r.label,
|
||||
endpoint: r.endpoint,
|
||||
description: r.description ?? null,
|
||||
orderId: r.orderId
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} hashedUserId
|
||||
* @returns {Promise<{ widgets: Array<{ id: string, title: string, endpoint: string }> }>}
|
||||
|
||||
Reference in New Issue
Block a user