-
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
6 changed files
with
30 additions
and
216 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
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); | ||
} | ||
} |
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 |
---|---|---|
@@ -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 <a href="https://www.510.global/"> <img src="images/510logo.jpg"></a> | ||
<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> |
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,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 <a href="https://www.510.global/"> <img src="images/510logo.jpg"></a> | ||
<a href="https://github.com/rodekruis/relief-app"> see the project on GitHub</a>. | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
</div> | ||
</section> | ||
</body> | ||
|
||
</html> | ||
</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
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) | ||
} | ||
} |