From 1211857dabb114948905d141b64e6d18aa4ab6f7 Mon Sep 17 00:00:00 2001 From: Menno <129762469+rcmenno@users.noreply.github.com> Date: Fri, 17 Nov 2023 18:01:42 +0100 Subject: [PATCH] #5 Wip input from camera --- ...eBenificiaryCodeInputMethodPageHandler.js} | 2 +- .../FetchEventHandlers/FetchEventHandlers.js | 6 +- ...SelectBenificiaryCodeInputMethodHandler.js | 11 +++ PWA/public/RouteEvents.js | 2 + PWA/public/Services/CacheFilePathService.js | 9 +- PWA/public/index.html | 2 +- PWA/public/input_video.html | 83 +++++++++++++++++++ PWA/public/sw.js | 1 + ...eBenificiaryCodeInputMethodPageHandler.ts} | 2 +- .../FetchEventHandlers/FetchEventHandlers.ts | 6 +- ...SelectBenificiaryCodeInputMethodHandler.ts | 15 ++++ PWA/src/RouteEvents.ts | 2 + PWA/src/Services/CacheFilePathService.ts | 9 +- PWA/src/sw.ts | 1 + 14 files changed, 138 insertions(+), 13 deletions(-) rename PWA/public/FetchEventHandlers/{ChooseBenificiaryCodeInputMethodHandler.js => ChooseBenificiaryCodeInputMethodPageHandler.js} (86%) create mode 100644 PWA/public/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js create mode 100644 PWA/public/input_video.html rename PWA/src/FetchEventHandlers/{ChooseBenificiaryCodeInputMethodHandler.ts => ChooseBenificiaryCodeInputMethodPageHandler.ts} (86%) create mode 100644 PWA/src/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.ts diff --git a/PWA/public/FetchEventHandlers/ChooseBenificiaryCodeInputMethodHandler.js b/PWA/public/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js similarity index 86% rename from PWA/public/FetchEventHandlers/ChooseBenificiaryCodeInputMethodHandler.js rename to PWA/public/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js index 0c1fd02..9e3673b 100644 --- a/PWA/public/FetchEventHandlers/ChooseBenificiaryCodeInputMethodHandler.js +++ b/PWA/public/FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js @@ -1,6 +1,6 @@ import { RouteEvents } from "../RouteEvents.js"; import { ResponseTools } from "../Services/ResponseTools.js"; -export class ChooseBenificiaryCodeInputMethodHandler { +export class ChooseBenificiaryCodeInputMethodPageHandler { canHandleEvent(event) { return event.request.url.endsWith(RouteEvents.chooseBenificiaryCodeInputMethod); } diff --git a/PWA/public/FetchEventHandlers/FetchEventHandlers.js b/PWA/public/FetchEventHandlers/FetchEventHandlers.js index 039da3f..af2cc0b 100644 --- a/PWA/public/FetchEventHandlers/FetchEventHandlers.js +++ b/PWA/public/FetchEventHandlers/FetchEventHandlers.js @@ -6,7 +6,8 @@ import { DeleteDistributionRequestHandler } from "./DeleteDistributionRequestHan import { UploadDataHandler } from "./UploadDataHandler.js"; import { BeneficiaryDataUploadHandler } from "./BeneficiaryDataUploadHandler.js"; import { DeleteDistributionPostHandler } from "./DeleteDistributionPostHandler.js"; -import { ChooseBenificiaryCodeInputMethodHandler } from "./ChooseBenificiaryCodeInputMethodHandler.js"; +import { ChooseBenificiaryCodeInputMethodPageHandler } from "./ChooseBenificiaryCodeInputMethodPageHandler.js"; +import { SelectBenificiaryCodeInputMethodHandler } from "./SelectBenificiaryCodeInputMethodHandler.js"; export class FetchEventHandlers { constructor() { this.all = [ @@ -18,7 +19,8 @@ export class FetchEventHandlers { new DeleteDistributionPostHandler(), new UploadDataHandler(), new BeneficiaryDataUploadHandler(), - new ChooseBenificiaryCodeInputMethodHandler() + new ChooseBenificiaryCodeInputMethodPageHandler(), + new SelectBenificiaryCodeInputMethodHandler() ]; } handlersForEvent(event) { diff --git a/PWA/public/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js b/PWA/public/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js new file mode 100644 index 0000000..22dd247 --- /dev/null +++ b/PWA/public/FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js @@ -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); + } +} diff --git a/PWA/public/RouteEvents.js b/PWA/public/RouteEvents.js index 041ce9a..aedc0e5 100644 --- a/PWA/public/RouteEvents.js +++ b/PWA/public/RouteEvents.js @@ -9,10 +9,12 @@ RouteEvents.uploadData = "/upload_data.html"; RouteEvents.uploadDataError = "/upload_error.html"; RouteEvents.template = "/template.html"; RouteEvents.chooseBenificiaryCodeInputMethodPage = "/choose_input_method.html"; +RouteEvents.codeInputUsingCamera = "/input_video.html"; //Non page route events RouteEvents.postCreateDistribution = "/create_distrib"; RouteEvents.postSelectDistribution = "/select_distrib"; RouteEvents.postDeleteDistribution = "/delete_distrib_confirm"; RouteEvents.listDistributionsFormAction = "/distrib?"; RouteEvents.chooseBenificiaryCodeInputMethod = "/choose_input_method?"; +RouteEvents.selectBenificiaryCodeInputMethod = "/save_input_method"; export { RouteEvents }; diff --git a/PWA/public/Services/CacheFilePathService.js b/PWA/public/Services/CacheFilePathService.js index 2b1429e..69df049 100644 --- a/PWA/public/Services/CacheFilePathService.js +++ b/PWA/public/Services/CacheFilePathService.js @@ -1,10 +1,11 @@ import { BeneficiaryDataUploadHandler } from "../FetchEventHandlers/BeneficiaryDataUploadHandler.js"; -import { ChooseBenificiaryCodeInputMethodHandler } from "../FetchEventHandlers/ChooseBenificiaryCodeInputMethodHandler.js"; +import { ChooseBenificiaryCodeInputMethodPageHandler } from "../FetchEventHandlers/ChooseBenificiaryCodeInputMethodPageHandler.js"; import { CreateDistributionRequestHandler } from "../FetchEventHandlers/CreateDistributionRequestHandler.js"; import { DeleteDistributionPostHandler } from "../FetchEventHandlers/DeleteDistributionPostHandler.js"; import { FetchEventHandlers } from "../FetchEventHandlers/FetchEventHandlers.js"; import { ListDistributionRequestHandler } from "../FetchEventHandlers/ListDistributionRequestHandler.js"; import { NameDistributionRequestHandler } from "../FetchEventHandlers/NameDistributionRequestHandler.js"; +import { SelectBenificiaryCodeInputMethodHandler } from "../FetchEventHandlers/SelectBenificiaryCodeInputMethodHandler.js"; import { SelectDistributionRequestHandler } from "../FetchEventHandlers/SelectDistributionRequestHandler.js"; import { UploadDataHandler } from "../FetchEventHandlers/UploadDataHandler.js"; import { BenificiarySpreadSheetRow } from "../Models/BenificiarySpreadSheetRow.js"; @@ -41,7 +42,8 @@ export class CacheFilePathService { RouteEvents.deleteDistribution, RouteEvents.uploadData, RouteEvents.uploadDataError, - RouteEvents.chooseBenificiaryCodeInputMethodPage + RouteEvents.chooseBenificiaryCodeInputMethodPage, + RouteEvents.codeInputUsingCamera ]; } toplevelScriptsPaths() { @@ -86,7 +88,8 @@ export class CacheFilePathService { NameDistributionRequestHandler.name, SelectDistributionRequestHandler.name, UploadDataHandler.name, - ChooseBenificiaryCodeInputMethodHandler.name + ChooseBenificiaryCodeInputMethodPageHandler.name, + SelectBenificiaryCodeInputMethodHandler.name ]); } interfacesPaths() { diff --git a/PWA/public/index.html b/PWA/public/index.html index 14d5d70..a9ddfef 100644 --- a/PWA/public/index.html +++ b/PWA/public/index.html @@ -39,7 +39,7 @@ - +