This commit is contained in:
legop3
2025-11-15 22:47:05 -05:00
parent 08011d7ea1
commit f27a5554f2
3 changed files with 11 additions and 5 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>webui</title> <title>webui</title>
<script type="module" crossorigin src="/assets/index-DeMYMr-m.js"></script> <script type="module" crossorigin src="/assets/index-sCjLoHHT.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BLqBO1Eu.css"> <link rel="stylesheet" crossorigin href="/assets/index-BLqBO1Eu.css">
</head> </head>
<body> <body>
+9 -3
View File
@@ -168,14 +168,20 @@ function BatteryBar({ charge, capacity, config, label, status }) {
</div> </div>
); );
} }
const span = config.full - config.warn; const normalizedConfig = {
full: config.full ?? config.Full ?? 0,
warn: config.warn ?? config.Warn ?? 0,
urgent: config.urgent ?? config.Urgent ?? null,
};
const span = normalizedConfig.full - normalizedConfig.warn;
if (span <= 0) return null; if (span <= 0) return null;
const normalized = (charge - config.warn) / span; const normalized = (charge - normalizedConfig.warn) / span;
const percent = Math.min(1, Math.max(0, normalized)); const percent = Math.min(1, Math.max(0, normalized));
const percentDisplay = Math.round(percent * 100); const percentDisplay = Math.round(percent * 100);
const percentText = `${percentDisplay}%`; const percentText = `${percentDisplay}%`;
const depleted = normalized <= 0; const depleted = normalized <= 0;
const urgent = config.urgent != null && charge <= config.urgent; const urgent = normalizedConfig.urgent != null && charge <= normalizedConfig.urgent;
const barClass = depleted ? 'bg-red-500 animate-pulse' : urgent ? 'bg-amber-400' : 'bg-emerald-500'; const barClass = depleted ? 'bg-red-500 animate-pulse' : urgent ? 'bg-amber-400' : 'bg-emerald-500';
const capText = capacity ? `${charge}/${capacity}` : `${charge}`; const capText = capacity ? `${charge}/${capacity}` : `${charge}`;
return ( return (