aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-05-26 16:47:51 +0300
committerFrederick Muriuki Muriithi2022-05-26 16:47:51 +0300
commit98367087f262c0d0cdd7aae691989f90f4d40dcc (patch)
tree8eecabe20ae487a1842e48b3c62e7c5f8854e89c /wqflask
parente71d2c5d35771645a85a5e0fa7ebdfca4809a16b (diff)
downloadgenenetwork2-98367087f262c0d0cdd7aae691989f90f4d40dcc.tar.gz
Fetch the menu data from GN3
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js17
-rwxr-xr-xwqflask/wqflask/templates/index_page.html3
-rw-r--r--wqflask/wqflask/views.py3
3 files changed, 19 insertions, 4 deletions
diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js
index 7a67a017..e087849a 100644
--- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js
+++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js
@@ -7,6 +7,10 @@ process_json = function(data) {
}
};
+range = function(size, startAt=0) {
+ return [...Array(size).keys()].map(idx => idx + startAt);
+};
+
indicate_error = function (jqXHR, textStatus, errorThrown) {
console.error(jqXHR);
console.error(textStatus);
@@ -25,10 +29,19 @@ indicate_error = function (jqXHR, textStatus, errorThrown) {
Array.from(form.getElementsByTagName("textarea")).forEach(disable_element);
};
-$.ajax('/api/v_pre1/gen_dropdown', {
+defaultStatusCodeFunctions = range(200, 400).reduce(
+ function(acc, scode) {
+ acc[scode] = indicate_error;
+ return acc;
+ }, {});
+
+$.ajax($("#search form").attr("data-gn_server_url") +'/api/menu/generate/json', {
dataType: 'json',
success: process_json,
- error: indicate_error
+ error: indicate_error,
+ statusCode: {
+ ...defaultStatusCodeFunctions,
+ }
});
populate_species = function() {
diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html
index 3a490658..af0e2fa2 100755
--- a/wqflask/wqflask/templates/index_page.html
+++ b/wqflask/wqflask/templates/index_page.html
@@ -61,7 +61,8 @@
<div class="page-header">
<h2>Select and search</h2>
</div>
- <form method="get" action="/search" target="_blank" name="SEARCHFORM">
+ <form method="get" action="/search" target="_blank" name="SEARCHFORM",
+ data-gn_server_url="{{gn_server_url}}">
<fieldset>
<div style="padding-left: 20px; padding-right: 20px;" class="form-horizontal">
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index c38d46ca..a371d983 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -178,7 +178,8 @@ def index_page():
import_collections = params['import_collections']
if import_collections == "true":
g.user_session.import_traits_to_user(params['anon_id'])
- return render_template("index_page.html", version=GN_VERSION)
+ return render_template(
+ "index_page.html", version=GN_VERSION, gn_server_url=GN_SERVER_URL)
@app.route("/tmp/<img_path>")