From 03a91557c119fc2c4cdfc36015260034ead0ba98 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Sep 2021 06:54:04 +0300 Subject: Provide UI elements for clustered heatmap generation Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * wqflask/wqflask/collect.py: provide hard-coded URL for testing * wqflask/wqflask/templates/collections/view.html: provide button Provide a button to trigger the heatmap generation. As a test, we also provide a hard-coded URL for the API endpoint to get the heatmap data. --- wqflask/wqflask/collect.py | 3 ++- wqflask/wqflask/templates/collections/view.html | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/collect.py b/wqflask/wqflask/collect.py index 01274ba9..41ff47ae 100644 --- a/wqflask/wqflask/collect.py +++ b/wqflask/wqflask/collect.py @@ -219,7 +219,8 @@ def view_collection(): json_version.append(jsonable(trait_ob)) collection_info = dict(trait_obs=trait_obs, - uc=uc) + uc=uc, + heatmap_data_url="http://localhost:8080/api/heatmaps/clustered") if "json" in params: return json.dumps(json_version) diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 9ec98ab1..09f9dd21 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -50,6 +50,12 @@ +
-- cgit v1.2.3 From 99bfeeef777bdaa804e4f91cae486a34fdf1e1c2 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Sep 2021 08:55:01 +0300 Subject: Implement proof-of-concept code to submit data Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Implement some javascript to activate the "Clustered Heatmap" button. This commit provides a proof-of-concept implementation to help with identifying the requirements for sending and receiving of the heatmaps data. --- wqflask/wqflask/templates/collections/view.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 09f9dd21..783458fc 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -253,6 +253,27 @@ $("#make_default").on("click", function(){ make_default(); }); + + $("#clustered-heatmaps").on("click", function() { + heatmap_url = $(this).attr("data-url") + console.log("heatmap url:", heatmap_url) + traits = $(".trait_checkbox:checked").map(function() { + return this.value + }).get(); + console.log("SELECTED TRAITS", traits); + $.ajax({ + type: "POST", + url: heatmap_url, + contentType: "application/json", + data: JSON.stringify({ + "traits_names": traits + }), + dataType: "JSON", + success: function(res) { + console.log("results:", res) + } + }); + }); }); -- cgit v1.2.3 From 614f641624582754e29b84d632e311ed5f186c1e Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Sep 2021 09:06:28 +0300 Subject: Move "Clustered Heatmap" button to separate form Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Move the button out of the "export_form" into a new "heatmaps_form" to avoid some weird JS interaction that showed up. --- wqflask/wqflask/templates/collections/view.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 783458fc..06fd80f4 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -50,13 +50,16 @@ - + +
+ +
Show/Hide Columns: -- cgit v1.2.3 From cfe0de277021c41eedeb65ec7f1560ac6d67ad0a Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Sep 2021 09:15:10 +0300 Subject: Fix id used. --- wqflask/wqflask/templates/collections/view.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 06fd80f4..0578460d 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -257,7 +257,7 @@ make_default(); }); - $("#clustered-heatmaps").on("click", function() { + $("#clustered-heatmap").on("click", function() { heatmap_url = $(this).attr("data-url") console.log("heatmap url:", heatmap_url) traits = $(".trait_checkbox:checked").map(function() { -- cgit v1.2.3 From f1876d4d8da5c973375fc398fedaa12825a0b780 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Sep 2021 09:20:44 +0300 Subject: Prevent the default submit action Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Prevent the default submit action. --- wqflask/wqflask/templates/collections/view.html | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 0578460d..51b96e10 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -257,6 +257,10 @@ make_default(); }); + $("#heatmaps_form").submit(function(e) { + e.preventDefault(); + }); + $("#clustered-heatmap").on("click", function() { heatmap_url = $(this).attr("data-url") console.log("heatmap url:", heatmap_url) -- cgit v1.2.3 From 98f9027b8ce8f33dda7f0b1b5495b22b4a450349 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 22 Sep 2021 06:30:42 +0300 Subject: Test heatmap creation from serialized figure Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * Attempt using the figure, serialized as JSON, to display the clustered heatmap. --- wqflask/wqflask/templates/collections/view.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 51b96e10..bca629a9 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -128,6 +128,9 @@ +
+

@@ -148,6 +151,8 @@ + +