diff --git a/admin.html b/admin.html
index eedb0a5..6dd2e5c 100644
--- a/admin.html
+++ b/admin.html
@@ -232,10 +232,28 @@ tailwind.config = {
-
+
+
+
+
+
+
+
+
+
@@ -659,6 +677,49 @@ tailwind.config = {
}
});
+ // ─── Schnell-Kategorie aus Übersicht ─────────────────────
+ document.getElementById('overviewAddCatBtn').addEventListener('click', function () {
+ document.getElementById('overviewAddCatForm').classList.remove('hidden');
+ document.getElementById('overviewNewCatInput').focus();
+ });
+ document.getElementById('overviewCancelCatBtn').addEventListener('click', function () {
+ document.getElementById('overviewAddCatForm').classList.add('hidden');
+ document.getElementById('overviewNewCatInput').value = '';
+ });
+ async function overviewSaveCat() {
+ const input = document.getElementById('overviewNewCatInput');
+ const name = input.value.trim();
+ if (!name) return;
+ try {
+ const r = await fetch('/api/categories', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ name })
+ });
+ const data = await r.json();
+ if (r.ok) {
+ allCategories = data.categories;
+ input.value = '';
+ document.getElementById('overviewAddCatForm').classList.add('hidden');
+ renderKatButtons();
+ renderFilterButtons();
+ renderEditKatOptions();
+ renderCatManage();
+ loadStats();
+ showToast('✓ Kategorie "' + name + '" hinzugefügt');
+ } else {
+ showToast(data.error || 'Fehler');
+ }
+ } catch (e) {
+ showToast('Verbindungsfehler');
+ }
+ }
+ document.getElementById('overviewSaveCatBtn').addEventListener('click', overviewSaveCat);
+ document.getElementById('overviewNewCatInput').addEventListener('keydown', function (e) {
+ if (e.key === 'Enter') overviewSaveCat();
+ if (e.key === 'Escape') document.getElementById('overviewCancelCatBtn').click();
+ });
+
// ─── Drag & Drop ──────────────────────────────────────────
const dropZone = document.getElementById('dropZone');
const fileInput = document.getElementById('fileInput');
@@ -878,17 +939,32 @@ tailwind.config = {
const photos = data.photos || [];
document.getElementById('statPhotos').textContent = photos.length;
- const counts = { Training: 0, 'Wettkämpfe': 0, 'Gürtelprüfungen': 0 };
+ const counts = {};
let lastDate = null;
photos.forEach(p => {
- if (counts[p.kategorie] !== undefined) counts[p.kategorie]++;
+ counts[p.kategorie] = (counts[p.kategorie] || 0) + 1;
const ts = parseInt(p.id);
if (!isNaN(ts) && (!lastDate || ts > lastDate)) lastDate = ts;
});
- document.getElementById('catTraining').textContent = counts['Training'] + ' Fotos';
- document.getElementById('catWettkampf').textContent = counts['Wettkämpfe'] + ' Fotos';
- document.getElementById('catGuertel').textContent = counts['Gürtelprüfungen'] + ' Fotos';
+ const icons = ['fitness_center', 'emoji_events', 'workspace_premium', 'sports_martial_arts', 'star', 'label'];
+ const colors = ['bg-pink-100 text-primary', 'bg-purple-100 text-secondary', 'bg-amber-100 text-amber-600', 'bg-blue-100 text-blue-600', 'bg-green-100 text-green-600', 'bg-surface-container text-on-surface-variant'];
+ const list = document.getElementById('catOverviewList');
+ list.innerHTML = '';
+ allCategories.forEach(function (kat, i) {
+ const colorClass = colors[i % colors.length];
+ const icon = icons[i % icons.length];
+ const row = document.createElement('div');
+ row.className = 'flex items-center justify-between';
+ row.innerHTML =
+ '' +
+ '
' +
+ '' + icon + '
' +
+ '
' + escHtml(kat) + '' +
+ '
' +
+ '' + (counts[kat] || 0) + ' Fotos';
+ list.appendChild(row);
+ });
if (lastDate) {
const d = new Date(lastDate);
@@ -1047,7 +1123,7 @@ tailwind.config = {
});
// ─── Init ─────────────────────────────────────────────────
- loadStats();
+ loadCategories().then(function () { loadStats(); });
})();