Skip to content

Commit

Permalink
Leverage more templates bump 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmenno committed Oct 14, 2024
1 parent ade1da4 commit 411c932
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 216 deletions.
2 changes: 1 addition & 1 deletion PWA/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ReliefBox",
"version": "0.2.0",
"version": "0.3.0",
"description": "A tool for managing the distribution of relief items during humanitarian emergencies.",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion PWA/public/Services/FetchEventHandlers/UploadDataHandler.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { RouteEvents } from "../../RouteEvents.js";
import { ResponseTools } from "../ResponseTools.js";
export class UploadDataHandler {
canHandleEvent(event) {
return event.request.url.endsWith("/upload_data?");
}
async handleEvent(event) {
return fetch(RouteEvents.uploadData);
return ResponseTools.wrapInHtmlTemplate(RouteEvents.uploadData);
}
}
2 changes: 1 addition & 1 deletion PWA/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<!-- <a class="navbar-item">-->
<img src="images/ReliefBox-horizontal-nobackground.png" width="220" height="30">
<!-- </a>-->
<div class="navbar-item">Alpha 0.2.0</div>
<div class="navbar-item">Alpha 0.3.0</div>
<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
Expand Down
119 changes: 12 additions & 107 deletions PWA/public/upload_data.html
Original file line number Diff line number Diff line change
@@ -1,109 +1,14 @@
<!DOCTYPE html>
<html>

<script type="text/javascript" src="/navbar-burger.js"></script>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ReliefBox</title>
<link rel="stylesheet" href="/ExternalLibraries/bulma.css">
<style>
#noteligible {
background-color: #F53335 !important;
}
#eligible {
background-color: #03e03e !important;
}
.label[style*="color: white"] {
color: white !important;
font-weight: normal !important;
}
</style>
<script type="text/javascript">
function checkCookiesStats() {
if(navigator.cookieEnabled) {
document.getElementById("check-cookies").innerHTML="";
} else {
document.getElementById("check-cookies").innerHTML="You must enable cookies in your browser to use ReliefBox";
}
}
</script>
</head>

<body onload="checkCookiesStats()">
<section class="hero is-primary is-fullheight">

<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<!-- <a class="navbar-item">-->
<img src="images/ReliefBox-horizontal-nobackground.png" width="220" height="30">
<!-- </a>-->

<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>

<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a href="/index.html" class="navbar-item">
Home
</a>

<a href="https://reliefbox.readthedocs.io/" class="navbar-item" target="_blank" rel="noopener noreferrer">
Documentation
</a>
<div class="box">
<label class="label is-medium">Warning!</label>
<label class="label is-medium">1. The file must be an Excel Workbook (.xlsx) and have one column named "code" containing unique values</label>
<label class="label is-medium">2. Previous beneficiary data will be overwritten</label>
<br>
<form action="/uploader" method="POST" enctype="multipart/form-data">
<div class="field">
<div class="control">
<input class="input is-medium" type="file" name="file" />
</div>
</div>
</nav>

<div class="hero-body">
<div class="container has-text-centered">

<div class="column is-4 is-offset-4">
<!-- <div class="box">-->
<!-- <div class="notification is-danger">-->
<label id="check-cookies" class="label is-medium" style="color:red; background-color:white"></label>
<!-- </div>-->
<!-- </div>-->
</div>
<div class="column is-4 is-offset-4">
<div class="box">
<label class="label is-medium">Warning!</label>
<label class="label is-medium">1. The file must be an Excel Workbook (.xlsx) and have one column named "code" containing unique values</label>
<label class="label is-medium">2. Previous beneficiary data will be overwritten</label>
<br>
<form action="/uploader" method="POST" enctype="multipart/form-data">
<div class="field">
<div class="control">
<input class="input is-medium" type="file" name="file" />
</div>
</div>
<button class="button is-block is-info is-medium is-fullwidth">Upload data</button>
</form>
</div>
</div>
</div>
</div>

<div class="hero-foot">
<nav class="navbar">
<div class="container">
<div id="navbarMenuHeroA" class="navbar-menu">
<div class="navbar-end" hidden>
<div class="navbar-item">
Built with love by &nbsp;<a href="https://www.510.global/"> <img src="images/510logo.jpg"></a>
&nbsp; <a href="https://github.com/rodekruis/relief-app"> see the project on GitHub</a>.
</div>
</div>
</div>
</div>
</nav>
</div>
</section>
</body>

</html>
<button class="button is-block is-info is-medium is-fullwidth">Upload data</button>
</form>
</div>
117 changes: 12 additions & 105 deletions PWA/public/upload_error.html
Original file line number Diff line number Diff line change
@@ -1,106 +1,13 @@
<!DOCTYPE html>
<html>

<script type="text/javascript" src="/navbar-burger.js"></script>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ReliefBox</title>
<link rel="stylesheet" href="/ExternalLibraries/bulma.css">
<style>
#noteligible {
background-color: #F53335 !important;
}
#eligible {
background-color: #03e03e !important;
}
.label[style*="color: white"] {
color: white !important;
font-weight: normal !important;
}
</style>
<script type="text/javascript">
function checkCookiesStats() {
if(navigator.cookieEnabled) {
document.getElementById("check-cookies").innerHTML="";
} else {
document.getElementById("check-cookies").innerHTML="You must enable cookies in your browser to use ReliefBox";
}
}
</script>
</head>

<body onload="checkCookiesStats()">
<section class="hero is-primary is-fullheight">

<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<!-- <a class="navbar-item">-->
<img src="images/ReliefBox-horizontal-nobackground.png" width="220" height="30">
<!-- </a>-->

<a role="button" class="navbar-burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>

<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a href="/index.html" class="navbar-item">
Home
</a>

<a href="https://reliefbox.readthedocs.io/" class="navbar-item" target="_blank" rel="noopener noreferrer">
Documentation
</a>
</div>
</div>
</nav>

<div class="hero-body">
<div class="container has-text-centered">

<div class="column is-4 is-offset-4">
<!-- <div class="box">-->
<!-- <div class="notification is-danger">-->
<label id="check-cookies" class="label is-medium" style="color:red; background-color:white"></label>
<!-- </div>-->
<!-- </div>-->
</div>
<div class="column is-4 is-offset-4">
<div class="box">
<label class="label is-medium">The data that you uploaded is in the wrong format, please use the template.</label>
<br>
<form action="/download_template" method="POST">
<button class="button is-block is-info is-medium is-fullwidth">Download data template</button>
</form>
<br>
<form action="/index.html" method="GET">
<button class="button is-block is-info is-medium is-fullwidth">Go back to main menu</button>
</form>
</div>
</div>
</div>
<div class="column is-4 is-offset-4">
<div class="box">
<label class="label is-medium">The data that you uploaded is in the wrong format, please use the template.</label>
<br>
<form action="/download_template" method="POST">
<button class="button is-block is-info is-medium is-fullwidth">Download data template</button>
</form>
<br>
<form action="/index.html" method="GET">
<button class="button is-block is-info is-medium is-fullwidth">Go back to main menu</button>
</form>
</div>

<div class="hero-foot">
<nav class="navbar">
<div class="container">
<div id="navbarMenuHeroA" class="navbar-menu">
<div class="navbar-end" hidden>
<div class="navbar-item">
Built with love by &nbsp;<a href="https://www.510.global/"> <img src="images/510logo.jpg"></a>
&nbsp; <a href="https://github.com/rodekruis/relief-app"> see the project on GitHub</a>.
</div>
</div>
</div>
</div>
</nav>
</div>
</section>
</body>

</html>
</div>
3 changes: 2 additions & 1 deletion PWA/src/Services/FetchEventHandlers/UploadDataHandler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { RouteEvents } from "../../RouteEvents.js";
import { FetchEvent } from "../../Interfaces/FetchEvent.js";
import { FetchEventHandler } from "../../Interfaces/FetchEventHandler.js";
import { ResponseTools } from "../ResponseTools.js";

export class UploadDataHandler implements FetchEventHandler {
canHandleEvent(event: FetchEvent): boolean {
return event.request.url.endsWith("/upload_data?");
}

async handleEvent(event: FetchEvent): Promise<Response> {
return fetch(RouteEvents.uploadData)
return ResponseTools.wrapInHtmlTemplate(RouteEvents.uploadData)
}
}

0 comments on commit 411c932

Please sign in to comment.