Label Scanner Enhancements: LCSC barcode, create part, augmented scanning#1194
Label Scanner Enhancements: LCSC barcode, create part, augmented scanning#1194swdee wants to merge 16 commits intoPart-DB:masterfrom
Conversation
|
I have setup a test server instance of Part-DB with these PR changes for end user to try out.
InstructionsLogin with the above credentials and click on the Check the Feedback RequestPlease provide feedback on UI usage, bugs, or any problems you experience with these enhancements. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1194 +/- ##
============================================
+ Coverage 54.77% 54.91% +0.13%
- Complexity 8012 8094 +82
============================================
Files 601 602 +1
Lines 25690 25929 +239
============================================
+ Hits 14072 14239 +167
- Misses 11618 11690 +72 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hey, The functionality for handling what should happen for part creation should be extracted to its own service. |
To confirm what you mean. We should;
This would then leave |
|
I just tried it out with a few LCSC components I had lying around, works flawlessly |
|
@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. |
|
Update: |
|
Some remarks about aspects I came across:
|
…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
…ookup to see part storage location quickly
…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
…a barcode scan or manual input) redirect to Create New part screen for the decoded information instead of showing 'Format Unknown' popup error message
…of new barcode
|
@swdee I just tested your updates - looks great! |
…ned off when scanning a part that did not exist, it now redirects user to create part page
…ecodes properly which causes the camera to not redraw on page reload due to unclean shutdown. this is an existing bug in the scanner interface. steps to produce the issue: - have camera active - put in code in Input - info mode ticked - click submit button on page reload the camera does not reactivate
UpdateI am back from holiday so this PR has my attention again. The code has been rebased and I have addressed the following bugs/feedback. Addressing Bugs/Feedback
The issues reported by @d-buchmann
I am not 100% sure, but I did find a bug with this behaviour for Parts that do not yet exist in the system which has now been fixed. This now correctly redirects to the Create New Part page or the Part loaded page.
I have fixed the decoded barcode table to expand the page width which is the existing behaviour of PartDB. If this is not what you meant, would you please provide a screenshot?
Would you please provide a screen shot and let me know what phone and browser your using?
I have created an account but don't see how to add new "Source Strings" to the project. I suspect this is a permission issue which only the project owner can do? (The option to add new Source Strings with my own test crowdin project was fine). New Bug FixedWhilst fixing the above I also found an existing bug in PartDB which was triggered by manual form submission on the Scanner page causing the camera to not redraw. This bug is confirmed on the Demo instance https://demo.part-db.de/ with the following steps:
On page reload the camera is broken and does not redraw. This is fundamentally an issue with the QRCode library not receiving a clean shutdown before form submission so upon page reload it does not reactivate. I have added a form submission hook to perform the clean shutdown so upon reload it reactivates cleanly. |
Those alignment issues in Firefox Dev tools actually occur in the existing PartDB code (ie: using the demo site https://demo.part-db.de/en/scan ). If I set the devtool screen resolution to your first sizing of 898x903 and click reload on the browser it draws fine. If I adjust the sizing to 588x903 then it redraws off center, however if you click reload again on the browser it draws ok. Before reload.
After reload.
From past experiences a way to fix this is to have a window/document level javascript hook that detects page/viewport resizing, which then triggers redrawing of the QRCode/Camera window to fix the alignment/sizing. Also the vertical space on the left hand side is a result of the responsive layout, if you adjust to 480x903 for example this resolution removes that left hand side space and stacks the camera, input field, and barcode types nicely.
However should we be doing that in this PR or leave it as a separate issue on the current code base? |
From my experience from other projects, it would make sense to solve it in a separate PR. Thats just my opinion and I can't speak for the project. |
When the devolopment mode in Part-DB is active, you should see the translation section in symfony debug bar. When clicking on that section the profiler shows all translations missing in the current request (in english), and you can edit/add them. they will get added to messages.en.xlf and can then later be translated to other languages in crowdin.
I think its the best to just do a separate PR for it. |
|
Ok, I have fixed up the translation messages. That addresses all the points and feedback so far, is there anything else we need to do before being able to merge? |
Is the PR description still fully up to date? |
Yes, the description is still accurate. |








Overview
This PR makes changes to the Label Scanner to enhance its functionality in the following ways.
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 Modecheckbox 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;
People to test this for any bugs or edge cases we have not come across.
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?
And of course we need feedback from the maintainers on our code changes.