fix uptime on dashboard

This commit is contained in:
Constantin
2025-09-13 14:42:44 +03:00
parent 47c2beaf96
commit b40e4f277e
2 changed files with 26 additions and 2 deletions
+18 -1
View File
@@ -62,6 +62,23 @@ function Dashboard({ isOnline }) {
}
};
const formatUptime = (seconds) => {
if (!seconds || seconds < 0) return '0s';
const days = Math.floor(seconds / 86400);
const hours = Math.floor((seconds % 86400) / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const secs = Math.floor(seconds % 60);
const parts = [];
if (days > 0) parts.push(`${days}d`);
if (hours > 0) parts.push(`${hours}h`);
if (minutes > 0) parts.push(`${minutes}m`);
if (secs > 0 || parts.length === 0) parts.push(`${secs}s`);
return parts.join(' ');
};
const handleServiceControl = async (serviceName, action) => {
if (!isOnline) return;
@@ -224,7 +241,7 @@ function Dashboard({ isOnline }) {
<div className="ml-4">
<p className="text-sm font-medium text-gray-500">Uptime</p>
<p className="text-lg font-semibold text-gray-900">
{Math.floor((cellStatus.uptime || 0) / 3600)}h {Math.floor(((cellStatus.uptime || 0) % 3600) / 60)}m
{formatUptime(cellStatus.uptime || 0)}
</p>
</div>
</div>