-
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.
#5 Wip input from camera and manual input
- Loading branch information
Showing
43 changed files
with
442 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class BeneficiaryCodeInputMethodPost { | ||
constructor(input_method) { | ||
this.input_method = input_method; | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
import { RouteEvents } from "../../RouteEvents.js"; | ||
import { DeserialisationService } from "../DeserialisationService.js"; | ||
import { ResponseTools } from "../ResponseTools.js"; | ||
export class SelectBenificiaryCodeInputMethodHandler { | ||
canHandleEvent(event) { | ||
return event.request.url.endsWith(RouteEvents.selectBenificiaryCodeInputMethod); | ||
} | ||
async handleEvent(event) { | ||
try { | ||
const post = await DeserialisationService.deserializeFormDataFromRequest(event.request); | ||
return ResponseTools.wrapInHtmlTemplate(this.templatepageForInputMethod(post.input_method)); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
return fetch(RouteEvents.home); | ||
} | ||
} | ||
templatepageForInputMethod(inputMethod) { | ||
if (inputMethod == "video") { | ||
return RouteEvents.codeInputUsingCamera; | ||
} | ||
else if (inputMethod == "text") { | ||
return RouteEvents.codeinputUsingTextField; | ||
} | ||
else { | ||
throw "Unexpected input method: " + inputMethod; | ||
} | ||
} | ||
} |
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,10 @@ | ||
<div class="column is-4 is-offset-4"> | ||
<form action="/entry" method="POST"> | ||
<div class="field"> | ||
<div class="control"> | ||
<input class="input is-medium" type="text" name="code" placeholder="Beneficiary code" autofocus=""> | ||
</div> | ||
</div> | ||
<button class="button is-block is-info is-medium is-fullwidth">Submit</button> | ||
</form> | ||
</div> |
Oops, something went wrong.