Skip to content

Conversation

@swdee
Copy link
Contributor

@swdee swdee commented Jan 17, 2026

Overview

This PR makes changes to the Label Scanner to enhance its functionality in the following ways.

  1. Scan and decode of LCSC.com barcodes
  2. Create new parts by scanning vendor barcodes (lcsc, mouser, digikey)
  3. Provides an augmented view of decoded barcode

These improvements provide a solution to the open issues #937 #520

It also provides functions for addressing #464

Use Case

In addition to the open Issues above, my use case for these enhancements is as follows.

I have 500+ components and loading them into Part-DB is a difficult and slow task, using the Tools->Create parts from info provider tool is slow to type in the Part numbers, it would be much easier to scan the vendor barcodes to create Parts.

The next problem is the Scanner only loads barcodes of Parts with a Part-DB barcode. It would be a hard task for someone wanting to use or migrate to Part-DB and having to load and print hundreds of labels/stickers for the Scanner to be usable.

Supplier barcodes (lcsc, mouser etc) already have all the necessary information on their labels to make the system work. There is however one important piece missing from the supplier label and that is the Storage Location. By providing an augmented view we can quickly scan the supplier barcode to return the component to its correct Storage location. This avoids the more complicated and current workflow of scanning a barcode, redirecting to the part page, clicking on the Stocks tab, then returning to the scanner page which has to go through the camera initialization routine again.

Demo

The existing function of Scanning parts and redirecting to the Part page has been preserved, to use these new enhancements tick the Info Mode checkbox to activate them.

The following video demonstrates the Augmented view which allows you to scan quickly supplier barcodes to perform part lookup and storage location retreival.

scan-parts-quickly.mp4

In the next video it demonstrates how you can create a new part when it is not found as well as showing support for decoding LCSC, Digikey, and Mouser barcodes.

add-parts-from-scan.mp4

Camera Bugs

Whilst developing these enhancements we have also fixed a number of bugs in the scanner, the CSRF token failure in #1191 and we found in Info Mode the camera would constantly connect and disconnect and sometimes become invisible/broken on view requiring a page reload in the browser.

To fix these we changed the architecure of the Scanner page to perform XHR requests for the barcode decoding, and then on the client side we either redirect to the Parts page to preverse the existing function, or display the decoded and augmented information. This allows us to stay on the Scanner page without causing the QR Code scanner to be constructed and destructed all the time.

As the QR Code scanner is persistently scanning, we also implemented logic to only do an XHR callback when it sees a new barcode to avoid multiple requests of the same barcode to the server. In comparison to the existing/old function which resulted in a reload loop in the browser after we fixed the QR Code scanner construct/destruct issues causing the camera interface to break under undetermined race conditions.

Development Status

This code is not yet ready to be merged, from our side we need;

  1. People to test this for any bugs or edge cases we have not come across.

  2. We are not sure how the Translation implementation works. For now we edited the translations/messages.en.xlf file and manually inserted our new language units. Would you please advise how we should approach this properly?

  3. And of course we need feedback from the maintainers on our code changes.

@swdee
Copy link
Contributor Author

swdee commented Jan 18, 2026

I have setup a test server instance of Part-DB with these PR changes for end user to try out.

Field Value
Server URL https://testing-partdb.bokumail.com
Username testing
Password test22

Instructions

Login with the above credentials and click on the Scanner menu option at the top to load the Label Scanner.

Check the Info Mode box and start scanning Barcodes. Currently only LCSC and EIGP (Mouser or Digikey barcodes) are supported for new part creation.

Feedback Request

Please provide feedback on UI usage, bugs, or any problems you experience with these enhancements.

swdee added 8 commits January 19, 2026 16:11
…canning subsequent parts was not possible without reloading the browser page. fixed the barcode scanner initialization and shutdown so it redraws properly after part not found
…nd mouser barcodes. added create part button if part does not exist in database
…checkbox. changed barcode scanner to use XHR callback for barcode decoding to avoid problems with form submission and camera caused by page reloaded when part not found.
…art lots. made scan result messages conditional for parts or other non-part barcodes
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 64.48980% with 87 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.34%. Comparing base (766ba07) to head (7336bc8).

Files with missing lines Patch % Lines
src/Controller/ScanController.php 49.29% 72 Missing ⚠️
...s/LabelSystem/BarcodeScanner/BarcodeRedirector.php 77.77% 10 Missing ⚠️
...belSystem/BarcodeScanner/LCSCBarcodeScanResult.php 90.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1194      +/-   ##
============================================
+ Coverage     58.23%   58.34%   +0.11%     
- Complexity     7430     7510      +80     
============================================
  Files           582      583       +1     
  Lines         23644    23877     +233     
============================================
+ Hits          13768    13932     +164     
- Misses         9876     9945      +69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jbtronics
Copy link
Member

Hey,
thanks for the PR, I think that is some very useful functionality.
I took some very rough look across the code changes (I have not tested it so far), and it looks quite well, I put some smaller remarks on the code, but that is not final yet.

The functionality for handling what should happen for part creation should be extracted to its own service.
If we expect that there will be many different vendor label types to be handled, it might be useful to extract each vendor type into its own handler class, that are then used by their container tag (similar to how the info provider classes or the label placeholders work). But for two different types that is probably not too useful.

@swdee
Copy link
Contributor Author

swdee commented Jan 20, 2026

The functionality for handling what should happen for part creation should be extracted to its own service.

To confirm what you mean. We should;

  1. create src/Services/LabelSystem/BarcodeScanner/PartCreationResolver.php and move from ScanController.php the function buildCreateUrlForScanResult() into the PartCreationResolver.php.

  2. create src/Services/LabelSystem/BarcodeScanner/ScanAugmentationService.php and move from ScanController.php the functions buildLocationsForPart() and buildStorageBreadcrumb() into it.

This would then leave ScanController.php with the endpoints for lookup() , dialog(), and scanQRCode.

@lukilukeskywalker
Copy link

I just tried it out with a few LCSC components I had lying around, works flawlessly

@swdee
Copy link
Contributor Author

swdee commented Jan 24, 2026

@jbtronics I will be away from my development environment for a couple of weeks, when I get back I will rebase the code and make any changes you recommend after you have had time to review.

@MayNiklas
Copy link
Contributor

I would love this feature!
I just tried it out and noticed an issue:

While it works flawlessly using my camera, I had issues using my barcode scanner (with the same LCSC bag).
For scanning using a barcode scanner, I click on input and then use my scanner, which basically acts as a keyboard and enters the string.

For debugging, here is my string: {pbn:PICK2506270148,on:GB2506270877,pc:C22437266,pm:IA0509S-2W,qty:3,mc:,cc:1,pdi:164234874,hp:null,wc:ZH}

Having info mode enabled, everything works:
image

Having info mode disabled, I get a Format unknown error.
image

This should be reproducible, using my string and the input field.

Still:
I hope this feature is able to make it upstream - I would love that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants