Skip to content
Snippets Groups Projects
Commit 05a378f1 authored by Tim Neumann's avatar Tim Neumann
Browse files

feat(qrScanner): Use class with more features

parent 4076716e
No related branches found
No related tags found
2 merge requests!4Improve Scanner,!2feat(qrScanner): Use class with more features
Source diff could not be displayed: it is too large. Options to address this: view the blob.
import { import {
Html5Qrcode Html5QrcodeScanner,
Html5QrcodeSupportedFormats
} from "html5-qrcode"; } from "html5-qrcode";
import { import {
ed448 ed448
...@@ -11,7 +12,13 @@ import { ...@@ -11,7 +12,13 @@ import {
var received_items = {}; var received_items = {};
var access_token; var access_token;
var config; var config;
var scanner = new Html5Qrcode("reader",{}); var scanner = new Html5QrcodeScanner("reader",{
fps: 10,
qrbox: { width: 250, height: 250 },
showTorchButtonIfSupported: true,
formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ], //there are many other types of codes on the labels we do not want
rememberLastUsedCamera: true,
});
var scanner_audio = new Audio("/beep.wav"); var scanner_audio = new Audio("/beep.wav");
scanner_audio.load(); scanner_audio.load();
...@@ -76,11 +83,8 @@ export async function addItemTag(form) { ...@@ -76,11 +83,8 @@ export async function addItemTag(form) {
} }
export async function addItemScan() { export async function addItemScan() {
scanner.start( scanner.render(
{ facingMode: "user" },
{fps: 10, qrbox: { width: 250, height: 250 }},
async function (item_uuid){ async function (item_uuid){
await scanner.stop();
if (item_uuid.length == 36) { if (item_uuid.length == 36) {
if (item_uuid in received_items) { if (item_uuid in received_items) {
received_items[item_uuid].num += 1; received_items[item_uuid].num += 1;
...@@ -133,7 +137,7 @@ export async function checkinItems() { ...@@ -133,7 +137,7 @@ export async function checkinItems() {
"num": received_items[item].num "num": received_items[item].num
}) })
}); });
var tracking_item = await response.json(); var tracking_item = await response.json(); // eslint-disable-line no-unused-vars
} }
received_items = {}; received_items = {};
updateItemsView(); updateItemsView();
...@@ -143,7 +147,6 @@ export async function checkinItems() { ...@@ -143,7 +147,6 @@ export async function checkinItems() {
async function onRecevierScanSuccess(scannedCode) { async function onRecevierScanSuccess(scannedCode) {
var [uuid,signature] = scannedCode.split("/"); var [uuid,signature] = scannedCode.split("/");
scanner_audio.play(); scanner_audio.play();
await scanner.stop();
await getConfig(); await getConfig();
var response = await fetch(config.backend_url + "/item/"+uuid); var response = await fetch(config.backend_url + "/item/"+uuid);
if (response.status == 200) { if (response.status == 200) {
...@@ -158,7 +161,7 @@ async function onRecevierScanSuccess(scannedCode) { ...@@ -158,7 +161,7 @@ async function onRecevierScanSuccess(scannedCode) {
} }
} }
export async function scanReceiver() { export async function scanReceiver() {
scanner.start({ facingMode: "user" }, { fps: 10, qrbox: { width: 250, height: 250 } }, onRecevierScanSuccess); scanner.render(onRecevierScanSuccess);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment