From 23203fd7a1166d0e26ae9131d78105e3032fe5f9 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 13 Mar 2025 00:10:18 +0300 Subject: [PATCH 1/4] feat: add createSystemButton function to ButtonFactory and flush cache button --- .../resources/view/podkop/podkop.js | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 4c12951..e0672d1 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 @@ -620,6 +620,27 @@ const ButtonFactory = { onClick: () => showConfigModal(config.command, config.title), style: config.style }); + }, + + createSystemButton: function (config) { + return this.createButton({ + label: config.label, + additionalClass: `cbi-button-${config.type || ''}`, + onClick: () => { + try { + const result = config.systemFunction(); + if (config.successMessage) { + ui.addNotification(null, E('p', {}, _(config.successMessage))); + } + return result; + } catch (e) { + if (config.errorMessage) { + ui.addNotification(null, E('p', {}, _(config.errorMessage) + ': ' + e.message)); + } + } + }, + style: config.style + }); } }; @@ -760,7 +781,13 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s E('strong', {}, _('Sing-box: ')), singbox.stdout ? singbox.stdout.trim() : _('Unknown'), '\n', E('strong', {}, _('OpenWrt Version: ')), system.stdout ? system.stdout.split('\n')[1].trim() : _('Unknown'), '\n', E('strong', {}, _('Device Model: ')), system.stdout ? system.stdout.split('\n')[4].trim() : _('Unknown') - ]) + ]), + ButtonFactory.createSystemButton({ + label: _('Flush Cache'), + systemFunction: () => ui.menu.flushCache(), + successMessage: _('Cache has been flushed successfully!'), + errorMessage: _('Failed to flush cache') + }) ]) ]) ]); From 1263b9b1b81d3c0ac96818f438157144a9123b5b Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 13 Mar 2025 10:00:37 +0300 Subject: [PATCH 2/4] fix: fix enable/disable functionality to podkop service --- .../resources/view/podkop/podkop.js | 19 ++++++------------- luci-app-podkop/po/ru/podkop.po | 5 ++++- luci-app-podkop/po/templates/podkop.pot | 3 +++ podkop/files/usr/bin/podkop | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 14 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 e0672d1..e2a8a26 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 @@ -677,19 +677,12 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s E('div', { 'class': 'table', style: 'display: flex; gap: 20px;' }, [ // Podkop Status Panel createStatusPanel('Podkop Status', podkopStatus, [ - podkopStatus.running ? - ButtonFactory.createActionButton({ - label: 'Stop Podkop', - type: 'remove', - action: 'stop', - reload: true - }) : - ButtonFactory.createActionButton({ - label: 'Start Podkop', - type: 'apply', - action: 'start', - reload: true - }), + ButtonFactory.createActionButton({ + label: podkopStatus.running ? 'Stop Podkop' : 'Start Podkop', + type: podkopStatus.running ? 'remove' : 'apply', + action: podkopStatus.running ? 'stop' : 'start', + reload: true + }), ButtonFactory.createActionButton({ label: 'Restart Podkop', type: 'apply', diff --git a/luci-app-podkop/po/ru/podkop.po b/luci-app-podkop/po/ru/podkop.po index b4757bb..ccb4e46 100644 --- a/luci-app-podkop/po/ru/podkop.po +++ b/luci-app-podkop/po/ru/podkop.po @@ -746,4 +746,7 @@ msgid "not works in browser" msgstr "не работает в браузере" msgid "not works on router" -msgstr "не работает на роутере" \ No newline at end of file +msgstr "не работает на роутере" + +msgid "Diagnostics" +msgstr "Диагностика" \ No newline at end of file diff --git a/luci-app-podkop/po/templates/podkop.pot b/luci-app-podkop/po/templates/podkop.pot index e478bb1..3f99179 100644 --- a/luci-app-podkop/po/templates/podkop.pot +++ b/luci-app-podkop/po/templates/podkop.pot @@ -1100,4 +1100,7 @@ msgid "not works in browser" msgstr "" msgid "not works on router" +msgstr "" + +msgid "Diagnostics" msgstr "" \ No newline at end of file diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index aca1f8b..06f1a9d 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -1965,6 +1965,18 @@ sing_box_add_secure_dns_probe_domain() { log "DNS probe domain ${domain} configured with override to port ${override_port}" } +enable() { + log "Enabling podkop service" + /etc/init.d/podkop enable + log "Podkop service enabled" +} + +disable() { + log "Disabling podkop service" + /etc/init.d/podkop disable + log "Podkop service disabled" +} + case "$1" in start) start @@ -1976,6 +1988,12 @@ case "$1" in stop start ;; + enable) + enable + ;; + disable) + disable + ;; main) main ;; From 884bbfee421f24c23ce38db3d724e50fcfda12c7 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 13 Mar 2025 10:32:34 +0300 Subject: [PATCH 3/4] fix: remove unused button creation code --- .../resources/view/podkop/podkop.js | 29 +------------------ 1 file changed, 1 insertion(+), 28 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 e2a8a26..030d4fb 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 @@ -620,27 +620,6 @@ const ButtonFactory = { onClick: () => showConfigModal(config.command, config.title), style: config.style }); - }, - - createSystemButton: function (config) { - return this.createButton({ - label: config.label, - additionalClass: `cbi-button-${config.type || ''}`, - onClick: () => { - try { - const result = config.systemFunction(); - if (config.successMessage) { - ui.addNotification(null, E('p', {}, _(config.successMessage))); - } - return result; - } catch (e) { - if (config.errorMessage) { - ui.addNotification(null, E('p', {}, _(config.errorMessage) + ': ' + e.message)); - } - } - }, - style: config.style - }); } }; @@ -774,13 +753,7 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s E('strong', {}, _('Sing-box: ')), singbox.stdout ? singbox.stdout.trim() : _('Unknown'), '\n', E('strong', {}, _('OpenWrt Version: ')), system.stdout ? system.stdout.split('\n')[1].trim() : _('Unknown'), '\n', E('strong', {}, _('Device Model: ')), system.stdout ? system.stdout.split('\n')[4].trim() : _('Unknown') - ]), - ButtonFactory.createSystemButton({ - label: _('Flush Cache'), - systemFunction: () => ui.menu.flushCache(), - successMessage: _('Cache has been flushed successfully!'), - errorMessage: _('Failed to flush cache') - }) + ]) ]) ]) ]); From c79016e45619b5129b9242ed06709eabb24fcde3 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Thu, 13 Mar 2025 10:35:48 +0300 Subject: [PATCH 4/4] feat: add createInitActionButton function to ButtonFactory --- .../resources/view/podkop/podkop.js | 12 +++++++++++- podkop/files/usr/bin/podkop | 18 ------------------ 2 files changed, 11 insertions(+), 19 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 030d4fb..81be69d 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 @@ -614,6 +614,16 @@ const ButtonFactory = { }); }, + createInitActionButton: function (config) { + return this.createButton({ + label: config.label, + additionalClass: `cbi-button-${config.type || ''}`, + onClick: () => safeExec('/etc/init.d/podkop', [config.action]) + .then(() => config.reload && location.reload()), + style: config.style + }); + }, + createModalButton: function (config) { return this.createButton({ label: config.label, @@ -668,7 +678,7 @@ let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, s action: 'restart', reload: true }), - ButtonFactory.createActionButton({ + ButtonFactory.createInitActionButton({ label: podkopStatus.enabled ? 'Disable Podkop' : 'Enable Podkop', type: podkopStatus.enabled ? 'remove' : 'apply', action: podkopStatus.enabled ? 'disable' : 'enable', diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index 06f1a9d..aca1f8b 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -1965,18 +1965,6 @@ sing_box_add_secure_dns_probe_domain() { log "DNS probe domain ${domain} configured with override to port ${override_port}" } -enable() { - log "Enabling podkop service" - /etc/init.d/podkop enable - log "Podkop service enabled" -} - -disable() { - log "Disabling podkop service" - /etc/init.d/podkop disable - log "Podkop service disabled" -} - case "$1" in start) start @@ -1988,12 +1976,6 @@ case "$1" in stop start ;; - enable) - enable - ;; - disable) - disable - ;; main) main ;;