diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 3a49b30..392f324 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -474,8 +474,6 @@ function App(): JSX.Element { const getStatusChip = (s: string | { status: string, cpu?: number, memory?: number }) => { const state = typeof s === 'string' ? s : s.status - const cpu = typeof s === 'object' ? s.cpu : null - const memory = typeof s === 'object' ? s.memory : null if (state === 'starting') { return } /> @@ -485,26 +483,62 @@ function App(): JSX.Element { } const color = state === 'running' ? 'success' : state === 'stopped' ? 'error' : 'warning' - return ( - - - {state === 'running' && cpu !== null && ( - - - - {cpu}% - - - - {formatMemory(memory as number)} - - - - )} - - ) + return } + const ResourceMonitor = ({ cpu, memory }: { cpu?: number; memory?: number }) => { + if (cpu === undefined && memory === undefined) return null; + + const ramMB = memory ? Math.round(memory / (1024 * 1024)) : 0; + const ramLimit = 1024; // 1GB scale for visual + const cpuValue = cpu || 0; + const ramPercent = Math.min((ramMB / ramLimit) * 100, 100); + + return ( + + + + CPU + {cpuValue}% + + + + + + RAM + {formatMemory(memory as number)} + + + + + ); + }; + const handleAddProject = async () => { if (!window.api) return if (newProject.id) { @@ -1155,8 +1189,9 @@ function App(): JSX.Element { {getStatusChip(status.nginx)} Nginx - Port: {settings.nginxPort} - + Port: {settings.nginxPort} + + handleOpenLogs('nginx')} title={t('diagnostics.logs')} size="small" sx={{ bgcolor: 'rgba(255,255,255,0.05)' }}> @@ -1217,8 +1252,9 @@ function App(): JSX.Element { {getStatusChip(status.apache)} Apache - Port: {settings.apachePort} - + Port: {settings.apachePort} + + handleOpenLogs('apache')} title={t('diagnostics.logs')} size="small" sx={{ bgcolor: 'rgba(255,255,255,0.05)' }}> @@ -1279,8 +1315,9 @@ function App(): JSX.Element { {getStatusChip(status[`php:${v.version}`] || { status: 'stopped' })} PHP {v.version} - Port: {v.port || '?'} - + Port: {v.port || '?'} + + handleOpenLogs(`php:${v.version}`)} size="small" sx={{ bgcolor: 'rgba(255,255,255,0.05)' }}> @@ -1310,8 +1347,9 @@ function App(): JSX.Element { {getStatusChip(status[`mariadb:${v.version}`] || { status: 'stopped' })} MariaDB {v.version} - Port: {settings.mariaDbPorts?.[v.id] || v.port} - + Port: {settings.mariaDbPorts?.[v.id] || v.port} + + handleOpenLogs(`mariadb:${v.version}`)} title={t('diagnostics.logs')} size="small" sx={{ bgcolor: 'rgba(255,255,255,0.05)' }}>