open-organism-observer/sample_prep_protocol.html

196 lines
6.9 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<html>
<header>
<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>
2025-01-23 14:18:10 +01:00
<meta charset="utf-8">
</header>
<body>
2025-02-25 18:12:30 +01:00
<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">
2025-02-25 18:12:30 +01:00
<h1> Add Preparation Protocol </h1>
<form class="needs-validation" id = "sample">
<div class="row">
<div class="col">
<label class = "form-label" for="name">
Name of Preparation Protocol
</label>
</div>
<div class="col">
<input class="form-control" type="text" name="name" id = "name"
placeholder="e.g. my favourite protocol">
</input>
</div>
</div>
<div class="row">
<div class="col-6">
<label class="form-label" for="sample_size">
Sample size [uL]
</label>
</div>
<div class="col">
<input class="form-control" type="number"
id = "Sample_Size" name="sample_size" value=40>
</input>
</div>
</div>
<div class="row">
<div class="col-6">
<label class = "form-label" for="main_dilution">
2025-02-25 18:12:48 +01:00
Main dilution factor (1:x)
</label>
</div>
<div class="col">
2025-01-17 02:42:25 +01:00
<input class="form-control" type="text" id = "Main_Dilution" name="main_dilution"
2025-02-25 18:12:48 +01:00
placeholder="e.g. 5 for a 1:5 dilution">
</input>
</div>
</div>
<div class="row">
<div class="col-6">
<label class = "form-label" for="setteling_time">
Setteling time [s]
</label>
</div>
<div class="col">
<input class="form-control" type="number" id="Setteling_Time"
name="setteling_time" value=15>
</input>
</div>
</div>
<div class="row">
<div class="col-6">
<label class="form-label" for="prep-notes">
Notes
</label>
</div>
<div class="col">
<textarea class="form-control" name="prep-notes" id="Prep_Notes"
placeholder="Notes about the preparation"
rows="1" cols="60">
</textarea>
</div>
</div>
2025-01-23 14:28:27 +01:00
<div class="row">
<div class="col">
<label class = "form-check-label" for="default">
This should be the default preparation setup
</label>
</div>
<div class="col">
<input class="form-check-input" type="checkbox" id = "Default" name="default">
</input>
</div>
</div>
<button class="btn btn-primary float-end" type="submit">submit</button>
</form>
</div>
</body>
<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){
2025-01-17 03:43:54 +01:00
2025-01-23 14:28:27 +01:00
event.preventDefault();
let prep_protocol = {
"name" : document.getElementById("name").value,
"Sample_Size" : document.getElementById("Sample_Size").value,
2025-01-17 02:42:25 +01:00
"Main_Dilution" : document.getElementById("Main_Dilution").value,
"Setteling_Time" : document.getElementById("Setteling_Time").value,
"Prep_Notes" : document.getElementById("Prep_Notes").value
}
let transaction = db.transaction(["prep_protocol"], "readwrite");
let objectStore = transaction.objectStore("prep_protocol");
let add_request = objectStore.add(prep_protocol); // (3)
2025-01-23 14:28:27 +01:00
let id_of_setup = 0;
add_request.onsuccess = (event) => {
console.log("All done!");
2025-01-23 14:28:27 +01:00
id_of_setup = event.target.result;
if (document.getElementById("Default").checked){
let my_default = {"id" : 1, "prep_setup" : id_of_setup};
let next_transaction = db.transaction(["defaults"], "readwrite");
let next_objectStore = next_transaction.objectStore("defaults");
let add_next_request = next_objectStore.put(my_default);
transaction.oncomplete = () => {
console.log("All done!");
};
transaction.onerror = () => {
console.log("something went wrong");
// Don't forget to handle errors!
};
}
};
transaction.onerror = (event) => {
console.log("something went wrong");
// Don't forget to handle errors!
};
2025-01-23 14:28:27 +01:00
};
</script>
</html>