@@ -275,7 +275,7 @@ export default function Status() {
|
|||||||
</ComponentCard>
|
</ComponentCard>
|
||||||
|
|
||||||
{/* Module Statistics */}
|
{/* Module Statistics */}
|
||||||
<ComponentCard title="Module Statistics1" desc="Data counts by module">
|
<ComponentCard title="Module Statistics" desc="Data counts by module">
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
{/* Planner Module */}
|
{/* Planner Module */}
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
@@ -359,28 +359,11 @@ function APIMonitoringCard() {
|
|||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
|
const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout
|
||||||
|
|
||||||
// Get auth token if available (for endpoints that require auth)
|
|
||||||
const headers: HeadersInit = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Try to get JWT token from localStorage for authenticated endpoints
|
|
||||||
try {
|
|
||||||
const authStorage = localStorage.getItem('auth-storage');
|
|
||||||
if (authStorage) {
|
|
||||||
const parsed = JSON.parse(authStorage);
|
|
||||||
const token = parsed?.state?.token;
|
|
||||||
if (token) {
|
|
||||||
headers['Authorization'] = `Bearer ${token}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Ignore errors getting token
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(`${API_BASE_URL}${endpoint.endpoint}`, {
|
const response = await fetch(`${API_BASE_URL}${endpoint.endpoint}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers,
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
});
|
});
|
||||||
@@ -391,29 +374,13 @@ function APIMonitoringCard() {
|
|||||||
|
|
||||||
// Determine status based on response time and status code
|
// Determine status based on response time and status code
|
||||||
let status: 'healthy' | 'warning' | 'critical' = 'healthy';
|
let status: 'healthy' | 'warning' | 'critical' = 'healthy';
|
||||||
|
|
||||||
// 401/403 for auth endpoints is normal (endpoint works, just needs auth)
|
|
||||||
const isAuthEndpoint = endpoint.endpoint.includes('/auth/') ||
|
|
||||||
endpoint.endpoint.includes('/me/');
|
|
||||||
|
|
||||||
if (response.status >= 500) {
|
if (response.status >= 500) {
|
||||||
// Server errors are critical
|
|
||||||
status = 'critical';
|
status = 'critical';
|
||||||
} else if (response.status === 401 || response.status === 403) {
|
} else if (response.status >= 400 || responseTime > 2000) {
|
||||||
// Auth errors are healthy for auth endpoints (endpoint is working)
|
|
||||||
// For other endpoints, it's a warning (endpoint works but access denied)
|
|
||||||
status = isAuthEndpoint ? 'healthy' : 'warning';
|
|
||||||
} else if (response.status >= 400) {
|
|
||||||
// Other 4xx errors are warnings (client errors, but endpoint responds)
|
|
||||||
status = 'warning';
|
status = 'warning';
|
||||||
} else if (responseTime > 2000) {
|
|
||||||
// Very slow responses are critical
|
|
||||||
status = 'critical';
|
|
||||||
} else if (responseTime > 1000) {
|
} else if (responseTime > 1000) {
|
||||||
// Slow responses are warnings
|
|
||||||
status = 'warning';
|
status = 'warning';
|
||||||
}
|
}
|
||||||
// Otherwise healthy (200-299, fast response)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...endpoint,
|
...endpoint,
|
||||||
|
|||||||
Reference in New Issue
Block a user