Update mobile app with the same stat changes and remove rate limiting
This commit is contained in:
@@ -88,10 +88,23 @@ export function Server({
|
||||
if (!cancelled) {
|
||||
setServerStatus(res?.status === 'online' ? 'online' : 'offline');
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('Failed to fetch server status:', error);
|
||||
if (!cancelled) {
|
||||
setServerStatus('offline');
|
||||
// Handle different error types from the new backend
|
||||
if (error?.response?.status === 503) {
|
||||
// Server is offline
|
||||
setServerStatus('offline');
|
||||
} else if (error?.response?.status === 504) {
|
||||
// Timeout - treat as degraded
|
||||
setServerStatus('offline');
|
||||
} else if (error?.response?.status === 404) {
|
||||
// Host not found
|
||||
setServerStatus('offline');
|
||||
} else {
|
||||
// Other errors - treat as offline
|
||||
setServerStatus('offline');
|
||||
}
|
||||
toast.error(t('serverStats.failedToFetchStatus'));
|
||||
}
|
||||
}
|
||||
@@ -190,8 +203,21 @@ export function Server({
|
||||
setServerStatus(res?.status === 'online' ? 'online' : 'offline');
|
||||
const data = await getServerMetricsById(currentHostConfig.id);
|
||||
setMetrics(data);
|
||||
} catch {
|
||||
setServerStatus('offline');
|
||||
} catch (error: any) {
|
||||
// Handle different error types from the new backend
|
||||
if (error?.response?.status === 503) {
|
||||
// Server is offline
|
||||
setServerStatus('offline');
|
||||
} else if (error?.response?.status === 504) {
|
||||
// Timeout - treat as offline
|
||||
setServerStatus('offline');
|
||||
} else if (error?.response?.status === 404) {
|
||||
// Host not found
|
||||
setServerStatus('offline');
|
||||
} else {
|
||||
// Other errors - treat as offline
|
||||
setServerStatus('offline');
|
||||
}
|
||||
setMetrics(null);
|
||||
} finally {
|
||||
setIsRefreshing(false);
|
||||
|
||||
@@ -5,7 +5,7 @@ import {ButtonGroup} from "@/components/ui/button-group.tsx";
|
||||
import {Server, Terminal} from "lucide-react";
|
||||
import {useTabs} from "@/ui/Desktop/Navigation/Tabs/TabContext.tsx";
|
||||
import {getServerStatusById} from "@/ui/main-axios.ts";
|
||||
import type { SSHHost, HostProps } from '../../../types/index.js';
|
||||
import type { HostProps } from '../../../../types/index.js';
|
||||
|
||||
export function Host({host}: HostProps): React.ReactElement {
|
||||
const {addTab} = useTabs();
|
||||
@@ -25,8 +25,18 @@ export function Host({host}: HostProps): React.ReactElement {
|
||||
if (!cancelled) {
|
||||
setServerStatus(res?.status === 'online' ? 'online' : 'offline');
|
||||
}
|
||||
} catch {
|
||||
if (!cancelled) setServerStatus('offline');
|
||||
} catch (error: any) {
|
||||
if (!cancelled) {
|
||||
if (error?.response?.status === 503) {
|
||||
setServerStatus('offline');
|
||||
} else if (error?.response?.status === 504) {
|
||||
setServerStatus('degraded');
|
||||
} else if (error?.response?.status === 404) {
|
||||
setServerStatus('offline');
|
||||
} else {
|
||||
setServerStatus('offline');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user