More error to toast migration

This commit is contained in:
LukeGus
2025-09-09 18:49:57 -05:00
parent 7ffeb51571
commit 56a1dd0b79
6 changed files with 26 additions and 13 deletions

View File

@@ -319,6 +319,9 @@
"oidcConfigurationUpdated": "OIDC configuration updated successfully!", "oidcConfigurationUpdated": "OIDC configuration updated successfully!",
"failedToFetchOidcConfig": "Failed to fetch OIDC configuration", "failedToFetchOidcConfig": "Failed to fetch OIDC configuration",
"failedToFetchRegistrationStatus": "Failed to fetch registration status", "failedToFetchRegistrationStatus": "Failed to fetch registration status",
"user": {
"failedToLoadVersionInfo": "Failed to load version information"
},
"oidcConfigurationDisabled": "OIDC configuration disabled successfully!", "oidcConfigurationDisabled": "OIDC configuration disabled successfully!",
"failedToUpdateOidcConfig": "Failed to update OIDC configuration", "failedToUpdateOidcConfig": "Failed to update OIDC configuration",
"failedToDisableOidcConfig": "Failed to disable OIDC configuration", "failedToDisableOidcConfig": "Failed to disable OIDC configuration",
@@ -682,7 +685,8 @@
"feedbackMessage": "Have ideas for what should come next for server management? Share them on", "feedbackMessage": "Have ideas for what should come next for server management? Share them on",
"failedToFetchHostConfig": "Failed to fetch host configuration", "failedToFetchHostConfig": "Failed to fetch host configuration",
"failedToFetchStatus": "Failed to fetch server status", "failedToFetchStatus": "Failed to fetch server status",
"failedToFetchMetrics": "Failed to fetch server metrics" "failedToFetchMetrics": "Failed to fetch server metrics",
"failedToFetchHomeData": "Failed to fetch home data"
}, },
"auth": { "auth": {
"loginTitle": "Login to Termix", "loginTitle": "Login to Termix",

View File

@@ -411,7 +411,7 @@ app.post('/ssh/file_manager/ssh/writeFile', async (req, res) => {
fileLogger.error('Fallback write command failed:', err); fileLogger.error('Fallback write command failed:', err);
if (!res.headersSent) { if (!res.headersSent) {
return res.status(500).json({error: `Write failed: ${err.message}`}); return res.status(500).json({error: `Write failed: ${err.message}`, toast: {type: 'error', message: `Write failed: ${err.message}`}});
} }
return; return;
} }
@@ -437,7 +437,7 @@ app.post('/ssh/file_manager/ssh/writeFile', async (req, res) => {
} else { } else {
fileLogger.error(`Fallback write failed with code ${code}: ${errorData}`); fileLogger.error(`Fallback write failed with code ${code}: ${errorData}`);
if (!res.headersSent) { if (!res.headersSent) {
res.status(500).json({error: `Write failed: ${errorData}`}); res.status(500).json({error: `Write failed: ${errorData}`, toast: {type: 'error', message: `Write failed: ${errorData}`}});
} }
} }
}); });
@@ -602,9 +602,9 @@ app.post('/ssh/file_manager/ssh/uploadFile', async (req, res) => {
} }
} else { } else {
fileLogger.error(`Fallback upload failed with code ${code}: ${errorData}`); fileLogger.error(`Fallback upload failed with code ${code}: ${errorData}`);
if (!res.headersSent) { if (!res.headersSent) {
res.status(500).json({error: `Upload failed: ${errorData}`}); res.status(500).json({error: `Upload failed: ${errorData}`, toast: {type: 'error', message: `Upload failed: ${errorData}`}});
} }
} }
}); });
@@ -659,9 +659,9 @@ app.post('/ssh/file_manager/ssh/uploadFile', async (req, res) => {
} }
} else { } else {
fileLogger.error(`Chunked fallback upload failed with code ${code}: ${errorData}`); fileLogger.error(`Chunked fallback upload failed with code ${code}: ${errorData}`);
if (!res.headersSent) { if (!res.headersSent) {
res.status(500).json({error: `Chunked upload failed: ${errorData}`}); res.status(500).json({error: `Chunked upload failed: ${errorData}`, toast: {type: 'error', message: `Chunked upload failed: ${errorData}`}});
} }
} }
}); });
@@ -748,7 +748,7 @@ app.post('/ssh/file_manager/ssh/createFile', async (req, res) => {
if (code !== 0) { if (code !== 0) {
fileLogger.error(`SSH createFile command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`); fileLogger.error(`SSH createFile command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`);
if (!res.headersSent) { if (!res.headersSent) {
return res.status(500).json({error: `Command failed: ${errorData}`}); return res.status(500).json({error: `Command failed: ${errorData}`, toast: {type: 'error', message: `File creation failed: ${errorData}`}});
} }
return; return;
} }
@@ -832,7 +832,7 @@ app.post('/ssh/file_manager/ssh/createFolder', async (req, res) => {
if (code !== 0) { if (code !== 0) {
fileLogger.error(`SSH createFolder command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`); fileLogger.error(`SSH createFolder command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`);
if (!res.headersSent) { if (!res.headersSent) {
return res.status(500).json({error: `Command failed: ${errorData}`}); return res.status(500).json({error: `Command failed: ${errorData}`, toast: {type: 'error', message: `Folder creation failed: ${errorData}`}});
} }
return; return;
} }
@@ -915,7 +915,7 @@ app.delete('/ssh/file_manager/ssh/deleteItem', async (req, res) => {
if (code !== 0) { if (code !== 0) {
fileLogger.error(`SSH deleteItem command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`); fileLogger.error(`SSH deleteItem command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`);
if (!res.headersSent) { if (!res.headersSent) {
return res.status(500).json({error: `Command failed: ${errorData}`}); return res.status(500).json({error: `Command failed: ${errorData}`, toast: {type: 'error', message: `Delete failed: ${errorData}`}});
} }
return; return;
} }
@@ -1000,7 +1000,7 @@ app.put('/ssh/file_manager/ssh/renameItem', async (req, res) => {
if (code !== 0) { if (code !== 0) {
fileLogger.error(`SSH renameItem command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`); fileLogger.error(`SSH renameItem command failed with code ${code}: ${errorData.replace(/\n/g, ' ').trim()}`);
if (!res.headersSent) { if (!res.headersSent) {
return res.status(500).json({error: `Command failed: ${errorData}`}); return res.status(500).json({error: `Command failed: ${errorData}`, toast: {type: 'error', message: `Rename failed: ${errorData}`}});
} }
return; return;
} }

View File

@@ -127,6 +127,9 @@ export function FileManager({onSelectView, embedded = false, initialHost = null}
type: 'directory' type: 'directory'
}))); })));
} catch (err: any) { } catch (err: any) {
console.error('Failed to fetch home data:', err);
const {toast} = await import('sonner');
toast.error(t('fileManager.failedToFetchHomeData'));
} }
} }

View File

@@ -49,6 +49,9 @@ export function HomepageAlertManager({userId, loggedIn}: AlertManagerProps): Rea
setAlerts(sortedAlerts); setAlerts(sortedAlerts);
setCurrentAlertIndex(0); setCurrentAlertIndex(0);
} catch (err) { } catch (err) {
console.error('Failed to fetch user alerts:', err);
const {toast} = await import('sonner');
toast.error(t('homepage.failedToLoadAlerts'));
setError(t('homepage.failedToLoadAlerts')); setError(t('homepage.failedToLoadAlerts'));
} finally { } finally {
setLoading(false); setLoading(false);

View File

@@ -43,6 +43,8 @@ export function UserProfile({isTopbarOpen = true}: UserProfileProps) {
setVersionInfo({version: info.localVersion}); setVersionInfo({version: info.localVersion});
} catch (err) { } catch (err) {
console.error("Failed to load version info", err); console.error("Failed to load version info", err);
const {toast} = await import('sonner');
toast.error(t('user.failedToLoadVersionInfo'));
} }
}; };

View File

@@ -90,6 +90,7 @@ export function TerminalKeyboard({onSendInput, onLayoutChange}: TerminalKeyboard
} }
} catch (e) { } catch (e) {
console.error("Vibration failed:", e); console.error("Vibration failed:", e);
// Don't show toast for vibration failure as it's not critical
} }
onSendInput(input); onSendInput(input);