feat: add toast when shell exec failed

This commit is contained in:
divocat
2025-10-23 19:08:27 +03:00
parent 9f8f032dce
commit 13d27dab21
7 changed files with 114 additions and 34 deletions

View File

@@ -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',