From 16fa5815af683ec5e0166421a5dc371507eb6f09 Mon Sep 17 00:00:00 2001 From: SC Date: Fri, 18 Mar 2016 16:08:55 -0700 Subject: [PATCH] possibly the final pice--fixed gene product details pages to use new stack; work on #317 --- gulpfile.js | 1 + javascript/web/GPDetails.js | 215 ++++++++++++------ perl/lib/AmiGO/WebApp/HTMLClient.pm | 10 +- .../html/bs3/pages/gene_product_details.tmpl | 26 ++- 4 files changed, 177 insertions(+), 75 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c1123ae4f..72b738c01 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -261,6 +261,7 @@ var web_compilables = [ 'GeneralSearchForwarding.js', 'Gannet.js', 'GOOSE.js', + 'GPDetails.js', 'Grebe.js', 'Medial.js', 'LandingGraphs.js', diff --git a/javascript/web/GPDetails.js b/javascript/web/GPDetails.js index fb6fb399f..7e026eaa2 100644 --- a/javascript/web/GPDetails.js +++ b/javascript/web/GPDetails.js @@ -2,6 +2,38 @@ //// A lot of the commented out stuff in the other completely gone here. //// +// Let jshint pass over over our external globals (browserify takes +// care of it all). +/* global jQuery */ +/* global global_acc */ +/* global global_live_search_query */ +/* global global_live_search_filters */ +/* global global_live_search_pins */ + +var us = require('underscore'); +var bbop = require('bbop-core'); +var widgets = require('bbop-widget-set'); +var html = widgets.html; + +// Config. +var amigo = new (require('amigo2-instance-data'))(); // no overload +var golr_conf = require('golr-conf'); +var gconf = new golr_conf.conf(amigo.data.golr); +var sd = amigo.data.server; +var gserv = amigo.data.server.golr_base; +var defs = amigo.data.definitions; +// Linker. +var linker = amigo.linker; +// Handler. +var handler = amigo.handler; +// Management. +var jquery_engine = require('bbop-rest-manager').jquery; +var golr_manager = require('bbop-manager-golr'); +var golr_response = require('bbop-response-golr'); + +// Aliases. +var dlimit = defs.download_limit; + // function GPDetailsInit(){ @@ -26,25 +58,29 @@ function GPDetailsInit(){ jQuery("#display-tabs").tabs('option', 'active', 0); } - // Ready the configuration that we'll use. - var gconf = new bbop.golr.conf(amigo.data.golr); - var sd = new amigo.data.server(); - var defs = new amigo.data.definitions(); - var solr_server = sd.golr_base(); - - // Setup the annotation profile and make the annotation document - // category and the current acc sticky in the filters. - var linker = new amigo.linker(); - var handler = new amigo.handler(); - var gps_args = { - 'linker': linker, - 'handler': handler, - 'spinner_shield_message' : 'Loading and using this widget may take a long time on some large filter sets. If it takes too long, please close it and further narrow your results using other facets or the text search.
Waiting...', - 'spinner_search_source' : sd.image_base() + '/waiting_ajax.gif' - }; - var gps = new bbop.widget.search_pane(solr_server, gconf, - 'display-associations', - gps_args); + /// + /// Manager setup. + /// + + var engine = new jquery_engine(golr_response); + engine.method('GET'); + engine.use_jsonp(true); + var gps = new golr_manager(gserv, gconf, engine, 'async'); + + var confc = gconf.get_class('annotation'); + + // // Setup the annotation profile and make the annotation document + // // category and the current acc sticky in the filters. + // var gps_args = { + // 'linker': linker, + // 'handler': handler, + // 'spinner_shield_message' : 'Loading and using this widget may take a long time on some large filter sets. If it takes too long, please close it and further narrow your results using other facets or the text search.
Waiting...', + // 'spinner_search_source' : sd.image_base + '/waiting_ajax.gif' + // }; + // var gps = new widget.search_pane(gserv, gconf, + // 'display-associations', + // gps_args); + // Set the manager profile. gps.set_personality('annotation'); // profile in gconf gps.include_highlighting(true); @@ -53,22 +89,18 @@ function GPDetailsInit(){ gps.add_query_filter('document_category', 'annotation', ['*']); gps.add_query_filter('bioentity', global_acc, ['*']); - // Download limit. - var dlimit = defs.download_limit(); - // Add a term id download button. - var btmpl = bbop.widget.display.button_templates; + var btmpl = widgets.display.button_templates; // var id_download_button = // btmpl.field_download('Download term IDs (up to ' + dlimit + ')', // dlimit, ['annotation_class']); // gps.add_button(id_download_button); - var bio_flex_download_button = - btmpl.flexible_download('Flex download (up to ' + dlimit + ')', - dlimit, - defs.gaf_from_golr_fields(), - 'annotation', - gconf); - gps.add_button(bio_flex_download_button); + var bio_flex_download_button = + btmpl.flexible_download('Flex download (up to ' + dlimit + ')', + dlimit, + defs.gaf_from_golr_fields, + 'annotation', + gconf); // Experiment. // Process incoming queries, pins, and filters (into @@ -78,22 +110,63 @@ function GPDetailsInit(){ global_live_search_query); gps.set_comfy_query(global_live_search_query); } - if( bbop.core.is_array(global_live_search_filters) ){ //has incoming filters - bbop.core.each(global_live_search_filters, - function(filter){ - gps.add_query_filter_as_string(filter, ['$']); - }); + if( us.isArray(global_live_search_filters) ){ //has incoming filters + us.each(global_live_search_filters, function(filter){ + gps.add_query_filter_as_string(filter, ['$']); + }); } - if( bbop.core.is_array(global_live_search_pins) ){ //has incoming pins - bbop.core.each(global_live_search_pins, - function(pin){ - gps.add_query_filter_as_string(pin, ['*']); - }); + if( us.isArray(global_live_search_pins) ){ //has incoming pins + us.each(global_live_search_pins, function(pin){ + gps.add_query_filter_as_string(pin, ['*']); + }); } - // Get the interface going. - gps.establish_display(); - //gps.reset(); + /// + /// Major widget attachements to the manager. + /// + + // Attach filters to manager. + var hargs = { + meta_label: 'Total annotations: ', + // free_text_placeholder: + // 'Input text to filter against all remaining documents', + 'display_free_text_p': false + }; + var filters = new widgets.live_filters('accordion', gps, gconf, hargs); + filters.establish_display(); + + // Attach pager to manager. + var pager_opts = { + results_title: 'Total annotations: ', + }; + var pager = new widgets.live_pager('pager', gps, pager_opts); + + // Attach the results pane and download buttons to manager. + var default_fields = confc.field_order_by_weight('result'); + var flex_download_button = btmpl.flexible_download_b3( + ' Download', + dlimit, + default_fields, + 'annotation', + gconf); + var results_opts = { + //'callback_priority': -200, + 'user_buttons_div_id': pager.button_span_id(), + 'user_buttons': [ + flex_download_button + ] + }; + var results = new widgets.live_results('results', gps, confc, + handler, linker, results_opts); + + // Add pre and post run spinner (borrow filter's for now). + gps.register('prerun', function(){ + filters.spin_up(); + }); + gps.register('postrun', function(){ + filters.spin_down(); + }); + gps.search(); /// @@ -107,33 +180,45 @@ function GPDetailsInit(){ // Get bookmark for annotations. (function(){ // Ready bookmark. - var man = new bbop.golr.manager.jquery(solr_server, gconf); - man.set_personality('annotation'); - man.add_query_filter('document_category', 'annotation', ['*']); - man.add_query_filter('bioentity', global_acc); - var lstate = man.get_filter_query_string(); - var lurl = linker.url(lstate, 'search', 'annotation'); + var engine = new jquery_engine(golr_response); + engine.method('GET'); + engine.use_jsonp(true); + var man = new golr_manager(gserv, gconf, engine, 'async'); + + man.set_personality('annotation'); + man.add_query_filter('document_category', 'annotation', ['*']); + man.add_query_filter('bioentity', global_acc); + var lstate = man.get_filter_query_string(); + var lurl = linker.url(lstate, 'search', 'annotation'); // Add it to the DOM. - jQuery('#prob_ann_href').attr('href', lurl); - jQuery('#prob_ann').removeClass('hidden'); - })(); + jQuery('#prob_ann_href').attr('href', lurl); + jQuery('#prob_ann').removeClass('hidden'); + })(); // Get bookmark for annotation download. (function(){ - // Ready bookmark. - var man = new bbop.golr.manager.jquery(solr_server, gconf); - man.set_personality('annotation'); - man.add_query_filter('document_category', 'annotation', ['*']); - man.add_query_filter('bioentity', global_acc); - var dstate = man.get_download_url(defs.gaf_from_golr_fields(), - { - 'rows': dlimit, - 'encapsulator': '' - }); - jQuery('#prob_ann_dl_href').attr('href', dstate); - jQuery('#prob_ann_dl').removeClass('hidden'); - })(); + // Ready bookmark. + var engine = new jquery_engine(golr_response); + engine.method('GET'); + engine.use_jsonp(true); + var man = new golr_manager(gserv, gconf, engine, 'async'); + + man.set_personality('annotation'); + man.add_query_filter('document_category', 'annotation', ['*']); + man.add_query_filter('bioentity', global_acc); + var dstate = man.get_download_url(defs.gaf_from_golr_fields, { + 'rows': dlimit, + 'encapsulator': '' + }); + jQuery('#prob_ann_dl_href').attr('href', dstate); + jQuery('#prob_ann_dl').removeClass('hidden'); + })(); // ll('GPDetailsInit done.'); } + +// Embed the jQuery setup runner. +(function (){ + jQuery(document).ready(function(){ GPDetailsInit(); }); +})(); diff --git a/perl/lib/AmiGO/WebApp/HTMLClient.pm b/perl/lib/AmiGO/WebApp/HTMLClient.pm index 4354431c1..d5c43351e 100644 --- a/perl/lib/AmiGO/WebApp/HTMLClient.pm +++ b/perl/lib/AmiGO/WebApp/HTMLClient.pm @@ -1659,7 +1659,7 @@ sub mode_gene_product_details { ## Now add the filters that come in from the YAML-defined simple ## public bookmarking API. $filters = $self->_add_search_bookmark_api_to_filters($params, $filters); - + ## Input sanity check. if( ! $input_gp_id ){ return $self->mode_fatal("No input gene product acc argument."); @@ -1747,9 +1747,7 @@ sub mode_gene_product_details { [ 'com.jquery', 'com.bootstrap', - 'com.jquery-ui', - 'bbop', - 'amigo2' + 'com.jquery-ui' ], javascript => [ @@ -1763,10 +1761,6 @@ sub mode_gene_product_details { $self->{JS}->make_var('global_live_search_pins', $pins), $self->{JS}->make_var('global_acc', $input_gp_id) ], - javascript_init => - [ - 'GPDetailsInit();' - ], content => [ 'pages/gene_product_details.tmpl' diff --git a/templates/html/bs3/pages/gene_product_details.tmpl b/templates/html/bs3/pages/gene_product_details.tmpl index 62761874e..b180ec3b2 100644 --- a/templates/html/bs3/pages/gene_product_details.tmpl +++ b/templates/html/bs3/pages/gene_product_details.tmpl @@ -101,9 +101,31 @@

Gene Product Associations

-
- Contacting server... + +
+ +
+
+

Filter results

+ +
+ Loading... +
+ +
+
+ +
+ +
+
+
+ pending... +
+
+
+