mirror of
https://github.com/hotheadhacker/seedbox-lite.git
synced 2025-09-02 00:51:36 +03:00
Refactor layout styles for improved spacing and update cache stats calculations to use actual cache size
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
.home-page {
|
||||
padding: 40px;
|
||||
padding: 20px 40px; /* Reduced top/bottom padding, keep left/right */
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
background: #0a0a0a;
|
||||
|
||||
@@ -318,6 +318,12 @@
|
||||
min-height: 100vh;
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
margin-left: 300px; /* Account for sidebar width + spacing */
|
||||
}
|
||||
|
||||
/* When sidebar is collapsed, main content expands */
|
||||
.main-content.expanded {
|
||||
margin-left: 100px; /* Account for collapsed sidebar width + spacing */
|
||||
}
|
||||
|
||||
/* Mobile Overlay */
|
||||
@@ -476,12 +482,12 @@
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 280px; /* Account for sidebar width */
|
||||
margin-left: 300px; /* Account for sidebar width + spacing */
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.main-content.expanded {
|
||||
margin-left: 80px; /* Account for collapsed sidebar width */
|
||||
margin-left: 100px; /* Account for collapsed sidebar width + spacing */
|
||||
}
|
||||
|
||||
.mobile-overlay {
|
||||
|
||||
@@ -34,7 +34,7 @@ const Layout = () => {
|
||||
const diskData = await diskResponse.json().catch(() => ({ percentage: 0, total: 0 }));
|
||||
|
||||
// Calculate cache usage percentage relative to total disk space
|
||||
const cacheSize = stats.downloadedBytes || 0;
|
||||
const cacheSize = stats.cacheSize || 0;
|
||||
const totalDisk = diskData.total || 1;
|
||||
const cacheUsagePercentage = totalDisk > 0 ? (cacheSize / totalDisk) * 100 : 0;
|
||||
|
||||
|
||||
@@ -1290,9 +1290,9 @@ app.get('/api/cache/stats', async (req, res) => {
|
||||
let downloadedBytes = 0;
|
||||
|
||||
client.torrents.forEach(torrent => {
|
||||
// Add total size of each torrent
|
||||
// Add total size of each torrent (this is the actual cache size)
|
||||
cacheSize += torrent.length || 0;
|
||||
// Add downloaded bytes
|
||||
// Add downloaded bytes (for information)
|
||||
downloadedBytes += torrent.downloaded || 0;
|
||||
});
|
||||
|
||||
@@ -1306,20 +1306,21 @@ app.get('/api/cache/stats', async (req, res) => {
|
||||
|
||||
// Cache limit (5GB default)
|
||||
const cacheLimitBytes = 5 * 1024 * 1024 * 1024; // 5GB in bytes
|
||||
const usagePercentage = cacheLimitBytes > 0 ? (downloadedBytes / cacheLimitBytes) * 100 : 0;
|
||||
const usagePercentage = cacheLimitBytes > 0 ? (cacheSize / cacheLimitBytes) * 100 : 0;
|
||||
|
||||
const stats = {
|
||||
totalSizeFormatted: formatBytes(downloadedBytes), // Use actual downloaded data
|
||||
totalSize: downloadedBytes,
|
||||
totalSizeFormatted: formatBytes(cacheSize), // Use total cache size (torrent lengths)
|
||||
totalSize: cacheSize,
|
||||
activeTorrents,
|
||||
cacheSize: downloadedBytes, // Use downloaded bytes for cache calculation
|
||||
totalTorrentSize: cacheSize, // Total size of all torrents
|
||||
cacheSize: cacheSize, // Total torrent sizes in cache
|
||||
downloadedBytes: downloadedBytes, // Actual downloaded data
|
||||
totalTorrentSize: cacheSize, // Same as cacheSize
|
||||
totalTorrentSizeFormatted: formatBytes(cacheSize),
|
||||
cacheLimitFormatted: formatBytes(cacheLimitBytes),
|
||||
usagePercentage: Math.round(usagePercentage * 100) / 100 // Round to 2 decimal places
|
||||
};
|
||||
|
||||
console.log(`📊 Cache stats: ${formatBytes(downloadedBytes)} downloaded (${activeTorrents} torrents, ${usagePercentage.toFixed(1)}% of 5GB limit)`);
|
||||
console.log(`📊 Cache stats: ${formatBytes(cacheSize)} cached (${activeTorrents} torrents, ${usagePercentage.toFixed(1)}% of 5GB limit)`);
|
||||
res.json(stats);
|
||||
} catch (error) {
|
||||
console.error('Error getting cache stats:', error);
|
||||
|
||||
Reference in New Issue
Block a user