mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-24 17:36:42 +00:00
feat: add frontend index.html and Vite logo; enhance system stats API with network metrics
- Created a new index.html file for the frontend with theme handling and linked assets. - Added a Vite logo SVG to the public directory. - Updated the system stats API to include network statistics (rxBytes, txBytes, rxSec, txSec). - Enhanced the EditorLayout component to display network I/O rates for containers. - Modified HomeDashboard to show host network statistics with appropriate formatting.
This commit is contained in:
+20
-1
@@ -578,12 +578,25 @@ app.get('/api/stats', async (req: Request, res: Response) => {
|
||||
// Get host system stats
|
||||
app.get('/api/system/stats', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const [currentLoad, mem, fsSize] = await Promise.all([
|
||||
const [currentLoad, mem, fsSize, networkStats] = await Promise.all([
|
||||
si.currentLoad(),
|
||||
si.mem(),
|
||||
si.fsSize(),
|
||||
si.networkStats(),
|
||||
]);
|
||||
|
||||
let rxBytes = 0;
|
||||
let txBytes = 0;
|
||||
let rxSec = 0;
|
||||
let txSec = 0;
|
||||
|
||||
networkStats.forEach(net => {
|
||||
rxBytes += net.rx_bytes || 0;
|
||||
txBytes += net.tx_bytes || 0;
|
||||
rxSec += net.rx_sec || 0;
|
||||
txSec += net.tx_sec || 0;
|
||||
});
|
||||
|
||||
// Find the main mount (usually the largest or root mount)
|
||||
const mainDisk = fsSize.find(fs => fs.mount === '/' || fs.mount === 'C:') || fsSize[0];
|
||||
|
||||
@@ -606,6 +619,12 @@ app.get('/api/system/stats', async (req: Request, res: Response) => {
|
||||
free: mainDisk.available,
|
||||
usagePercent: mainDisk.use ? mainDisk.use.toFixed(1) : '0',
|
||||
} : null,
|
||||
network: {
|
||||
rxBytes,
|
||||
txBytes,
|
||||
rxSec,
|
||||
txSec
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch system stats:', error);
|
||||
|
||||
Reference in New Issue
Block a user