Part-DB-server/templates/components
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
..
attachments.macro.html.twig Fixed margins of the upload files button 2024-03-02 18:33:20 +01:00
collection_type.macro.html.twig Add a blue dot to the collection type delete buttons in forms to indicate that this element was not yet saved to DB yet 2023-11-20 23:40:14 +01:00
datatables.macro.html.twig Add a component value calculator & image generator 2026-07-30 17:49:18 +02:00
history_log_macros.html.twig Include the query part of the request, when generating the url for the datatables via a custom twig function. 2024-10-16 23:57:02 +02:00
new_version.macro.html.twig Show a notification on homepage and server info page if there is a new version available. 2023-08-04 23:49:26 +02:00
projects.macro.html.twig Added a tab "Build" to project info page, where you can see how often you can build this project. 2023-01-18 23:07:51 +01:00
quick_links.macro.html.twig Show entity preview image on admin page 2023-02-05 20:00:11 +01:00
search.macro.html.twig Properly disable the id search by default 2026-01-18 23:48:04 +01:00
tree_macros.html.twig Implemented the ability to set user-defined synonyms/labels for internal element types 2025-11-12 21:35:02 +01:00