Add news widget functionality: Integrate newsRouter for fetching news data, update initializeWidgetTypes to include news endpoint, and enhance DashboardWidget component to display news articles with pagination support. Update LoggedInView to manage widget request counters for unique endpoint handling.
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
:widget-id="w.id"
|
||||
:title="w.title"
|
||||
:endpoint="w.endpoint"
|
||||
:request-counter="widgetRequestCounter(index)"
|
||||
@drag-start="() => (draggedIndex = index)"
|
||||
@drag-end="() => (draggedIndex = null)"
|
||||
/>
|
||||
@@ -143,6 +144,16 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['logout']),
|
||||
/** Counter für EP: wievieltes Widget mit gleichem Endpoint (0, 1, 2, …), damit z. B. News nicht doppelt. */
|
||||
widgetRequestCounter(index) {
|
||||
const endpoint = this.widgets[index]?.endpoint;
|
||||
if (endpoint == null) return undefined;
|
||||
let count = 0;
|
||||
for (let i = 0; i < index; i++) {
|
||||
if (this.widgets[i].endpoint === endpoint) count++;
|
||||
}
|
||||
return count;
|
||||
},
|
||||
handleLogout() {
|
||||
this.logout();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user