diff options
author | uditgulati | 2020-09-13 13:55:33 -0500 |
---|---|---|
committer | uditgulati | 2020-11-01 06:47:02 -0600 |
commit | 59e611827bf0621b2613cc29b3f4ba730ef3631e (patch) | |
tree | 0110eb2d0b8a7c3dc2d2f80cbe53fe129f721e08 /wqflask | |
parent | f3351f698c7961aa28578b90fa0c73a2e14f864d (diff) | |
download | genenetwork2-59e611827bf0621b2613cc29b3f4ba730ef3631e.tar.gz |
add server side processing to search table (/search and search_result_page.html)
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/search_results.py | 16 | ||||
-rw-r--r-- | wqflask/wqflask/templates/search_result_page.html | 21 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 20 |
3 files changed, 47 insertions, 10 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py index ce836ce2..8a5a7a80 100644 --- a/wqflask/wqflask/search_results.py +++ b/wqflask/wqflask/search_results.py @@ -28,9 +28,9 @@ class SearchResultPage(object): #maxReturn = 3000 def __init__(self, kw): - """This class gets invoked after hitting submit on the main menu (in -views.py). - + """ + This class gets invoked after hitting submit on the main menu (in + views.py). """ ########################################### @@ -86,7 +86,6 @@ views.py). else: self.gen_search_result() - def gen_search_result(self): """ Get the info displayed in the search result table from the set of results computed in @@ -155,7 +154,14 @@ views.py). trait_dict[key] = trait_dict[key].decode('utf-8') trait_list.append(trait_dict) - self.trait_list = json.dumps(trait_list) + self.trait_list = trait_list + + if this_trait.dataset.type == "ProbeSet": + self.header_data_names = ['index', 'display_name', 'symbol', 'description', 'location', 'mean', 'lrs_score', 'lrs_location', 'additive'] + elif this_trait.dataset.type == "Publish": + self.header_data_names = ['index', 'display_name', 'description', 'mean', 'authors', 'pubmed_text', 'lrs_score', 'lrs_location', 'additive'] + elif this_trait.dataset.type == "Geno": + self.header_data_names = ['index', 'display_name', 'location'] def search(self): """ diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 2318bfb8..7d36d32e 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -174,6 +174,16 @@ <script type="text/javascript" charset="utf-8"> $(document).ready( function () { + + var getParams = function(url) { + var parser = document.createElement('a'); + parser.href = url; + var params = parser.search.substring(1); + if(params.length > 0) { + return ('?'+params); + } + return params; + }; $('#trait_table tr').click(function(event) { if (event.target.type !== 'checkbox') { @@ -260,7 +270,7 @@ 'data': null, 'width': "25px", 'orderDataType': "dom-checkbox", - 'orderSequence': [ "desc", "asc"], + 'orderable': false, 'render': function(data, type, row, meta) { return '<input type="checkbox" name="searchResult" class="checkbox trait_checkbox" value="' + data.hmac + '">' } @@ -426,14 +436,15 @@ {% else %} 'sDom': "pitirp", {% endif %} - 'iDisplayLength': 500, + 'iDisplayLength': 10, 'deferRender': true, 'paging': true, 'orderClasses': true, 'processing': true, - 'language': { - 'loadingRecords': ' ', - 'processing': 'Loading...' + 'bServerSide': true, + 'sAjaxSource': '/search_table'+getParams(window.location.href), + 'infoCallback': function(settings, start, end, max, total, pre) { + return "Showing " + start + " to " + (start + this.api().data().length - 1) + " of " + total + " entries"; } } ); diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 63570815..2c1fa94b 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -234,6 +234,26 @@ def search_page(): else: return render_template("search_error.html") +@app.route("/search_table", methods=('GET',)) +def search_page_table(): + logger.info("in search_page table") + logger.info(request.url) + + logger.info("request.args is", request.args) + the_search = search_results.SearchResultPage(request.args) + + logger.info(type(the_search.trait_list)) + logger.info(the_search.trait_list) + + current_page = server_side.ServerSideTable( + len(the_search.trait_list), + the_search.trait_list, + the_search.header_data_names, + request.args, + ).get_page() + + return flask.jsonify(current_page) + @app.route("/gsearch", methods=('GET',)) def gsearchact(): logger.info(request.url) |