Skip to content

Commit d947bd0

Browse files
authored
add pyyaml as dependency (missing for docker) and improve submission of pombe form (#243)
1 parent de70f64 commit d947bd0

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

batch_cloning.html

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
<body>
4444
<h1>Batch Cloning Gene List</h1>
45-
<form action="/batch_cloning" method="post" enctype="multipart/form-data">
45+
<form>
4646
<label for="gene_list">Enter your list of genes (one gene per line):</label><br>
4747
<textarea id="gene_list" name="gene_list" required>SPAPB1A10.09
4848
SPBC15D4.01c</textarea><br>
@@ -68,7 +68,7 @@ <h1>Batch Cloning Gene List</h1>
6868

6969
<div id="addgene_input">
7070
<label for="addgene_id">AddGene Identifier:</label><br>
71-
<input value="39296" type="text" id="addgene_id" name="addgene_id"><br><br>
71+
<input value="19343" type="text" id="addgene_id" name="addgene_id"><br><br>
7272
</div>
7373

7474
<div>
@@ -106,7 +106,10 @@ <h1>Batch Cloning Gene List</h1>
106106
</div>
107107

108108
<br>
109-
<input type="submit" value="Submit">
109+
<input type="submit" value="Submit" id="submit-button">
110+
<div id="loading-message" style="display: none;">
111+
Processing request, please wait...
112+
</div>
110113
<script>
111114
function togglePlasmidInput() {
112115
var selectedOption = document.querySelector('input[name="plasmid_option"]:checked').value;
@@ -133,6 +136,53 @@ <h1>Batch Cloning Gene List</h1>
133136
window.onload = () => {
134137
togglePrimerCheck();
135138
togglePlasmidInput();
139+
140+
// Add form submit handler
141+
document.querySelector('form').addEventListener('submit', async function (e) {
142+
e.preventDefault(); // Prevent default form submission
143+
144+
document.getElementById('submit-button').style.display = 'none';
145+
document.getElementById('loading-message').style.display = 'block';
146+
147+
try {
148+
const formData = new FormData(this);
149+
const response = await fetch('/batch_cloning', {
150+
method: 'POST',
151+
body: formData
152+
});
153+
154+
if (!response.ok) {
155+
throw new Error((await response.json()).detail);
156+
}
157+
158+
// Get the filename from the Content-Disposition header if available
159+
const contentDisposition = response.headers.get('Content-Disposition');
160+
let filename = 'batch_cloning_results.zip';
161+
if (contentDisposition) {
162+
const filenameMatch = contentDisposition.match(/filename="?([^"]+)"?/);
163+
if (filenameMatch) {
164+
filename = filenameMatch[1];
165+
}
166+
}
167+
168+
// Convert the response to a blob and download it
169+
const blob = await response.blob();
170+
const url = window.URL.createObjectURL(blob);
171+
const a = document.createElement('a');
172+
a.href = url;
173+
a.download = filename;
174+
document.body.appendChild(a);
175+
a.click();
176+
window.URL.revokeObjectURL(url);
177+
document.body.removeChild(a);
178+
} catch (error) {
179+
console.error('Error:', error);
180+
alert(error.message);
181+
} finally {
182+
document.getElementById('submit-button').style.display = 'block';
183+
document.getElementById('loading-message').style.display = 'none';
184+
}
185+
});
136186
}
137187
</script>
138188
</form>

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pydantic = "^2.7.1"
2020
shareyourcloning-linkml = "0.1.11a0"
2121
pandas = "^2.2.3"
2222
openpyxl = "^3.1.5"
23+
pyyaml = "^6.0.2"
2324

2425
[tool.poetry.group.dev.dependencies]
2526
autopep8 = "^2.0.4"

0 commit comments

Comments
 (0)