From b6f6d16817d272f50cfada06633d4be4cb78a4d1 Mon Sep 17 00:00:00 2001 From: Michael Reber Date: Sat, 24 Jan 2026 15:15:13 +0100 Subject: [PATCH] Added the 'show more' button to the Permanent Block Log in Settings and only show 10entries by default --- pkg/web/static/js/settings.js | 72 +++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/pkg/web/static/js/settings.js b/pkg/web/static/js/settings.js index 3d17021..fbe1d89 100644 --- a/pkg/web/static/js/settings.js +++ b/pkg/web/static/js/settings.js @@ -395,6 +395,25 @@ function loadPermanentBlockLog() { }); } +function renderPermanentBlockLogRow(block) { + const statusClass = block.status === 'blocked' + ? 'text-green-600' + : (block.status === 'unblocked' ? 'text-gray-500' : 'text-red-600'); + const message = block.message ? escapeHtml(block.message) : ''; + return '' + + '' + + ' ' + escapeHtml(block.ip) + '' + + ' ' + escapeHtml(block.integration) + '' + + ' ' + escapeHtml(block.status) + '' + + ' ' + (message || ' ') + '' + + ' ' + escapeHtml(block.serverId || '') + '' + + ' ' + (block.updatedAt ? new Date(block.updatedAt).toLocaleString() : '') + '' + + ' ' + + ' ' + + ' ' + + ''; +} + function renderPermanentBlockLog(blocks) { const container = document.getElementById('permanentBlockLog'); if (!container) return; @@ -403,25 +422,14 @@ function renderPermanentBlockLog(blocks) { if (typeof updateTranslations === 'function') updateTranslations(); return; } - let rows = blocks.map(block => { - const statusClass = block.status === 'blocked' - ? 'text-green-600' - : (block.status === 'unblocked' ? 'text-gray-500' : 'text-red-600'); - const message = block.message ? escapeHtml(block.message) : ''; - return '' - + '' - + ' ' + escapeHtml(block.ip) + '' - + ' ' + escapeHtml(block.integration) + '' - + ' ' + escapeHtml(block.status) + '' - + ' ' + (message || ' ') + '' - + ' ' + escapeHtml(block.serverId || '') + '' - + ' ' + (block.updatedAt ? new Date(block.updatedAt).toLocaleString() : '') + '' - + ' ' - + ' ' - + ' ' - + ''; - }).join(''); - container.innerHTML = '' + const maxVisible = 10; + const visible = blocks.slice(0, maxVisible); + const hidden = blocks.slice(maxVisible); + + let visibleRows = visible.map(renderPermanentBlockLogRow).join(''); + let hiddenRows = hidden.map(renderPermanentBlockLogRow).join(''); + + let html = '' + '' + ' ' + ' ' @@ -434,8 +442,30 @@ function renderPermanentBlockLog(blocks) { + ' ' + ' ' + ' ' - + ' ' + rows + '' - + '
Actions
'; + + ' ' + visibleRows + ''; + + if (hidden.length > 0) { + const hiddenId = 'permanentBlockLog-hidden'; + const toggleId = 'permanentBlockLog-toggle'; + const moreLabel = (typeof t === 'function' ? t('dashboard.banned.show_more', 'Show more') : 'Show more') + ' +' + hidden.length; + const lessLabel = typeof t === 'function' ? t('dashboard.banned.show_less', 'Hide extra') : 'Hide extra'; + html += '' + + ' ' + hiddenRows + '' + + '' + + ''; + } else { + html += ''; + } + + container.innerHTML = html; if (typeof updateTranslations === 'function') updateTranslations(); }