188 lines
6.9 KiB
HTML
188 lines
6.9 KiB
HTML
<!--- this is the main file --->
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<link href="bootstrap-5.0.2-dist/css/bootstrap.min.css" rel="stylesheet" ></link>
|
|
<script src="bootstrap-5.0.2-dist/js/bootstrap.bundle.min.js" ></script>
|
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"</link>
|
|
<meta charset="utf-8">
|
|
<style>
|
|
#map {
|
|
height: 30em;
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="#">Open Microscopy App</a>
|
|
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
|
|
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
Settings
|
|
</a>
|
|
<ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
|
|
<li><a class="dropdown-item" href="/setup_microscope.html">Setup Camera</a></li>
|
|
<li><a class="dropdown-item" href="/sample_prep_protocol.html">Setup Preparation Protocol</a></li>
|
|
<li><hr class="dropdown-divider"></li>
|
|
<li><a class="dropdown-item" href="#">Defaults</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" aria-current="page" href="/sample_intake.html">add sample</a>
|
|
</li>
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarScrollingDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
Observe
|
|
</a>
|
|
<ul class="dropdown-menu" aria-labelledby="navbarScrollingDropdown">
|
|
<li><a class="dropdown-item" href="/observe_nema.html">Nematodes</a></li>
|
|
<li><a class="dropdown-item" href="/observe_main.html">Filamentous and Protozoa</a></li>
|
|
<li><a class="dropdown-item" href="/observe_bact.html">Bacteria</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/create_report.html">generate report</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<div class="container">
|
|
<h1>Add Sample</h1>
|
|
<div class="row">
|
|
<div class="col">
|
|
<form class="needs-validation" id = "sample">
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class = "form-label" for="name">
|
|
Name of Sample
|
|
</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="text" name="name" id = "Name"
|
|
placeholder="choose a name for your sample">
|
|
</input>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class = "form-label" for="type">Sample Type</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="text" name="type"
|
|
placeholder="e.g. compost"
|
|
id = "Type"></input>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class = "form-label" for="time_collection">Collection Time</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" type="datetime-local" name="time_collection"
|
|
id = "Date_Collected"></input>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class="form-label" for="notes">Notes</label>
|
|
</div>
|
|
<div class="col">
|
|
<textarea class="form-control" name="notes" id = "Notes"
|
|
placeholder="Notes about the sample"
|
|
rows="1"
|
|
cols="60"
|
|
></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<label class = "form-label" for="location">Location of Sample</label>
|
|
</div>
|
|
<div class="col">
|
|
<input class="form-control" name="location" id="Location" value=""></input>
|
|
</div>
|
|
</div>
|
|
<button class="btn btn-primary float-end" type="submit"> submit </button>
|
|
</form>
|
|
</div>
|
|
<div class = "col">
|
|
<div id="map"></div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<script>
|
|
|
|
var map = L.map('map').fitWorld();
|
|
var sample_form = document.getElementById("sample");
|
|
L.tileLayer(
|
|
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
{attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
|
|
maxNativeZoom:19,
|
|
maxZoom:25}).addTo(map);
|
|
var marker = {};
|
|
map.on('click', function(ev){
|
|
var latlng = map.mouseEventToLatLng(ev.originalEvent);
|
|
console.log(latlng.lat + ', ' + latlng.lng);
|
|
sample_form.location.value = latlng.lat + ', ' + latlng.lng;
|
|
if (marker != undefined) {
|
|
map.removeLayer(marker);
|
|
};
|
|
marker = L.marker([latlng.lat,latlng.lng]).addTo(map);
|
|
});
|
|
map.setView([53.518203, 9.983701], 16);
|
|
|
|
</script>
|
|
<script>
|
|
var db;
|
|
let openRequest = indexedDB.open("my_db");
|
|
|
|
openRequest.onerror = function() {
|
|
console.error("Error", openRequest.error);
|
|
};
|
|
|
|
openRequest.onsuccess = function() {
|
|
db = openRequest.result;
|
|
// continue working with database using db object
|
|
};
|
|
|
|
const form = document.getElementById("sample");
|
|
form.addEventListener("submit", add);
|
|
|
|
function add(event){
|
|
event.preventDefault();
|
|
|
|
let sample = {
|
|
"Name" : document.getElementById("Name").value,
|
|
"Type" : document.getElementById("Type").value,
|
|
"Date_Collected" : new Date(document.getElementById("Date_Collected").value),
|
|
"Place" : document.getElementById("Location").value,
|
|
"Notes" : document.getElementById("Notes").value
|
|
}
|
|
let transaction = db.transaction(["sample"], "readwrite");
|
|
let objectStore = transaction.objectStore("sample");
|
|
let add_request = objectStore.add(sample); // (3)
|
|
|
|
transaction.oncomplete = (event) => {
|
|
console.log("All done!");
|
|
};
|
|
transaction.onerror = (event) => {
|
|
console.log("something went wrong");
|
|
// Don't forget to handle errors!
|
|
};
|
|
|
|
}
|
|
</script>
|
|
</html>
|