From cf5b2216beb85b5a61408bf1fa4f6d6982718684 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Fri, 16 May 2025 18:23:16 +0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(podkop):=20reorga?= =?UTF-8?q?nize=20sections=20into=20subdirectory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/view/podkop/podkop.js | 6 ++-- .../additional.js} | 0 .../{configSection.js => sections/config.js} | 0 .../diagnostic.js} | 32 +++++-------------- 4 files changed, 11 insertions(+), 27 deletions(-) rename luci-app-podkop/htdocs/luci-static/resources/view/podkop/{additionalSection.js => sections/additional.js} (100%) rename luci-app-podkop/htdocs/luci-static/resources/view/podkop/{configSection.js => sections/config.js} (100%) rename luci-app-podkop/htdocs/luci-static/resources/view/podkop/{diagnosticSection.js => sections/diagnostic.js} (98%) 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 32b1943..066f4af 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 @@ -3,9 +3,9 @@ 'require form'; 'require network'; 'require view.podkop.networkUtils as networkUtils'; -'require view.podkop.configSection as config'; -'require view.podkop.diagnosticSection as diagnostic'; -'require view.podkop.additionalSection as additional'; +'require view.podkop.sections.config as config'; +'require view.podkop.sections.diagnostic as diagnostic'; +'require view.podkop.sections.additional as additional'; return view.extend({ async render() { diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/additionalSection.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/additional.js similarity index 100% rename from luci-app-podkop/htdocs/luci-static/resources/view/podkop/additionalSection.js rename to luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/additional.js diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/configSection.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/config.js similarity index 100% rename from luci-app-podkop/htdocs/luci-static/resources/view/podkop/configSection.js rename to luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/config.js diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticSection.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/diagnostic.js similarity index 98% rename from luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticSection.js rename to luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/diagnostic.js index 6831020..967977a 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/diagnosticSection.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/sections/diagnostic.js @@ -7,6 +7,14 @@ 'require view.podkop.constants as constants'; // Helper Functions +// Common status object creator +function createStatus(state, message, color) { + return { + state, + message: _(message), + color: constants.STATUS_COLORS[color] + }; +} function formatDiagnosticOutput(output) { if (typeof output !== 'string') return ''; return output.trim() @@ -63,12 +71,6 @@ async function safeExec(command, args = [], timeout = constants.COMMAND_TIMEOUT) // Status Check Functions async function checkFakeIP() { - const createStatus = (state, message, color) => ({ - state, - message: _(message), - color: constants.STATUS_COLORS[color] - }); - try { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), constants.FETCH_TIMEOUT); @@ -94,12 +96,6 @@ async function checkFakeIP() { } async function checkFakeIPCLI() { - const createStatus = (state, message, color) => ({ - state, - message: _(message), - color: constants.STATUS_COLORS[color] - }); - try { const singboxStatusResult = await safeExec('/usr/bin/podkop', ['get_sing_box_status']); const singboxStatus = JSON.parse(singboxStatusResult.stdout || '{"running":0,"dns_configured":0}'); @@ -121,12 +117,6 @@ async function checkFakeIPCLI() { } function checkDNSAvailability() { - const createStatus = (state, message, color) => ({ - state, - message: _(message), - color: constants.STATUS_COLORS[color] - }); - return new Promise(async (resolve) => { try { const dnsStatusResult = await safeExec('/usr/bin/podkop', ['check_dns_available']); @@ -168,12 +158,6 @@ function checkDNSAvailability() { } async function checkBypass() { - const createStatus = (state, message, color) => ({ - state, - message: _(message), - color: constants.STATUS_COLORS[color] - }); - return new Promise(async (resolve) => { try { let configMode = 'proxy'; // Default fallback