This commit is contained in:
sairaj mote 2020-10-04 12:51:59 +05:30
parent 2df7068cb5
commit 00c1797e5d
4 changed files with 52 additions and 34 deletions

View File

@ -467,6 +467,8 @@ sm-popup h5:not(.tag) {
} }
#qr_code_popup sm-panel { #qr_code_popup sm-panel {
display: flex; display: flex;
height: max-content;
flex-direction: column;
justify-content: center; justify-content: center;
} }

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -483,6 +483,8 @@ sm-popup{
} }
sm-panel{ sm-panel{
display: flex; display: flex;
height: max-content;
flex-direction: column;
justify-content: center; justify-content: center;
} }
} }

View File

@ -69,6 +69,7 @@
<sm-tab-panels id="qr_selector"> <sm-tab-panels id="qr_selector">
<sm-panel> <sm-panel>
<div id="reader"></div> <div id="reader"></div>
<sm-select id="select_camera"></sm-select>
</sm-panel> </sm-panel>
<sm-panel> <sm-panel>
<div id="my_qr_code"></div> <div id="my_qr_code"></div>
@ -424,9 +425,9 @@
</svg> </svg>
<svg id="delete_person" onclick="deletePerson()" class="icon" viewBox="0 0 64 64" title="Remove"> <svg id="delete_person" onclick="deletePerson()" class="icon" viewBox="0 0 64 64" title="Remove">
<title>remove</title> <title>remove</title>
<line x1="10.5" y1="2.5" x2="53.5" y2="2.5"/> <line x1="8" y1="2.5" x2="56" y2="2.5"/>
<line x1="34" y1="0.5" x2="30" y2="0.5"/> <line x1="33.92" y1="0.5" x2="30.08" y2="0.5"/>
<path d="M53.5,16.5V59.42a4.08,4.08,0,0,1-4.08,4.08H14.58a4.08,4.08,0,0,1-4.08-4.08V16.5"/> <path d="M53.5,17.5V59.42a4.08,4.08,0,0,1-4.08,4.08H14.58a4.08,4.08,0,0,1-4.08-4.08V17.5"/>
</svg> </svg>
</div> </div>
</div> </div>
@ -1612,7 +1613,8 @@
let personPopupOpen = false, let personPopupOpen = false,
scannedFloId, scannedFloId,
scannerOn = false scannerOn = false
const qrScannerInstance = new Html5Qrcode("reader");; const qrScannerInstance = new Html5Qrcode("reader"),
selectCamera = document.getElementById('select_camera');
document.addEventListener('popupopened', e => { document.addEventListener('popupopened', e => {
let thisPopup = e.detail.popup, let thisPopup = e.detail.popup,
@ -1630,7 +1632,7 @@
if (personPopupOpen) { if (personPopupOpen) {
tokenReceiver.value = person.dataset.floId tokenReceiver.value = person.dataset.floId
} }
if (scannerOn) { if (scannerOn && scannedFloId) {
tokenReceiver.value = scannedFloId tokenReceiver.value = scannedFloId
} }
break; break;
@ -1642,12 +1644,30 @@
case 'qr_code_popup': case 'qr_code_popup':
Html5Qrcode.getCameras().then(devices => { Html5Qrcode.getCameras().then(devices => {
if (devices && devices.length) { if (devices && devices.length) {
let cameraId = devices[0].id; let cameras = ``
for(device of devices){
cameras += `<sm-option value="${device.id}">${device.label}</sm-option>`
}
selectCamera.innerHTML = cameras
startScanning(devices[devices.length-1].id)
}
}).catch(err => {
// handle err
});
break;
}
})
selectCamera.addEventListener('change', e => {
startScanning(selectCamera.value)
})
function startScanning(cameraId){
qrScannerInstance.start( qrScannerInstance.start(
cameraId, cameraId,
{ {
fps: 10, fps: 10,
qrbox: 200 qrbox: 250
}, },
qrCodeMessage => { qrCodeMessage => {
scannedFloId = qrCodeMessage scannedFloId = qrCodeMessage
@ -1671,12 +1691,6 @@
console.log(`Unable to start scanning, error: ${err}`); console.log(`Unable to start scanning, error: ${err}`);
}); });
} }
}).catch(err => {
// handle err
});
break;
}
})
document.addEventListener('popupclosed', e => { document.addEventListener('popupclosed', e => {
popupStack = e.detail.popupStack popupStack = e.detail.popupStack