feat(frontend): reorganize config forms and add unit segmented controls (#17, #18)#38
Open
markoceri wants to merge 4 commits into
Open
feat(frontend): reorganize config forms and add unit segmented controls (#17, #18)#38markoceri wants to merge 4 commits into
markoceri wants to merge 4 commits into
Conversation
…ls (edge-mining#17, edge-mining#18) Schema-driven configuration forms previously presented every field as a flat list, with unit-of-measure fields rendered as free-text inputs (error-prone: "w", "KW", "kw") and entity/unit fields split far apart. This reworks ConfigSchemaForm so that, generically for all forms: - entity_<x> fields are paired with their unit_<x> counterpart on the same row, keeping the value next to its unit of measure (edge-mining#17); - rows are grouped by domain (Power / Energy / Hash Rate) when at least two domains are present, preserving the schema declaration (chronological) order within each group (edge-mining#17); - unit fields are rendered as a segmented control whose options are inferred from the field's value family (power/energy/hash rate), instead of a free-text input (edge-mining#18). Field rendering is extracted into a reusable ConfigFieldControl component and the schema/unit helpers into core/utils/configSchema.ts. Field names and helper texts are intentionally left unchanged (a separate naming issue).
…e-mining#17, edge-mining#18) MinerControllerConfigForm had its own duplicated copy of the schema-driven form renderer, so the miner controller add/edit modal did not get the entity/unit pairing or the unit segmented controls. Home Assistant-based controllers (e.g. generic socket) therefore showed entities and their unit of measure as separate, unpaired free-text fields. Replace the duplicated implementation with a delegation to the shared ConfigSchemaForm (config-endpoint "miner-controllers"). sensorPrefix is left disabled because these controllers mix entity prefixes (switch., sensor.) and expect full entity ids.
…dge-mining#17) The Configuration section rendered each entity and its unit as two separate fields side by side; long titles and descriptions wrapped onto multiple lines and broke the vertical alignment between the entity input and its unit. Render the unit-of-measure segmented control inline as the entity field's addon, so each paired row keeps a single (entity) label and helper text, with the unit selector attached to the right of the input. This removes the redundant unit labels/descriptions and keeps rows aligned regardless of text length. ConfigFieldControl gains hideLabel / hideDescription props and an "addon" slot. Configuration modals are widened to max-w-3xl for more breathing room.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #17 (configuration forms field organization) and #18 (segmented controls for unit fields). The two are tightly coupled — #17 places each Unit field next to its Entity field using the segmented control from #18 — so they are delivered together.
Everything is implemented generically in the schema-driven
ConfigSchemaForm, so it applies to every configuration form (Forecast Provider, Energy Monitor, Miner Controller, Home Load providers), not just the "Add Forecast Provider" example. No backend change is required and the underlying field names / helper texts are left unchanged (deferred to the separate naming issue, as noted in #17).Changes
#18 — Unit segmented controls
Unit-of-measure fields are rendered as a segmented control instead of a free-text input. The option set is inferred from the field's value family:
W/kW/MWWh/kWh/MWhGH/s/TH/s/PH/sThe family is detected from the field's current/default value (with a name-keyword fallback). Any previously-saved custom value is preserved and remains selectable, so no data is lost.
#17 — Field organization
entity_<x>field is paired with itsunit_<x>counterpart on the same row;Layout optimization
Paired rows use a compact layout: the unit segmented control is rendered inline next to the entity input, so each row keeps a single (entity) label and helper text and stays aligned regardless of text length (previously long titles/descriptions wrapped and broke the entity/unit alignment). Configuration modals were widened to
max-w-3xl.Miner controller
MinerControllerConfigFormhad its own duplicated copy of the form renderer and therefore missed pairing and segmented controls. It now delegates to the sharedConfigSchemaForm.sensorPrefixis intentionally left disabled because these controllers mix entity prefixes (switch.,sensor.) and expect full entity ids.Refactor
Field rendering is extracted into a reusable
ConfigFieldControl.vue, and the schema/unit helpers intocore/utils/configSchema.ts.Testing
vue-tsctype-check andvite buildpass.sensor.prefix) is unchanged.Closes #17
Closes #18