aboutsummaryrefslogtreecommitdiff
path: root/qc_app/static
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-07-08 07:32:58 +0300
committerFrederick Muriuki Muriithi2022-07-19 04:46:09 +0300
commit7a3a54ec40fac9071a513487602957f8418f163e (patch)
tree4acec2accb54bcb1c2f9c25c39d8f82c4b81be20 /qc_app/static
parenta21e759ac7a6b72a3d02814c2bfb26bc4f49204c (diff)
downloadgn-uploader-7a3a54ec40fac9071a513487602957f8418f163e.tar.gz
Select the platform (GeneChipId) first
Diffstat (limited to 'qc_app/static')
-rw-r--r--qc_app/static/js/select_platform.js59
-rw-r--r--qc_app/static/js/utils.js10
2 files changed, 69 insertions, 0 deletions
diff --git a/qc_app/static/js/select_platform.js b/qc_app/static/js/select_platform.js
new file mode 100644
index 0000000..d7541fa
--- /dev/null
+++ b/qc_app/static/js/select_platform.js
@@ -0,0 +1,59 @@
+function radio_column(chip) {
+ col = document.createElement("td");
+ radio = document.createElement("input");
+ radio.setAttribute("type", "radio");
+ radio.setAttribute("name", "genechipid");
+ radio.setAttribute("value", chip["GeneChipId"]);
+ radio.setAttribute("required", "required");
+ col.appendChild(radio);
+ return col;
+}
+
+function setup_genechips(genechip_data) {
+ columns = ["GeneChipName", "Name", "GeoPlatform", "GO_tree_value"]
+ submit_button = document.querySelector(
+ "#select-platform-form input[type='submit']");
+ elt = document.getElementById(
+ "genechips-table").getElementsByTagName("tbody")[0];
+ remove_children(elt);
+ if((genechip_data === undefined) || genechip_data.length === 0) {
+ row = document.createElement("tr");
+ col = document.createElement("td");
+ col.setAttribute("colspan", "5");
+ text = document.createTextNode("No chips found for selected species");
+ col.appendChild(text);
+ row.appendChild(col);
+ elt.appendChild(row);
+ submit_button.setAttribute("disabled", true);
+ return false;
+ }
+
+ submit_button.removeAttribute("disabled")
+ genechip_data.forEach(chip => {
+ row = document.createElement("tr");
+ row.appendChild(radio_column(chip));
+ columns.forEach(column => {
+ col = document.createElement("td");
+ content = document.createTextNode(chip[column]);
+ col.appendChild(content);
+ row.appendChild(col);
+ });
+ elt.appendChild(row);
+ });
+}
+
+function genechips() {
+ return JSON.parse(
+ document.getElementById("select-platform-form").getAttribute(
+ "data-genechips"));
+}
+
+function update_genechips(event) {
+ genec = genechips();
+
+ species_elt = document.getElementById("species");
+
+ if(event.target == species_elt) {
+ setup_genechips(genec[species_elt.value.toLowerCase()]);
+ }
+}
diff --git a/qc_app/static/js/utils.js b/qc_app/static/js/utils.js
new file mode 100644
index 0000000..045dd47
--- /dev/null
+++ b/qc_app/static/js/utils.js
@@ -0,0 +1,10 @@
+function remove_children(element) {
+ Array.from(element.children).forEach(child => {
+ element.removeChild(child);
+ });
+}
+
+function trigger_change_event(element) {
+ evt = new Event("change");
+ element.dispatchEvent(evt);
+}