-
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
40 changed files
with
374 additions
and
123 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
PWA/public/Services/FetchEventHandlers/BeneficiaryCodePostHandler.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,46 @@ | ||
import { RouteEvents } from "../../RouteEvents.js"; | ||
import { ResponseTools } from "../ResponseTools.js"; | ||
/* | ||
@main.route('/entry', methods=['POST', 'GET']) | ||
@login_required | ||
def beneficiary(): | ||
"""Get beneficiary data.""" | ||
if 'distrib_id' not in session.keys(): | ||
return render_template('index_distrib.html') | ||
if 'code' in request.form.keys(): | ||
if request.form['code'].strip() == '': | ||
return render_template('input.html') | ||
else: | ||
code = str(request.form['code']) | ||
elif 'code' in request.args.keys(): | ||
if request.args['code'].strip() == '': | ||
return render_template('input.html') | ||
else: | ||
code = str(request.args['code']) | ||
else: | ||
return render_template('input.html') | ||
beneficiary_data = get_beneficiary_entry(beneficiary_id=str(session['distrib_id'])+str(code), | ||
user_email=current_user.email, | ||
distrib_id=session['distrib_id']) | ||
if beneficiary_data == "not_found": | ||
return render_template('entry_not_found.html') | ||
elif beneficiary_data == "no_data": | ||
return render_template('no_data.html') | ||
else: | ||
for internal_field in ['id', 'distrib_id', 'partitionKey']: | ||
if internal_field in beneficiary_data.keys(): | ||
beneficiary_data.pop(internal_field) | ||
return render_template('entry.html', | ||
data=beneficiary_data) | ||
*/ | ||
export class BeneficiaryCodePostHandler { | ||
canHandleEvent(event) { | ||
return event.request.url.includes(RouteEvents.checkBenificiaryCodeInputMethod); | ||
} | ||
async handleEvent(event) { | ||
//TODO: handle other cases | ||
return ResponseTools.wrapInHtmlTemplate(RouteEvents.codeInputNotFound); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...tHandlers/BeneficiaryDataUploadHandler.js → ...tHandlers/BeneficiaryDataUploadHandler.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
6 changes: 3 additions & 3 deletions
6
...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
10 changes: 5 additions & 5 deletions
10
...dlers/CreateDistributionRequestHandler.js → ...dlers/CreateDistributionRequestHandler.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
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...Handlers/DeleteDistributionPostHandler.js → ...Handlers/DeleteDistributionPostHandler.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
8 changes: 4 additions & 4 deletions
8
...dlers/DeleteDistributionRequestHandler.js → ...dlers/DeleteDistributionRequestHandler.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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...andlers/ListDistributionRequestHandler.js → ...andlers/ListDistributionRequestHandler.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
4 changes: 2 additions & 2 deletions
4
...andlers/NameDistributionRequestHandler.js → ...andlers/NameDistributionRequestHandler.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
11 changes: 11 additions & 0 deletions
11
PWA/public/Services/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 "../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); | ||
} | ||
} |
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
...dlers/SelectDistributionRequestHandler.js → ...dlers/SelectDistributionRequestHandler.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
2 changes: 1 addition & 1 deletion
2
...c/FetchEventHandlers/UploadDataHandler.js → ...s/FetchEventHandlers/UploadDataHandler.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="column is-4 is-offset-4"> | ||
<div class="box"> | ||
<label class="label is-medium">Beneficiary not found!</label> | ||
<br> | ||
<form action="/input" method="GET"> | ||
<button class="button is-block is-info is-medium is-fullwidth">Continue distribution</button> | ||
</form> | ||
<br> | ||
<form action="/" method="GET"> | ||
<button class="button is-block is-info is-medium is-fullwidth">Go back to main menu</button> | ||
</form> | ||
</div> | ||
</div> |
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 = | ||
"/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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { FetchEventHandlers } from "./FetchEventHandlers/FetchEventHandlers.js"; | ||
import { FetchEventHandlers } from "./Services/FetchEventHandlers/FetchEventHandlers.js"; | ||
import { CacheFilePathService } from "./Services/CacheFilePathService.js"; | ||
var CACHE_STATIC_NAME = "static-v10"; | ||
var CACHE_DYNAMIC_NAME = "dynamic-v2"; | ||
|
@@ -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", | ||
|
14 changes: 0 additions & 14 deletions
14
PWA/src/FetchEventHandlers/ChooseBenificiaryCodeInputMethodHandler.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.