From 5c47200dece98c44bac60bb8ceb86e787ef02a16 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 13 Apr 2016 20:36:50 +0000 Subject: All the datatables stuff should be passable by AJAX now, just need to figure out how --- wqflask/wqflask/templates/gsearch_gene.html | 21 +++++++++++++++++++-- wqflask/wqflask/update_search_results.py | 28 ++++++++++++++-------------- wqflask/wqflask/views.py | 3 ++- 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 7898435c..92b0b411 100755 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -140,10 +140,11 @@ "paging": false, "ajax": { "url": "/gsearch_updating?terms={{ terms }}&type={{ type }}", + "type": "POST", "dataType": "json", "contentType": "application/json; charset=utf-8", - "complete": function(response) { - console.log("Response:" + JSON.stringify(response)); + "data": function ( args ) { + return { "args": JSON.stringify( args ) }; } }, "buttons": [ @@ -157,6 +158,22 @@ } } ], + "columns": [ + { "data": "checkbox", "orderable" : false }, + { "data": "index", "orderable" : true }, + { "data": "species", "orderable" : true }, + { "data": "group", "orderable" : true }, + { "data": "tissue", "orderable" : true }, + { "data": "dataset", "orderable" : true }, + { "data": "record", "orderable" : true }, + { "data": "symbol", "orderable" : true }, + { "data": "description", "orderable" : true }, + { "data": "location", "orderable" : true }, + { "data": "mean", "orderable" : true }, + { "data": "max_lrs", "orderable" : true }, + { "data": "max_lrs_location", "orderable" : true }, + { "data": "additive_effect", "orderable" : true } + ], "sDom": "Bfrti", "autoWidth": false, "scrollY": "800px", diff --git a/wqflask/wqflask/update_search_results.py b/wqflask/wqflask/update_search_results.py index 7de2d8c0..ffd7fd51 100644 --- a/wqflask/wqflask/update_search_results.py +++ b/wqflask/wqflask/update_search_results.py @@ -105,20 +105,20 @@ class GSearch(object): json_dict['data'] = [] for i, trait in enumerate(self.trait_list): - trait_row = ["".format(trait.name, trait.dataset.name), - i+1, - trait.dataset.group.species, - trait.dataset.group.name, - trait.dataset.tissue, - trait.dataset.fullname, - "" + trait.name + "", - trait.symbol, - trait.description_display, - trait.location_repr, - trait.mean, - trait.LRS_score_repr, - trait.LRS_location_repr, - trait.additive] + trait_row = { "checkbox": "".format(trait.name, trait.dataset.name), + "index": i+1, + "species": trait.dataset.group.species, + "group": trait.dataset.group.name, + "tissue": trait.dataset.tissue, + "dataset": trait.dataset.fullname, + "record": "" + trait.name + "", + "symbol": trait.symbol, + "description": trait.description_display, + "location": trait.location_repr, + "mean": trait.mean, + "max_lrs": trait.LRS_score_repr, + "max_lrs_location": trait.LRS_location_repr, + "additive_effect": trait.additive} json_dict['data'].append(trait_row) json_results = json.dumps(json_dict) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 6184edc7..412491a1 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -168,8 +168,9 @@ def gsearchact(): elif type == "phenotype": return render_template("gsearch_pheno.html", **result) -@app.route("/gsearch_updating", methods=('GET',)) +@app.route("/gsearch_updating", methods=('POST',)) def gsearch_updating(): + print("REQUEST ARGS:", request.values) result = update_search_results.GSearch(request.args).__dict__ return result['results'] # type = request.args['type'] -- cgit v1.2.3