-
Notifications
You must be signed in to change notification settings - Fork 16
feat(client): adaptive W/kW display for miner power usage #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,18 @@ export const padLeft = (value: number, length: number) => { | |
| return value.toString().padStart(length, "0"); | ||
| }; | ||
|
|
||
| /** | ||
| * Formats a power value in kW with adaptive units. | ||
| * Values >= 1 kW are shown in kW (1 decimal place). | ||
| * Values < 1 kW are converted to W (rounded to nearest integer). | ||
| */ | ||
| export const formatPowerKW = (kw: number): { value: string; unit: string } => { | ||
| if (kw >= 1) { | ||
| return { value: separateByCommas(kw.toFixed(1)), unit: "kW" }; | ||
| } | ||
| return { value: separateByCommas((kw * 1000).toFixed(1)), unit: "W" }; | ||
|
Comment on lines
+35
to
+44
|
||
| }; | ||
|
|
||
| export const stripLeadingSlash = (str: string) => { | ||
| return str.startsWith("/") ? str.substring(1) : str; | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinerPowerUsagenow re-implements the same loading/offline/empty/latest-value logic that already exists inMinerMeasurement. To avoid future drift between measurement cells, consider refactoringMinerMeasurementto accept a formatter (or render prop) soMinerPowerUsagecan keep the shared state handling while still using adaptive units.