Part-DB-server/templates/parts/edit
Sebastian Almberg d73bc42362 Add a component value calculator & image generator
Adds a "Value calculator" tool (Tools menu) that decodes/encodes the value of
common components and generates a clean SVG picture you can attach to a part —
handy for assortments imported with blank thumbnails and sparse data.

Calculator tabs (bidirectional decode <-> encode), each drawing the part to the
selected package with a collapsible appearance panel and an "attach to part"
action (optionally as the master picture):
- Resistor: 4/5/6-band colour code
- Capacitor: value <-> 3-digit code <-> tolerance
- SMD resistor: value <-> 3-digit / 4-digit / EIA-96 code
- Inductor: colour-band code
- SMD inductor: value <-> uH code

Bulk "Generate component images" parts-table action:
- Classifies each selected part (resistor / capacitor / inductor / diode / LED,
  THT or SMD) with ComponentValueGuesser and detects value, voltage, tolerance,
  power, ppm, pitch, diameter, colour, SMD package and marking from the name,
  description and parameters.
- Renders a preview per part, lets you tweak appearance, and attaches the images
  in one go; can also write matching KiCad symbol/footprint/reference-prefix EDA
  fields.

Backend: ComponentValueGuesser (classification + detection + EDA suggestion),
GeneratedImageAttachmentHelper (stores the SVG through the existing attachment
pipeline, so it is sanitised on save), two POST endpoints on PartController
(generate_image, set_eda) guarded by `edit` + CSRF, a new `@tools.value_calculator`
permission, a Tools-tree entry and docs. All drawing is client-side in a Stimulus
controller; the un-sanitised live preview escapes part-derived text and validates
colours as defence-in-depth.

Tests: unit tests for ComponentValueGuesser and functional tests for the
endpoints, including permission and CSRF enforcement and the persisted side
effects.
2026-07-30 17:49:18 +02:00
..
_advanced.html.twig Allow to edit info provider reference 2026-06-28 23:47:49 +02:00
_associated_parts.html.twig Use a custom delete confirmation message for part associations 2023-11-16 22:38:01 +01:00
_attachments.html.twig Add a component value calculator & image generator 2026-07-30 17:49:18 +02:00
_eda.html.twig Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
_lots.html.twig Renamed parts/ templates folder to recommended snake_case style 2023-02-04 23:05:39 +01:00
_main.html.twig Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
_manufacturer.html.twig Renamed parts/ templates folder to recommended snake_case style 2023-02-04 23:05:39 +01:00
_orderdetails.html.twig Replaced leftover bootstrap_4 form theme usages with BS5 2023-03-05 23:12:44 +01:00
_specifications.html.twig Enhance KiCad integration: API v2, batch EDA editing, field export control (#1241) 2026-03-01 22:10:13 +01:00
edit_form_styles.html.twig Make form layout better at wide screens & Make horizontal form column layout configurable via global Twig variables (#1293) 2026-03-07 16:14:58 +01:00
edit_part_info.html.twig Add a component value calculator & image generator 2026-07-30 17:49:18 +02:00
merge_parts.html.twig Added an form for merging two parts together 2023-11-22 20:11:38 +01:00
new_part.html.twig Added an form for merging two parts together 2023-11-22 20:11:38 +01:00
update_from_ip.html.twig More sophisticated two-step bulk import from info providers 2025-08-31 22:16:27 +02:00