From 389def90562bc5d52fa2b3827e2fde5f14d15f9c Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 3 Apr 2025 13:40:41 +0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(podkop):=20remove?= =?UTF-8?q?=20unused=20createErrorModal=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/view/podkop/podkop.js | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js index 149b543..91493b1 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js @@ -871,32 +871,6 @@ async function getPodkopErrors() { } } -function createErrorModal(errors) { - return [ - E('div', { - 'class': 'panel-body', - style: 'max-height: 70vh; overflow-y: auto; margin: 1em 0; padding: 1.5em; ' + - 'font-family: monospace; white-space: pre-wrap; word-wrap: break-word; ' + - 'line-height: 1.5; font-size: 14px; background-color: #1e1e1e; color: #e0e0e0;' - }, [ - E('pre', { style: 'margin: 0; white-space: pre-wrap;' }, errors) - ]), - E('div', { - 'class': 'right', - style: 'margin-top: 1em;' - }, [ - E('button', { - 'class': 'btn', - 'click': ev => copyToClipboard(errors, ev.target) - }, _('Copy')), - E('button', { - 'class': 'btn', - 'click': ui.hideModal - }, _('Close')) - ]) - ]; -} - let errorPollTimer = null; let lastErrorsSet = new Set(); let isInitialCheck = true; @@ -906,7 +880,7 @@ function showErrorNotification(error, isMultiple = false) { E('pre', { 'class': 'error-log' }, error) ]); - const notification = ui.addNotification(null, notificationContent); + ui.addNotification(null, notificationContent); } function startErrorPolling() { @@ -918,10 +892,8 @@ function startErrorPolling() { const result = await safeExec('/usr/bin/podkop', ['check_logs']); if (!result || !result.stdout) return; - // Get all logs since last "Starting podkop" const logs = result.stdout; - // Extract all error messages const errorLines = logs.split('\n').filter(line => line.includes('error') || line.includes('Error') || @@ -929,34 +901,26 @@ function startErrorPolling() { ); if (errorLines.length > 0) { - // Create a set of current errors const currentErrors = new Set(errorLines); if (isInitialCheck) { - // При первой проверке показываем все ошибки в одном уведомлении if (errorLines.length > 0) { showErrorNotification(errorLines.join('\n'), true); } isInitialCheck = false; } else { - // Find new errors that weren't shown before const newErrors = [...currentErrors].filter(error => !lastErrorsSet.has(error)); - // Show each new error as a separate notification newErrors.forEach(error => { showErrorNotification(error, false); }); } - - // Update the set of shown errors lastErrorsSet = currentErrors; } } - // Initial check checkErrors(); - // Set up polling errorPollTimer = setInterval(checkErrors, ERROR_POLL_INTERVAL); }