Spaces:
Runtime error
Runtime error
Topallaj Denis
commited on
Commit
·
97030c2
1
Parent(s):
b83473a
add spinner, change data returned
Browse files- static/index.js +12 -7
- static/styles.css +18 -0
static/index.js
CHANGED
@@ -1,12 +1,20 @@
|
|
1 |
"use strict";
|
2 |
|
3 |
const form = document.getElementById("predictionForm");
|
|
|
|
|
4 |
form.addEventListener("submit", async (e) => {
|
5 |
e.preventDefault();
|
6 |
|
7 |
const sequence = document.getElementById("sequence").value;
|
8 |
const smiles = document.getElementById("smiles").value;
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
const response = await fetch("/api/predict", {
|
11 |
method: "POST",
|
12 |
headers: {
|
@@ -17,14 +25,11 @@ form.addEventListener("submit", async (e) => {
|
|
17 |
});
|
18 |
|
19 |
const data = await response.json();
|
20 |
-
const predictionResults = document.getElementById("predictionResults");
|
21 |
-
|
22 |
-
// unhide the results
|
23 |
-
predictionResults.style.display = "block";
|
24 |
|
|
|
25 |
predictionResults.innerHTML = `
|
26 |
<h2>Prediction Results</h2>
|
27 |
-
<p><strong>Km:</strong> ${data.
|
28 |
-
<p><strong>Kcat:</strong> ${data.
|
29 |
-
<p><strong>Vmax:</strong> ${data.
|
30 |
});
|
|
|
1 |
"use strict";
|
2 |
|
3 |
const form = document.getElementById("predictionForm");
|
4 |
+
const predictionResults = document.getElementById("predictionResults");
|
5 |
+
|
6 |
form.addEventListener("submit", async (e) => {
|
7 |
e.preventDefault();
|
8 |
|
9 |
const sequence = document.getElementById("sequence").value;
|
10 |
const smiles = document.getElementById("smiles").value;
|
11 |
|
12 |
+
// unhide the div
|
13 |
+
predictionResults.style.display = "block";
|
14 |
+
|
15 |
+
// loader until the results are fetched
|
16 |
+
predictionResults.innerHTML = `<div class="loader"></div>`
|
17 |
+
|
18 |
const response = await fetch("/api/predict", {
|
19 |
method: "POST",
|
20 |
headers: {
|
|
|
25 |
});
|
26 |
|
27 |
const data = await response.json();
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
// display the results
|
30 |
predictionResults.innerHTML = `
|
31 |
<h2>Prediction Results</h2>
|
32 |
+
<p><strong>Km:</strong> ${data.Km}</p>
|
33 |
+
<p><strong>Kcat:</strong> ${data.Kcat}</p>
|
34 |
+
<p><strong>Vmax:</strong> ${data.Vmax}</p>`;
|
35 |
});
|
static/styles.css
CHANGED
@@ -92,3 +92,21 @@ a:hover {
|
|
92 |
height: 50px;
|
93 |
margin-right: 5px;
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
height: 50px;
|
93 |
margin-right: 5px;
|
94 |
}
|
95 |
+
|
96 |
+
.loader {
|
97 |
+
border: 16px solid lightgray;
|
98 |
+
border-top: 16px solid lightgreen;
|
99 |
+
border-radius: 50%;
|
100 |
+
width: 50px;
|
101 |
+
height: 50px;
|
102 |
+
animation: spin 2s linear infinite;
|
103 |
+
}
|
104 |
+
|
105 |
+
@keyframes spin {
|
106 |
+
0% {
|
107 |
+
transform: rotate(0deg);
|
108 |
+
}
|
109 |
+
100% {
|
110 |
+
transform: rotate(360deg);
|
111 |
+
}
|
112 |
+
}
|