From 13d27dab216e9088441d0c9cab151c94f7c2bc16 Mon Sep 17 00:00:00 2001 From: divocat Date: Thu, 23 Oct 2025 19:08:27 +0300 Subject: [PATCH] feat: add toast when shell exec failed --- fe-app-podkop/locales/calls.json | 28 +++++++++++++----- fe-app-podkop/locales/podkop.pot | 29 ++++++++++++------- fe-app-podkop/locales/podkop.ru.po | 7 +++-- .../podkop/tabs/diagnostic/initController.ts | 25 +++++++++++++++- .../luci-static/resources/view/podkop/main.js | 23 ++++++++++++++- luci-app-podkop/po/ru/podkop.po | 7 +++-- luci-app-podkop/po/templates/podkop.pot | 29 ++++++++++++------- 7 files changed, 114 insertions(+), 34 deletions(-) diff --git a/fe-app-podkop/locales/calls.json b/fe-app-podkop/locales/calls.json index c11f557..b4e1ca0 100644 --- a/fe-app-podkop/locales/calls.json +++ b/fe-app-podkop/locales/calls.json @@ -508,6 +508,18 @@ "src/helpers/copyToClipboard.ts:12" ] }, + { + "call": "Failed to execute!", + "key": "Failed to execute!", + "places": [ + "src/podkop/tabs/diagnostic/initController.ts:225", + "src/podkop/tabs/diagnostic/initController.ts:229", + "src/podkop/tabs/diagnostic/initController.ts:259", + "src/podkop/tabs/diagnostic/initController.ts:263", + "src/podkop/tabs/diagnostic/initController.ts:297", + "src/podkop/tabs/diagnostic/initController.ts:301" + ] + }, { "call": "Fastest", "key": "Fastest", @@ -533,7 +545,7 @@ "call": "Global check", "key": "Global check", "places": [ - "src/podkop/tabs/diagnostic/initController.ts:218" + "src/podkop/tabs/diagnostic/initController.ts:220" ] }, { @@ -786,7 +798,7 @@ "call": "Latest", "key": "Latest", "places": [ - "src/podkop/tabs/diagnostic/initController.ts:404" + "src/podkop/tabs/diagnostic/initController.ts:427" ] }, { @@ -901,7 +913,7 @@ "call": "Outdated", "key": "Outdated", "places": [ - "src/podkop/tabs/diagnostic/initController.ts:394" + "src/podkop/tabs/diagnostic/initController.ts:417" ] }, { @@ -1227,7 +1239,7 @@ "call": "Show sing-box config", "key": "Show sing-box config", "places": [ - "src/podkop/tabs/diagnostic/initController.ts:278", + "src/podkop/tabs/diagnostic/initController.ts:288", "src/podkop/tabs/diagnostic/partials/renderAvailableActions.ts:116" ] }, @@ -1447,13 +1459,13 @@ "call": "unknown", "key": "unknown", "places": [ - "src/podkop/tabs/diagnostic/initController.ts:34", - "src/podkop/tabs/diagnostic/initController.ts:35", "src/podkop/tabs/diagnostic/initController.ts:36", "src/podkop/tabs/diagnostic/initController.ts:37", "src/podkop/tabs/diagnostic/initController.ts:38", "src/podkop/tabs/diagnostic/initController.ts:39", - "src/podkop/tabs/diagnostic/initController.ts:373" + "src/podkop/tabs/diagnostic/initController.ts:40", + "src/podkop/tabs/diagnostic/initController.ts:41", + "src/podkop/tabs/diagnostic/initController.ts:391" ] }, { @@ -1572,7 +1584,7 @@ "call": "View logs", "key": "View logs", "places": [ - "src/podkop/tabs/diagnostic/initController.ts:248", + "src/podkop/tabs/diagnostic/initController.ts:254", "src/podkop/tabs/diagnostic/partials/renderAvailableActions.ts:107" ] }, diff --git a/fe-app-podkop/locales/podkop.pot b/fe-app-podkop/locales/podkop.pot index 55acc57..2b6b460 100644 --- a/fe-app-podkop/locales/podkop.pot +++ b/fe-app-podkop/locales/podkop.pot @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PODKOP\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-23 15:55+0300\n" -"PO-Revision-Date: 2025-10-23 15:55+0300\n" +"POT-Creation-Date: 2025-10-23 16:08+0300\n" +"PO-Revision-Date: 2025-10-23 16:08+0300\n" "Last-Translator: divocat \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -312,6 +312,15 @@ msgstr "" msgid "Failed to copy!" msgstr "" +#: src/podkop/tabs/diagnostic/initController.ts:225 +#: src/podkop/tabs/diagnostic/initController.ts:229 +#: src/podkop/tabs/diagnostic/initController.ts:259 +#: src/podkop/tabs/diagnostic/initController.ts:263 +#: src/podkop/tabs/diagnostic/initController.ts:297 +#: src/podkop/tabs/diagnostic/initController.ts:301 +msgid "Failed to execute!" +msgstr "" + #: src/podkop/methods/custom/getDashboardSections.ts:117 msgid "Fastest" msgstr "" @@ -324,7 +333,7 @@ msgstr "" msgid "Get global check" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:218 +#: src/podkop/tabs/diagnostic/initController.ts:220 msgid "Global check" msgstr "" @@ -469,7 +478,7 @@ msgstr "" msgid "IP address 0.0.0.0 is not allowed" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:404 +#: src/podkop/tabs/diagnostic/initController.ts:427 msgid "Latest" msgstr "" @@ -536,7 +545,7 @@ msgstr "" msgid "Outbound JSON must contain at least \"type\", \"server\" and \"server_port\" fields" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:394 +#: src/podkop/tabs/diagnostic/initController.ts:417 msgid "Outdated" msgstr "" @@ -724,7 +733,7 @@ msgstr "" msgid "Settings" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:278 +#: src/podkop/tabs/diagnostic/initController.ts:288 #: src/podkop/tabs/diagnostic/partials/renderAvailableActions.ts:116 msgid "Show sing-box config" msgstr "" @@ -851,13 +860,13 @@ msgstr "" msgid "UDP over TCP" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:34 -#: src/podkop/tabs/diagnostic/initController.ts:35 #: src/podkop/tabs/diagnostic/initController.ts:36 #: src/podkop/tabs/diagnostic/initController.ts:37 #: src/podkop/tabs/diagnostic/initController.ts:38 #: src/podkop/tabs/diagnostic/initController.ts:39 -#: src/podkop/tabs/diagnostic/initController.ts:373 +#: src/podkop/tabs/diagnostic/initController.ts:40 +#: src/podkop/tabs/diagnostic/initController.ts:41 +#: src/podkop/tabs/diagnostic/initController.ts:391 msgid "unknown" msgstr "" @@ -931,7 +940,7 @@ msgstr "" msgid "Validation errors:" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:248 +#: src/podkop/tabs/diagnostic/initController.ts:254 #: src/podkop/tabs/diagnostic/partials/renderAvailableActions.ts:107 msgid "View logs" msgstr "" diff --git a/fe-app-podkop/locales/podkop.ru.po b/fe-app-podkop/locales/podkop.ru.po index 471a18f..56cff1e 100644 --- a/fe-app-podkop/locales/podkop.ru.po +++ b/fe-app-podkop/locales/podkop.ru.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PODKOP\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-23 18:55+0300\n" -"PO-Revision-Date: 2025-10-23 18:55+0300\n" +"POT-Creation-Date: 2025-10-23 19:08+0300\n" +"PO-Revision-Date: 2025-10-23 19:08+0300\n" "Last-Translator: divocat\n" "Language-Team: none\n" "Language: ru\n" @@ -230,6 +230,9 @@ msgstr "Исключите трафик протокола NTP из туннел msgid "Failed to copy!" msgstr "Не удалось скопировать!" +msgid "Failed to execute!" +msgstr "Не удалось выполнить!" + msgid "Fastest" msgstr "Самый быстрый" diff --git a/fe-app-podkop/src/podkop/tabs/diagnostic/initController.ts b/fe-app-podkop/src/podkop/tabs/diagnostic/initController.ts index 8e6a3c2..75e0977 100644 --- a/fe-app-podkop/src/podkop/tabs/diagnostic/initController.ts +++ b/fe-app-podkop/src/podkop/tabs/diagnostic/initController.ts @@ -16,6 +16,8 @@ import { PodkopShellMethods } from '../../methods'; import { fetchServicesInfo } from '../../fetchers'; import { normalizeCompiledVersion } from '../../../helpers/normalizeCompiledVersion'; import { renderModal } from '../../../partials'; +import { PODKOP_LUCI_APP_VERSION } from '../../../constants'; +import { showToast } from '../../../helpers/showToast'; async function fetchSystemInfo() { const systemInfo = await PodkopShellMethods.getSystemInfo(); @@ -218,9 +220,13 @@ async function handleShowGlobalCheck() { _('Global check'), renderModal(globalCheck.data as string, 'global_check'), ); + } else { + logger.error('[DIAGNOSTIC]', 'handleShowGlobalCheck - e', globalCheck); + showToast(_('Failed to execute!'), 'error'); } } catch (e) { logger.error('[DIAGNOSTIC]', 'handleShowGlobalCheck - e', e); + showToast(_('Failed to execute!'), 'error'); } finally { store.set({ diagnosticsActions: { @@ -248,9 +254,13 @@ async function handleViewLogs() { _('View logs'), renderModal(viewLogs.data as string, 'view_logs'), ); + } else { + logger.error('[DIAGNOSTIC]', 'handleViewLogs - e', viewLogs); + showToast(_('Failed to execute!'), 'error'); } } catch (e) { logger.error('[DIAGNOSTIC]', 'handleViewLogs - e', e); + showToast(_('Failed to execute!'), 'error'); } finally { store.set({ diagnosticsActions: { @@ -278,9 +288,17 @@ async function handleShowSingBoxConfig() { _('Show sing-box config'), renderModal(showSingBoxConfig.data as string, 'show_sing_box_config'), ); + } else { + logger.error( + '[DIAGNOSTIC]', + 'handleShowSingBoxConfig - e', + showSingBoxConfig, + ); + showToast(_('Failed to execute!'), 'error'); } } catch (e) { logger.error('[DIAGNOSTIC]', 'handleShowSingBoxConfig - e', e); + showToast(_('Failed to execute!'), 'error'); } finally { store.set({ diagnosticsActions: { @@ -387,6 +405,11 @@ function renderDiagnosticSystemInfoWidget() { } if (version !== `v${diagnosticsSystemInfo.podkop_latest_version}`) { + logger.debug( + '[DIAGNOSTIC]', + 'diagnosticsSystemInfo', + diagnosticsSystemInfo, + ); return { key: 'Podkop', value: version, @@ -412,7 +435,7 @@ function renderDiagnosticSystemInfoWidget() { getPodkopVersionRow(), { key: 'Luci App', - value: normalizeCompiledVersion(diagnosticsSystemInfo.luci_app_version), + value: normalizeCompiledVersion(PODKOP_LUCI_APP_VERSION), }, { key: 'Sing-box', diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js index b68dcec..0439e17 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/main.js @@ -3797,9 +3797,13 @@ async function handleShowGlobalCheck() { _("Global check"), renderModal(globalCheck.data, "global_check") ); + } else { + logger.error("[DIAGNOSTIC]", "handleShowGlobalCheck - e", globalCheck); + showToast(_("Failed to execute!"), "error"); } } catch (e) { logger.error("[DIAGNOSTIC]", "handleShowGlobalCheck - e", e); + showToast(_("Failed to execute!"), "error"); } finally { store.set({ diagnosticsActions: { @@ -3824,9 +3828,13 @@ async function handleViewLogs() { _("View logs"), renderModal(viewLogs.data, "view_logs") ); + } else { + logger.error("[DIAGNOSTIC]", "handleViewLogs - e", viewLogs); + showToast(_("Failed to execute!"), "error"); } } catch (e) { logger.error("[DIAGNOSTIC]", "handleViewLogs - e", e); + showToast(_("Failed to execute!"), "error"); } finally { store.set({ diagnosticsActions: { @@ -3851,9 +3859,17 @@ async function handleShowSingBoxConfig() { _("Show sing-box config"), renderModal(showSingBoxConfig.data, "show_sing_box_config") ); + } else { + logger.error( + "[DIAGNOSTIC]", + "handleShowSingBoxConfig - e", + showSingBoxConfig + ); + showToast(_("Failed to execute!"), "error"); } } catch (e) { logger.error("[DIAGNOSTIC]", "handleShowSingBoxConfig - e", e); + showToast(_("Failed to execute!"), "error"); } finally { store.set({ diagnosticsActions: { @@ -3946,6 +3962,11 @@ function renderDiagnosticSystemInfoWidget() { }; } if (version !== `v${diagnosticsSystemInfo.podkop_latest_version}`) { + logger.debug( + "[DIAGNOSTIC]", + "diagnosticsSystemInfo", + diagnosticsSystemInfo + ); return { key: "Podkop", value: version, @@ -3969,7 +3990,7 @@ function renderDiagnosticSystemInfoWidget() { getPodkopVersionRow(), { key: "Luci App", - value: normalizeCompiledVersion(diagnosticsSystemInfo.luci_app_version) + value: normalizeCompiledVersion(PODKOP_LUCI_APP_VERSION) }, { key: "Sing-box", diff --git a/luci-app-podkop/po/ru/podkop.po b/luci-app-podkop/po/ru/podkop.po index 471a18f..56cff1e 100644 --- a/luci-app-podkop/po/ru/podkop.po +++ b/luci-app-podkop/po/ru/podkop.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PODKOP\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-23 18:55+0300\n" -"PO-Revision-Date: 2025-10-23 18:55+0300\n" +"POT-Creation-Date: 2025-10-23 19:08+0300\n" +"PO-Revision-Date: 2025-10-23 19:08+0300\n" "Last-Translator: divocat\n" "Language-Team: none\n" "Language: ru\n" @@ -230,6 +230,9 @@ msgstr "Исключите трафик протокола NTP из туннел msgid "Failed to copy!" msgstr "Не удалось скопировать!" +msgid "Failed to execute!" +msgstr "Не удалось выполнить!" + msgid "Fastest" msgstr "Самый быстрый" diff --git a/luci-app-podkop/po/templates/podkop.pot b/luci-app-podkop/po/templates/podkop.pot index 55acc57..2b6b460 100644 --- a/luci-app-podkop/po/templates/podkop.pot +++ b/luci-app-podkop/po/templates/podkop.pot @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PODKOP\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2025-10-23 15:55+0300\n" -"PO-Revision-Date: 2025-10-23 15:55+0300\n" +"POT-Creation-Date: 2025-10-23 16:08+0300\n" +"PO-Revision-Date: 2025-10-23 16:08+0300\n" "Last-Translator: divocat \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -312,6 +312,15 @@ msgstr "" msgid "Failed to copy!" msgstr "" +#: src/podkop/tabs/diagnostic/initController.ts:225 +#: src/podkop/tabs/diagnostic/initController.ts:229 +#: src/podkop/tabs/diagnostic/initController.ts:259 +#: src/podkop/tabs/diagnostic/initController.ts:263 +#: src/podkop/tabs/diagnostic/initController.ts:297 +#: src/podkop/tabs/diagnostic/initController.ts:301 +msgid "Failed to execute!" +msgstr "" + #: src/podkop/methods/custom/getDashboardSections.ts:117 msgid "Fastest" msgstr "" @@ -324,7 +333,7 @@ msgstr "" msgid "Get global check" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:218 +#: src/podkop/tabs/diagnostic/initController.ts:220 msgid "Global check" msgstr "" @@ -469,7 +478,7 @@ msgstr "" msgid "IP address 0.0.0.0 is not allowed" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:404 +#: src/podkop/tabs/diagnostic/initController.ts:427 msgid "Latest" msgstr "" @@ -536,7 +545,7 @@ msgstr "" msgid "Outbound JSON must contain at least \"type\", \"server\" and \"server_port\" fields" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:394 +#: src/podkop/tabs/diagnostic/initController.ts:417 msgid "Outdated" msgstr "" @@ -724,7 +733,7 @@ msgstr "" msgid "Settings" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:278 +#: src/podkop/tabs/diagnostic/initController.ts:288 #: src/podkop/tabs/diagnostic/partials/renderAvailableActions.ts:116 msgid "Show sing-box config" msgstr "" @@ -851,13 +860,13 @@ msgstr "" msgid "UDP over TCP" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:34 -#: src/podkop/tabs/diagnostic/initController.ts:35 #: src/podkop/tabs/diagnostic/initController.ts:36 #: src/podkop/tabs/diagnostic/initController.ts:37 #: src/podkop/tabs/diagnostic/initController.ts:38 #: src/podkop/tabs/diagnostic/initController.ts:39 -#: src/podkop/tabs/diagnostic/initController.ts:373 +#: src/podkop/tabs/diagnostic/initController.ts:40 +#: src/podkop/tabs/diagnostic/initController.ts:41 +#: src/podkop/tabs/diagnostic/initController.ts:391 msgid "unknown" msgstr "" @@ -931,7 +940,7 @@ msgstr "" msgid "Validation errors:" msgstr "" -#: src/podkop/tabs/diagnostic/initController.ts:248 +#: src/podkop/tabs/diagnostic/initController.ts:254 #: src/podkop/tabs/diagnostic/partials/renderAvailableActions.ts:107 msgid "View logs" msgstr ""