diff --git a/app.js b/app.js
index 538ad2c..c09098d 100644
--- a/app.js
+++ b/app.js
@@ -17,6 +17,7 @@ let cards = [];
let sections = [];
let config = null;
let activeFilter = 'all';
+let categoryById = new Map();
const searchInput = document.querySelector('#serviceSearch');
const segments = [...document.querySelectorAll('.segment')];
@@ -56,6 +57,7 @@ function serviceSearchText(service) {
}
function createServiceCard(service) {
+ const category = categoryById.get(service.category);
const card = document.createElement('a');
card.href = service.url;
card.target = '_blank';
@@ -72,6 +74,7 @@ function createServiceCard(service) {
+
${category?.label || 'Dienst'}
${service.name}
${service.description}
@@ -83,32 +86,41 @@ function createServiceCard(service) {
function renderDashboard(nextConfig) {
dashboardSections.innerHTML = '';
serviceCount.textContent = String(nextConfig.services.length);
+ categoryById = new Map(nextConfig.categories.map((category) => [category.id, category]));
- nextConfig.categories.forEach((category) => {
- const services = nextConfig.services.filter((service) => service.category === category.id);
- if (!services.length) return;
-
- const section = document.createElement('section');
- section.className = 'section';
- section.dataset.category = category.id;
- section.innerHTML = `
-
-
-
${category.label}
-
${category.title}
-
-
${services.length} ${services.length === 1 ? 'Dienst' : 'Dienste'}
+ const section = document.createElement('section');
+ section.className = 'section service-overview';
+ section.innerHTML = `
+
+
+
Dashboard
+
Alle Dienste
-
- `;
+
${nextConfig.services.length} Dienste
+
+
+ `;
- const grid = section.querySelector('.grid');
- services.forEach((service) => grid.appendChild(createServiceCard(service)));
- dashboardSections.appendChild(section);
- });
+ const grid = section.querySelector('.grid');
+ nextConfig.services.forEach((service) => grid.appendChild(createServiceCard(service)));
+ dashboardSections.appendChild(section);
cards = [...document.querySelectorAll('.service-card')];
sections = [...document.querySelectorAll('.section')];
+ updateOverviewHeading(nextConfig.services.length);
+}
+
+function updateOverviewHeading(visibleCards) {
+ const activeCategory = categoryById.get(activeFilter);
+ const term = normalize(searchInput.value);
+ const kicker = document.querySelector('#overviewKicker');
+ const title = document.querySelector('#overviewTitle');
+ const count = document.querySelector('#overviewCount');
+ if (!kicker || !title || !count) return;
+
+ kicker.textContent = activeCategory ? activeCategory.label : 'Dashboard';
+ title.textContent = activeCategory ? activeCategory.title : 'Alle Dienste';
+ count.textContent = `${visibleCards} ${visibleCards === 1 ? 'Dienst' : 'Dienste'}${term ? ' gefunden' : ''}`;
}
function updateVisibility() {
@@ -128,6 +140,7 @@ function updateVisibility() {
section.hidden = !hasVisibleCards;
});
+ updateOverviewHeading(visibleCards);
emptyState.hidden = visibleCards !== 0;
}
diff --git a/index.html b/index.html
index 191dd96..7b18973 100644
--- a/index.html
+++ b/index.html
@@ -13,7 +13,7 @@
-
+
@@ -73,6 +73,6 @@
Status wird im Hintergrund geprueft.
-
+