Skip to content

Commit 122efac

Browse files
committed
show runtime in gui
1 parent 7f53652 commit 122efac

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

gui/src/components/tracker/TrackerBattery.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Typography } from '@/components/commons/Typography';
66
export function TrackerBattery({
77
value,
88
voltage,
9+
runtime,
910
disabled,
1011
textColor = 'primary',
1112
}: {
@@ -14,6 +15,7 @@ export function TrackerBattery({
1415
*/
1516
value: number;
1617
voltage?: number | null;
18+
runtime?: BigInt | null
1719
disabled?: boolean;
1820
textColor?: string;
1921
}) {
@@ -33,11 +35,27 @@ export function TrackerBattery({
3335
return (
3436
<div className="flex gap-2">
3537
<div className="flex flex-col justify-around">
36-
<BatteryIcon value={value} disabled={disabled} charging={charging} />
38+
<BatteryIcon value={value} disabled={disabled} charging={charging}/>
3739
</div>
3840
{((!charging || showVoltage) && (
39-
<div className="w-10">
40-
{!charging && (
41+
<div className="w-15">
42+
{!charging && runtime && (
43+
<Typography color={textColor}>
44+
{((
45+
runtime.valueOf() /
46+
BigInt(3600000000)
47+
).toString() +
48+
'h ' +
49+
(
50+
(runtime.valueOf() %
51+
BigInt(3600000000)) /
52+
BigInt(60000000)
53+
).toString() +
54+
'min') ||
55+
'N/A'}
56+
</Typography>
57+
)}
58+
{!charging && (!runtime || showVoltage) && (
4159
<Typography color={textColor}>
4260
{percentFormatter.format(value)}
4361
</Typography>
@@ -49,7 +67,7 @@ export function TrackerBattery({
4967
)}
5068
</div>
5169
)) || (
52-
<div className="flex flex-col justify-center w-10">
70+
<div className="flex flex-col justify-center w-15">
5371
<div className="w-5 h-1 bg-background-30 rounded-full" />
5472
</div>
5573
)}

gui/src/components/tracker/TrackerCard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function TrackerBig({
5151
<TrackerBattery
5252
voltage={device.hardwareStatus.batteryVoltage}
5353
value={device.hardwareStatus.batteryPctEstimate / 100}
54+
runtime={device.hardwareStatus.batteryRuntimeEstimate}
5455
disabled={tracker.status === TrackerStatusEnum.DISCONNECTED}
5556
/>
5657
)}
@@ -119,6 +120,7 @@ function TrackerSmol({
119120
<TrackerBattery
120121
voltage={device.hardwareStatus.batteryVoltage}
121122
value={device.hardwareStatus.batteryPctEstimate / 100}
123+
runtime={device.hardwareStatus.batteryRuntimeEstimate}
122124
disabled={tracker.status === TrackerStatusEnum.DISCONNECTED}
123125
/>
124126
)}

gui/src/components/tracker/TrackersTable.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ function Row({
229229
<TrackerBattery
230230
value={device.hardwareStatus.batteryPctEstimate / 100}
231231
voltage={device.hardwareStatus.batteryVoltage}
232+
runtime={device.hardwareStatus.batteryRuntimeEstimate}
232233
disabled={tracker.status === TrackerStatusEnum.DISCONNECTED}
233234
textColor={fontColor}
234235
/>
@@ -329,7 +330,7 @@ export function TrackersTable({
329330
const cols = [
330331
'minmax(150px, 1.5fr)', // Name
331332
'minmax(100px, 1fr)', // Type
332-
'minmax(60px, 1fr)', // Battery
333+
'minmax(110px, 1fr)', // Battery
333334
'6rem', // Ping (w-24)
334335
'minmax(60px, 1fr)', // TPS
335336
config?.devSettings?.preciseRotation ? '11rem' : '8rem', // Rotation

0 commit comments

Comments
 (0)