Skip to content

feat(frontend): reorganize config forms and add unit segmented controls (#17, #18)#38

Open
markoceri wants to merge 4 commits into
edge-mining:mainfrom
markoceri:fix/issue-17-18-config-forms
Open

feat(frontend): reorganize config forms and add unit segmented controls (#17, #18)#38
markoceri wants to merge 4 commits into
edge-mining:mainfrom
markoceri:fix/issue-17-18-config-forms

Conversation

@markoceri

@markoceri markoceri commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

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).

image

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:

  • Power → W / kW / MW
  • Energy → Wh / kWh / MWh
  • Hash rate → GH/s / TH/s / PH/s

The 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

  • each entity_<x> field is paired with its unit_<x> counterpart on the same row;
  • rows are grouped by domain (Power / Energy / Hash Rate) when at least two domains are present (e.g. the Forecast Provider form); otherwise the form stays a flat list (e.g. Energy Monitor / Miner);
  • the original schema declaration order (already chronological) is preserved within each group.

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

MinerControllerConfigForm had its own duplicated copy of the form renderer and therefore missed pairing and segmented controls. It now delegates to the shared ConfigSchemaForm. sensorPrefix is 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 into core/utils/configSchema.ts.

Testing

  • vue-tsc type-check and vite build pass.
  • Behaviour for non-unit fields (entity, number, boolean, enum, nested objects, password, Home Assistant sensor. prefix) is unchanged.

Closes #17
Closes #18

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace free-text unit inputs with segmented controls for measurement units Configuration Forms – Field Organization Guidelines

1 participant