diff --git a/docs/admin/index.html b/docs/admin/index.html index 79e3331..17b76ba 100644 --- a/docs/admin/index.html +++ b/docs/admin/index.html @@ -8,4 +8,5 @@ All updates
\ No newline at end of file +Blog posts
\ No newline at end of file diff --git a/docs/css/custom.css b/docs/css/custom.css index 04b471b..313e046 100644 --- a/docs/css/custom.css +++ b/docs/css/custom.css @@ -1364,6 +1364,7 @@ border-collapse: collapse; font-size: 0.88rem; margin-top: 1rem; + background: var(--background-color); } .admin-table th, @@ -1373,9 +1374,9 @@ border-bottom: 1px solid var(--background-color1, #e0e0e0); } -.admin-table th { +.admin-table__header th { font-weight: 700; - background: var(--background-color1, #f5f5f5); + background: var(--background-color); } .admin-table tr:last-child td { @@ -1400,11 +1401,39 @@ background: #d4edda; color: #155724; } +.admin-badge--admin { + background: #dbeafe; + color: #1e3a8a; +} .admin-badge--blocked { background: #f8d7da; color: #721c24; } +.admin-search { + display: block; + max-width: 32rem; + margin-top: 1rem; +} + +.admin-search__label { + display: block; + margin-bottom: 0.35rem; + font-size: 0.88rem; + font-weight: 600; +} + +.admin-search__input { + box-sizing: border-box; + width: 100%; + padding: 0.55rem 0.7rem; + border: 1px solid var(--background-color1, #ccc); + border-radius: 4px; + background: var(--background-color); + color: var(--foreground-color); + font: inherit; +} + .admin-btn { padding: 0.25rem 0.65rem; border: none; diff --git a/layouts/admin/single.html b/layouts/admin/single.html index 77439d8..8eab20b 100644 --- a/layouts/admin/single.html +++ b/layouts/admin/single.html @@ -6,6 +6,16 @@ @@ -19,6 +29,8 @@ var panel = document.getElementById('admin-panel'); var msg = document.getElementById('admin-msg'); var wrap = document.getElementById('admin-table-wrap'); + var search = document.getElementById('admin-user-search'); + var allUsers = []; if (username !== 'hyzen') { gate.style.display = ''; @@ -41,24 +53,32 @@ function renderTable(users) { if (!users.length) { - wrap.innerHTML = '

No users found.

'; + wrap.innerHTML = '

No matching users found.

'; return; } + var adminIndex = users.findIndex(function (u) { + return u.username === username; + }); + var adminUser = adminIndex === -1 ? null : users[adminIndex]; + var otherUsers = users.filter(function (u) { + return u.username !== username; + }); var html = '' + - '' + - '' + - ''; + '' + + '' + + (adminUser ? '' : '') + + ''; - users.forEach(function (u) { + function userRow(u, isCurrentUser) { var joined = new Date(u.created_at).toLocaleDateString(); var blocked = u.blocked === true || u.blocked === 't' || u.blocked === '1'; - var status = blocked - ? 'Blocked' - : 'Active'; - - var isCurrentUser = u.username === username; + var status = isCurrentUser + ? 'Admin' + : blocked + ? 'Blocked' + : 'Active'; var blockBtn = ''; var deleteBtn = ''; @@ -79,7 +99,7 @@ '" data-action="delete_user">Delete Records'; } - html += + return ( '' + @@ -98,12 +118,18 @@ '' + - '' + - ''; + (isCurrentUser + ? '' + : '') + + '' + ); + } + + if (adminUser) { + html += userRow(adminUser, true); + } + otherUsers.forEach(function (u) { + html += userRow(u, false); }); html += '
#UsernameEmailJoinedStatusActions
#UsernameEmailJoinedStatusActionsActions
' + status + '' + - blockBtn + - ' ' + - deleteBtn + - '
' + blockBtn + ' ' + deleteBtn + '
'; @@ -145,11 +171,12 @@ .then(function (data) { if (data.success) { if (action === 'delete_user') { - var row = document.getElementById('user-row-' + id); - if (row) row.remove(); + allUsers = allUsers.filter(function (u) { + return Number(u.id) !== id; + }); + filterUsers(); showMsg('User deleted.', 'success'); } else { - // Reload to reflect new block state loadUsers(); } } else { @@ -175,7 +202,8 @@ }) .then(function (data) { if (data.success) { - renderTable(data.users); + allUsers = data.users; + filterUsers(); } else { wrap.innerHTML = '

' + @@ -188,6 +216,19 @@ }); } + function filterUsers() { + var query = search.value.trim().toLowerCase(); + var users = allUsers.filter(function (u) { + return ( + !query || + String(u.username).toLowerCase().includes(query) || + String(u.email).toLowerCase().includes(query) + ); + }); + renderTable(users); + } + + search.addEventListener('input', filterUsers); loadUsers(); })(); diff --git a/static/css/custom.css b/static/css/custom.css index 04b471b..313e046 100644 --- a/static/css/custom.css +++ b/static/css/custom.css @@ -1364,6 +1364,7 @@ border-collapse: collapse; font-size: 0.88rem; margin-top: 1rem; + background: var(--background-color); } .admin-table th, @@ -1373,9 +1374,9 @@ border-bottom: 1px solid var(--background-color1, #e0e0e0); } -.admin-table th { +.admin-table__header th { font-weight: 700; - background: var(--background-color1, #f5f5f5); + background: var(--background-color); } .admin-table tr:last-child td { @@ -1400,11 +1401,39 @@ background: #d4edda; color: #155724; } +.admin-badge--admin { + background: #dbeafe; + color: #1e3a8a; +} .admin-badge--blocked { background: #f8d7da; color: #721c24; } +.admin-search { + display: block; + max-width: 32rem; + margin-top: 1rem; +} + +.admin-search__label { + display: block; + margin-bottom: 0.35rem; + font-size: 0.88rem; + font-weight: 600; +} + +.admin-search__input { + box-sizing: border-box; + width: 100%; + padding: 0.55rem 0.7rem; + border: 1px solid var(--background-color1, #ccc); + border-radius: 4px; + background: var(--background-color); + color: var(--foreground-color); + font: inherit; +} + .admin-btn { padding: 0.25rem 0.65rem; border: none;