Skip to content

Commit

Permalink
possibly the final pice--fixed gene product details pages to use new …
Browse files Browse the repository at this point in the history
…stack; work on #317
  • Loading branch information
kltm committed Mar 18, 2016
1 parent 0dc3fbc commit 16fa581
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 75 deletions.
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ var web_compilables = [
'GeneralSearchForwarding.js',
'Gannet.js',
'GOOSE.js',
'GPDetails.js',
'Grebe.js',
'Medial.js',
'LandingGraphs.js',
Expand Down
215 changes: 150 additions & 65 deletions javascript/web/GPDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){

Expand All @@ -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.<br />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.<br />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);
Expand All @@ -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
Expand All @@ -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:&nbsp;',
// 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:&nbsp;',
};
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(
'<span class="glyphicon glyphicon-download"></span> 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();

///
Expand All @@ -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(); });
})();
10 changes: 2 additions & 8 deletions perl/lib/AmiGO/WebApp/HTMLClient.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -1747,9 +1747,7 @@ sub mode_gene_product_details {
[
'com.jquery',
'com.bootstrap',
'com.jquery-ui',
'bbop',
'amigo2'
'com.jquery-ui'
],
javascript =>
[
Expand All @@ -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'
Expand Down
26 changes: 24 additions & 2 deletions templates/html/bs3/pages/gene_product_details.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,31 @@
<h3 class="panel-title">Gene Product Associations</h3>
</div>
<div class="panel-body">
<div id="display-associations">
Contacting server...

<div id="results-area" class="row">

<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div>
<h4>Filter results</h4>

<div id="accordion">
Loading...
</div>

</div>
</div>

<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">

<div id="pager">
</div>
<div id="results">
pending...
</div>
</div>

</div>

</div>
</div>

Expand Down

0 comments on commit 16fa581

Please sign in to comment.