Add user list to admin panel and validated/guest badges on posts
Admin panel: new "Käyttäjät" section showing all registered users with post count, likes count, email and join date. Posts: submissions by logged-in users show a green "Vahvistettu" badge, while guest submissions show a random code (e.g. #L01U51) for tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
admin.html
43
admin.html
@@ -159,6 +159,14 @@
|
||||
.cat-info { flex: 1; font-family: Arial, sans-serif; font-size: 0.88rem; color: #3b2a1a; }
|
||||
.cat-info span { color: #7a5c3e; font-size: 0.78rem; }
|
||||
|
||||
/* User list */
|
||||
.user-table { width: 100%; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 0.88rem; }
|
||||
.user-table th { text-align: left; color: #7a5c3e; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 10px; border-bottom: 2px solid #e8d5c0; }
|
||||
.user-table td { padding: 9px 10px; border-bottom: 1px solid #f0e8dc; color: #3b2a1a; }
|
||||
.user-table tr:last-child td { border-bottom: none; }
|
||||
.user-table .user-nick { font-weight: bold; color: #7c4a1e; }
|
||||
.user-table .badge { display: inline-block; background: #f0e8dc; color: #7a5c3e; padding: 2px 8px; border-radius: 10px; font-size: 0.78rem; }
|
||||
|
||||
.empty-state { text-align: center; color: #7a5c3e; font-style: italic; padding: 20px 0; }
|
||||
|
||||
.toast {
|
||||
@@ -340,9 +348,15 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<!-- RIGHT: Categories + Post list -->
|
||||
<!-- RIGHT: Users + Categories + Post list -->
|
||||
<div class="section-right">
|
||||
|
||||
<!-- USERS -->
|
||||
<section class="admin-panel">
|
||||
<h2>Käyttäjät</h2>
|
||||
<div id="userList"><p class="empty-state">Ladataan...</p></div>
|
||||
</section>
|
||||
|
||||
<!-- CATEGORIES -->
|
||||
<section class="admin-panel">
|
||||
<h2 id="lbl_categories">Kategoriat</h2>
|
||||
@@ -454,17 +468,20 @@
|
||||
}
|
||||
|
||||
async function loadAdminData() {
|
||||
const [postsData, catsData] = await Promise.all([
|
||||
const [postsData, catsData, usersData] = await Promise.all([
|
||||
apiGet('posts'),
|
||||
apiGet('categories'),
|
||||
apiGet('admin_users'),
|
||||
]);
|
||||
ADMIN.posts = postsData.posts || [];
|
||||
ADMIN.categories = catsData.categories || [];
|
||||
ADMIN.users = usersData.users || [];
|
||||
document.getElementById('backLink').textContent = at('back');
|
||||
document.getElementById('saveBtn').textContent = at('save');
|
||||
populateCategorySelect();
|
||||
renderCatList();
|
||||
renderPostList();
|
||||
renderUserList();
|
||||
}
|
||||
|
||||
// ===========================
|
||||
@@ -803,6 +820,28 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ===========================
|
||||
// USER LIST
|
||||
// ===========================
|
||||
function renderUserList() {
|
||||
const users = ADMIN.users || [];
|
||||
const el = document.getElementById('userList');
|
||||
if (!users.length) { el.innerHTML = '<p class="empty-state">Ei rekisteröityneitä käyttäjiä.</p>'; return; }
|
||||
el.innerHTML = `
|
||||
<table class="user-table">
|
||||
<thead><tr><th>Nimimerkki</th><th>Sähköposti</th><th>Julkaisut</th><th>Tykkäykset</th><th>Liittynyt</th></tr></thead>
|
||||
<tbody>${users.map(u => `
|
||||
<tr>
|
||||
<td class="user-nick">${u.nickname}</td>
|
||||
<td>${u.email || '<span style="color:#bbb">–</span>'}</td>
|
||||
<td><span class="badge">${u.postCount}</span></td>
|
||||
<td><span class="badge">${u.likes}</span></td>
|
||||
<td>${u.created || '–'}</td>
|
||||
</tr>`).join('')}
|
||||
</tbody>
|
||||
</table>`;
|
||||
}
|
||||
|
||||
// ===========================
|
||||
// TOAST
|
||||
// ===========================
|
||||
|
||||
Reference in New Issue
Block a user