huge refactor to remove depenencie hell and add typesafe container
This commit is contained in:
parent
28b9822d55
commit
843a7b9b9b
148 changed files with 3603 additions and 2378 deletions
|
|
@ -11,4 +11,4 @@ export { ProxyStatsCard } from './ProxyStatsCard';
|
|||
export { StatusBadge, ConnectionStatus, HealthStatus, ServiceStatusIndicator } from './StatusBadge';
|
||||
export { MetricCard } from './MetricCard';
|
||||
export { ServiceCard } from './ServiceCard';
|
||||
export { DatabaseCard } from './DatabaseCard';
|
||||
export { DatabaseCard } from './DatabaseCard';
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
* Monitoring hooks exports
|
||||
*/
|
||||
|
||||
export * from './useMonitoring';
|
||||
export * from './useMonitoring';
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
* Custom hook for monitoring data
|
||||
*/
|
||||
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { monitoringApi } from '../services/monitoringApi';
|
||||
import type {
|
||||
SystemHealth,
|
||||
CacheStats,
|
||||
QueueStats,
|
||||
import type {
|
||||
CacheStats,
|
||||
DatabaseStats,
|
||||
ServiceStatus,
|
||||
ProxyStats,
|
||||
SystemOverview
|
||||
QueueStats,
|
||||
ServiceStatus,
|
||||
SystemHealth,
|
||||
SystemOverview,
|
||||
} from '../types';
|
||||
|
||||
export function useSystemHealth(refreshInterval: number = 5000) {
|
||||
|
|
@ -33,7 +33,7 @@ export function useSystemHealth(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -62,7 +62,7 @@ export function useCacheStats(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -91,7 +91,7 @@ export function useQueueStats(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -120,7 +120,7 @@ export function useDatabaseStats(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -149,7 +149,7 @@ export function useServiceStatus(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -178,7 +178,7 @@ export function useProxyStats(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -207,7 +207,7 @@ export function useSystemOverview(refreshInterval: number = 5000) {
|
|||
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
|
||||
|
||||
if (refreshInterval > 0) {
|
||||
const interval = setInterval(fetchData, refreshInterval);
|
||||
return () => clearInterval(interval);
|
||||
|
|
@ -215,4 +215,4 @@ export function useSystemOverview(refreshInterval: number = 5000) {
|
|||
}, [fetchData, refreshInterval]);
|
||||
|
||||
return { data, loading, error, refetch: fetchData };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
export { MonitoringPage } from './MonitoringPage';
|
||||
export * from './types';
|
||||
export * from './hooks/useMonitoring';
|
||||
export * from './services/monitoringApi';
|
||||
export * from './services/monitoringApi';
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
* Monitoring API Service
|
||||
*/
|
||||
|
||||
import type {
|
||||
SystemHealth,
|
||||
CacheStats,
|
||||
QueueStats,
|
||||
import type {
|
||||
CacheStats,
|
||||
DatabaseStats,
|
||||
ServiceStatus,
|
||||
ProxyStats,
|
||||
SystemOverview
|
||||
QueueStats,
|
||||
ServiceStatus,
|
||||
SystemHealth,
|
||||
SystemOverview,
|
||||
} from '../types';
|
||||
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:2003';
|
||||
|
|
@ -125,4 +125,4 @@ export const monitoringApi = {
|
|||
}
|
||||
return response.json();
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,4 +117,4 @@ export interface SystemOverview {
|
|||
architecture: string;
|
||||
hostname: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,48 @@
|
|||
/**
|
||||
* Common formatting utilities for monitoring components
|
||||
*/
|
||||
|
||||
export function formatUptime(ms: number): string {
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
|
||||
if (days > 0) {return `${days}d ${hours % 24}h`;}
|
||||
if (hours > 0) {return `${hours}h ${minutes % 60}m`;}
|
||||
if (minutes > 0) {return `${minutes}m ${seconds % 60}s`;}
|
||||
return `${seconds}s`;
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
const gb = bytes / 1024 / 1024 / 1024;
|
||||
if (gb >= 1) {
|
||||
return gb.toFixed(2) + ' GB';
|
||||
}
|
||||
|
||||
const mb = bytes / 1024 / 1024;
|
||||
if (mb >= 1) {
|
||||
return mb.toFixed(2) + ' MB';
|
||||
}
|
||||
|
||||
const kb = bytes / 1024;
|
||||
if (kb >= 1) {
|
||||
return kb.toFixed(2) + ' KB';
|
||||
}
|
||||
|
||||
return bytes + ' B';
|
||||
}
|
||||
|
||||
export function formatNumber(num: number): string {
|
||||
return num.toLocaleString();
|
||||
}
|
||||
|
||||
export function formatPercentage(value: number, decimals: number = 1): string {
|
||||
return `${value.toFixed(decimals)}%`;
|
||||
}
|
||||
/**
|
||||
* Common formatting utilities for monitoring components
|
||||
*/
|
||||
|
||||
export function formatUptime(ms: number): string {
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
|
||||
if (days > 0) {
|
||||
return `${days}d ${hours % 24}h`;
|
||||
}
|
||||
if (hours > 0) {
|
||||
return `${hours}h ${minutes % 60}m`;
|
||||
}
|
||||
if (minutes > 0) {
|
||||
return `${minutes}m ${seconds % 60}s`;
|
||||
}
|
||||
return `${seconds}s`;
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
const gb = bytes / 1024 / 1024 / 1024;
|
||||
if (gb >= 1) {
|
||||
return gb.toFixed(2) + ' GB';
|
||||
}
|
||||
|
||||
const mb = bytes / 1024 / 1024;
|
||||
if (mb >= 1) {
|
||||
return mb.toFixed(2) + ' MB';
|
||||
}
|
||||
|
||||
const kb = bytes / 1024;
|
||||
if (kb >= 1) {
|
||||
return kb.toFixed(2) + ' KB';
|
||||
}
|
||||
|
||||
return bytes + ' B';
|
||||
}
|
||||
|
||||
export function formatNumber(num: number): string {
|
||||
return num.toLocaleString();
|
||||
}
|
||||
|
||||
export function formatPercentage(value: number, decimals: number = 1): string {
|
||||
return `${value.toFixed(decimals)}%`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue