From 037e057c5375cdf5c5f706b79de896af62473885 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 9 May 2022 19:46:11 +1000 Subject: [PATCH] Adds global setting to enable or disable webcam support for barcode scanning --- InvenTree/common/models.py | 7 +++++++ InvenTree/templates/InvenTree/settings/barcode.html | 1 + InvenTree/templates/js/translated/barcode.js | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 1434bba95e..11157763cb 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -842,6 +842,13 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'validator': bool, }, + 'BARCODE_WEBCAM_SUPPORT': { + 'name': _('Barcode Webcam Support'), + 'description': _('Allow barcode scanning via webcam in browser'), + 'default': True, + 'validator': bool, + }, + 'PART_IPN_REGEX': { 'name': _('IPN Regex'), 'description': _('Regular expression pattern for matching Part IPN') diff --git a/InvenTree/templates/InvenTree/settings/barcode.html b/InvenTree/templates/InvenTree/settings/barcode.html index 8532476b75..ea45455203 100644 --- a/InvenTree/templates/InvenTree/settings/barcode.html +++ b/InvenTree/templates/InvenTree/settings/barcode.html @@ -13,6 +13,7 @@ {% include "InvenTree/settings/setting.html" with key="BARCODE_ENABLE" icon="fa-qrcode" %} + {% include "InvenTree/settings/setting.html" with key="BARCODE_WEBCAM_SUPPORT" icon="fa-video" %}
diff --git a/InvenTree/templates/js/translated/barcode.js b/InvenTree/templates/js/translated/barcode.js index a6305eb1df..d6ce81fa38 100644 --- a/InvenTree/templates/js/translated/barcode.js +++ b/InvenTree/templates/js/translated/barcode.js @@ -70,7 +70,7 @@ function onBarcodeScanClicked(e) { } function onCameraAvailable(hasCamera, options) { - if ( hasCamera == true ) { + if (hasCamera && global_settings.BARCODE_WEBCAM_SUPPORT) { // Camera is only acccessible if page is served over secure connection if ( window.isSecureContext == true ) { qrScanner = new QrScanner(document.getElementById('barcode_scan_video'), (result) => {