-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
138 additions
and
13 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...hooseBenificiaryCodeInputMethodHandler.js → ...eBenificiaryCodeInputMethodPageHandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
PWA/public/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { RouteEvents } from "../RouteEvents.js"; | ||
import { ResponseTools } from "../Services/ResponseTools.js"; | ||
export class SelectBenificiaryCodeInputMethodHandler { | ||
canHandleEvent(event) { | ||
return event.request.url.endsWith(RouteEvents.selectBenificiaryCodeInputMethod); | ||
} | ||
async handleEvent(event) { | ||
//We actually still need to check which one to serve | ||
return ResponseTools.wrapInHtmlTemplate(RouteEvents.codeInputUsingCamera); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<div> | ||
<video | ||
id="video" | ||
width="300" | ||
height="200" | ||
style="border: 1px solid gray" | ||
></video> | ||
</div> | ||
|
||
<div class="column is-4 is-offset-4"> | ||
<div class="box"> | ||
<div id="sourceSelectPanel" style="display: none"> | ||
<label for="sourceSelect" class="label is-small" | ||
>Change video source:</label | ||
> | ||
<select id="sourceSelect" style="max-width: 400px"></select> | ||
</div> | ||
<br /> | ||
<label class="label is-small" | ||
>Barcode and QR code formats supported: UPC-A and UPC-E, EAN-8 and EAN-13, | ||
Code 39-93-128, ITF, Codabar, RSS-14 (all variants), RSS Expanded (most | ||
variants), Data Matrix, Aztec ('beta' quality), PDF 417 ('alpha' quality), | ||
MaxiCode.</label | ||
> | ||
</div> | ||
</div> | ||
<label hidden>Result:</label> | ||
<pre hidden><code id="result"></code></pre> | ||
|
||
<script | ||
type="text/javascript" | ||
src="https://unpkg.com/@zxing/library@latest/umd/index.min.js" | ||
></script> | ||
<script type="text/javascript"> | ||
window.addEventListener("load", function () { | ||
let selectedDeviceId; | ||
const codeReader = new ZXing.BrowserMultiFormatReader(); | ||
console.log("ZXing code reader initialized"); | ||
codeReader | ||
.listVideoInputDevices() | ||
.then((videoInputDevices) => { | ||
const sourceSelect = document.getElementById("sourceSelect"); | ||
selectedDeviceId = videoInputDevices[0].deviceId; | ||
if (videoInputDevices.length >= 1) { | ||
videoInputDevices.forEach((element) => { | ||
const sourceOption = document.createElement("option"); | ||
sourceOption.text = element.label; | ||
sourceOption.value = element.deviceId; | ||
sourceSelect.appendChild(sourceOption); | ||
}); | ||
|
||
sourceSelect.onchange = () => { | ||
selectedDeviceId = sourceSelect.value; | ||
}; | ||
|
||
const sourceSelectPanel = | ||
document.getElementById("sourceSelectPanel"); | ||
sourceSelectPanel.style.display = "block"; | ||
} | ||
|
||
codeReader.decodeFromVideoDevice( | ||
selectedDeviceId, | ||
"video", | ||
(result, err) => { | ||
if (result) { | ||
console.log(result); | ||
document.getElementById("result").textContent = result.text; | ||
window.location = | ||
"https://relief-system-webapp.azurewebsites.net/entry?code=" + | ||
result.text; | ||
} | ||
if (err && !(err instanceof ZXing.NotFoundException)) { | ||
console.error(err); | ||
document.getElementById("result").textContent = err; | ||
} | ||
} | ||
); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ self.addEventListener("install", function (event) { | |
cache.addAll([ | ||
"/", | ||
"https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css", | ||
"https://unpkg.com/@zxing/library@latest/umd/index.min.js", | ||
"/favicon.ico", | ||
"/manifest.json", | ||
"/images/ReliefBox-horizontal-nobackground.png", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
PWA/src/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FetchEvent } from "../Interfaces/FetchEvent.js"; | ||
import { FetchEventHandler } from "../Interfaces/FetchEventHandler.js"; | ||
import { RouteEvents } from "../RouteEvents.js"; | ||
import { ResponseTools } from "../Services/ResponseTools.js"; | ||
|
||
export class SelectBenificiaryCodeInputMethodHandler implements FetchEventHandler { | ||
canHandleEvent(event: FetchEvent): boolean { | ||
return event.request.url.endsWith(RouteEvents.selectBenificiaryCodeInputMethod); | ||
} | ||
|
||
async handleEvent(event: FetchEvent): Promise<Response> { | ||
//We actually still need to check which one to serve | ||
return ResponseTools.wrapInHtmlTemplate(RouteEvents.codeInputUsingCamera) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ self.addEventListener("install", function (event: any) { | |
cache.addAll([ | ||
"/", | ||
"https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css", | ||
"https://unpkg.com/@zxing/library@latest/umd/index.min.js", | ||
"/favicon.ico", | ||
"/manifest.json", | ||
"/images/ReliefBox-horizontal-nobackground.png", | ||
|