galaxy-commits
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
October 2014
- 2 participants
- 174 discussions
commit/galaxy-central: guerler: ToolForm: Move dictionary building methods from mako to api.
by commits-noreply@bitbucket.org 16 Oct '14
by commits-noreply@bitbucket.org 16 Oct '14
16 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/0d44e35432ab/
Changeset: 0d44e35432ab
User: guerler
Date: 2014-10-16 16:43:39+00:00
Summary: ToolForm: Move dictionary building methods from mako to api.
Affected #: 15 files
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 client/galaxy/scripts/mvc/tools/tools-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-content.js
@@ -22,7 +22,7 @@
// get history summary
Utils.get({
- url : self.base_url + '?deleted=false',
+ url : self.base_url + '?deleted=false&state=ok',
success : function(response) {
// backup summary
self.summary = response;
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 client/galaxy/scripts/mvc/tools/tools-form.js
--- a/client/galaxy/scripts/mvc/tools/tools-form.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form.js
@@ -27,10 +27,8 @@
this.modal = new Ui.Modal.View();
}
- // link model/inputs and all options
- this.options = options;
- this.model = options.model;
- this.inputs = options.model.inputs;
+ // link options
+ this.options = options;
// set element
this.setElement('<div/>');
@@ -53,9 +51,13 @@
// reset input element list, which contains the dom elements of each input element (includes also the input field)
this.element_list = {};
- // initialize contents
+ // for now the initial tool model is parsed through the mako
+ this.model = this.options;
+ this.inputs = this.options.inputs;
+
+ // request history content and build form
this.content = new ToolContent({
- history_id : this.options.history_id,
+ history_id : self.options.history_id,
success : function() {
self._buildForm();
}
@@ -89,6 +91,51 @@
console.debug('tools-form::refresh() - Recreated data structure. Refresh.');
},
+ // build tool model through api call
+ _buildModel: function() {
+ // link this
+ var self = this;
+
+ // construct url
+ var model_url = galaxy_config.root + 'api/tools/' + this.options.id + '/build?';
+ if (this.options.job_id) {
+ model_url += 'job_id=' + this.options.job_id;
+ } else {
+ if (this.options.dataset_id) {
+ model_url += 'dataset_id=' + this.options.dataset_id;
+ } else {
+ var loc = top.location.href;
+ var pos = loc.indexOf('?');
+ if (loc.indexOf('tool_id=') != -1 && pos !== -1) {
+ model_url += loc.slice(pos + 1);
+ }
+ }
+ }
+
+ // get initial model
+ Utils.request({
+ type : 'GET',
+ url : model_url,
+ success : function(response) {
+ // link model data update options
+ self.options = $.extend(self.options, response);
+ self.model = response;
+ self.inputs = response.inputs;
+
+ // log success
+ console.debug('tools-form::initialize() - Initial tool model ready.');
+ console.debug(response);
+
+ // build form
+ self._buildForm();
+ },
+ error : function(response) {
+ console.debug('tools-form::initialize() - Initial tool model request failed.');
+ console.debug(response);
+ }
+ });
+ },
+
// refresh form data
_refreshForm: function() {
// link this
@@ -111,7 +158,7 @@
// post job
Utils.request({
type : 'GET',
- url : galaxy_config.root + 'tool_runner/index?tool_id=' + this.options.id + '&form_refresh=True',
+ url : galaxy_config.root + 'api/tools/' + this.options.id + '/build',
data : current_state,
success : function(response) {
console.debug('tools-form::_refreshForm() - Refreshed inputs/states.');
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -106,17 +106,17 @@
value : function (dict) {
// update current value
if (dict !== undefined) {
- if (dict.values.length > 0 && dict.values[0] && dict.values[0].src) {
+ try {
+ // set source
+ this.current = dict.values[0].src;
+ this.refresh();
+
// create list
var list = [];
for (var i in dict.values) {
list.push(dict.values[i].id);
}
- // set source
- this.current = dict.values[0].src;
- this.refresh();
-
// identify select element
switch(this.current) {
case 'hda':
@@ -126,6 +126,8 @@
this.select_collection.value(list[0]);
break;
}
+ } catch (err) {
+ console.debug('tools-select-content::value() - Skipped.');
}
}
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -2175,7 +2175,7 @@
for expanded_incoming in expanded_incomings:
state, state_new = self.__fetch_state( trans, expanded_incoming, history, all_pages=all_pages )
all_states.append( state )
- if state_new and "form_refresh" not in incoming:
+ if state_new:
# This feels a bit like a hack. It allows forcing full processing
# of inputs even when there is no state in the incoming dictionary
# by providing either 'runtool_btn' (the name of the submit button
@@ -2358,7 +2358,7 @@
message='Your upload was interrupted. If this was uninentional, please retry it.',
refresh_frames=[], cont=None )
- def populate_state( self, trans, inputs, state, incoming, history, source, prefix="", context=None ):
+ def populate_state( self, trans, inputs, state, incoming, history=None, source="html", prefix="", context=None ):
errors = dict()
# Push this level onto the context stack
context = ExpressionContext( state, context )
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 lib/galaxy/webapps/galaxy/api/tools.py
--- a/lib/galaxy/webapps/galaxy/api/tools.py
+++ b/lib/galaxy/webapps/galaxy/api/tools.py
@@ -10,8 +10,13 @@
from galaxy.visualization.genomes import GenomeRegion
from galaxy.util.json import dumps
from galaxy.visualization.data_providers.genome import *
-
+from galaxy.tools.parameters import params_to_incoming
+from galaxy.tools.parameters import visit_input_values
+from galaxy.tools.parameters.meta import expand_meta_parameters
from galaxy.managers.collections_util import dictify_dataset_collection_instance
+from galaxy.model import HistoryDatasetAssociation
+from galaxy.util.expressions import ExpressionContext
+from collections import Iterable
import galaxy.queue_worker
@@ -61,6 +66,15 @@
tool = self._get_tool( id )
return tool.to_dict( trans, io_details=io_details, link_details=link_details )
+ @_future_expose_api_anonymous
+ def build( self, trans, id, **kwd ):
+ """
+ GET /api/tools/{tool_id}/build
+ Returns a tool model including dynamic parameters and updated values, repeats block etc.
+ """
+ tool = self._get_tool( id )
+ return self._build_dict(trans, tool, kwd)
+
@_future_expose_api
@web.require_admin
def reload( self, trans, tool_id, **kwd ):
@@ -464,3 +478,174 @@
dataset_dict[ 'id' ] = trans.security.encode_id( dataset_dict[ 'id' ] )
dataset_dict[ 'track_config' ] = self.get_new_track_config( trans, output_dataset )
return dataset_dict
+
+ def _build_dict(self, trans, tool, kwd={}):
+ """
+ Recursively creates a tool dictionary containing repeats, dynamic options and updated states.
+ """
+ job_id = kwd.get('job_id', None)
+ dataset_id = kwd.get('dataset_id', None)
+
+ # load job details if provided
+ job = None
+ if job_id:
+ try:
+ job_id = trans.security.decode_id( job_id )
+ job = trans.sa_session.query( trans.app.model.Job ).get( job_id )
+ except Exception, exception:
+ trans.response.status = 500
+ return { 'error': 'Failed to retrieve job.' }
+ elif dataset_id:
+ try:
+ dataset_id = trans.security.decode_id( dataset_id )
+ data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( dataset_id )
+ if not ( trans.user_is_admin() or trans.app.security_agent.can_access_dataset( trans.get_current_user_roles(), data.dataset ) ):
+ trans.response.status = 500
+ return { 'error': 'User has no access to dataset.' }
+ job = data.creating_job
+ if not job:
+ trans.response.status = 500
+ return { 'error': 'Creating job not found.' }
+ except Exception, exception:
+ trans.response.status = 500
+ return { 'error': 'Failed to get job information.' }
+
+ # check if job was identified
+ if job:
+ try:
+ job_params = job.get_param_values( trans.app, ignore_errors = True )
+ job_messages = tool.check_and_update_param_values( job_params, trans, update_values=False )
+ params_to_incoming( kwd, tool.inputs, job_params, trans.app )
+ except Exception, exception:
+ trans.response.status = 500
+ return { 'error': str( exception ) }
+
+ # create parameter object
+ params = galaxy.util.Params( kwd, sanitize = False )
+
+ # convert value to jsonifiable value
+ def convert(v):
+ # check if value is numeric
+ isnumber = False
+ try:
+ float(v)
+ isnumber = True
+ except Exception:
+ pass
+
+ # fix hda parsing
+ if isinstance(v, HistoryDatasetAssociation):
+ return {
+ 'id' : trans.security.encode_id(v.id),
+ 'src' : 'hda'
+ }
+ elif isinstance(v, basestring) or isnumber:
+ return v
+ else:
+ return None
+
+ # ensures that input dictionary is jsonifiable
+ def sanitize(dict):
+ # get current value
+ value = dict['value'] if 'value' in dict else None
+
+ # identify lists
+ if dict['type'] == 'data':
+ if isinstance(value, list):
+ value = [ convert(v) for v in value ]
+ else:
+ value = [ convert(value) ]
+ value = {
+ 'batch' : dict['multiple'],
+ 'values' : value
+ }
+ elif isinstance(value, list):
+ value = [ convert(v) for v in value ]
+ else:
+ value = convert(value)
+
+ # update and return
+ dict['value'] = value
+ return dict
+
+ # build model
+ def iterate(group_inputs, inputs, tool_state, errors, other_values=None):
+ other_values = ExpressionContext( tool_state, other_values )
+ for input_index, input in enumerate( inputs.itervalues() ):
+ # create model dictionary
+ group_inputs[input_index] = input.to_dict(trans)
+
+ # identify stat for subsection/group
+ group_state = tool_state[input.name]
+
+ # iterate and update values
+ if input.type == 'repeat':
+ group_cache = group_inputs[input_index]['cache'] = {}
+ for i in range( len( group_state ) ):
+ group_cache[i] = {}
+ group_errors = errors[input.name][i] if input.name in errors else dict()
+ iterate( group_cache[i], input.inputs, group_state[i], group_errors, other_values )
+ elif input.type == 'conditional':
+ # TODO: loop over all cases
+ try:
+ test_param = group_inputs[input_index]['test_param']
+ test_param['value'] = group_state[test_param['name']]
+ except Exception:
+ pass
+ i = group_state['__current_case__']
+ group_errors = errors.get( input.name, {} )
+ iterate(group_inputs[input_index]['cases'][i]['inputs'], input.cases[i].inputs, group_state, group_errors, other_values)
+ else:
+ # create input dictionary, try to pass other_values if to_dict function supports it e.g. dynamic options
+ try:
+ group_inputs[input_index] = input.to_dict(trans, other_values=other_values)
+ except Exception:
+ pass
+
+ # update input value from tool state
+ try:
+ group_inputs[input_index]['value'] = tool_state[group_inputs[input_index]['name']]
+ except Exception:
+ pass
+
+ # sanitize if value exists
+ if group_inputs[input_index]['value']:
+ group_inputs[input_index] = sanitize(group_inputs[input_index])
+
+ # do param translation here, used by datasource tools
+ if tool.input_translator:
+ tool.input_translator.translate( params )
+
+ # create tool state
+ state = tool.new_state(trans, all_pages=True)
+ errors = tool.populate_state( trans, tool.inputs, state.inputs, params.__dict__ )
+
+ # create basic tool model
+ tool_model = tool.to_dict(trans)
+ tool_model['inputs'] = {}
+
+ # build tool model
+ iterate(tool_model['inputs'], tool.inputs, state.inputs, errors, '')
+
+ # load tool help
+ tool_help = ''
+ if tool.help:
+ tool_help = tool.help
+ tool_help = tool_help.render( static_path=web.url_for( '/static' ), host_url=web.url_for('/', qualified=True) )
+ if type( tool_help ) is not unicode:
+ tool_help = unicode( tool_help, 'utf-8')
+
+ # check if citations exist
+ tool_citations = False
+ if tool.citations:
+ tool_citations = True
+
+ # add additional properties
+ tool_model.update({
+ 'help' : tool_help,
+ 'citations' : tool_citations,
+ 'biostar_url' : trans.app.config.biostar_url
+ })
+
+ # return enriched tool model
+ return tool_model
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 lib/galaxy/webapps/galaxy/buildapp.py
--- a/lib/galaxy/webapps/galaxy/buildapp.py
+++ b/lib/galaxy/webapps/galaxy/buildapp.py
@@ -180,6 +180,7 @@
webapp.mapper.resource( 'ftp_file', 'ftp_files', path_prefix='/api' )
webapp.mapper.resource( 'group', 'groups', path_prefix='/api' )
webapp.mapper.resource_with_deleted( 'quota', 'quotas', path_prefix='/api' )
+ webapp.mapper.connect( '/api/tools/{id:.+?}/build', action='build', controller="tools" )
webapp.mapper.connect( '/api/tools/{id:.+?}/reload', action='reload', controller="tools" )
webapp.mapper.connect( '/api/tools/{id:.+?}/citations', action='citations', controller="tools" )
webapp.mapper.connect( '/api/tools/{id:.+?}/download', action='download', controller="tools" )
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 lib/galaxy/webapps/galaxy/controllers/tool_runner.py
--- a/lib/galaxy/webapps/galaxy/controllers/tool_runner.py
+++ b/lib/galaxy/webapps/galaxy/controllers/tool_runner.py
@@ -60,9 +60,6 @@
# so the default selected option should be the most recent version of the tool. The following
# check will mae sure this occurs.
refreshed_on_change = kwd.get( 'refresh', False )
- # This is the new tool forms equivalent to the 'refresh' parameter of the classic tool form
- form_refresh = kwd.get( 'form_refresh', False )
- process_state = "populate" if form_refresh else "update"
tool_version_select_field, tools, tool = self.__get_tool_components( tool_id,
tool_version=None,
get_loaded_tools_by_lineage=False,
@@ -90,7 +87,7 @@
# We may be visiting Galaxy for the first time ( e.g., sending data from UCSC ),
# so make sure to create a new history if we've never had one before.
history = tool.get_default_history_by_trans( trans, create=True )
- template, vars = tool.handle_input( trans, params.__dict__, process_state=process_state)
+ template, vars = tool.handle_input( trans, params.__dict__ )
if len( params ) > 0:
trans.log_event( "Tool params: %s" % ( str( params ) ), tool_id=tool_id )
add_frame = AddFrameData()
@@ -98,8 +95,6 @@
if from_noframe is not None:
add_frame.wiki_url = trans.app.config.wiki_url
add_frame.from_noframe = True
- if form_refresh:
- template = "tool_form_refresh.mako"
return trans.fill_template( template,
history=history,
toolbox=self.get_toolbox(),
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 static/scripts/mvc/tools/tools-content.js
--- a/static/scripts/mvc/tools/tools-content.js
+++ b/static/scripts/mvc/tools/tools-content.js
@@ -22,7 +22,7 @@
// get history summary
Utils.get({
- url : self.base_url + '?deleted=false',
+ url : self.base_url + '?deleted=false&state=ok',
success : function(response) {
// backup summary
self.summary = response;
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -27,10 +27,8 @@
this.modal = new Ui.Modal.View();
}
- // link model/inputs and all options
- this.options = options;
- this.model = options.model;
- this.inputs = options.model.inputs;
+ // link options
+ this.options = options;
// set element
this.setElement('<div/>');
@@ -53,9 +51,13 @@
// reset input element list, which contains the dom elements of each input element (includes also the input field)
this.element_list = {};
- // initialize contents
+ // for now the initial tool model is parsed through the mako
+ this.model = this.options;
+ this.inputs = this.options.inputs;
+
+ // request history content and build form
this.content = new ToolContent({
- history_id : this.options.history_id,
+ history_id : self.options.history_id,
success : function() {
self._buildForm();
}
@@ -89,6 +91,51 @@
console.debug('tools-form::refresh() - Recreated data structure. Refresh.');
},
+ // build tool model through api call
+ _buildModel: function() {
+ // link this
+ var self = this;
+
+ // construct url
+ var model_url = galaxy_config.root + 'api/tools/' + this.options.id + '/build?';
+ if (this.options.job_id) {
+ model_url += 'job_id=' + this.options.job_id;
+ } else {
+ if (this.options.dataset_id) {
+ model_url += 'dataset_id=' + this.options.dataset_id;
+ } else {
+ var loc = top.location.href;
+ var pos = loc.indexOf('?');
+ if (loc.indexOf('tool_id=') != -1 && pos !== -1) {
+ model_url += loc.slice(pos + 1);
+ }
+ }
+ }
+
+ // get initial model
+ Utils.request({
+ type : 'GET',
+ url : model_url,
+ success : function(response) {
+ // link model data update options
+ self.options = $.extend(self.options, response);
+ self.model = response;
+ self.inputs = response.inputs;
+
+ // log success
+ console.debug('tools-form::initialize() - Initial tool model ready.');
+ console.debug(response);
+
+ // build form
+ self._buildForm();
+ },
+ error : function(response) {
+ console.debug('tools-form::initialize() - Initial tool model request failed.');
+ console.debug(response);
+ }
+ });
+ },
+
// refresh form data
_refreshForm: function() {
// link this
@@ -111,7 +158,7 @@
// post job
Utils.request({
type : 'GET',
- url : galaxy_config.root + 'tool_runner/index?tool_id=' + this.options.id + '&form_refresh=True',
+ url : galaxy_config.root + 'api/tools/' + this.options.id + '/build',
data : current_state,
success : function(response) {
console.debug('tools-form::_refreshForm() - Refreshed inputs/states.');
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -106,17 +106,17 @@
value : function (dict) {
// update current value
if (dict !== undefined) {
- if (dict.values.length > 0 && dict.values[0] && dict.values[0].src) {
+ try {
+ // set source
+ this.current = dict.values[0].src;
+ this.refresh();
+
// create list
var list = [];
for (var i in dict.values) {
list.push(dict.values[i].id);
}
- // set source
- this.current = dict.values[0].src;
- this.refresh();
-
// identify select element
switch(this.current) {
case 'hda':
@@ -126,6 +126,8 @@
this.select_collection.value(list[0]);
break;
}
+ } catch (err) {
+ console.debug('tools-select-content::value() - Skipped.');
}
}
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 static/scripts/packed/mvc/tools/tools-content.js
--- a/static/scripts/packed/mvc/tools/tools-content.js
+++ b/static/scripts/packed/mvc/tools/tools-content.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(c){this.base_url=galaxy_config.root+"api/histories/"+c.history_id+"/contents";this.datatypes={};this.summary={};var b=this;a.get({url:galaxy_config.root+"api/datatypes/mapping",cache:true,success:function(d){b.datatypes=d;a.get({url:b.base_url+"?deleted=false",success:function(e){b.summary=e;b.summary.sort(function(g,f){return g.hid>f.hid?-1:(g.hid<f.hid?1:0)});console.debug("tools-content::initialize() - Completed.");c.success&&c.success()},error:function(e){console.debug("tools-content::initialize() - Ajax request for summary failed.");console.debug(e)}})},error:function(d){console.debug("tools-content::initialize() - Ajax request for datatypes failed.");console.debug(d)}})},filterType:function(c){c=c||{};var b=[];var g="dataset";if(c.src=="hdca"){g="dataset_collection"}for(var d in this.summary){var e=this.summary[d];var f=false;for(var d in c.extensions){if(this._matchType(c.extensions[d],e.extension)){f=true;break}}if((e.history_content_type===g)&&(f||!c.extensions)){b.push(e)}}return b},get:function(b){return _.findWhere(this.summary,b)||{}},getDetails:function(b){if(!b.id||b.id==="null"){b.success&&b.success();return}var c=this.base_url+"/datasets/"+b.id;if(b.src=="hdca"){c=this.base_url+"/dataset_collections/"+b.id}a.get({url:c,success:function(d){b.success&&b.success(d)},error:function(d){b.success&&b.success();console.debug("tools-content::getDetails() - Ajax request for content failed.");console.debug(d)}})},_matchType:function(f,b){var c=this.datatypes.ext_to_class_name[f];if(!c){console.debug("tools-content::_matchType() - Specific target class unavailable. Accepting all formats.");return true}var d=this.datatypes.ext_to_class_name[b];if(!d){console.debug("tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.");return true}var e=this.datatypes.class_to_classes[d];if(e[c]){return true}return false}})});
\ No newline at end of file
+define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(c){this.base_url=galaxy_config.root+"api/histories/"+c.history_id+"/contents";this.datatypes={};this.summary={};var b=this;a.get({url:galaxy_config.root+"api/datatypes/mapping",cache:true,success:function(d){b.datatypes=d;a.get({url:b.base_url+"?deleted=false&state=ok",success:function(e){b.summary=e;b.summary.sort(function(g,f){return g.hid>f.hid?-1:(g.hid<f.hid?1:0)});console.debug("tools-content::initialize() - Completed.");c.success&&c.success()},error:function(e){console.debug("tools-content::initialize() - Ajax request for summary failed.");console.debug(e)}})},error:function(d){console.debug("tools-content::initialize() - Ajax request for datatypes failed.");console.debug(d)}})},filterType:function(c){c=c||{};var b=[];var g="dataset";if(c.src=="hdca"){g="dataset_collection"}for(var d in this.summary){var e=this.summary[d];var f=false;for(var d in c.extensions){if(this._matchType(c.extensions[d],e.extension)){f=true;break}}if((e.history_content_type===g)&&(f||!c.extensions)){b.push(e)}}return b},get:function(b){return _.findWhere(this.summary,b)||{}},getDetails:function(b){if(!b.id||b.id==="null"){b.success&&b.success();return}var c=this.base_url+"/datasets/"+b.id;if(b.src=="hdca"){c=this.base_url+"/dataset_collections/"+b.id}a.get({url:c,success:function(d){b.success&&b.success(d)},error:function(d){b.success&&b.success();console.debug("tools-content::getDetails() - Ajax request for content failed.");console.debug(d)}})},_matchType:function(f,b){var c=this.datatypes.ext_to_class_name[f];if(!c){console.debug("tools-content::_matchType() - Specific target class unavailable. Accepting all formats.");return true}var d=this.datatypes.ext_to_class_name[b];if(!d){console.debug("tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.");return true}var e=this.datatypes.class_to_classes[d];if(e[c]){return true}return false}})});
\ No newline at end of file
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 static/scripts/packed/mvc/tools/tools-form.js
--- a/static/scripts/packed/mvc/tools/tools-form.js
+++ b/static/scripts/packed/mvc/tools/tools-form.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(this.options.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.model=this.options;this.inputs=this.options.inputs;this.content=new f({history_id:m.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_buildModel:function(){var m=this;var n=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){n+="job_id="+this.options.job_id}else{if(this.options.dataset_id){n+="dataset_id="+this.options.dataset_id}else{var o=top.location.href;var p=o.indexOf("?");if(o.indexOf("tool_id=")!=-1&&p!==-1){n+=o.slice(p+1)}}}i.request({type:"GET",url:n,success:function(q){m.options=$.extend(m.options,q);m.model=q;m.inputs=q.inputs;console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(q);m._buildForm()},error:function(q){console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(q)}})},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"api/tools/"+this.options.id+"/build",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(this.options.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(n,h){this.options=h;var g=this;this.setElement("<div/>");this.current="hda";this.button_new=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Select datasets",value:"hda"},{icon:"fa-files-o",label:"Select a collection",value:"hdca"}],onchange:function(i){g.current=i;g.refresh();g.trigger("change")}});var l=n.content.filterType({src:"hda",extensions:h.extensions});var k=[];for(var j in l){k.push({label:l[j].hid+": "+l[j].name,value:l[j].id})}this.select_datasets=new e.Select.View({multiple:true,data:k,value:k[0]&&k[0].value,onchange:function(){g.trigger("change")}});var m=n.content.filterType({src:"hdca",extensions:h.extensions});var f=[];for(var j in m){f.push({label:m[j].hid+": "+m[j].name,value:m[j].id})}this.select_collection=new e.Select.View({data:f,value:f[0]&&f[0].value,onchange:function(){g.trigger("change")}});this.$el.append(c.wrap(this.button_new.$el));this.$el.append(this.select_datasets.$el);this.$el.append(this.select_collection.$el);if(!this.options.multiple){this.$el.append(a.batchMode())}this.refresh();this.on("change",function(){if(h.onchange){h.onchange(g.value())}})},value:function(k){if(k!==undefined){if(k.values.length>0&&k.values[0]&&k.values[0].src){var j=[];for(var g in k.values){j.push(k.values[g].id)}this.current=k.values[0].src;this.refresh();switch(this.current){case"hda":this.select_datasets.value(j);break;case"hdca":this.select_collection.value(j[0]);break}}}var h=this._select().value();if(!(h instanceof Array)){h=[h]}var f={batch:!this.options.multiple,values:[]};for(var g in h){f.values.push({id:h[g],src:this.current})}return f},validate:function(){return this._select().validate()},refresh:function(){switch(this.current){case"hda":this.select_datasets.$el.fadeIn();this.select_collection.$el.hide();break;case"hdca":this.select_datasets.$el.hide();this.select_collection.$el.fadeIn();break}},_select:function(){switch(this.current){case"hdca":return this.select_collection;default:return this.select_datasets}}});return{View:d}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(n,h){this.options=h;var g=this;this.setElement("<div/>");this.current="hda";this.button_new=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Select datasets",value:"hda"},{icon:"fa-files-o",label:"Select a collection",value:"hdca"}],onchange:function(i){g.current=i;g.refresh();g.trigger("change")}});var l=n.content.filterType({src:"hda",extensions:h.extensions});var k=[];for(var j in l){k.push({label:l[j].hid+": "+l[j].name,value:l[j].id})}this.select_datasets=new e.Select.View({multiple:true,data:k,value:k[0]&&k[0].value,onchange:function(){g.trigger("change")}});var m=n.content.filterType({src:"hdca",extensions:h.extensions});var f=[];for(var j in m){f.push({label:m[j].hid+": "+m[j].name,value:m[j].id})}this.select_collection=new e.Select.View({data:f,value:f[0]&&f[0].value,onchange:function(){g.trigger("change")}});this.$el.append(c.wrap(this.button_new.$el));this.$el.append(this.select_datasets.$el);this.$el.append(this.select_collection.$el);if(!this.options.multiple){this.$el.append(a.batchMode())}this.refresh();this.on("change",function(){if(h.onchange){h.onchange(g.value())}})},value:function(l){if(l!==undefined){try{this.current=l.values[0].src;this.refresh();var k=[];for(var g in l.values){k.push(l.values[g].id)}switch(this.current){case"hda":this.select_datasets.value(k);break;case"hdca":this.select_collection.value(k[0]);break}}catch(j){console.debug("tools-select-content::value() - Skipped.")}}var h=this._select().value();if(!(h instanceof Array)){h=[h]}var f={batch:!this.options.multiple,values:[]};for(var g in h){f.values.push({id:h[g],src:this.current})}return f},validate:function(){return this._select().validate()},refresh:function(){switch(this.current){case"hda":this.select_datasets.$el.fadeIn();this.select_collection.$el.hide();break;case"hdca":this.select_datasets.$el.hide();this.select_collection.$el.fadeIn();break}},_select:function(){switch(this.current){case"hdca":return this.select_collection;default:return this.select_datasets}}});return{View:d}});
\ No newline at end of file
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 templates/webapps/galaxy/tool_form.mako
--- a/templates/webapps/galaxy/tool_form.mako
+++ b/templates/webapps/galaxy/tool_form.mako
@@ -1,16 +1,27 @@
<%inherit file="/base.mako"/>
-## initialize configuration
-<%namespace name="tool_form_refresh" file="./webapps/galaxy/tool_form_refresh.mako" import="*" />
-${tool_form_refresh.init()}
-
## new tool form
+<%
+ ## TEMPORARY: create tool dictionary in mako while both tool forms are in use.
+ ## This avoids making two separate requests since the classic form requires the mako anyway.
+ from galaxy.webapps.galaxy.api.tools import ToolsController
+ controller = ToolsController(trans.app)
+ params = dict(trans.request.params)
+ if 'id' in params:
+ params['dataset_id'] = params['id']
+ self.form_config = controller._build_dict(trans, tool, params)
+ self.form_config.update({
+ 'id' : tool.id,
+ 'job_id' : trans.security.encode_id( job.id ) if job else None,
+ 'history_id' : trans.security.encode_id( trans.history.id )
+ })
+%>
${h.js("libs/bibtex", "libs/jquery/jquery-ui")}
${h.css('base', 'jquery-ui/smoothness/jquery-ui')}
<script>
require(['mvc/tools/tools-form'], function(ToolsForm){
$(function(){
- var form = new ToolsForm.View(${ h.dumps(tool_form_refresh.form_config) });
+ var form = new ToolsForm.View(${ h.dumps(self.form_config) });
});
});
</script>
diff -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 -r 0d44e35432abe4071aa073d1eb4cad074b7fc067 templates/webapps/galaxy/tool_form_refresh.mako
--- a/templates/webapps/galaxy/tool_form_refresh.mako
+++ /dev/null
@@ -1,138 +0,0 @@
-<%def name="init()">
-<%
- ## create basic tool model
- tool_model = tool.to_dict(trans)
- tool_model['inputs'] = {}
-
- ## convert value to jsonifiable value
- def convert(v):
- # check if value is numeric
- isnumber = False
- try:
- float(v)
- isnumber = True
- except Exception:
- pass
-
- ## fix hda parsing
- if isinstance(v, HistoryDatasetAssociation):
- return {
- 'id' : trans.security.encode_id(v.id),
- 'src' : 'hda'
- }
- elif isinstance(v, basestring) or isnumber:
- return v
- else:
- return None
-
- ## ensures that input dictionary is jsonifiable
- from collections import Iterable
- from galaxy.model import HistoryDatasetAssociation
- def sanitize(dict):
- ## quotations for Infinity so its jsonifiable
- for name in dict:
- if dict[name] == Infinity:
- dict[name] = 'Infinity'
-
- ## get current value
- value = dict['value'] if 'value' in dict else None
-
- ## identify lists
- if dict['type'] == 'data':
- if isinstance(value, list):
- value = [ convert(v) for v in value ]
- else:
- value = [ convert(value) ]
- value = {
- 'batch' : dict['multiple'],
- 'values' : value
- }
- elif isinstance(value, list):
- value = [ convert(v) for v in value ]
- else:
- value = convert(value)
-
- ## update and return
- dict['value'] = value
- return dict
-
- ## build model
- def build(group_inputs, inputs, tool_state, errors, other_values=None):
- from galaxy.util.expressions import ExpressionContext
- other_values = ExpressionContext( tool_state, other_values )
- for input_index, input in enumerate( inputs.itervalues() ):
- ## create model dictionary
- group_inputs[input_index] = input.to_dict(trans)
-
- ## identify stat for subsection/group
- group_state = tool_state[input.name]
-
- ## iterate and update values
- if input.type == "repeat":
- group_cache = group_inputs[input_index]['cache'] = {}
- for i in range( len( group_state ) ):
- group_cache[i] = {}
- group_errors = errors[input.name][i] if input.name in errors else dict()
- build( group_cache[i], input.inputs, group_state[i], group_errors, other_values )
- elif input.type == "conditional":
- try:
- test_param = group_inputs[input_index]['test_param']
- test_param['value'] = group_state[test_param['name']]
- except Exception:
- pass
- i = group_state['__current_case__']
- group_errors = errors.get( input.name, {} )
- build(group_inputs[input_index]['cases'][i]['inputs'], input.cases[i].inputs, group_state, group_errors, other_values)
- else:
- ## create input dictionary, try to pass other_values if to_dict function supports it e.g. dynamic options
- try:
- group_inputs[input_index] = input.to_dict(trans, other_values=other_values)
- except Exception:
- pass
-
- ## update input value from tool state
- try:
- group_inputs[input_index]['value'] = tool_state[group_inputs[input_index]['name']]
- group_inputs[input_index] = sanitize(group_inputs[input_index])
- except Exception:
- pass
- endif
- endfor
- build(tool_model['inputs'], tool.inputs, tool_state.inputs, errors, "")
-
- # load tool help
- tool_help = ''
- if tool.help:
- if tool.has_multiple_pages:
- tool_help = tool.help_by_page[tool_state.page]
- else:
- tool_help = tool.help
-
- # Help is Mako template, so render using current static path.
- tool_help = tool_help.render( static_path=h.url_for( '/static' ), host_url=h.url_for('/', qualified=True) )
-
- # Convert to unicode to display non-ascii characters.
- if type( tool_help ) is not unicode:
- tool_help = unicode( tool_help, 'utf-8')
- endif
-
- # check if citations exist
- tool_citations = False
- if tool.citations:
- tool_citations = True
-
- # form configuration
- self.form_config = {
- 'id' : tool.id,
- 'model' : tool_model,
- 'help' : tool_help,
- 'citations' : tool_citations,
- 'biostar_url' : trans.app.config.biostar_url,
- 'history_id' : trans.security.encode_id( trans.history.id ),
- 'job_id' : trans.security.encode_id( job.id ) if job else None
- }
-%>
-</%def>
-
-${ init() }
-${ h.dumps(self.form_config) }
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: jmchilton: Fix for datatypes consuming output extra files path for the change in d781366.
by commits-noreply@bitbucket.org 16 Oct '14
by commits-noreply@bitbucket.org 16 Oct '14
16 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/e1404e285ccb/
Changeset: e1404e285ccb
Branch: stable
User: jmchilton
Date: 2014-10-15 16:57:10+00:00
Summary: Fix for datatypes consuming output extra files path for the change in d781366.
That change forced $output.extra_files_path to be the same thing as $output.files_path. See rational in changeset.
Some datatypes however consume this path when generated metadata - post d781366 these datatypes would be accessing the wrong directory. This fixes them.
The suggested best practice I would put forward is $input.extra_files_path and $output.files_path. $output.extra_files_path redirects to $output.files_path for newer Galaxy versions (August 2014+) so that Galaxy configurations requiring this directory be in the jobs working directory work. Datatypes consuming dataset.extra_files_path for these outputs will be broken when used with $output.files_path for the August release of Galaxy - but if this changeset is back-ported to the October 2014 release then these types and tools will work going forward (without modification).
It can be verified that the older releases are broken with the following existing test (fixed with this changeset).
./run_functional_tests.sh -framework -id composite_output
Affected #: 2 files
diff -r cdd3a8a9cd7d5d71705843d2fa448462c7ed0675 -r e1404e285ccb9e52bd09c5827934cd0da1974acc lib/galaxy/model/__init__.py
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -1332,6 +1332,7 @@
self.purged = False
self.purgable = purgable
self.external_filename = external_filename
+ self.external_extra_files_path = None
self._extra_files_path = extra_files_path
self.file_size = file_size
if uuid is None:
@@ -1355,9 +1356,20 @@
else:
self.external_filename = filename
file_name = property( get_file_name, set_file_name )
- @property
- def extra_files_path( self ):
- return self.object_store.get_filename( self, dir_only=True, extra_dir=self._extra_files_path or "dataset_%d_files" % self.id )
+ def get_extra_files_path( self ):
+ # Unlike get_file_name - extrnal_extra_files_path is not backed by an
+ # actual database column so if SA instantiates this object - the
+ # attribute won't exist yet.
+ if not getattr( self, "external_extra_files_path", None ):
+ return self.object_store.get_filename( self, dir_only=True, extra_dir=self._extra_files_path or "dataset_%d_files" % self.id )
+ else:
+ return os.path.abspath( self.external_extra_files_path )
+ def set_extra_files_path( self, extra_files_path ):
+ if not extra_files_path:
+ self.external_extra_files_path = None
+ else:
+ self.external_extra_files_path = extra_files_path
+ extra_files_path = property( get_extra_files_path, set_extra_files_path)
def _calculate_size( self ):
if self.external_filename:
try:
diff -r cdd3a8a9cd7d5d71705843d2fa448462c7ed0675 -r e1404e285ccb9e52bd09c5827934cd0da1974acc scripts/set_metadata.py
--- a/scripts/set_metadata.py
+++ b/scripts/set_metadata.py
@@ -120,6 +120,8 @@
dataset = cPickle.load( open( filename_in ) ) # load DatasetInstance
if dataset_filename_override:
dataset.dataset.external_filename = dataset_filename_override
+ files_path = os.path.abspath(os.path.join( tool_job_working_directory, "dataset_%s_files" % (dataset.dataset.id) ))
+ dataset.dataset.external_extra_files_path = files_path
if dataset.dataset.id in existing_job_metadata_dict:
dataset.extension = existing_job_metadata_dict[ dataset.dataset.id ].get( 'ext', dataset.extension )
# Metadata FileParameter types may not be writable on a cluster node, and are therefore temporarily substituted with MetadataTempFiles
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: guerler: ToolForm: Fix options menu
by commits-noreply@bitbucket.org 16 Oct '14
by commits-noreply@bitbucket.org 16 Oct '14
16 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/9b09297ed0db/
Changeset: 9b09297ed0db
User: guerler
Date: 2014-10-16 14:48:18+00:00
Summary: ToolForm: Fix options menu
Affected #: 3 files
diff -r 6e605c5d9feff984bfb5e67f2c36a400abdcae85 -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 client/galaxy/scripts/mvc/tools/tools-form.js
--- a/client/galaxy/scripts/mvc/tools/tools-form.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form.js
@@ -135,25 +135,28 @@
tooltip : 'Click to see a list of options.'
});
- // add question option
- menu.addMenu({
- icon : 'fa-question-circle',
- title : 'Question?',
- tooltip : 'Ask a question about this tool (Biostar)',
- onclick : function() {
- window.open(self.options.biostar_url + '/p/new/post/');
- }
- });
-
- // create search button
- menu.addMenu({
- icon : 'fa-search',
- title : 'Search',
- tooltip : 'Search help for this tool (Biostar)',
- onclick : function() {
- window.open(self.options.biostar_url + '/t/' + self.options.id + '/');
- }
- });
+ // configure button selection
+ if(this.options.biostar_url) {
+ // add question option
+ menu.addMenu({
+ icon : 'fa-question-circle',
+ title : 'Question?',
+ tooltip : 'Ask a question about this tool (Biostar)',
+ onclick : function() {
+ window.open(self.options.biostar_url + '/p/new/post/');
+ }
+ });
+
+ // create search button
+ menu.addMenu({
+ icon : 'fa-search',
+ title : 'Search',
+ tooltip : 'Search help for this tool (Biostar)',
+ onclick : function() {
+ window.open(self.options.biostar_url + '/t/' + self.options.id + '/');
+ }
+ });
+ };
// create share button
menu.addMenu({
@@ -213,12 +216,6 @@
}
});
- // configure button selection
- if(!this.options.biostar_url) {
- button_question.$el.hide();
- button_search.$el.hide();
- }
-
// append form
this.$el.append(this.portlet.$el);
diff -r 6e605c5d9feff984bfb5e67f2c36a400abdcae85 -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -135,25 +135,28 @@
tooltip : 'Click to see a list of options.'
});
- // add question option
- menu.addMenu({
- icon : 'fa-question-circle',
- title : 'Question?',
- tooltip : 'Ask a question about this tool (Biostar)',
- onclick : function() {
- window.open(self.options.biostar_url + '/p/new/post/');
- }
- });
-
- // create search button
- menu.addMenu({
- icon : 'fa-search',
- title : 'Search',
- tooltip : 'Search help for this tool (Biostar)',
- onclick : function() {
- window.open(self.options.biostar_url + '/t/' + self.options.id + '/');
- }
- });
+ // configure button selection
+ if(this.options.biostar_url) {
+ // add question option
+ menu.addMenu({
+ icon : 'fa-question-circle',
+ title : 'Question?',
+ tooltip : 'Ask a question about this tool (Biostar)',
+ onclick : function() {
+ window.open(self.options.biostar_url + '/p/new/post/');
+ }
+ });
+
+ // create search button
+ menu.addMenu({
+ icon : 'fa-search',
+ title : 'Search',
+ tooltip : 'Search help for this tool (Biostar)',
+ onclick : function() {
+ window.open(self.options.biostar_url + '/t/' + self.options.id + '/');
+ }
+ });
+ };
// create share button
menu.addMenu({
@@ -213,12 +216,6 @@
}
});
- // configure button selection
- if(!this.options.biostar_url) {
- button_question.$el.hide();
- button_search.$el.hide();
- }
-
// append form
this.$el.append(this.portlet.$el);
diff -r 6e605c5d9feff984bfb5e67f2c36a400abdcae85 -r 9b09297ed0dbf506d5de13b6f91bbbd334b86238 static/scripts/packed/mvc/tools/tools-form.js
--- a/static/scripts/packed/mvc/tools/tools-form.js
+++ b/static/scripts/packed/mvc/tools/tools-form.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!this.options.biostar_url){button_question.$el.hide();button_search.$el.hide()}this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});if(this.options.biostar_url){p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}})}p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: guerler: ToolForm: Fix sorting of content labels
by commits-noreply@bitbucket.org 15 Oct '14
by commits-noreply@bitbucket.org 15 Oct '14
15 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/6e605c5d9fef/
Changeset: 6e605c5d9fef
User: guerler
Date: 2014-10-15 22:38:07+00:00
Summary: ToolForm: Fix sorting of content labels
Affected #: 3 files
diff -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 -r 6e605c5d9feff984bfb5e67f2c36a400abdcae85 client/galaxy/scripts/mvc/tools/tools-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-content.js
@@ -27,6 +27,11 @@
// backup summary
self.summary = response;
+ // sort by id
+ self.summary.sort(function(a, b) {
+ return a.hid > b.hid ? -1 : (a.hid < b.hid ? 1 : 0);
+ });
+
// log
console.debug('tools-content::initialize() - Completed.');
diff -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 -r 6e605c5d9feff984bfb5e67f2c36a400abdcae85 static/scripts/mvc/tools/tools-content.js
--- a/static/scripts/mvc/tools/tools-content.js
+++ b/static/scripts/mvc/tools/tools-content.js
@@ -27,6 +27,11 @@
// backup summary
self.summary = response;
+ // sort by id
+ self.summary.sort(function(a, b) {
+ return a.hid > b.hid ? -1 : (a.hid < b.hid ? 1 : 0);
+ });
+
// log
console.debug('tools-content::initialize() - Completed.');
diff -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 -r 6e605c5d9feff984bfb5e67f2c36a400abdcae85 static/scripts/packed/mvc/tools/tools-content.js
--- a/static/scripts/packed/mvc/tools/tools-content.js
+++ b/static/scripts/packed/mvc/tools/tools-content.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(c){this.base_url=galaxy_config.root+"api/histories/"+c.history_id+"/contents";this.datatypes={};this.summary={};var b=this;a.get({url:galaxy_config.root+"api/datatypes/mapping",cache:true,success:function(d){b.datatypes=d;a.get({url:b.base_url+"?deleted=false",success:function(e){b.summary=e;console.debug("tools-content::initialize() - Completed.");c.success&&c.success()},error:function(e){console.debug("tools-content::initialize() - Ajax request for summary failed.");console.debug(e)}})},error:function(d){console.debug("tools-content::initialize() - Ajax request for datatypes failed.");console.debug(d)}})},filterType:function(c){c=c||{};var b=[];var g="dataset";if(c.src=="hdca"){g="dataset_collection"}for(var d in this.summary){var e=this.summary[d];var f=false;for(var d in c.extensions){if(this._matchType(c.extensions[d],e.extension)){f=true;break}}if((e.history_content_type===g)&&(f||!c.extensions)){b.push(e)}}return b},get:function(b){return _.findWhere(this.summary,b)||{}},getDetails:function(b){if(!b.id||b.id==="null"){b.success&&b.success();return}var c=this.base_url+"/datasets/"+b.id;if(b.src=="hdca"){c=this.base_url+"/dataset_collections/"+b.id}a.get({url:c,success:function(d){b.success&&b.success(d)},error:function(d){b.success&&b.success();console.debug("tools-content::getDetails() - Ajax request for content failed.");console.debug(d)}})},_matchType:function(f,b){var c=this.datatypes.ext_to_class_name[f];if(!c){console.debug("tools-content::_matchType() - Specific target class unavailable. Accepting all formats.");return true}var d=this.datatypes.ext_to_class_name[b];if(!d){console.debug("tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.");return true}var e=this.datatypes.class_to_classes[d];if(e[c]){return true}return false}})});
\ No newline at end of file
+define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(c){this.base_url=galaxy_config.root+"api/histories/"+c.history_id+"/contents";this.datatypes={};this.summary={};var b=this;a.get({url:galaxy_config.root+"api/datatypes/mapping",cache:true,success:function(d){b.datatypes=d;a.get({url:b.base_url+"?deleted=false",success:function(e){b.summary=e;b.summary.sort(function(g,f){return g.hid>f.hid?-1:(g.hid<f.hid?1:0)});console.debug("tools-content::initialize() - Completed.");c.success&&c.success()},error:function(e){console.debug("tools-content::initialize() - Ajax request for summary failed.");console.debug(e)}})},error:function(d){console.debug("tools-content::initialize() - Ajax request for datatypes failed.");console.debug(d)}})},filterType:function(c){c=c||{};var b=[];var g="dataset";if(c.src=="hdca"){g="dataset_collection"}for(var d in this.summary){var e=this.summary[d];var f=false;for(var d in c.extensions){if(this._matchType(c.extensions[d],e.extension)){f=true;break}}if((e.history_content_type===g)&&(f||!c.extensions)){b.push(e)}}return b},get:function(b){return _.findWhere(this.summary,b)||{}},getDetails:function(b){if(!b.id||b.id==="null"){b.success&&b.success();return}var c=this.base_url+"/datasets/"+b.id;if(b.src=="hdca"){c=this.base_url+"/dataset_collections/"+b.id}a.get({url:c,success:function(d){b.success&&b.success(d)},error:function(d){b.success&&b.success();console.debug("tools-content::getDetails() - Ajax request for content failed.");console.debug(d)}})},_matchType:function(f,b){var c=this.datatypes.ext_to_class_name[f];if(!c){console.debug("tools-content::_matchType() - Specific target class unavailable. Accepting all formats.");return true}var d=this.datatypes.ext_to_class_name[b];if(!d){console.debug("tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.");return true}var e=this.datatypes.class_to_classes[d];if(e[c]){return true}return false}})});
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: guerler: ToolForm: Highlight first error only
by commits-noreply@bitbucket.org 15 Oct '14
by commits-noreply@bitbucket.org 15 Oct '14
15 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/a100c09d3e3a/
Changeset: a100c09d3e3a
User: guerler
Date: 2014-10-15 20:43:42+00:00
Summary: ToolForm: Highlight first error only
Affected #: 6 files
diff -r d94ef8154c63145b0e2928b099017324097d4352 -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 client/galaxy/scripts/mvc/tools/tools-form.js
--- a/client/galaxy/scripts/mvc/tools/tools-form.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form.js
@@ -132,7 +132,7 @@
// button menu
var menu = new Ui.ButtonMenu({
icon : 'fa-gear',
- tooltip : 'Click to see a list of available operations.'
+ tooltip : 'Click to see a list of options.'
});
// add question option
diff -r d94ef8154c63145b0e2928b099017324097d4352 -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 client/galaxy/scripts/mvc/tools/tools-jobs.js
--- a/client/galaxy/scripts/mvc/tools/tools-jobs.js
+++ b/client/galaxy/scripts/mvc/tools/tools-jobs.js
@@ -55,6 +55,7 @@
var error_messages = self.app.tree.matchResponse(response.message.data);
for (var input_id in error_messages) {
self._foundError(input_id, error_messages[input_id]);
+ break;
}
} else {
// show error message with details
diff -r d94ef8154c63145b0e2928b099017324097d4352 -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -132,7 +132,7 @@
// button menu
var menu = new Ui.ButtonMenu({
icon : 'fa-gear',
- tooltip : 'Click to see a list of available operations.'
+ tooltip : 'Click to see a list of options.'
});
// add question option
diff -r d94ef8154c63145b0e2928b099017324097d4352 -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 static/scripts/mvc/tools/tools-jobs.js
--- a/static/scripts/mvc/tools/tools-jobs.js
+++ b/static/scripts/mvc/tools/tools-jobs.js
@@ -55,6 +55,7 @@
var error_messages = self.app.tree.matchResponse(response.message.data);
for (var input_id in error_messages) {
self._foundError(input_id, error_messages[input_id]);
+ break;
}
} else {
// show error message with details
diff -r d94ef8154c63145b0e2928b099017324097d4352 -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 static/scripts/packed/mvc/tools/tools-form.js
--- a/static/scripts/packed/mvc/tools/tools-form.js
+++ b/static/scripts/packed/mvc/tools/tools-form.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of available operations."});p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!this.options.biostar_url){button_question.$el.hide();button_search.$el.hide()}this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of options."});p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!this.options.biostar_url){button_question.$el.hide();button_search.$el.hide()}this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
diff -r d94ef8154c63145b0e2928b099017324097d4352 -r a100c09d3e3ad5d8df2747384d3d6b22c3658cb9 static/scripts/packed/mvc/tools/tools-jobs.js
--- a/static/scripts/packed/mvc/tools/tools-jobs.js
+++ b/static/scripts/packed/mvc/tools/tools-jobs.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.debug(d);this.app.modal.show({title:"Please wait...",body:"progress",closing_events:true,buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.message(a.success(e));c._refreshHdas()},error:function(e,g){c.app.modal.hide();if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var f in h){c._foundError(f,h[f])}}else{console.debug(e);c.app.modal.show({title:"Job submission failed",body:a.error(d),buttons:{Close:function(){c.app.modal.hide()}}})}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(g){var c=g.inputs;var k=-1;for(var i in c){var e=c[i];var j=this.app.tree.match(i);var d=this.app.field_list[j];var h=this.app.input_list[j];if(h&&d&&d.validate&&!d.validate()){this._foundError(j);return false}if(e.batch){var f=e.values.length;if(k===-1){k=f}else{if(k!==f){this._foundError(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+f+"</b> selection(s) while a previous field contains <b>"+k+"</b>.");return false}}}}return true},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})});
\ No newline at end of file
+define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.debug(d);this.app.modal.show({title:"Please wait...",body:"progress",closing_events:true,buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.message(a.success(e));c._refreshHdas()},error:function(e,g){c.app.modal.hide();if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var f in h){c._foundError(f,h[f]);break}}else{console.debug(e);c.app.modal.show({title:"Job submission failed",body:a.error(d),buttons:{Close:function(){c.app.modal.hide()}}})}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(g){var c=g.inputs;var k=-1;for(var i in c){var e=c[i];var j=this.app.tree.match(i);var d=this.app.field_list[j];var h=this.app.input_list[j];if(h&&d&&d.validate&&!d.validate()){this._foundError(j);return false}if(e.batch){var f=e.values.length;if(k===-1){k=f}else{if(k!==f){this._foundError(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+f+"</b> selection(s) while a previous field contains <b>"+k+"</b>.");return false}}}}return true},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})});
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: dannon: Merged in jmchilton/galaxy-central-fork-1 (pull request #530)
by commits-noreply@bitbucket.org 15 Oct '14
by commits-noreply@bitbucket.org 15 Oct '14
15 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d94ef8154c63/
Changeset: d94ef8154c63
User: dannon
Date: 2014-10-15 20:30:56+00:00
Summary: Merged in jmchilton/galaxy-central-fork-1 (pull request #530)
Implement creating tool shed repository revisions via API tarball upload.
Affected #: 5 files
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/tools/actions/upload_common.py
--- a/lib/galaxy/tools/actions/upload_common.py
+++ b/lib/galaxy/tools/actions/upload_common.py
@@ -30,7 +30,7 @@
f.file.close()
upload_dataset['file_data'] = dict( filename=f.filename,
local_filename=local_filename )
- elif type( f ) == dict and 'filename' and 'local_filename' not in f:
+ elif type( f ) == dict and 'local_filename' not in f:
raise Exception( 'Uploaded file was encoded in a way not understood by Galaxy.' )
if upload_dataset['url_paste'] and upload_dataset['url_paste'].strip() != '':
upload_dataset['url_paste'], is_multi_byte = datatypes.sniff.stream_to_file( StringIO.StringIO( upload_dataset['url_paste'] ), prefix="strio_url_paste_" )
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/webapps/tool_shed/api/repositories.py
--- a/lib/galaxy/webapps/tool_shed/api/repositories.py
+++ b/lib/galaxy/webapps/tool_shed/api/repositories.py
@@ -2,11 +2,15 @@
import logging
import os
import tarfile
+import StringIO
import tempfile
from time import strftime
+from cgi import FieldStorage
+
from galaxy import util
from galaxy import web
+from galaxy.datatypes import checkers
from galaxy.model.orm import and_
from galaxy.web.base.controller import BaseAPIController
from galaxy.web.base.controller import HTTPBadRequest
@@ -16,10 +20,14 @@
from tool_shed.metadata import repository_metadata_manager
from tool_shed.repository_types import util as rt_util
+from tool_shed.dependencies import attribute_handlers
+
from tool_shed.util import basic_util
+from tool_shed.util import commit_util
from tool_shed.util import encoding_util
from tool_shed.util import hg_util
from tool_shed.util import repository_util
+from tool_shed.util import repository_content_util
from tool_shed.util import shed_util_common as suc
from tool_shed.util import tool_util
@@ -568,3 +576,108 @@
action='show',
id=trans.security.encode_id( repository.id ) )
return repository_dict
+
+ @web.expose_api
+ def create_changeset_revision( self, trans, id, payload, **kwd ):
+ """
+ POST /api/repositories/{encoded_repository_id}/changeset_revision
+
+ Create a new tool shed repository commit - leaving PUT on parent
+ resource open for updating meta-attirbutes of the repository (and
+ Galaxy doesn't allow PUT multipart data anyway
+ https://trello.com/c/CQwmCeG6)
+
+ :param id: the encoded id of the Repository object
+
+ The following parameters may be included in the payload.
+ :param commit_message: hg commit message for update.
+ """
+
+ # Example URL: http://localhost:9009/api/repositories/f9cad7b01a472135
+ rdah = attribute_handlers.RepositoryDependencyAttributeHandler( trans.app, unpopulate=False )
+ tdah = attribute_handlers.ToolDependencyAttributeHandler( trans.app, unpopulate=False )
+
+ repository = suc.get_repository_in_tool_shed( trans.app, id )
+ repo_dir = repository.repo_path( trans.app )
+ repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
+
+ upload_point = commit_util.get_upload_point( repository, **kwd )
+ tip = repository.tip( trans.app )
+
+ file_data = payload.get('file')
+ # Code stolen from gx's upload_common.py
+ if isinstance( file_data, FieldStorage ):
+ assert not isinstance( file_data.file, StringIO.StringIO )
+ assert file_data.file.name != '<fdopen>'
+ local_filename = util.mkstemp_ln( file_data.file.name, 'upload_file_data_' )
+ file_data.file.close()
+ file_data = dict( filename=file_data.filename,
+ local_filename=local_filename )
+ elif type( file_data ) == dict and 'local_filename' not in file_data:
+ raise Exception( 'Uploaded file was encoded in a way not understood.' )
+
+ commit_message = kwd.get( 'commit_message', 'Uploaded' )
+
+ uploaded_file = open(file_data['local_filename'], 'rb')
+ uploaded_file_name = file_data['local_filename']
+
+ isgzip = False
+ isbz2 = False
+ isgzip = checkers.is_gzip( uploaded_file_name )
+ if not isgzip:
+ isbz2 = checkers.is_bz2( uploaded_file_name )
+ if ( isgzip or isbz2 ):
+ # Open for reading with transparent compression.
+ tar = tarfile.open( uploaded_file_name, 'r:*' )
+ else:
+ tar = tarfile.open( uploaded_file_name )
+
+ new_repo_alert = False
+ remove_repo_files_not_in_tar = True
+
+ ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
+ repository_content_util.upload_tar(
+ trans,
+ rdah,
+ tdah,
+ repository,
+ tar,
+ uploaded_file,
+ upload_point,
+ remove_repo_files_not_in_tar,
+ commit_message,
+ new_repo_alert
+ )
+ if ok:
+ # Update the repository files for browsing.
+ hg_util.update_repository( repo )
+ # Get the new repository tip.
+ if tip == repository.tip( trans.app ):
+ trans.response.status = 400
+ message = 'No changes to repository.'
+ ok = False
+ else:
+ rmm = repository_metadata_manager.RepositoryMetadataManager( app=trans.app,
+ user=trans.user,
+ repository=repository )
+ status, error_message = \
+ rmm.set_repository_metadata_due_to_new_tip( trans.request.host,
+ content_alert_str=content_alert_str,
+ **kwd )
+ if error_message:
+ ok = False
+ trans.response.status = 500
+ message = error_message
+ else:
+ trans.response.status = 500
+
+ if not ok:
+ return {
+ "err_msg": message,
+ "content_alert": content_alert_str
+ }
+ else:
+ return {
+ "message": message,
+ "content_alert": content_alert_str
+ }
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/webapps/tool_shed/buildapp.py
--- a/lib/galaxy/webapps/tool_shed/buildapp.py
+++ b/lib/galaxy/webapps/tool_shed/buildapp.py
@@ -119,6 +119,12 @@
name_prefix='user_',
path_prefix='/api',
parent_resources=dict( member_name='user', collection_name='users' ) )
+ webapp.mapper.connect( 'repository_create_changeset_revision',
+ '/api/repositories/:id/changeset_revision',
+ controller='repositories',
+ action='create_changeset_revision',
+ conditions=dict( method=[ "POST" ] ) )
+
webapp.finalize_config()
# Wrap the webapp in some useful middleware
if kwargs.get( 'middleware', True ):
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/webapps/tool_shed/controllers/upload.py
--- a/lib/galaxy/webapps/tool_shed/controllers/upload.py
+++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py
@@ -20,6 +20,7 @@
from tool_shed.util import commit_util
from tool_shed.util import hg_util
from tool_shed.util import shed_util_common as suc
+from tool_shed.util import repository_content_util
from tool_shed.util import xml_util
from galaxy import eggs
@@ -129,16 +130,18 @@
istar = False
if istar:
ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
- self.upload_tar( trans,
- rdah,
- tdah,
- repository,
- tar,
- uploaded_file,
- upload_point,
- remove_repo_files_not_in_tar,
- commit_message,
- new_repo_alert )
+ repository_content_util.upload_tar(
+ trans,
+ rdah,
+ tdah,
+ repository,
+ tar,
+ uploaded_file,
+ upload_point,
+ remove_repo_files_not_in_tar,
+ commit_message,
+ new_repo_alert
+ )
elif uploaded_directory:
ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
self.upload_directory( trans,
@@ -407,69 +410,3 @@
commit_message,
undesirable_dirs_removed,
undesirable_files_removed )
-
- def upload_tar( self, trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar,
- commit_message, new_repo_alert ):
- # Upload a tar archive of files.
- repo_dir = repository.repo_path( trans.app )
- repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
- undesirable_dirs_removed = 0
- undesirable_files_removed = 0
- ok, message = commit_util.check_archive( repository, tar )
- if not ok:
- tar.close()
- uploaded_file.close()
- return ok, message, [], '', undesirable_dirs_removed, undesirable_files_removed
- else:
- if upload_point is not None:
- full_path = os.path.abspath( os.path.join( repo_dir, upload_point ) )
- else:
- full_path = os.path.abspath( repo_dir )
- filenames_in_archive = []
- for tarinfo_obj in tar.getmembers():
- ok = os.path.basename( tarinfo_obj.name ) not in commit_util.UNDESIRABLE_FILES
- if ok:
- for file_path_item in tarinfo_obj.name.split( '/' ):
- if file_path_item in commit_util.UNDESIRABLE_DIRS:
- undesirable_dirs_removed += 1
- ok = False
- break
- else:
- undesirable_files_removed += 1
- if ok:
- filenames_in_archive.append( tarinfo_obj.name )
- # Extract the uploaded tar to the load_point within the repository hierarchy.
- tar.extractall( path=full_path )
- tar.close()
- uploaded_file.close()
- for filename in filenames_in_archive:
- uploaded_file_name = os.path.join( full_path, filename )
- if os.path.split( uploaded_file_name )[ -1 ] == rt_util.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
- # Inspect the contents of the file to see if toolshed or changeset_revision attributes
- # are missing and if so, set them appropriately.
- altered, root_elem, error_message = rdah.handle_tag_attributes( uploaded_file_name )
- if error_message:
- return False, error_message, [], '', [], []
- elif altered:
- tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
- shutil.move( tmp_filename, uploaded_file_name )
- elif os.path.split( uploaded_file_name )[ -1 ] == rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME:
- # Inspect the contents of the file to see if toolshed or changeset_revision
- # attributes are missing and if so, set them appropriately.
- altered, root_elem, error_message = tdah.handle_tag_attributes( uploaded_file_name )
- if error_message:
- return False, error_message, [], '', [], []
- if altered:
- tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
- shutil.move( tmp_filename, uploaded_file_name )
- return commit_util.handle_directory_changes( trans.app,
- trans.request.host,
- trans.user.username,
- repository,
- full_path,
- filenames_in_archive,
- remove_repo_files_not_in_tar,
- new_repo_alert,
- commit_message,
- undesirable_dirs_removed,
- undesirable_files_removed )
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/tool_shed/util/repository_content_util.py
--- /dev/null
+++ b/lib/tool_shed/util/repository_content_util.py
@@ -0,0 +1,75 @@
+import os
+import shutil
+
+from tool_shed.util import commit_util
+from tool_shed.util import hg_util
+from tool_shed.util import xml_util
+
+import tool_shed.repository_types.util as rt_util
+
+
+def upload_tar( trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar,
+ commit_message, new_repo_alert ):
+ # Upload a tar archive of files.
+ repo_dir = repository.repo_path( trans.app )
+ hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
+ undesirable_dirs_removed = 0
+ undesirable_files_removed = 0
+ ok, message = commit_util.check_archive( repository, tar )
+ if not ok:
+ tar.close()
+ uploaded_file.close()
+ return ok, message, [], '', undesirable_dirs_removed, undesirable_files_removed
+ else:
+ if upload_point is not None:
+ full_path = os.path.abspath( os.path.join( repo_dir, upload_point ) )
+ else:
+ full_path = os.path.abspath( repo_dir )
+ filenames_in_archive = []
+ for tarinfo_obj in tar.getmembers():
+ ok = os.path.basename( tarinfo_obj.name ) not in commit_util.UNDESIRABLE_FILES
+ if ok:
+ for file_path_item in tarinfo_obj.name.split( '/' ):
+ if file_path_item in commit_util.UNDESIRABLE_DIRS:
+ undesirable_dirs_removed += 1
+ ok = False
+ break
+ else:
+ undesirable_files_removed += 1
+ if ok:
+ filenames_in_archive.append( tarinfo_obj.name )
+ # Extract the uploaded tar to the load_point within the repository hierarchy.
+ tar.extractall( path=full_path )
+ tar.close()
+ uploaded_file.close()
+ for filename in filenames_in_archive:
+ uploaded_file_name = os.path.join( full_path, filename )
+ if os.path.split( uploaded_file_name )[ -1 ] == rt_util.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
+ # Inspect the contents of the file to see if toolshed or changeset_revision attributes
+ # are missing and if so, set them appropriately.
+ altered, root_elem, error_message = rdah.handle_tag_attributes( uploaded_file_name )
+ if error_message:
+ return False, error_message, [], '', [], []
+ elif altered:
+ tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
+ shutil.move( tmp_filename, uploaded_file_name )
+ elif os.path.split( uploaded_file_name )[ -1 ] == rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME:
+ # Inspect the contents of the file to see if toolshed or changeset_revision
+ # attributes are missing and if so, set them appropriately.
+ altered, root_elem, error_message = tdah.handle_tag_attributes( uploaded_file_name )
+ if error_message:
+ return False, error_message, [], '', [], []
+ if altered:
+ tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
+ shutil.move( tmp_filename, uploaded_file_name )
+ return commit_util.handle_directory_changes( trans.app,
+ trans.request.host,
+ trans.user.username,
+ repository,
+ full_path,
+ filenames_in_archive,
+ remove_repo_files_not_in_tar,
+ new_repo_alert,
+ commit_message,
+ undesirable_dirs_removed,
+ undesirable_files_removed )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
3 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d6059c7194ef/
Changeset: d6059c7194ef
User: jmchilton
Date: 2014-10-14 20:30:27+00:00
Summary: Implement creating tool shed repository revisions via API tarball upload.
Affected #: 4 files
diff -r 42cd5d55755a729dd2f19ccd1ed20649ed29f6ac -r d6059c7194effc68dbfae4a459bd456c82fe8478 lib/galaxy/webapps/tool_shed/api/repositories.py
--- a/lib/galaxy/webapps/tool_shed/api/repositories.py
+++ b/lib/galaxy/webapps/tool_shed/api/repositories.py
@@ -2,11 +2,15 @@
import logging
import os
import tarfile
+import StringIO
import tempfile
from time import strftime
+from cgi import FieldStorage
+
from galaxy import util
from galaxy import web
+from galaxy.datatypes import checkers
from galaxy.model.orm import and_
from galaxy.web.base.controller import BaseAPIController
from galaxy.web.base.controller import HTTPBadRequest
@@ -16,10 +20,14 @@
from tool_shed.metadata import repository_metadata_manager
from tool_shed.repository_types import util as rt_util
+from tool_shed.dependencies import attribute_handlers
+
from tool_shed.util import basic_util
+from tool_shed.util import commit_util
from tool_shed.util import encoding_util
from tool_shed.util import hg_util
from tool_shed.util import repository_util
+from tool_shed.util import repository_content_util
from tool_shed.util import shed_util_common as suc
from tool_shed.util import tool_util
@@ -568,3 +576,109 @@
action='show',
id=trans.security.encode_id( repository.id ) )
return repository_dict
+
+ @web.expose_api
+ def create_changeset_revision( self, trans, id, payload, **kwd ):
+ """
+ POST /api/repositories/{encoded_repository_id}/changeset_revision
+
+ Create a new tool shed repository commit - leaving PUT on parent
+ resource open for updating meta-attirbutes of the repository (and
+ Galaxy doesn't allow PUT multipart data anyway
+ https://trello.com/c/CQwmCeG6)
+
+ :param id: the encoded id of the Repository object
+
+ The following parameters may be included in the payload.
+ :param commit_message: hg commit message for update.
+ """
+
+ # Example URL: http://localhost:9009/api/repositories/f9cad7b01a472135
+ rdah = attribute_handlers.RepositoryDependencyAttributeHandler( trans.app, unpopulate=False )
+ tdah = attribute_handlers.ToolDependencyAttributeHandler( trans.app, unpopulate=False )
+
+ repository = suc.get_repository_in_tool_shed( trans.app, id )
+ repo_dir = repository.repo_path( trans.app )
+ repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
+
+ upload_point = commit_util.get_upload_point( repository, **kwd )
+ tip = repository.tip( trans.app )
+
+ file_data = payload.get('file')
+ # Code stolen from gx's upload_common.py
+ if isinstance( file_data, FieldStorage ):
+ assert not isinstance( file_data.file, StringIO.StringIO )
+ assert file_data.file.name != '<fdopen>'
+ local_filename = util.mkstemp_ln( file_data.file.name, 'upload_file_data_' )
+ file_data.file.close()
+ file_data = dict( filename=file_data.filename,
+ local_filename=local_filename )
+ elif type( file_data ) == dict and 'filename' and 'local_filename' not in file_data:
+ raise Exception( 'Uploaded file was encoded in a way not understood.' )
+
+ commit_message = kwd.get( 'commit_message', 'Uploaded' )
+
+ uploaded_file = open(file_data['local_filename'], 'rb')
+ uploaded_file_name = file_data['local_filename']
+
+ ok = True
+ isgzip = False
+ isbz2 = False
+ isgzip = checkers.is_gzip( uploaded_file_name )
+ if not isgzip:
+ isbz2 = checkers.is_bz2( uploaded_file_name )
+ if ( isgzip or isbz2 ):
+ # Open for reading with transparent compression.
+ tar = tarfile.open( uploaded_file_name, 'r:*' )
+ else:
+ tar = tarfile.open( uploaded_file_name )
+
+ new_repo_alert = False
+ remove_repo_files_not_in_tar = True
+
+ ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
+ repository_content_util.upload_tar(
+ trans,
+ rdah,
+ tdah,
+ repository,
+ tar,
+ uploaded_file,
+ upload_point,
+ remove_repo_files_not_in_tar,
+ commit_message,
+ new_repo_alert
+ )
+ if ok:
+ # Update the repository files for browsing.
+ hg_util.update_repository( repo )
+ # Get the new repository tip.
+ if tip == repository.tip( trans.app ):
+ trans.response.status = 400
+ message = 'No changes to repository.'
+ ok = False
+ else:
+ rmm = repository_metadata_manager.RepositoryMetadataManager( app=trans.app,
+ user=trans.user,
+ repository=repository )
+ status, error_message = \
+ rmm.set_repository_metadata_due_to_new_tip( trans.request.host,
+ content_alert_str=content_alert_str,
+ **kwd )
+ if error_message:
+ ok = False
+ trans.response.status = 500
+ message = error_message
+ else:
+ trans.response.status = 500
+
+ if not ok:
+ return {
+ "err_msg": message,
+ "content_alert": content_alert_str
+ }
+ else:
+ return {
+ "message": message,
+ "content_alert": content_alert_str
+ }
diff -r 42cd5d55755a729dd2f19ccd1ed20649ed29f6ac -r d6059c7194effc68dbfae4a459bd456c82fe8478 lib/galaxy/webapps/tool_shed/buildapp.py
--- a/lib/galaxy/webapps/tool_shed/buildapp.py
+++ b/lib/galaxy/webapps/tool_shed/buildapp.py
@@ -119,6 +119,12 @@
name_prefix='user_',
path_prefix='/api',
parent_resources=dict( member_name='user', collection_name='users' ) )
+ webapp.mapper.connect( 'repository_create_changeset_revision',
+ '/api/repositories/:id/changeset_revision',
+ controller='repositories',
+ action='create_changeset_revision',
+ conditions=dict( method=[ "POST" ] ) )
+
webapp.finalize_config()
# Wrap the webapp in some useful middleware
if kwargs.get( 'middleware', True ):
diff -r 42cd5d55755a729dd2f19ccd1ed20649ed29f6ac -r d6059c7194effc68dbfae4a459bd456c82fe8478 lib/galaxy/webapps/tool_shed/controllers/upload.py
--- a/lib/galaxy/webapps/tool_shed/controllers/upload.py
+++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py
@@ -20,6 +20,7 @@
from tool_shed.util import commit_util
from tool_shed.util import hg_util
from tool_shed.util import shed_util_common as suc
+from tool_shed.util import repository_content_util
from tool_shed.util import xml_util
from galaxy import eggs
@@ -129,16 +130,18 @@
istar = False
if istar:
ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
- self.upload_tar( trans,
- rdah,
- tdah,
- repository,
- tar,
- uploaded_file,
- upload_point,
- remove_repo_files_not_in_tar,
- commit_message,
- new_repo_alert )
+ repository_content_util.upload_tar(
+ trans,
+ rdah,
+ tdah,
+ repository,
+ tar,
+ uploaded_file,
+ upload_point,
+ remove_repo_files_not_in_tar,
+ commit_message,
+ new_repo_alert
+ )
elif uploaded_directory:
ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
self.upload_directory( trans,
@@ -407,69 +410,3 @@
commit_message,
undesirable_dirs_removed,
undesirable_files_removed )
-
- def upload_tar( self, trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar,
- commit_message, new_repo_alert ):
- # Upload a tar archive of files.
- repo_dir = repository.repo_path( trans.app )
- repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
- undesirable_dirs_removed = 0
- undesirable_files_removed = 0
- ok, message = commit_util.check_archive( repository, tar )
- if not ok:
- tar.close()
- uploaded_file.close()
- return ok, message, [], '', undesirable_dirs_removed, undesirable_files_removed
- else:
- if upload_point is not None:
- full_path = os.path.abspath( os.path.join( repo_dir, upload_point ) )
- else:
- full_path = os.path.abspath( repo_dir )
- filenames_in_archive = []
- for tarinfo_obj in tar.getmembers():
- ok = os.path.basename( tarinfo_obj.name ) not in commit_util.UNDESIRABLE_FILES
- if ok:
- for file_path_item in tarinfo_obj.name.split( '/' ):
- if file_path_item in commit_util.UNDESIRABLE_DIRS:
- undesirable_dirs_removed += 1
- ok = False
- break
- else:
- undesirable_files_removed += 1
- if ok:
- filenames_in_archive.append( tarinfo_obj.name )
- # Extract the uploaded tar to the load_point within the repository hierarchy.
- tar.extractall( path=full_path )
- tar.close()
- uploaded_file.close()
- for filename in filenames_in_archive:
- uploaded_file_name = os.path.join( full_path, filename )
- if os.path.split( uploaded_file_name )[ -1 ] == rt_util.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
- # Inspect the contents of the file to see if toolshed or changeset_revision attributes
- # are missing and if so, set them appropriately.
- altered, root_elem, error_message = rdah.handle_tag_attributes( uploaded_file_name )
- if error_message:
- return False, error_message, [], '', [], []
- elif altered:
- tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
- shutil.move( tmp_filename, uploaded_file_name )
- elif os.path.split( uploaded_file_name )[ -1 ] == rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME:
- # Inspect the contents of the file to see if toolshed or changeset_revision
- # attributes are missing and if so, set them appropriately.
- altered, root_elem, error_message = tdah.handle_tag_attributes( uploaded_file_name )
- if error_message:
- return False, error_message, [], '', [], []
- if altered:
- tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
- shutil.move( tmp_filename, uploaded_file_name )
- return commit_util.handle_directory_changes( trans.app,
- trans.request.host,
- trans.user.username,
- repository,
- full_path,
- filenames_in_archive,
- remove_repo_files_not_in_tar,
- new_repo_alert,
- commit_message,
- undesirable_dirs_removed,
- undesirable_files_removed )
diff -r 42cd5d55755a729dd2f19ccd1ed20649ed29f6ac -r d6059c7194effc68dbfae4a459bd456c82fe8478 lib/tool_shed/util/repository_content_util.py
--- /dev/null
+++ b/lib/tool_shed/util/repository_content_util.py
@@ -0,0 +1,75 @@
+import os
+import shutil
+
+from tool_shed.util import commit_util
+from tool_shed.util import hg_util
+from tool_shed.util import xml_util
+
+import tool_shed.repository_types.util as rt_util
+
+
+def upload_tar( trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar,
+ commit_message, new_repo_alert ):
+ # Upload a tar archive of files.
+ repo_dir = repository.repo_path( trans.app )
+ hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
+ undesirable_dirs_removed = 0
+ undesirable_files_removed = 0
+ ok, message = commit_util.check_archive( repository, tar )
+ if not ok:
+ tar.close()
+ uploaded_file.close()
+ return ok, message, [], '', undesirable_dirs_removed, undesirable_files_removed
+ else:
+ if upload_point is not None:
+ full_path = os.path.abspath( os.path.join( repo_dir, upload_point ) )
+ else:
+ full_path = os.path.abspath( repo_dir )
+ filenames_in_archive = []
+ for tarinfo_obj in tar.getmembers():
+ ok = os.path.basename( tarinfo_obj.name ) not in commit_util.UNDESIRABLE_FILES
+ if ok:
+ for file_path_item in tarinfo_obj.name.split( '/' ):
+ if file_path_item in commit_util.UNDESIRABLE_DIRS:
+ undesirable_dirs_removed += 1
+ ok = False
+ break
+ else:
+ undesirable_files_removed += 1
+ if ok:
+ filenames_in_archive.append( tarinfo_obj.name )
+ # Extract the uploaded tar to the load_point within the repository hierarchy.
+ tar.extractall( path=full_path )
+ tar.close()
+ uploaded_file.close()
+ for filename in filenames_in_archive:
+ uploaded_file_name = os.path.join( full_path, filename )
+ if os.path.split( uploaded_file_name )[ -1 ] == rt_util.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
+ # Inspect the contents of the file to see if toolshed or changeset_revision attributes
+ # are missing and if so, set them appropriately.
+ altered, root_elem, error_message = rdah.handle_tag_attributes( uploaded_file_name )
+ if error_message:
+ return False, error_message, [], '', [], []
+ elif altered:
+ tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
+ shutil.move( tmp_filename, uploaded_file_name )
+ elif os.path.split( uploaded_file_name )[ -1 ] == rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME:
+ # Inspect the contents of the file to see if toolshed or changeset_revision
+ # attributes are missing and if so, set them appropriately.
+ altered, root_elem, error_message = tdah.handle_tag_attributes( uploaded_file_name )
+ if error_message:
+ return False, error_message, [], '', [], []
+ if altered:
+ tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
+ shutil.move( tmp_filename, uploaded_file_name )
+ return commit_util.handle_directory_changes( trans.app,
+ trans.request.host,
+ trans.user.username,
+ repository,
+ full_path,
+ filenames_in_archive,
+ remove_repo_files_not_in_tar,
+ new_repo_alert,
+ commit_message,
+ undesirable_dirs_removed,
+ undesirable_files_removed )
https://bitbucket.org/galaxy/galaxy-central/commits/7d8d1396b7ca/
Changeset: 7d8d1396b7ca
User: jmchilton
Date: 2014-10-15 19:27:23+00:00
Summary: Fixes to tool shed tar upload API enhancement.
Thanks to Bjoern and Dannon for the comments.
Affected #: 2 files
diff -r d6059c7194effc68dbfae4a459bd456c82fe8478 -r 7d8d1396b7cad129e9d89677a8c10d5bc9b2f1f4 lib/galaxy/tools/actions/upload_common.py
--- a/lib/galaxy/tools/actions/upload_common.py
+++ b/lib/galaxy/tools/actions/upload_common.py
@@ -30,7 +30,7 @@
f.file.close()
upload_dataset['file_data'] = dict( filename=f.filename,
local_filename=local_filename )
- elif type( f ) == dict and 'filename' and 'local_filename' not in f:
+ elif type( f ) == dict and 'local_filename' not in f:
raise Exception( 'Uploaded file was encoded in a way not understood by Galaxy.' )
if upload_dataset['url_paste'] and upload_dataset['url_paste'].strip() != '':
upload_dataset['url_paste'], is_multi_byte = datatypes.sniff.stream_to_file( StringIO.StringIO( upload_dataset['url_paste'] ), prefix="strio_url_paste_" )
diff -r d6059c7194effc68dbfae4a459bd456c82fe8478 -r 7d8d1396b7cad129e9d89677a8c10d5bc9b2f1f4 lib/galaxy/webapps/tool_shed/api/repositories.py
--- a/lib/galaxy/webapps/tool_shed/api/repositories.py
+++ b/lib/galaxy/webapps/tool_shed/api/repositories.py
@@ -613,7 +613,7 @@
file_data.file.close()
file_data = dict( filename=file_data.filename,
local_filename=local_filename )
- elif type( file_data ) == dict and 'filename' and 'local_filename' not in file_data:
+ elif type( file_data ) == dict and 'local_filename' not in file_data:
raise Exception( 'Uploaded file was encoded in a way not understood.' )
commit_message = kwd.get( 'commit_message', 'Uploaded' )
@@ -621,7 +621,6 @@
uploaded_file = open(file_data['local_filename'], 'rb')
uploaded_file_name = file_data['local_filename']
- ok = True
isgzip = False
isbz2 = False
isgzip = checkers.is_gzip( uploaded_file_name )
https://bitbucket.org/galaxy/galaxy-central/commits/d94ef8154c63/
Changeset: d94ef8154c63
User: dannon
Date: 2014-10-15 20:30:56+00:00
Summary: Merged in jmchilton/galaxy-central-fork-1 (pull request #530)
Implement creating tool shed repository revisions via API tarball upload.
Affected #: 5 files
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/tools/actions/upload_common.py
--- a/lib/galaxy/tools/actions/upload_common.py
+++ b/lib/galaxy/tools/actions/upload_common.py
@@ -30,7 +30,7 @@
f.file.close()
upload_dataset['file_data'] = dict( filename=f.filename,
local_filename=local_filename )
- elif type( f ) == dict and 'filename' and 'local_filename' not in f:
+ elif type( f ) == dict and 'local_filename' not in f:
raise Exception( 'Uploaded file was encoded in a way not understood by Galaxy.' )
if upload_dataset['url_paste'] and upload_dataset['url_paste'].strip() != '':
upload_dataset['url_paste'], is_multi_byte = datatypes.sniff.stream_to_file( StringIO.StringIO( upload_dataset['url_paste'] ), prefix="strio_url_paste_" )
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/webapps/tool_shed/api/repositories.py
--- a/lib/galaxy/webapps/tool_shed/api/repositories.py
+++ b/lib/galaxy/webapps/tool_shed/api/repositories.py
@@ -2,11 +2,15 @@
import logging
import os
import tarfile
+import StringIO
import tempfile
from time import strftime
+from cgi import FieldStorage
+
from galaxy import util
from galaxy import web
+from galaxy.datatypes import checkers
from galaxy.model.orm import and_
from galaxy.web.base.controller import BaseAPIController
from galaxy.web.base.controller import HTTPBadRequest
@@ -16,10 +20,14 @@
from tool_shed.metadata import repository_metadata_manager
from tool_shed.repository_types import util as rt_util
+from tool_shed.dependencies import attribute_handlers
+
from tool_shed.util import basic_util
+from tool_shed.util import commit_util
from tool_shed.util import encoding_util
from tool_shed.util import hg_util
from tool_shed.util import repository_util
+from tool_shed.util import repository_content_util
from tool_shed.util import shed_util_common as suc
from tool_shed.util import tool_util
@@ -568,3 +576,108 @@
action='show',
id=trans.security.encode_id( repository.id ) )
return repository_dict
+
+ @web.expose_api
+ def create_changeset_revision( self, trans, id, payload, **kwd ):
+ """
+ POST /api/repositories/{encoded_repository_id}/changeset_revision
+
+ Create a new tool shed repository commit - leaving PUT on parent
+ resource open for updating meta-attirbutes of the repository (and
+ Galaxy doesn't allow PUT multipart data anyway
+ https://trello.com/c/CQwmCeG6)
+
+ :param id: the encoded id of the Repository object
+
+ The following parameters may be included in the payload.
+ :param commit_message: hg commit message for update.
+ """
+
+ # Example URL: http://localhost:9009/api/repositories/f9cad7b01a472135
+ rdah = attribute_handlers.RepositoryDependencyAttributeHandler( trans.app, unpopulate=False )
+ tdah = attribute_handlers.ToolDependencyAttributeHandler( trans.app, unpopulate=False )
+
+ repository = suc.get_repository_in_tool_shed( trans.app, id )
+ repo_dir = repository.repo_path( trans.app )
+ repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
+
+ upload_point = commit_util.get_upload_point( repository, **kwd )
+ tip = repository.tip( trans.app )
+
+ file_data = payload.get('file')
+ # Code stolen from gx's upload_common.py
+ if isinstance( file_data, FieldStorage ):
+ assert not isinstance( file_data.file, StringIO.StringIO )
+ assert file_data.file.name != '<fdopen>'
+ local_filename = util.mkstemp_ln( file_data.file.name, 'upload_file_data_' )
+ file_data.file.close()
+ file_data = dict( filename=file_data.filename,
+ local_filename=local_filename )
+ elif type( file_data ) == dict and 'local_filename' not in file_data:
+ raise Exception( 'Uploaded file was encoded in a way not understood.' )
+
+ commit_message = kwd.get( 'commit_message', 'Uploaded' )
+
+ uploaded_file = open(file_data['local_filename'], 'rb')
+ uploaded_file_name = file_data['local_filename']
+
+ isgzip = False
+ isbz2 = False
+ isgzip = checkers.is_gzip( uploaded_file_name )
+ if not isgzip:
+ isbz2 = checkers.is_bz2( uploaded_file_name )
+ if ( isgzip or isbz2 ):
+ # Open for reading with transparent compression.
+ tar = tarfile.open( uploaded_file_name, 'r:*' )
+ else:
+ tar = tarfile.open( uploaded_file_name )
+
+ new_repo_alert = False
+ remove_repo_files_not_in_tar = True
+
+ ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
+ repository_content_util.upload_tar(
+ trans,
+ rdah,
+ tdah,
+ repository,
+ tar,
+ uploaded_file,
+ upload_point,
+ remove_repo_files_not_in_tar,
+ commit_message,
+ new_repo_alert
+ )
+ if ok:
+ # Update the repository files for browsing.
+ hg_util.update_repository( repo )
+ # Get the new repository tip.
+ if tip == repository.tip( trans.app ):
+ trans.response.status = 400
+ message = 'No changes to repository.'
+ ok = False
+ else:
+ rmm = repository_metadata_manager.RepositoryMetadataManager( app=trans.app,
+ user=trans.user,
+ repository=repository )
+ status, error_message = \
+ rmm.set_repository_metadata_due_to_new_tip( trans.request.host,
+ content_alert_str=content_alert_str,
+ **kwd )
+ if error_message:
+ ok = False
+ trans.response.status = 500
+ message = error_message
+ else:
+ trans.response.status = 500
+
+ if not ok:
+ return {
+ "err_msg": message,
+ "content_alert": content_alert_str
+ }
+ else:
+ return {
+ "message": message,
+ "content_alert": content_alert_str
+ }
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/webapps/tool_shed/buildapp.py
--- a/lib/galaxy/webapps/tool_shed/buildapp.py
+++ b/lib/galaxy/webapps/tool_shed/buildapp.py
@@ -119,6 +119,12 @@
name_prefix='user_',
path_prefix='/api',
parent_resources=dict( member_name='user', collection_name='users' ) )
+ webapp.mapper.connect( 'repository_create_changeset_revision',
+ '/api/repositories/:id/changeset_revision',
+ controller='repositories',
+ action='create_changeset_revision',
+ conditions=dict( method=[ "POST" ] ) )
+
webapp.finalize_config()
# Wrap the webapp in some useful middleware
if kwargs.get( 'middleware', True ):
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/galaxy/webapps/tool_shed/controllers/upload.py
--- a/lib/galaxy/webapps/tool_shed/controllers/upload.py
+++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py
@@ -20,6 +20,7 @@
from tool_shed.util import commit_util
from tool_shed.util import hg_util
from tool_shed.util import shed_util_common as suc
+from tool_shed.util import repository_content_util
from tool_shed.util import xml_util
from galaxy import eggs
@@ -129,16 +130,18 @@
istar = False
if istar:
ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
- self.upload_tar( trans,
- rdah,
- tdah,
- repository,
- tar,
- uploaded_file,
- upload_point,
- remove_repo_files_not_in_tar,
- commit_message,
- new_repo_alert )
+ repository_content_util.upload_tar(
+ trans,
+ rdah,
+ tdah,
+ repository,
+ tar,
+ uploaded_file,
+ upload_point,
+ remove_repo_files_not_in_tar,
+ commit_message,
+ new_repo_alert
+ )
elif uploaded_directory:
ok, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed = \
self.upload_directory( trans,
@@ -407,69 +410,3 @@
commit_message,
undesirable_dirs_removed,
undesirable_files_removed )
-
- def upload_tar( self, trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar,
- commit_message, new_repo_alert ):
- # Upload a tar archive of files.
- repo_dir = repository.repo_path( trans.app )
- repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
- undesirable_dirs_removed = 0
- undesirable_files_removed = 0
- ok, message = commit_util.check_archive( repository, tar )
- if not ok:
- tar.close()
- uploaded_file.close()
- return ok, message, [], '', undesirable_dirs_removed, undesirable_files_removed
- else:
- if upload_point is not None:
- full_path = os.path.abspath( os.path.join( repo_dir, upload_point ) )
- else:
- full_path = os.path.abspath( repo_dir )
- filenames_in_archive = []
- for tarinfo_obj in tar.getmembers():
- ok = os.path.basename( tarinfo_obj.name ) not in commit_util.UNDESIRABLE_FILES
- if ok:
- for file_path_item in tarinfo_obj.name.split( '/' ):
- if file_path_item in commit_util.UNDESIRABLE_DIRS:
- undesirable_dirs_removed += 1
- ok = False
- break
- else:
- undesirable_files_removed += 1
- if ok:
- filenames_in_archive.append( tarinfo_obj.name )
- # Extract the uploaded tar to the load_point within the repository hierarchy.
- tar.extractall( path=full_path )
- tar.close()
- uploaded_file.close()
- for filename in filenames_in_archive:
- uploaded_file_name = os.path.join( full_path, filename )
- if os.path.split( uploaded_file_name )[ -1 ] == rt_util.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
- # Inspect the contents of the file to see if toolshed or changeset_revision attributes
- # are missing and if so, set them appropriately.
- altered, root_elem, error_message = rdah.handle_tag_attributes( uploaded_file_name )
- if error_message:
- return False, error_message, [], '', [], []
- elif altered:
- tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
- shutil.move( tmp_filename, uploaded_file_name )
- elif os.path.split( uploaded_file_name )[ -1 ] == rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME:
- # Inspect the contents of the file to see if toolshed or changeset_revision
- # attributes are missing and if so, set them appropriately.
- altered, root_elem, error_message = tdah.handle_tag_attributes( uploaded_file_name )
- if error_message:
- return False, error_message, [], '', [], []
- if altered:
- tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
- shutil.move( tmp_filename, uploaded_file_name )
- return commit_util.handle_directory_changes( trans.app,
- trans.request.host,
- trans.user.username,
- repository,
- full_path,
- filenames_in_archive,
- remove_repo_files_not_in_tar,
- new_repo_alert,
- commit_message,
- undesirable_dirs_removed,
- undesirable_files_removed )
diff -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 -r d94ef8154c63145b0e2928b099017324097d4352 lib/tool_shed/util/repository_content_util.py
--- /dev/null
+++ b/lib/tool_shed/util/repository_content_util.py
@@ -0,0 +1,75 @@
+import os
+import shutil
+
+from tool_shed.util import commit_util
+from tool_shed.util import hg_util
+from tool_shed.util import xml_util
+
+import tool_shed.repository_types.util as rt_util
+
+
+def upload_tar( trans, rdah, tdah, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar,
+ commit_message, new_repo_alert ):
+ # Upload a tar archive of files.
+ repo_dir = repository.repo_path( trans.app )
+ hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
+ undesirable_dirs_removed = 0
+ undesirable_files_removed = 0
+ ok, message = commit_util.check_archive( repository, tar )
+ if not ok:
+ tar.close()
+ uploaded_file.close()
+ return ok, message, [], '', undesirable_dirs_removed, undesirable_files_removed
+ else:
+ if upload_point is not None:
+ full_path = os.path.abspath( os.path.join( repo_dir, upload_point ) )
+ else:
+ full_path = os.path.abspath( repo_dir )
+ filenames_in_archive = []
+ for tarinfo_obj in tar.getmembers():
+ ok = os.path.basename( tarinfo_obj.name ) not in commit_util.UNDESIRABLE_FILES
+ if ok:
+ for file_path_item in tarinfo_obj.name.split( '/' ):
+ if file_path_item in commit_util.UNDESIRABLE_DIRS:
+ undesirable_dirs_removed += 1
+ ok = False
+ break
+ else:
+ undesirable_files_removed += 1
+ if ok:
+ filenames_in_archive.append( tarinfo_obj.name )
+ # Extract the uploaded tar to the load_point within the repository hierarchy.
+ tar.extractall( path=full_path )
+ tar.close()
+ uploaded_file.close()
+ for filename in filenames_in_archive:
+ uploaded_file_name = os.path.join( full_path, filename )
+ if os.path.split( uploaded_file_name )[ -1 ] == rt_util.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME:
+ # Inspect the contents of the file to see if toolshed or changeset_revision attributes
+ # are missing and if so, set them appropriately.
+ altered, root_elem, error_message = rdah.handle_tag_attributes( uploaded_file_name )
+ if error_message:
+ return False, error_message, [], '', [], []
+ elif altered:
+ tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
+ shutil.move( tmp_filename, uploaded_file_name )
+ elif os.path.split( uploaded_file_name )[ -1 ] == rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME:
+ # Inspect the contents of the file to see if toolshed or changeset_revision
+ # attributes are missing and if so, set them appropriately.
+ altered, root_elem, error_message = tdah.handle_tag_attributes( uploaded_file_name )
+ if error_message:
+ return False, error_message, [], '', [], []
+ if altered:
+ tmp_filename = xml_util.create_and_write_tmp_file( root_elem )
+ shutil.move( tmp_filename, uploaded_file_name )
+ return commit_util.handle_directory_changes( trans.app,
+ trans.request.host,
+ trans.user.username,
+ repository,
+ full_path,
+ filenames_in_archive,
+ remove_repo_files_not_in_tar,
+ new_repo_alert,
+ commit_message,
+ undesirable_dirs_removed,
+ undesirable_files_removed )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: carlfeberhard: History structure: found a way to sync SVG and DOM when expanding/collapsing jobs and datasets in the vertical layout
by commits-noreply@bitbucket.org 15 Oct '14
by commits-noreply@bitbucket.org 15 Oct '14
15 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/9728fcd5167c/
Changeset: 9728fcd5167c
User: carlfeberhard
Date: 2014-10-15 20:21:51+00:00
Summary: History structure: found a way to sync SVG and DOM when expanding/collapsing jobs and datasets in the vertical layout
Affected #: 9 files
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 client/galaxy/scripts/mvc/history/history-structure-view.js
--- a/client/galaxy/scripts/mvc/history/history-structure-view.js
+++ b/client/galaxy/scripts/mvc/history/history-structure-view.js
@@ -52,14 +52,22 @@
//this.debug( job.outputCollection );
// create the bbone view for the job (to be positioned later accrd. to the layout) and cache
- var li = new JOB_LI.JobListItemView({ model: job, expanded: true });
+ var li = new JOB_LI.JobListItemView({ model: job });
//var li = new JOB_LI.JobListItemView({ model: job });
- li.$el.appendTo( view.$el );
+ li.render( 0 ).$el.appendTo( view.$el );
view._jobLiMap[ job.id ] = li;
+ view._setUpJobListeners( li );
+
});
return view.jobs;
},
+ _setUpJobListeners : function( jobLi ){
+ // update the layout during expansion and collapsing of job and output li's
+ jobLi.on( 'expanding expanded collapsing collapsed', this.render, this );
+ jobLi.foldout.on( 'view:expanding view:expanded view:collapsing view:collapsed', this.render, this );
+ },
+
layoutDefaults : {
paddingTop : 8,
paddingLeft : 20,
@@ -131,32 +139,32 @@
},
render : function( options ){
- this.log( this + '.renderComponent:', options );
+ this.debug( this + '.render:', options );
var view = this;
- view.component.eachVertex( function( v ){
- //TODO:? liMap needed - can't we attach to vertex?
- var li = view._jobLiMap[ v.name ];
- if( !li.$el.is( ':visible' ) ){
- li.render( 0 );
- }
- });
+ function _render(){
+ view._updateLayout();
+ // set up the display containers
+ view.$el
+ .width( view.layout.el.width )
+ .height( view.layout.el.height );
+ view.renderSVG();
- view._updateLayout();
- // set up the display containers
- view.$el
- .width( view.layout.el.width )
- .height( view.layout.el.height );
- this.renderSVG();
-
- // position the job views accrd. to the layout
- view.component.eachVertex( function( v ){
- //TODO:? liMap needed - can't we attach to vertex?
- var li = view._jobLiMap[ v.name ],
- position = view.layout.nodeMap[ li.model.id ];
- //this.debug( position );
- li.$el.css({ top: position.y, left: position.x });
- });
+ // position the job views accrd. to the layout
+ view.component.eachVertex( function( v ){
+//TODO:? liMap needed - can't we attach to vertex?
+ var li = view._jobLiMap[ v.name ],
+ position = view.layout.nodeMap[ li.model.id ];
+ //this.debug( position );
+ li.$el.css({ top: position.y, left: position.x });
+ });
+ }
+//TODO: hack - li's invisible in updateLayout without this delay
+ if( !this.$el.is( ':visible' ) ){
+ _.delay( _render, 0 );
+ } else {
+ _render();
+ }
return this;
},
@@ -195,7 +203,7 @@
.on( 'mouseover', highlightConnect )
.on( 'mouseout', unhighlightConnect );
- connections.transition()
+ connections
.attr( 'd', function( d ){ return view._connectionPath( d ); });
//TODO: ? can we use tick here to update the links?
@@ -256,7 +264,7 @@
*/
var VerticalHistoryStructureComponent = HistoryStructureComponent.extend({
- logger : console,
+ //logger : console,
className : HistoryStructureComponent.prototype.className + ' vertical',
@@ -376,8 +384,8 @@
_createComponent : function( component ){
this.log( this + '._createComponent:', component );
- return new HistoryStructureComponent({
- //return new VerticalHistoryStructureComponent({
+ //return new HistoryStructureComponent({
+ return new VerticalHistoryStructureComponent({
model : this.model,
component : component
});
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 client/galaxy/scripts/mvc/job/job-li.js
--- a/client/galaxy/scripts/mvc/job/job-li.js
+++ b/client/galaxy/scripts/mvc/job/job-li.js
@@ -30,7 +30,6 @@
/** where should pages from links be displayed? (default to new tab/window) */
this.linkTarget = attributes.linkTarget || '_blank';
- this._setUpListeners();
},
/** In this override, add the state as a class for use with state-based CSS */
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 client/galaxy/scripts/mvc/list/list-item.js
--- a/client/galaxy/scripts/mvc/list/list-item.js
+++ b/client/galaxy/scripts/mvc/list/list-item.js
@@ -17,7 +17,7 @@
/** are the details of this view expanded/shown or not? */
this.expanded = attributes.expanded || false;
this.log( '\t expanded:', this.expanded );
- this.fxSpeed = attributes.fxSpeed || this.fxSpeed;
+ this.fxSpeed = attributes.fxSpeed !== undefined? attributes.fxSpeed : this.fxSpeed;
},
// ........................................................................ render main
@@ -119,15 +119,8 @@
*/
expand : function(){
var view = this;
- return view._fetchModelDetails()
- .always(function(){
- var $newDetails = view._renderDetails();
- view.$details().replaceWith( $newDetails );
- // needs to be set after the above or the slide will not show
- view.expanded = true;
- view.$details().slideDown( view.fxSpeed, function(){
- view.trigger( 'expanded', view );
- });
+ return view._fetchModelDetails().always( function(){
+ view._expand();
});
},
@@ -141,6 +134,24 @@
return jQuery.when();
},
+ /** Inner fn called when expand (public) has fetched the details */
+ _expand : function(){
+ var view = this,
+ $newDetails = view._renderDetails();
+ view.$details().replaceWith( $newDetails );
+ // needs to be set after the above or the slide will not show
+ view.expanded = true;
+ view.$details().slideDown({
+ duration : view.fxSpeed,
+ step: function(){
+ view.trigger( 'expanding', view );
+ },
+ complete: function(){
+ view.trigger( 'expanded', view );
+ }
+ });
+ },
+
/** Hide the body/details of an HDA.
* @fires collapsed when a body has been collapsed
*/
@@ -148,8 +159,14 @@
this.debug( this + '(ExpandableView).collapse' );
var view = this;
view.expanded = false;
- this.$details().slideUp( view.fxSpeed, function(){
- view.trigger( 'collapsed', view );
+ this.$details().slideUp({
+ duration : view.fxSpeed,
+ step: function(){
+ view.trigger( 'collapsing', view );
+ },
+ complete: function(){
+ view.trigger( 'collapsed', view );
+ }
});
}
@@ -377,11 +394,13 @@
* disrespect attributes.expanded if drilldown
*/
initialize : function( attributes ){
- ListItemView.prototype.initialize.call( this, attributes );
//TODO: hackish
if( this.foldoutStyle === 'drilldown' ){ this.expanded = false; }
this.foldoutStyle = attributes.foldoutStyle || this.foldoutStyle;
this.foldoutPanelClass = attributes.foldoutPanelClass || this.foldoutPanelClass;
+
+ ListItemView.prototype.initialize.call( this, attributes );
+ this.foldout = this._createFoldoutPanel();
},
//TODO:?? override to exclude foldout scope?
@@ -395,7 +414,7 @@
//TODO: hackish
if( this.foldoutStyle === 'drilldown' ){ return $(); }
var $newDetails = ListItemView.prototype._renderDetails.call( this );
- return this._attachFoldout( this._createFoldoutPanel(), $newDetails );
+ return this._attachFoldout( this.foldout, $newDetails );
},
/** In this override, handle collection expansion. */
@@ -419,7 +438,8 @@
_getFoldoutPanelOptions : function(){
return {
// propagate foldout style down
- foldoutStyle : this.foldoutStyle
+ foldoutStyle : this.foldoutStyle,
+ fxSpeed : this.fxSpeed
};
},
@@ -438,25 +458,13 @@
return view._fetchModelDetails()
.always(function(){
if( view.foldoutStyle === 'foldout' ){
- view._expandByFoldout();
+ view._expand();
} else if( view.foldoutStyle === 'drilldown' ){
view._expandByDrilldown();
}
});
},
- /** For foldout, call render details then slide down */
- _expandByFoldout : function(){
- var view = this;
- var $newDetails = view._renderDetails();
- view.$details().replaceWith( $newDetails );
- // needs to be set after the above or the slide will not show
- view.expanded = true;
- view.$details().slideDown( view.fxSpeed, function(){
- view.trigger( 'expanded', view );
- });
- },
-
/** For drilldown, set up close handler and fire expanded:drilldown
* containing views can listen to this and handle other things
* (like hiding themselves) by listening for expanded/collapsed:drilldown
@@ -464,7 +472,6 @@
_expandByDrilldown : function(){
var view = this;
// attachment and rendering done by listener
- view.foldout = this._createFoldoutPanel();
view.foldout.on( 'close', function(){
view.trigger( 'collapsed:drilldown', view, view.foldout );
});
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 static/scripts/mvc/history/history-structure-view.js
--- a/static/scripts/mvc/history/history-structure-view.js
+++ b/static/scripts/mvc/history/history-structure-view.js
@@ -52,14 +52,22 @@
//this.debug( job.outputCollection );
// create the bbone view for the job (to be positioned later accrd. to the layout) and cache
- var li = new JOB_LI.JobListItemView({ model: job, expanded: true });
+ var li = new JOB_LI.JobListItemView({ model: job });
//var li = new JOB_LI.JobListItemView({ model: job });
- li.$el.appendTo( view.$el );
+ li.render( 0 ).$el.appendTo( view.$el );
view._jobLiMap[ job.id ] = li;
+ view._setUpJobListeners( li );
+
});
return view.jobs;
},
+ _setUpJobListeners : function( jobLi ){
+ // update the layout during expansion and collapsing of job and output li's
+ jobLi.on( 'expanding expanded collapsing collapsed', this.render, this );
+ jobLi.foldout.on( 'view:expanding view:expanded view:collapsing view:collapsed', this.render, this );
+ },
+
layoutDefaults : {
paddingTop : 8,
paddingLeft : 20,
@@ -131,32 +139,32 @@
},
render : function( options ){
- this.log( this + '.renderComponent:', options );
+ this.debug( this + '.render:', options );
var view = this;
- view.component.eachVertex( function( v ){
- //TODO:? liMap needed - can't we attach to vertex?
- var li = view._jobLiMap[ v.name ];
- if( !li.$el.is( ':visible' ) ){
- li.render( 0 );
- }
- });
+ function _render(){
+ view._updateLayout();
+ // set up the display containers
+ view.$el
+ .width( view.layout.el.width )
+ .height( view.layout.el.height );
+ view.renderSVG();
- view._updateLayout();
- // set up the display containers
- view.$el
- .width( view.layout.el.width )
- .height( view.layout.el.height );
- this.renderSVG();
-
- // position the job views accrd. to the layout
- view.component.eachVertex( function( v ){
- //TODO:? liMap needed - can't we attach to vertex?
- var li = view._jobLiMap[ v.name ],
- position = view.layout.nodeMap[ li.model.id ];
- //this.debug( position );
- li.$el.css({ top: position.y, left: position.x });
- });
+ // position the job views accrd. to the layout
+ view.component.eachVertex( function( v ){
+//TODO:? liMap needed - can't we attach to vertex?
+ var li = view._jobLiMap[ v.name ],
+ position = view.layout.nodeMap[ li.model.id ];
+ //this.debug( position );
+ li.$el.css({ top: position.y, left: position.x });
+ });
+ }
+//TODO: hack - li's invisible in updateLayout without this delay
+ if( !this.$el.is( ':visible' ) ){
+ _.delay( _render, 0 );
+ } else {
+ _render();
+ }
return this;
},
@@ -195,7 +203,7 @@
.on( 'mouseover', highlightConnect )
.on( 'mouseout', unhighlightConnect );
- connections.transition()
+ connections
.attr( 'd', function( d ){ return view._connectionPath( d ); });
//TODO: ? can we use tick here to update the links?
@@ -256,7 +264,7 @@
*/
var VerticalHistoryStructureComponent = HistoryStructureComponent.extend({
- logger : console,
+ //logger : console,
className : HistoryStructureComponent.prototype.className + ' vertical',
@@ -376,8 +384,8 @@
_createComponent : function( component ){
this.log( this + '._createComponent:', component );
- return new HistoryStructureComponent({
- //return new VerticalHistoryStructureComponent({
+ //return new HistoryStructureComponent({
+ return new VerticalHistoryStructureComponent({
model : this.model,
component : component
});
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 static/scripts/mvc/job/job-li.js
--- a/static/scripts/mvc/job/job-li.js
+++ b/static/scripts/mvc/job/job-li.js
@@ -30,7 +30,6 @@
/** where should pages from links be displayed? (default to new tab/window) */
this.linkTarget = attributes.linkTarget || '_blank';
- this._setUpListeners();
},
/** In this override, add the state as a class for use with state-based CSS */
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 static/scripts/mvc/list/list-item.js
--- a/static/scripts/mvc/list/list-item.js
+++ b/static/scripts/mvc/list/list-item.js
@@ -17,7 +17,7 @@
/** are the details of this view expanded/shown or not? */
this.expanded = attributes.expanded || false;
this.log( '\t expanded:', this.expanded );
- this.fxSpeed = attributes.fxSpeed || this.fxSpeed;
+ this.fxSpeed = attributes.fxSpeed !== undefined? attributes.fxSpeed : this.fxSpeed;
},
// ........................................................................ render main
@@ -119,15 +119,8 @@
*/
expand : function(){
var view = this;
- return view._fetchModelDetails()
- .always(function(){
- var $newDetails = view._renderDetails();
- view.$details().replaceWith( $newDetails );
- // needs to be set after the above or the slide will not show
- view.expanded = true;
- view.$details().slideDown( view.fxSpeed, function(){
- view.trigger( 'expanded', view );
- });
+ return view._fetchModelDetails().always( function(){
+ view._expand();
});
},
@@ -141,6 +134,24 @@
return jQuery.when();
},
+ /** Inner fn called when expand (public) has fetched the details */
+ _expand : function(){
+ var view = this,
+ $newDetails = view._renderDetails();
+ view.$details().replaceWith( $newDetails );
+ // needs to be set after the above or the slide will not show
+ view.expanded = true;
+ view.$details().slideDown({
+ duration : view.fxSpeed,
+ step: function(){
+ view.trigger( 'expanding', view );
+ },
+ complete: function(){
+ view.trigger( 'expanded', view );
+ }
+ });
+ },
+
/** Hide the body/details of an HDA.
* @fires collapsed when a body has been collapsed
*/
@@ -148,8 +159,14 @@
this.debug( this + '(ExpandableView).collapse' );
var view = this;
view.expanded = false;
- this.$details().slideUp( view.fxSpeed, function(){
- view.trigger( 'collapsed', view );
+ this.$details().slideUp({
+ duration : view.fxSpeed,
+ step: function(){
+ view.trigger( 'collapsing', view );
+ },
+ complete: function(){
+ view.trigger( 'collapsed', view );
+ }
});
}
@@ -377,11 +394,13 @@
* disrespect attributes.expanded if drilldown
*/
initialize : function( attributes ){
- ListItemView.prototype.initialize.call( this, attributes );
//TODO: hackish
if( this.foldoutStyle === 'drilldown' ){ this.expanded = false; }
this.foldoutStyle = attributes.foldoutStyle || this.foldoutStyle;
this.foldoutPanelClass = attributes.foldoutPanelClass || this.foldoutPanelClass;
+
+ ListItemView.prototype.initialize.call( this, attributes );
+ this.foldout = this._createFoldoutPanel();
},
//TODO:?? override to exclude foldout scope?
@@ -395,7 +414,7 @@
//TODO: hackish
if( this.foldoutStyle === 'drilldown' ){ return $(); }
var $newDetails = ListItemView.prototype._renderDetails.call( this );
- return this._attachFoldout( this._createFoldoutPanel(), $newDetails );
+ return this._attachFoldout( this.foldout, $newDetails );
},
/** In this override, handle collection expansion. */
@@ -419,7 +438,8 @@
_getFoldoutPanelOptions : function(){
return {
// propagate foldout style down
- foldoutStyle : this.foldoutStyle
+ foldoutStyle : this.foldoutStyle,
+ fxSpeed : this.fxSpeed
};
},
@@ -438,25 +458,13 @@
return view._fetchModelDetails()
.always(function(){
if( view.foldoutStyle === 'foldout' ){
- view._expandByFoldout();
+ view._expand();
} else if( view.foldoutStyle === 'drilldown' ){
view._expandByDrilldown();
}
});
},
- /** For foldout, call render details then slide down */
- _expandByFoldout : function(){
- var view = this;
- var $newDetails = view._renderDetails();
- view.$details().replaceWith( $newDetails );
- // needs to be set after the above or the slide will not show
- view.expanded = true;
- view.$details().slideDown( view.fxSpeed, function(){
- view.trigger( 'expanded', view );
- });
- },
-
/** For drilldown, set up close handler and fire expanded:drilldown
* containing views can listen to this and handle other things
* (like hiding themselves) by listening for expanded/collapsed:drilldown
@@ -464,7 +472,6 @@
_expandByDrilldown : function(){
var view = this;
// attachment and rendering done by listener
- view.foldout = this._createFoldoutPanel();
view.foldout.on( 'close', function(){
view.trigger( 'collapsed:drilldown', view, view.foldout );
});
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 static/scripts/packed/mvc/history/history-structure-view.js
--- a/static/scripts/packed/mvc/history/history-structure-view.js
+++ b/static/scripts/packed/mvc/history/history-structure-view.js
@@ -1,1 +1,1 @@
-define(["mvc/job/job-model","mvc/job/job-li","mvc/history/history-content-model","mvc/history/job-dag","mvc/base-mvc","utils/localization","libs/d3"],function(e,f,i,c,h,a){var b=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure-component",initialize:function(j){this.log(this+"(HistoryStructureComponent).initialize:",j);this.component=j.component;this._jobLiMap={};this._createJobModels();this.layout=this._createLayout(j.layoutOptions)},_createJobModels:function(){var j=this;j.component.eachVertex(function(o){var n=o.data.job,m=new e.Job(n);var l=_.map(m.get("outputs"),function(p){var r=p.src==="hda"?"dataset":"dataset_collection",q=i.typeIdStr(r,p.id);return j.model.contents.get(q)});m.outputCollection.reset(l);m.outputCollection.historyId=j.model.id;var k=new f.JobListItemView({model:m,expanded:true});k.$el.appendTo(j.$el);j._jobLiMap[m.id]=k});return j.jobs},layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobHeight:308,jobWidthSpacing:320,linkAdjX:4,linkAdjY:0},_createLayout:function(l){l=_.defaults(_.clone(l||{}),this.layoutDefaults);var j=this,k=_.values(j.component.vertices),m=_.extend(l,{nodeMap:{},links:[],el:{width:0,height:0},svg:{width:0,height:0,top:0,left:0}});k.forEach(function(n,o){var p={name:n.name,x:0,y:0};m.nodeMap[n.name]=p});j.component.edges(function(o){var n={source:o.source,target:o.target};m.links.push(n)});return m},_updateLayout:function(){var k=this,l=k.layout;l.svg.height=l.paddingTop+(l.linkSpacing*_.size(l.nodeMap));l.el.height=l.svg.height+l.jobHeight;var j=l.paddingLeft,m=l.svg.height;_.each(l.nodeMap,function(o,n){o.x=j;o.y=m;j+=l.jobWidthSpacing});l.el.width=l.svg.width=Math.max(l.el.width,j);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY});return this.layout},render:function(k){this.log(this+".renderComponent:",k);var j=this;j.component.eachVertex(function(m){var l=j._jobLiMap[m.name];if(!l.$el.is(":visible")){l.render(0)}});j._updateLayout();j.$el.width(j.layout.el.width).height(j.layout.el.height);this.renderSVG();j.component.eachVertex(function(n){var m=j._jobLiMap[n.name],l=j.layout.nodeMap[m.model.id];m.$el.css({top:l.y,left:l.x})});return this},renderSVG:function(){var j=this,o=j.layout;var k=d3.select(this.el).select("svg");if(k.empty()){k=d3.select(this.el).append("svg")}k.attr("width",o.svg.width).attr("height",o.svg.height);function m(p){d3.select(this).classed("highlighted",true);j._jobLiMap[p.source].$el.addClass("highlighted");j._jobLiMap[p.target].$el.addClass("highlighted")}function l(p){d3.select(this).classed("highlighted",false);j._jobLiMap[p.source].$el.removeClass("highlighted");j._jobLiMap[p.target].$el.removeClass("highlighted")}var n=k.selectAll(".connection").data(o.links);n.enter().append("path").attr("class","connection").attr("id",function(p){return p.source+"-"+p.target}).on("mouseover",m).on("mouseout",l);n.transition().attr("d",function(p){return j._connectionPath(p)});return k.node()},_connectionPath:function(k){var l=0,j=((k.x2-k.x1)/this.layout.svg.width)*this.layout.svg.height;return["M",k.x1,",",k.y1," ","C",k.x1+l,",",k.y1-j," ",k.x2-l,",",k.y2-j," ",k.x2,",",k.y2].join("")},events:{"mouseover .job.list-item":function(j){this.highlightConnected(j.currentTarget,true)},"mouseout .job.list-item":function(j){this.highlightConnected(j.currentTarget,false)}},highlightConnected:function(p,k){k=k!==undefined?k:true;var j=this,l=j.component,n=k?jQuery.prototype.addClass:jQuery.prototype.removeClass,m=k?"connection highlighted":"connection";var o=n.call($(p),"highlighted"),q=o.attr("id").replace("job-","");l.edges({target:q}).forEach(function(r){n.call(j.$("#job-"+r.source),"highlighted");j.$("#"+r.source+"-"+q).attr("class",m)});l.vertices[q].eachEdge(function(r){n.call(j.$("#job-"+r.target),"highlighted");j.$("#"+q+"-"+r.target).attr("class",m)})},toString:function(){return"HistoryStructureComponent("+this.model.id+")"}});var g=b.extend({logger:console,className:b.prototype.className+" vertical",layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobWidth:308,jobHeight:308,initialSpacing:64,jobSpacing:16,linkAdjX:0,linkAdjY:4},_updateLayout:function(){var k=this,l=k.layout;l.svg.width=l.paddingLeft+(l.linkSpacing*_.size(l.nodeMap));l.el.width=l.svg.width+l.jobWidth;l.el.height=0;var j=l.svg.width,m=l.paddingTop;_.each(l.nodeMap,function(p,o){p.x=j;p.y=m;var n=k._jobLiMap[o];if(n.$el.is(":visible")){m+=n.$el.height()+l.jobSpacing}else{m+=l.initialSpacing+l.jobSpacing}});l.el.height=l.svg.height=Math.max(l.el.height,m);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY;k.debug("link:",n.x1,n.y1,n.x2,n.y2,n)});k.debug("el:",l.el);k.debug("svg:",l.svg);return l},_connectionPath:function(l){var k=0,j=((l.y2-l.y1)/this.layout.svg.height)*this.layout.svg.width;return["M",l.x1,",",l.y1," ","C",l.x1-j,",",l.y1+k," ",l.x2-j,",",l.y2-k," ",l.x2,",",l.y2].join("")},toString:function(){return"VerticalHistoryStructureComponent("+this.model.id+")"}});var d=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure",initialize:function(j){this.log(this+"(HistoryStructureView).initialize:",j,this.model);this.jobs=j.jobs;this._createDAG()},_createDAG:function(){this.dag=new c({historyContents:this.model.contents.toJSON(),jobs:this.jobs,excludeSetMetadata:true,excludeErroredJobs:true});this.log(this+".dag:",this.dag);this._createComponents()},_createComponents:function(){this.log(this+"._createComponents");var j=this;j.componentViews=j.dag.weakComponentGraphArray().map(function(k){return j._createComponent(k)})},_createComponent:function(j){this.log(this+"._createComponent:",j);return new b({model:this.model,component:j})},render:function(k){this.log(this+".render:",k);var j=this;j.$el.html(['<div class="controls"></div>','<div class="components"></div>'].join(""));j.componentViews.forEach(function(l){l.render().$el.appendTo(j.$components())});return j},$components:function(){return this.$(".components")},toString:function(){return"HistoryStructureView()"}});return d});
\ No newline at end of file
+define(["mvc/job/job-model","mvc/job/job-li","mvc/history/history-content-model","mvc/history/job-dag","mvc/base-mvc","utils/localization","libs/d3"],function(e,f,i,c,h,a){var b=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure-component",initialize:function(j){this.log(this+"(HistoryStructureComponent).initialize:",j);this.component=j.component;this._jobLiMap={};this._createJobModels();this.layout=this._createLayout(j.layoutOptions)},_createJobModels:function(){var j=this;j.component.eachVertex(function(o){var n=o.data.job,m=new e.Job(n);var l=_.map(m.get("outputs"),function(p){var r=p.src==="hda"?"dataset":"dataset_collection",q=i.typeIdStr(r,p.id);return j.model.contents.get(q)});m.outputCollection.reset(l);m.outputCollection.historyId=j.model.id;var k=new f.JobListItemView({model:m});k.render(0).$el.appendTo(j.$el);j._jobLiMap[m.id]=k;j._setUpJobListeners(k)});return j.jobs},_setUpJobListeners:function(j){j.on("expanding expanded collapsing collapsed",this.render,this);j.foldout.on("view:expanding view:expanded view:collapsing view:collapsed",this.render,this)},layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobHeight:308,jobWidthSpacing:320,linkAdjX:4,linkAdjY:0},_createLayout:function(l){l=_.defaults(_.clone(l||{}),this.layoutDefaults);var j=this,k=_.values(j.component.vertices),m=_.extend(l,{nodeMap:{},links:[],el:{width:0,height:0},svg:{width:0,height:0,top:0,left:0}});k.forEach(function(n,o){var p={name:n.name,x:0,y:0};m.nodeMap[n.name]=p});j.component.edges(function(o){var n={source:o.source,target:o.target};m.links.push(n)});return m},_updateLayout:function(){var k=this,l=k.layout;l.svg.height=l.paddingTop+(l.linkSpacing*_.size(l.nodeMap));l.el.height=l.svg.height+l.jobHeight;var j=l.paddingLeft,m=l.svg.height;_.each(l.nodeMap,function(o,n){o.x=j;o.y=m;j+=l.jobWidthSpacing});l.el.width=l.svg.width=Math.max(l.el.width,j);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY});return this.layout},render:function(k){this.debug(this+".render:",k);var j=this;function l(){j._updateLayout();j.$el.width(j.layout.el.width).height(j.layout.el.height);j.renderSVG();j.component.eachVertex(function(o){var n=j._jobLiMap[o.name],m=j.layout.nodeMap[n.model.id];n.$el.css({top:m.y,left:m.x})})}if(!this.$el.is(":visible")){_.delay(l,0)}else{l()}return this},renderSVG:function(){var j=this,o=j.layout;var k=d3.select(this.el).select("svg");if(k.empty()){k=d3.select(this.el).append("svg")}k.attr("width",o.svg.width).attr("height",o.svg.height);function m(p){d3.select(this).classed("highlighted",true);j._jobLiMap[p.source].$el.addClass("highlighted");j._jobLiMap[p.target].$el.addClass("highlighted")}function l(p){d3.select(this).classed("highlighted",false);j._jobLiMap[p.source].$el.removeClass("highlighted");j._jobLiMap[p.target].$el.removeClass("highlighted")}var n=k.selectAll(".connection").data(o.links);n.enter().append("path").attr("class","connection").attr("id",function(p){return p.source+"-"+p.target}).on("mouseover",m).on("mouseout",l);n.attr("d",function(p){return j._connectionPath(p)});return k.node()},_connectionPath:function(k){var l=0,j=((k.x2-k.x1)/this.layout.svg.width)*this.layout.svg.height;return["M",k.x1,",",k.y1," ","C",k.x1+l,",",k.y1-j," ",k.x2-l,",",k.y2-j," ",k.x2,",",k.y2].join("")},events:{"mouseover .job.list-item":function(j){this.highlightConnected(j.currentTarget,true)},"mouseout .job.list-item":function(j){this.highlightConnected(j.currentTarget,false)}},highlightConnected:function(p,k){k=k!==undefined?k:true;var j=this,l=j.component,n=k?jQuery.prototype.addClass:jQuery.prototype.removeClass,m=k?"connection highlighted":"connection";var o=n.call($(p),"highlighted"),q=o.attr("id").replace("job-","");l.edges({target:q}).forEach(function(r){n.call(j.$("#job-"+r.source),"highlighted");j.$("#"+r.source+"-"+q).attr("class",m)});l.vertices[q].eachEdge(function(r){n.call(j.$("#job-"+r.target),"highlighted");j.$("#"+q+"-"+r.target).attr("class",m)})},toString:function(){return"HistoryStructureComponent("+this.model.id+")"}});var g=b.extend({className:b.prototype.className+" vertical",layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobWidth:308,jobHeight:308,initialSpacing:64,jobSpacing:16,linkAdjX:0,linkAdjY:4},_updateLayout:function(){var k=this,l=k.layout;l.svg.width=l.paddingLeft+(l.linkSpacing*_.size(l.nodeMap));l.el.width=l.svg.width+l.jobWidth;l.el.height=0;var j=l.svg.width,m=l.paddingTop;_.each(l.nodeMap,function(p,o){p.x=j;p.y=m;var n=k._jobLiMap[o];if(n.$el.is(":visible")){m+=n.$el.height()+l.jobSpacing}else{m+=l.initialSpacing+l.jobSpacing}});l.el.height=l.svg.height=Math.max(l.el.height,m);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY;k.debug("link:",n.x1,n.y1,n.x2,n.y2,n)});k.debug("el:",l.el);k.debug("svg:",l.svg);return l},_connectionPath:function(l){var k=0,j=((l.y2-l.y1)/this.layout.svg.height)*this.layout.svg.width;return["M",l.x1,",",l.y1," ","C",l.x1-j,",",l.y1+k," ",l.x2-j,",",l.y2-k," ",l.x2,",",l.y2].join("")},toString:function(){return"VerticalHistoryStructureComponent("+this.model.id+")"}});var d=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure",initialize:function(j){this.log(this+"(HistoryStructureView).initialize:",j,this.model);this.jobs=j.jobs;this._createDAG()},_createDAG:function(){this.dag=new c({historyContents:this.model.contents.toJSON(),jobs:this.jobs,excludeSetMetadata:true,excludeErroredJobs:true});this.log(this+".dag:",this.dag);this._createComponents()},_createComponents:function(){this.log(this+"._createComponents");var j=this;j.componentViews=j.dag.weakComponentGraphArray().map(function(k){return j._createComponent(k)})},_createComponent:function(j){this.log(this+"._createComponent:",j);return new g({model:this.model,component:j})},render:function(k){this.log(this+".render:",k);var j=this;j.$el.html(['<div class="controls"></div>','<div class="components"></div>'].join(""));j.componentViews.forEach(function(l){l.render().$el.appendTo(j.$components())});return j},$components:function(){return this.$(".components")},toString:function(){return"HistoryStructureView()"}});return d});
\ No newline at end of file
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 static/scripts/packed/mvc/job/job-li.js
--- a/static/scripts/packed/mvc/job/job-li.js
+++ b/static/scripts/packed/mvc/job/job-li.js
@@ -1,1 +1,1 @@
-define(["mvc/list/list-item","mvc/dataset/dataset-list","mvc/base-mvc","utils/localization"],function(d,f,b,c){var e=d.FoldoutListItemView;var a=e.extend({className:e.prototype.className+" job",id:function(){return["job",this.model.get("id")].join("-")},foldoutPanelClass:f.DatasetList,initialize:function(g){if(g.logger){this.logger=this.model.logger=g.logger}this.log(this+".initialize:",g);e.prototype.initialize.call(this,g);this.linkTarget=g.linkTarget||"_blank";this._setUpListeners()},_swapNewRender:function(g){e.prototype._swapNewRender.call(this,g);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_getFoldoutPanelOptions:function(){var g=e.prototype._getFoldoutPanelOptions.call(this);return _.extend(g,{collection:this.model.outputCollection,selecting:false})},toString:function(){return"JobListItemView("+this.model+")"}});a.prototype.templates=(function(){var g=b.wrapTemplate(['<div class="list-element">','<div class="id"><%= model.id %></div>','<div class="warnings"></div>','<div class="selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="primary-actions"></div>','<div class="title-bar"></div>','<div class="details"></div>',"</div>"]);var h=b.wrapTemplate(['<div class="title-bar clear" tabindex="0">','<div class="title">','<span class="name"><%- job.tool_id %></span>',"</div>",'<div class="subtitle"></div>',"</div>"],"job");return _.extend({},e.prototype.templates,{titleBar:h,})}());return{JobListItemView:a}});
\ No newline at end of file
+define(["mvc/list/list-item","mvc/dataset/dataset-list","mvc/base-mvc","utils/localization"],function(d,f,b,c){var e=d.FoldoutListItemView;var a=e.extend({className:e.prototype.className+" job",id:function(){return["job",this.model.get("id")].join("-")},foldoutPanelClass:f.DatasetList,initialize:function(g){if(g.logger){this.logger=this.model.logger=g.logger}this.log(this+".initialize:",g);e.prototype.initialize.call(this,g);this.linkTarget=g.linkTarget||"_blank"},_swapNewRender:function(g){e.prototype._swapNewRender.call(this,g);if(this.model.has("state")){this.$el.addClass("state-"+this.model.get("state"))}return this.$el},_getFoldoutPanelOptions:function(){var g=e.prototype._getFoldoutPanelOptions.call(this);return _.extend(g,{collection:this.model.outputCollection,selecting:false})},toString:function(){return"JobListItemView("+this.model+")"}});a.prototype.templates=(function(){var g=b.wrapTemplate(['<div class="list-element">','<div class="id"><%= model.id %></div>','<div class="warnings"></div>','<div class="selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="primary-actions"></div>','<div class="title-bar"></div>','<div class="details"></div>',"</div>"]);var h=b.wrapTemplate(['<div class="title-bar clear" tabindex="0">','<div class="title">','<span class="name"><%- job.tool_id %></span>',"</div>",'<div class="subtitle"></div>',"</div>"],"job");return _.extend({},e.prototype.templates,{titleBar:h,})}());return{JobListItemView:a}});
\ No newline at end of file
diff -r 78124761ad558e4670c338fdbdbf371acb6b91bd -r 9728fcd5167c2aceb8e0b72d3d8b9dc6fd5435b7 static/scripts/packed/mvc/list/list-item.js
--- a/static/scripts/packed/mvc/list/list-item.js
+++ b/static/scripts/packed/mvc/list/list-item.js
@@ -1,1 +1,1 @@
-define(["mvc/base-mvc","utils/localization"],function(b,d){var e=Backbone.View.extend(b.LoggableMixin).extend({initialize:function(f){this.expanded=f.expanded||false;this.log("\t expanded:",this.expanded);this.fxSpeed=f.fxSpeed||this.fxSpeed},fxSpeed:"fast",render:function(g){var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){var f=$(this.templates.el(this.model.toJSON(),this));if(this.expanded){this.$details(f).replaceWith(this._renderDetails().show())}return f},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){this.trigger("rendered",f);i()}])},_swapNewRender:function(f){return this.$el.empty().attr("class",_.isFunction(this.className)?this.className():this.className).append(f.children())},_setUpBehaviors:function(f){f=f||this.$el;f.find("[title]").tooltip({placement:"bottom"})},$details:function(f){f=f||this.$el;return f.find("> .details")},_renderDetails:function(){var f=$(this.templates.details(this.model.toJSON(),this));this._setUpBehaviors(f);return f},toggleExpanded:function(f){f=(f===undefined)?(!this.expanded):(f);if(f){this.expand()}else{this.collapse()}return this},expand:function(){var f=this;return f._fetchModelDetails().always(function(){var g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown(f.fxSpeed,function(){f.trigger("expanded",f)})})},_fetchModelDetails:function(){if(!this.model.hasDetails()){return this.model.fetch()}return jQuery.when()},collapse:function(){this.debug(this+"(ExpandableView).collapse");var f=this;f.expanded=false;this.$details().slideUp(f.fxSpeed,function(){f.trigger("collapsed",f)})}});var a=e.extend(b.mixin(b.SelectableViewMixin,b.DraggableViewMixin,{tagName:"div",className:"list-item",initialize:function(f){e.prototype.initialize.call(this,f);b.SelectableViewMixin.initialize.call(this,f);b.DraggableViewMixin.initialize.call(this,f);this._setUpListeners()},_setUpListeners:function(){this.on("selectable",function(f){if(f){this.$(".primary-actions").hide()}else{this.$(".primary-actions").show()}},this);return this},_buildNewRender:function(){var f=e.prototype._buildNewRender.call(this);f.children(".warnings").replaceWith(this._renderWarnings());f.children(".title-bar").replaceWith(this._renderTitleBar());f.children(".primary-actions").append(this._renderPrimaryActions());f.find("> .title-bar .subtitle").replaceWith(this._renderSubtitle());return f},_swapNewRender:function(f){e.prototype._swapNewRender.call(this,f);if(this.selectable){this.showSelector(0)}if(this.draggable){this.draggableOn()}return this.$el},_renderWarnings:function(){var f=this,h=$('<div class="warnings"></div>'),g=f.model.toJSON();_.each(f.templates.warnings,function(i){h.append($(i(g,f)))});return h},_renderTitleBar:function(){return $(this.templates.titleBar(this.model.toJSON(),this))},_renderPrimaryActions:function(){return[]},_renderSubtitle:function(){return $(this.templates.subtitle(this.model.toJSON(),this))},events:{"click .title-bar":"_clickTitleBar","keydown .title-bar":"_keyDownTitleBar","click .selector":"toggleSelect"},_clickTitleBar:function(f){f.stopPropagation();if(f.altKey){this.toggleSelect(f);if(!this.selectable){this.showSelector()}}else{this.toggleExpanded()}},_keyDownTitleBar:function(h){var f=32,g=13;if(h&&(h.type==="keydown")&&(h.keyCode===f||h.keyCode===g)){this.toggleExpanded();h.stopPropagation();return false}return true},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"ListItemView("+f+")"}}));a.prototype.templates=(function(){var h=b.wrapTemplate(['<div class="list-element">','<div class="warnings"></div>','<div class="selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="primary-actions"></div>','<div class="title-bar"></div>','<div class="details"></div>',"</div>"]);var f={};var i=b.wrapTemplate(['<div class="title-bar clear" tabindex="0">','<span class="state-icon"></span>','<div class="title">','<span class="name"><%- element.name %></span>',"</div>",'<div class="subtitle"></div>',"</div>"],"element");var j=b.wrapTemplate(['<div class="subtitle"></div>']);var g=b.wrapTemplate(['<div class="details"></div>']);return{el:h,warnings:f,titleBar:i,subtitle:j,details:g}}());var c=a.extend({foldoutStyle:"foldout",foldoutPanelClass:null,initialize:function(f){a.prototype.initialize.call(this,f);if(this.foldoutStyle==="drilldown"){this.expanded=false}this.foldoutStyle=f.foldoutStyle||this.foldoutStyle;this.foldoutPanelClass=f.foldoutPanelClass||this.foldoutPanelClass},_renderDetails:function(){if(this.foldoutStyle==="drilldown"){return $()}var f=a.prototype._renderDetails.call(this);return this._attachFoldout(this._createFoldoutPanel(),f)},_createFoldoutPanel:function(){var h=this.model;var i=this._getFoldoutPanelClass(h),g=this._getFoldoutPanelOptions(h),f=new i(_.extend(g,{model:h}));return f},_getFoldoutPanelClass:function(){return this.foldoutPanelClass},_getFoldoutPanelOptions:function(){return{foldoutStyle:this.foldoutStyle}},_attachFoldout:function(f,g){g=g||this.$("> .details");this.foldout=f.render(0);f.$("> .controls").hide();return g.append(f.$el)},expand:function(){var f=this;return f._fetchModelDetails().always(function(){if(f.foldoutStyle==="foldout"){f._expandByFoldout()}else{if(f.foldoutStyle==="drilldown"){f._expandByDrilldown()}}})},_expandByFoldout:function(){var f=this;var g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown(f.fxSpeed,function(){f.trigger("expanded",f)})},_expandByDrilldown:function(){var f=this;f.foldout=this._createFoldoutPanel();f.foldout.on("close",function(){f.trigger("collapsed:drilldown",f,f.foldout)});f.trigger("expanded:drilldown",f,f.foldout)}});c.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="details">',"</div>"],"collection");return _.extend({},a.prototype.templates,{details:f})}());return{ExpandableView:e,ListItemView:a,FoldoutListItemView:c}});
\ No newline at end of file
+define(["mvc/base-mvc","utils/localization"],function(b,d){var e=Backbone.View.extend(b.LoggableMixin).extend({initialize:function(f){this.expanded=f.expanded||false;this.log("\t expanded:",this.expanded);this.fxSpeed=f.fxSpeed!==undefined?f.fxSpeed:this.fxSpeed},fxSpeed:"fast",render:function(g){var f=this._buildNewRender();this._setUpBehaviors(f);this._queueNewRender(f,g);return this},_buildNewRender:function(){var f=$(this.templates.el(this.model.toJSON(),this));if(this.expanded){this.$details(f).replaceWith(this._renderDetails().show())}return f},_queueNewRender:function(g,h){h=(h===undefined)?(this.fxSpeed):(h);var f=this;$(f).queue("fx",[function(i){this.$el.fadeOut(h,i)},function(i){f._swapNewRender(g);i()},function(i){this.$el.fadeIn(h,i)},function(i){this.trigger("rendered",f);i()}])},_swapNewRender:function(f){return this.$el.empty().attr("class",_.isFunction(this.className)?this.className():this.className).append(f.children())},_setUpBehaviors:function(f){f=f||this.$el;f.find("[title]").tooltip({placement:"bottom"})},$details:function(f){f=f||this.$el;return f.find("> .details")},_renderDetails:function(){var f=$(this.templates.details(this.model.toJSON(),this));this._setUpBehaviors(f);return f},toggleExpanded:function(f){f=(f===undefined)?(!this.expanded):(f);if(f){this.expand()}else{this.collapse()}return this},expand:function(){var f=this;return f._fetchModelDetails().always(function(){f._expand()})},_fetchModelDetails:function(){if(!this.model.hasDetails()){return this.model.fetch()}return jQuery.when()},_expand:function(){var f=this,g=f._renderDetails();f.$details().replaceWith(g);f.expanded=true;f.$details().slideDown({duration:f.fxSpeed,step:function(){f.trigger("expanding",f)},complete:function(){f.trigger("expanded",f)}})},collapse:function(){this.debug(this+"(ExpandableView).collapse");var f=this;f.expanded=false;this.$details().slideUp({duration:f.fxSpeed,step:function(){f.trigger("collapsing",f)},complete:function(){f.trigger("collapsed",f)}})}});var a=e.extend(b.mixin(b.SelectableViewMixin,b.DraggableViewMixin,{tagName:"div",className:"list-item",initialize:function(f){e.prototype.initialize.call(this,f);b.SelectableViewMixin.initialize.call(this,f);b.DraggableViewMixin.initialize.call(this,f);this._setUpListeners()},_setUpListeners:function(){this.on("selectable",function(f){if(f){this.$(".primary-actions").hide()}else{this.$(".primary-actions").show()}},this);return this},_buildNewRender:function(){var f=e.prototype._buildNewRender.call(this);f.children(".warnings").replaceWith(this._renderWarnings());f.children(".title-bar").replaceWith(this._renderTitleBar());f.children(".primary-actions").append(this._renderPrimaryActions());f.find("> .title-bar .subtitle").replaceWith(this._renderSubtitle());return f},_swapNewRender:function(f){e.prototype._swapNewRender.call(this,f);if(this.selectable){this.showSelector(0)}if(this.draggable){this.draggableOn()}return this.$el},_renderWarnings:function(){var f=this,h=$('<div class="warnings"></div>'),g=f.model.toJSON();_.each(f.templates.warnings,function(i){h.append($(i(g,f)))});return h},_renderTitleBar:function(){return $(this.templates.titleBar(this.model.toJSON(),this))},_renderPrimaryActions:function(){return[]},_renderSubtitle:function(){return $(this.templates.subtitle(this.model.toJSON(),this))},events:{"click .title-bar":"_clickTitleBar","keydown .title-bar":"_keyDownTitleBar","click .selector":"toggleSelect"},_clickTitleBar:function(f){f.stopPropagation();if(f.altKey){this.toggleSelect(f);if(!this.selectable){this.showSelector()}}else{this.toggleExpanded()}},_keyDownTitleBar:function(h){var f=32,g=13;if(h&&(h.type==="keydown")&&(h.keyCode===f||h.keyCode===g)){this.toggleExpanded();h.stopPropagation();return false}return true},toString:function(){var f=(this.model)?(this.model+""):("(no model)");return"ListItemView("+f+")"}}));a.prototype.templates=(function(){var h=b.wrapTemplate(['<div class="list-element">','<div class="warnings"></div>','<div class="selector">','<span class="fa fa-2x fa-square-o"></span>',"</div>",'<div class="primary-actions"></div>','<div class="title-bar"></div>','<div class="details"></div>',"</div>"]);var f={};var i=b.wrapTemplate(['<div class="title-bar clear" tabindex="0">','<span class="state-icon"></span>','<div class="title">','<span class="name"><%- element.name %></span>',"</div>",'<div class="subtitle"></div>',"</div>"],"element");var j=b.wrapTemplate(['<div class="subtitle"></div>']);var g=b.wrapTemplate(['<div class="details"></div>']);return{el:h,warnings:f,titleBar:i,subtitle:j,details:g}}());var c=a.extend({foldoutStyle:"foldout",foldoutPanelClass:null,initialize:function(f){if(this.foldoutStyle==="drilldown"){this.expanded=false}this.foldoutStyle=f.foldoutStyle||this.foldoutStyle;this.foldoutPanelClass=f.foldoutPanelClass||this.foldoutPanelClass;a.prototype.initialize.call(this,f);this.foldout=this._createFoldoutPanel()},_renderDetails:function(){if(this.foldoutStyle==="drilldown"){return $()}var f=a.prototype._renderDetails.call(this);return this._attachFoldout(this.foldout,f)},_createFoldoutPanel:function(){var h=this.model;var i=this._getFoldoutPanelClass(h),g=this._getFoldoutPanelOptions(h),f=new i(_.extend(g,{model:h}));return f},_getFoldoutPanelClass:function(){return this.foldoutPanelClass},_getFoldoutPanelOptions:function(){return{foldoutStyle:this.foldoutStyle,fxSpeed:this.fxSpeed}},_attachFoldout:function(f,g){g=g||this.$("> .details");this.foldout=f.render(0);f.$("> .controls").hide();return g.append(f.$el)},expand:function(){var f=this;return f._fetchModelDetails().always(function(){if(f.foldoutStyle==="foldout"){f._expand()}else{if(f.foldoutStyle==="drilldown"){f._expandByDrilldown()}}})},_expandByDrilldown:function(){var f=this;f.foldout.on("close",function(){f.trigger("collapsed:drilldown",f,f.foldout)});f.trigger("expanded:drilldown",f,f.foldout)}});c.prototype.templates=(function(){var f=b.wrapTemplate(['<div class="details">',"</div>"],"collection");return _.extend({},a.prototype.templates,{details:f})}());return{ExpandableView:e,ListItemView:a,FoldoutListItemView:c}});
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
commit/galaxy-central: guerler: ToolForm: Activate rerun feature for new tool form, fix sliders, fix content labels
by commits-noreply@bitbucket.org 15 Oct '14
by commits-noreply@bitbucket.org 15 Oct '14
15 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/78124761ad55/
Changeset: 78124761ad55
User: guerler
Date: 2014-10-15 20:06:03+00:00
Summary: ToolForm: Activate rerun feature for new tool form, fix sliders, fix content labels
Affected #: 20 files
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-form.js
--- a/client/galaxy/scripts/mvc/tools/tools-form.js
+++ b/client/galaxy/scripts/mvc/tools/tools-form.js
@@ -97,7 +97,7 @@
// finalize data
var current_state = this.tree.finalize({
data : function(dict) {
- if (dict.values.length > 0 && dict.values[0].src === 'hda') {
+ if (dict.values.length > 0 && dict.values[0] && dict.values[0].src === 'hda') {
return self.content.get({id: dict.values[0].id}).dataset_id;
}
return null;
@@ -185,11 +185,11 @@
});
// switch to classic tool form mako if the form definition is incompatible
- //if (this.incompatible) {
+ if (this.incompatible) {
this.$el.hide();
$('#tool-form-classic').show();
return;
- //}
+ }
// create portlet
this.portlet = new Portlet.View({
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-jobs.js
--- a/client/galaxy/scripts/mvc/tools/tools-jobs.js
+++ b/client/galaxy/scripts/mvc/tools/tools-jobs.js
@@ -37,7 +37,7 @@
console.debug(job_def);
// show progress modal
- this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }});
+ this.app.modal.show({title: 'Please wait...', body: 'progress', closing_events: true, buttons: { 'Close' : function () {self.app.modal.hide();} }});
// post job
Utils.request({
@@ -59,6 +59,15 @@
} else {
// show error message with details
console.debug(response);
+ self.app.modal.show({
+ title : 'Job submission failed',
+ body : ToolTemplate.error(job_def),
+ buttons : {
+ 'Close' : function() {
+ self.app.modal.hide();
+ }
+ }
+ });
}
}
});
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-section.js
--- a/client/galaxy/scripts/mvc/tools/tools-section.js
+++ b/client/galaxy/scripts/mvc/tools/tools-section.js
@@ -529,22 +529,12 @@
/** Slider field
*/
_fieldSlider: function(input_def) {
- // set min/max
- input_def.min = input_def.min || 0;
- input_def.max = input_def.max || 100000;
-
- // calculate step size
- var step = 1;
- if (input_def.type == 'float') {
- step = (input_def.max - input_def.min) / 10000;
- }
-
// create slider
return new Ui.Slider.View({
id : 'field-' + input_def.id,
+ precise : input_def.type == 'float',
min : input_def.min,
- max : input_def.max,
- step : step
+ max : input_def.max
});
},
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-select-content.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-content.js
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -40,7 +40,7 @@
var dataset_options = [];
for (var i in datasets) {
dataset_options.push({
- label: datasets[i].name,
+ label: datasets[i].hid + ': ' + datasets[i].name,
value: datasets[i].id
});
}
@@ -67,7 +67,7 @@
var collection_options = [];
for (var i in collections) {
collection_options.push({
- label: collections[i].name,
+ label: collections[i].hid + ': ' + collections[i].name,
value: collections[i].id
});
}
@@ -103,20 +103,34 @@
},
/** Return the currently selected dataset values */
- value : function () {
- // identify select element
- var select = null;
- switch(this.current) {
- case 'hda':
- select = this.select_datasets;
- break;
- case 'hdca':
- select = this.select_collection;
- break;
+ value : function (dict) {
+ // update current value
+ if (dict !== undefined) {
+ if (dict.values.length > 0 && dict.values[0] && dict.values[0].src) {
+ // create list
+ var list = [];
+ for (var i in dict.values) {
+ list.push(dict.values[i].id);
+ }
+
+ // set source
+ this.current = dict.values[0].src;
+ this.refresh();
+
+ // identify select element
+ switch(this.current) {
+ case 'hda':
+ this.select_datasets.value(list);
+ break;
+ case 'hdca':
+ this.select_collection.value(list[0]);
+ break;
+ }
+ }
}
// transform into an array
- var id_list = select.value();
+ var id_list = this._select().value();
if (!(id_list instanceof Array)) {
id_list = [id_list];
}
@@ -142,12 +156,7 @@
/** Validate current selection
*/
validate: function() {
- switch(this.current) {
- case 'hda':
- return this.select_datasets.validate();
- case 'hdca':
- return this.select_collection.validate();
- }
+ return this._select().validate();
},
/** Refreshes data selection view */
@@ -162,6 +171,16 @@
this.select_collection.$el.fadeIn();
break;
}
+ },
+
+ /** Assists in selecting the current field */
+ _select: function() {
+ switch(this.current) {
+ case 'hdca':
+ return this.select_collection;
+ default:
+ return this.select_datasets;
+ }
}
});
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/tools/tools-template.js
--- a/client/galaxy/scripts/mvc/tools/tools-template.js
+++ b/client/galaxy/scripts/mvc/tools/tools-template.js
@@ -49,7 +49,7 @@
error: function(job_def) {
return '<div>' +
'<p>' +
- 'Sorry, the server could not complete the request. Please contact the Galaxy Team if this error is persistent.' +
+ 'The server could not complete the request. Please contact the Galaxy Team if this error persists.' +
'</p>' +
'<textarea class="ui-textarea" disabled style="color: black;" rows="6">' +
JSON.stringify(job_def, undefined, 4) +
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd client/galaxy/scripts/mvc/ui/ui-slider.js
--- a/client/galaxy/scripts/mvc/ui/ui-slider.js
+++ b/client/galaxy/scripts/mvc/ui/ui-slider.js
@@ -6,9 +6,11 @@
// options
optionsDefault: {
value : '',
- min : 1,
- max : 100,
- step : 1
+ min : null,
+ max : null,
+ step : null,
+ precise : false,
+ split : 10000
},
// initialize
@@ -18,19 +20,35 @@
// configure options
this.options = Utils.merge(options, this.optionsDefault);
-
+
// create new element
this.setElement(this._template(this.options));
- // backup slider
- this.$slider = this.$el.find('#slider');
+ // determine wether to use the slider
+ this.useslider = this.options.max !== null && this.options.min !== null && this.options.max > this.options.min;
+
+ // set default step size
+ if (this.options.step === null) {
+ this.options.step = 1;
+ if (this.options.precise && this.useslider) {
+ this.options.step = (this.options.max - this.options.min) / this.options.split;
+ }
+ }
+
+ // create slider if min and max are defined properly
+ if (this.useslider) {
+ this.$slider = this.$el.find('#slider');
+ this.$slider.slider(this.options);
+ this.$slider.on('slide', function (event, ui) {
+ self.value(ui.value);
+ });
+ } else {
+ this.$el.find('.ui-form-slider-text').css('width', '100%');
+ }
// backup integer field
this.$text = this.$el.find('#text');
- // load slider plugin
- this.$slider.slider(this.options);
-
// add text field event
this.$text.on('change', function () {
self.value($(this).val());
@@ -39,24 +57,23 @@
// add text field event
this.$text.on('keydown', function (event) {
var v = event.which;
- console.log(v);
if (!(v == 8 || v == 9 || v == 13 || v == 37 || v == 39 || v == 189 || (v >= 48 && v <= 57)
- || (self.options.step != 1 && $(this).val().indexOf('.') == -1) && v == 190)) {
+ || (self.options.precise && $(this).val().indexOf('.') == -1) && v == 190)) {
event.preventDefault();
}
});
-
- // add slider event
- this.$slider.on('slide', function (event, ui) {
- self.value(ui.value);
- });
},
// value
value : function (new_val) {
if (new_val !== undefined) {
- // limit
- new_val = Math.max(Math.min(new_val, this.options.max), this.options.min);
+ // apply limit
+ if (this.options.max !== null) {
+ new_val = Math.min(new_val, this.options.max);
+ }
+ if (this.options.min !== null) {
+ new_val = Math.max(new_val, this.options.min);
+ }
// trigger on change event
if (this.options.onchange) {
@@ -64,7 +81,7 @@
}
// set values
- this.$slider.slider('value', new_val);
+ this.$slider && this.$slider.slider('value', new_val);
this.$text.val(new_val);
}
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd lib/galaxy/tools/parameters/basic.py
--- a/lib/galaxy/tools/parameters/basic.py
+++ b/lib/galaxy/tools/parameters/basic.py
@@ -1278,7 +1278,7 @@
def to_dict( self, trans, view='collection', value_mapper=None, other_values={} ):
# call parent to_dict
- d = super( ColumnListParameter, self ).to_dict( trans, other_values )
+ d = super( ColumnListParameter, self ).to_dict( trans, other_values=other_values)
# add data reference
d['data_ref'] = self.data_ref
@@ -1432,7 +1432,10 @@
call_other_values = { '__trans__': trans, '__value__': value }
if other_values:
call_other_values.update( other_values.dict )
- return eval( self.dynamic_options, self.tool.code_namespace, call_other_values )
+ try:
+ return eval( self.dynamic_options, self.tool.code_namespace, call_other_values )
+ except Exception:
+ return []
def get_options( self, trans=None, value=None, other_values={} ):
if self.is_dynamic:
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -97,7 +97,7 @@
// finalize data
var current_state = this.tree.finalize({
data : function(dict) {
- if (dict.values.length > 0 && dict.values[0].src === 'hda') {
+ if (dict.values.length > 0 && dict.values[0] && dict.values[0].src === 'hda') {
return self.content.get({id: dict.values[0].id}).dataset_id;
}
return null;
@@ -185,11 +185,11 @@
});
// switch to classic tool form mako if the form definition is incompatible
- //if (this.incompatible) {
+ if (this.incompatible) {
this.$el.hide();
$('#tool-form-classic').show();
return;
- //}
+ }
// create portlet
this.portlet = new Portlet.View({
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-jobs.js
--- a/static/scripts/mvc/tools/tools-jobs.js
+++ b/static/scripts/mvc/tools/tools-jobs.js
@@ -37,7 +37,7 @@
console.debug(job_def);
// show progress modal
- this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }});
+ this.app.modal.show({title: 'Please wait...', body: 'progress', closing_events: true, buttons: { 'Close' : function () {self.app.modal.hide();} }});
// post job
Utils.request({
@@ -59,6 +59,15 @@
} else {
// show error message with details
console.debug(response);
+ self.app.modal.show({
+ title : 'Job submission failed',
+ body : ToolTemplate.error(job_def),
+ buttons : {
+ 'Close' : function() {
+ self.app.modal.hide();
+ }
+ }
+ });
}
}
});
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -529,22 +529,12 @@
/** Slider field
*/
_fieldSlider: function(input_def) {
- // set min/max
- input_def.min = input_def.min || 0;
- input_def.max = input_def.max || 100000;
-
- // calculate step size
- var step = 1;
- if (input_def.type == 'float') {
- step = (input_def.max - input_def.min) / 10000;
- }
-
// create slider
return new Ui.Slider.View({
id : 'field-' + input_def.id,
+ precise : input_def.type == 'float',
min : input_def.min,
- max : input_def.max,
- step : step
+ max : input_def.max
});
},
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-select-content.js
--- a/static/scripts/mvc/tools/tools-select-content.js
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -40,7 +40,7 @@
var dataset_options = [];
for (var i in datasets) {
dataset_options.push({
- label: datasets[i].name,
+ label: datasets[i].hid + ': ' + datasets[i].name,
value: datasets[i].id
});
}
@@ -67,7 +67,7 @@
var collection_options = [];
for (var i in collections) {
collection_options.push({
- label: collections[i].name,
+ label: collections[i].hid + ': ' + collections[i].name,
value: collections[i].id
});
}
@@ -103,20 +103,34 @@
},
/** Return the currently selected dataset values */
- value : function () {
- // identify select element
- var select = null;
- switch(this.current) {
- case 'hda':
- select = this.select_datasets;
- break;
- case 'hdca':
- select = this.select_collection;
- break;
+ value : function (dict) {
+ // update current value
+ if (dict !== undefined) {
+ if (dict.values.length > 0 && dict.values[0] && dict.values[0].src) {
+ // create list
+ var list = [];
+ for (var i in dict.values) {
+ list.push(dict.values[i].id);
+ }
+
+ // set source
+ this.current = dict.values[0].src;
+ this.refresh();
+
+ // identify select element
+ switch(this.current) {
+ case 'hda':
+ this.select_datasets.value(list);
+ break;
+ case 'hdca':
+ this.select_collection.value(list[0]);
+ break;
+ }
+ }
}
// transform into an array
- var id_list = select.value();
+ var id_list = this._select().value();
if (!(id_list instanceof Array)) {
id_list = [id_list];
}
@@ -142,12 +156,7 @@
/** Validate current selection
*/
validate: function() {
- switch(this.current) {
- case 'hda':
- return this.select_datasets.validate();
- case 'hdca':
- return this.select_collection.validate();
- }
+ return this._select().validate();
},
/** Refreshes data selection view */
@@ -162,6 +171,16 @@
this.select_collection.$el.fadeIn();
break;
}
+ },
+
+ /** Assists in selecting the current field */
+ _select: function() {
+ switch(this.current) {
+ case 'hdca':
+ return this.select_collection;
+ default:
+ return this.select_datasets;
+ }
}
});
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/tools/tools-template.js
--- a/static/scripts/mvc/tools/tools-template.js
+++ b/static/scripts/mvc/tools/tools-template.js
@@ -49,7 +49,7 @@
error: function(job_def) {
return '<div>' +
'<p>' +
- 'Sorry, the server could not complete the request. Please contact the Galaxy Team if this error is persistent.' +
+ 'The server could not complete the request. Please contact the Galaxy Team if this error persists.' +
'</p>' +
'<textarea class="ui-textarea" disabled style="color: black;" rows="6">' +
JSON.stringify(job_def, undefined, 4) +
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/mvc/ui/ui-slider.js
--- a/static/scripts/mvc/ui/ui-slider.js
+++ b/static/scripts/mvc/ui/ui-slider.js
@@ -6,9 +6,11 @@
// options
optionsDefault: {
value : '',
- min : 1,
- max : 100,
- step : 1
+ min : null,
+ max : null,
+ step : null,
+ precise : false,
+ split : 10000
},
// initialize
@@ -18,19 +20,35 @@
// configure options
this.options = Utils.merge(options, this.optionsDefault);
-
+
// create new element
this.setElement(this._template(this.options));
- // backup slider
- this.$slider = this.$el.find('#slider');
+ // determine wether to use the slider
+ this.useslider = this.options.max !== null && this.options.min !== null && this.options.max > this.options.min;
+
+ // set default step size
+ if (this.options.step === null) {
+ this.options.step = 1;
+ if (this.options.precise && this.useslider) {
+ this.options.step = (this.options.max - this.options.min) / this.options.split;
+ }
+ }
+
+ // create slider if min and max are defined properly
+ if (this.useslider) {
+ this.$slider = this.$el.find('#slider');
+ this.$slider.slider(this.options);
+ this.$slider.on('slide', function (event, ui) {
+ self.value(ui.value);
+ });
+ } else {
+ this.$el.find('.ui-form-slider-text').css('width', '100%');
+ }
// backup integer field
this.$text = this.$el.find('#text');
- // load slider plugin
- this.$slider.slider(this.options);
-
// add text field event
this.$text.on('change', function () {
self.value($(this).val());
@@ -39,24 +57,23 @@
// add text field event
this.$text.on('keydown', function (event) {
var v = event.which;
- console.log(v);
if (!(v == 8 || v == 9 || v == 13 || v == 37 || v == 39 || v == 189 || (v >= 48 && v <= 57)
- || (self.options.step != 1 && $(this).val().indexOf('.') == -1) && v == 190)) {
+ || (self.options.precise && $(this).val().indexOf('.') == -1) && v == 190)) {
event.preventDefault();
}
});
-
- // add slider event
- this.$slider.on('slide', function (event, ui) {
- self.value(ui.value);
- });
},
// value
value : function (new_val) {
if (new_val !== undefined) {
- // limit
- new_val = Math.max(Math.min(new_val, this.options.max), this.options.min);
+ // apply limit
+ if (this.options.max !== null) {
+ new_val = Math.min(new_val, this.options.max);
+ }
+ if (this.options.min !== null) {
+ new_val = Math.max(new_val, this.options.min);
+ }
// trigger on change event
if (this.options.onchange) {
@@ -64,7 +81,7 @@
}
// set values
- this.$slider.slider('value', new_val);
+ this.$slider && this.$slider.slider('value', new_val);
this.$text.val(new_val);
}
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-form.js
--- a/static/scripts/packed/mvc/tools/tools-form.js
+++ b/static/scripts/packed/mvc/tools/tools-form.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of available operations."});p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});this.$el.hide();$("#tool-form-classic").show();return;this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!this.options.biostar_url){button_question.$el.hide();button_search.$el.hide()}this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/citation/citation-model","mvc/citation/citation-view","mvc/tools","mvc/tools/tools-template","mvc/tools/tools-content","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(i,h,l,j,a,e,d,f,k,c,g){var b=Backbone.View.extend({container:"body",initialize:function(n){console.debug(n);var m=this;if(parent.Galaxy&&parent.Galaxy.modal){this.modal=parent.Galaxy.modal}else{this.modal=new l.Modal.View()}this.options=n;this.model=n.model;this.inputs=n.model.inputs;this.setElement("<div/>");$(this.container).append(this.$el);this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.content=new f({history_id:this.options.history_id,success:function(){m._buildForm()}})},message:function(m){$(this.container).empty();$(this.container).append(m)},reset:function(){for(var m in this.element_list){this.element_list[m].reset()}},refresh:function(){this.tree.refresh();for(var m in this.field_list){this.field_list[m].trigger("change")}console.debug("tools-form::refresh() - Recreated data structure. Refresh.")},_refreshForm:function(){var m=this;var n=this.tree.finalize({data:function(o){if(o.values.length>0&&o.values[0]&&o.values[0].src==="hda"){return m.content.get({id:o.values[0].id}).dataset_id}return null}});console.debug("tools-form::_refreshForm() - Refreshing inputs/states.");console.debug(n);i.request({type:"GET",url:galaxy_config.root+"tool_runner/index?tool_id="+this.options.id+"&form_refresh=True",data:n,success:function(o){console.debug("tools-form::_refreshForm() - Refreshed inputs/states.");console.debug(o)},error:function(o){console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(o)}})},_buildForm:function(){var n=this;var p=new l.ButtonMenu({icon:"fa-gear",tooltip:"Click to see a list of available operations."});p.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/p/new/post/")}});p.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});p.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+n.options.id)}});if(Galaxy.currUser.get("is_admin")){p.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.section=new k.View(n,{inputs:this.inputs,cls:"ui-table-plain"});if(this.incompatible){this.$el.hide();$("#tool-form-classic").show();return}this.portlet=new h.View({icon:"fa-wrench",title:"<b>"+this.model.name+"</b> "+this.model.description,operations:{menu:p},buttons:{execute:new l.Button({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!this.options.biostar_url){button_question.$el.hide();button_search.$el.hide()}this.$el.append(this.portlet.$el);if(this.options.help!=""){this.$el.append(d.help(this.options.help))}if(this.options.citations){this.$el.append(d.citations());var m=new j.ToolCitationCollection();m.tool_id=this.options.id;var o=new a.CitationListView({collection:m});o.render();m.fetch()}this.portlet.append(this.section.$el);this.refresh()}});return{View:b}});
\ No newline at end of file
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-jobs.js
--- a/static/scripts/packed/mvc/tools/tools-jobs.js
+++ b/static/scripts/packed/mvc/tools/tools-jobs.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.debug(d);this.app.modal.show({title:"Please wait...",body:"progress",buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.message(a.success(e));c._refreshHdas()},error:function(e,g){c.app.modal.hide();if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var f in h){c._foundError(f,h[f])}}else{console.debug(e)}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(g){var c=g.inputs;var k=-1;for(var i in c){var e=c[i];var j=this.app.tree.match(i);var d=this.app.field_list[j];var h=this.app.input_list[j];if(h&&d&&d.validate&&!d.validate()){this._foundError(j);return false}if(e.batch){var f=e.values.length;if(k===-1){k=f}else{if(k!==f){this._foundError(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+f+"</b> selection(s) while a previous field contains <b>"+k+"</b>.");return false}}}}return true},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})});
\ No newline at end of file
+define(["utils/utils","mvc/tools/tools-template"],function(b,a){return Backbone.Model.extend({initialize:function(d,c){this.app=d;this.options=b.merge(c,this.optionsDefault)},submit:function(){var c=this;var d={tool_id:this.app.options.id,inputs:this.app.tree.finalize()};this.app.reset();if(!this._validation(d)){console.debug("tools-jobs::submit - Submission canceled. Validation failed.");return}console.debug(d);this.app.modal.show({title:"Please wait...",body:"progress",closing_events:true,buttons:{Close:function(){c.app.modal.hide()}}});b.request({type:"POST",url:galaxy_config.root+"api/tools",data:d,success:function(e){c.app.modal.hide();c.app.message(a.success(e));c._refreshHdas()},error:function(e,g){c.app.modal.hide();if(e&&e.message&&e.message.data){var h=c.app.tree.matchResponse(e.message.data);for(var f in h){c._foundError(f,h[f])}}else{console.debug(e);c.app.modal.show({title:"Job submission failed",body:a.error(d),buttons:{Close:function(){c.app.modal.hide()}}})}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500)},_validation:function(g){var c=g.inputs;var k=-1;for(var i in c){var e=c[i];var j=this.app.tree.match(i);var d=this.app.field_list[j];var h=this.app.input_list[j];if(h&&d&&d.validate&&!d.validate()){this._foundError(j);return false}if(e.batch){var f=e.values.length;if(k===-1){k=f}else{if(k!==f){this._foundError(j,"Please make sure that you select the same number of inputs for all batch mode fields. This field contains <b>"+f+"</b> selection(s) while a previous field contains <b>"+k+"</b>.");return false}}}}return true},_refreshHdas:function(){if(parent.Galaxy&&parent.Galaxy.currHistoryPanel){parent.Galaxy.currHistoryPanel.refreshContents()}}})});
\ No newline at end of file
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-section.js
--- a/static/scripts/packed/mvc/tools/tools-section.js
+++ b/static/scripts/packed/mvc/tools/tools-section.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(k,h)}},_addConditional:function(h){h.label=h.test_param.label;h.value=h.test_param.value;var j=this._addRow("conditional",h);for(var l in h.cases){var k=h.id+"-section-"+l;var m=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(k)}},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,l>=h)}var j=new e({label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.is_dynamic=false;i=this._fieldSelect(h);break;case"conditional":i=this._fieldConditional(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":i=this._fieldSelect(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_fieldConditional:function(h){var j=this;var k=[];for(var l in h.test_param.options){var m=h.test_param.options[l];k.push({label:m[0],value:m[1]})}return new g.Select.View({id:"field-"+h.id,data:k,onchange:function(u){for(var s in h.cases){var o=h.cases[s];var r=h.id+"-section-"+s;var n=j.table.get(r);var q=false;for(var p in o.inputs){var t=o.inputs[p].type;if(t&&t!=="hidden"){q=true;break}}if(o.value==u&&q){n.fadeIn("fast")}else{n.hide()}}}})},_fieldData:function(h){var i=this;var j=h.id;return new a.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(q){var o=q.values[0];var m=o.id;var p=o.src;var l=i.app.tree.references(j,"data_column");if(l.length<=0){console.debug("tool-form::field_data() - Data column parameters unavailable.");return}for(var n in l){var k=i.app.field_list[l[n]];k.wait&&k.wait()}i.app.content.getDetails({id:m,src:p,success:function(y){var B=null;if(y){console.debug("tool-form::field_data() - Selected content "+m+".");if(p=="hdca"&&y.elements&&y.elements.length>0){y=y.elements[0].object}B=y.metadata_column_types;if(!B){console.debug("tool-form::field_data() - FAILED: Could not find metadata for content "+m+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find content "+m+".")}for(var u in l){var w=i.app.input_list[l[u]];var x=i.app.field_list[l[u]];if(!w||!x){console.debug("tool-form::field_data() - FAILED: Column not found.")}var t=w.numerical;var s=[];for(var A in B){var z=B[A];var r=(parseInt(A)+1);var v="Text";if(z=="int"||z=="float"){v="Number"}if(z=="int"||z=="float"||!t){s.push({label:"Column: "+r+" ["+v+"]",value:r})}}if(x){x.update(s);if(!x.exists(x.value())){x.value(x.first())}x.show()}}}})}})},_fieldSelect:function(h){if(h.is_dynamic){this.app.incompatible=true}var j=[];for(var k in h.options){var l=h.options[k];j.push({label:l[0],value:l[1]})}var m=g.Select;switch(h.display){case"checkboxes":m=g.Checkbox;break;case"radio":m=g.Radio;break}return new m.View({id:"field-"+h.id,data:j,multiple:h.multiple})},_fieldText:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_fieldSlider:function(h){h.min=h.min||0;h.max=h.max||100000;var i=1;if(h.type=="float"){i=(h.max-h.min)/10000}return new g.Slider.View({id:"field-"+h.id,min:h.min,max:h.max,step:i})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/tools/tools-repeat","mvc/tools/tools-select-content","mvc/tools/tools-input"],function(d,b,g,c,a,e){var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new b.View(h);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var h in this.inputs){this._add(this.inputs[h])}},_add:function(j){var i=this;var h=jQuery.extend(true,{},j);h.id=d.uuid();this.app.input_list[h.id]=h;var k=h.type;switch(k){case"conditional":this._addConditional(h);break;case"repeat":this._addRepeat(h);break;default:this._addRow(k,h)}},_addConditional:function(h){h.label=h.test_param.label;h.value=h.test_param.value;var j=this._addRow("conditional",h);for(var l in h.cases){var k=h.id+"-section-"+l;var m=new f(this.app,{inputs:h.cases[l].inputs,cls:"ui-table-plain"});m.$el.addClass("ui-table-form-section");this.table.add(m.$el);this.table.append(k)}},_addRepeat:function(o){var r=this;var p=0;function m(i,t){var s=o.id+"-section-"+(p++);var u=null;if(t){u=function(){k.del(s);k.retitle(o.title);r.app.refresh()}}var v=new f(r.app,{inputs:i,cls:"ui-table-plain"});k.add({id:s,title:o.title,$el:v.$el,ondel:u});k.retitle(o.title)}var k=new c.View({title_new:o.title,max:o.max,onnew:function(){m(o.inputs,true);r.app.refresh()}});var h=o.min;var q=_.size(o.cache);for(var l=0;l<Math.max(q,h);l++){var n=null;if(l<q){n=o.cache[l]}else{n=o.inputs}m(n,l>=h)}var j=new e({label:o.title,help:o.help,field:k});j.$el.addClass("ui-table-form-section");this.table.add(j.$el);this.table.append(o.id)},_addRow:function(j,h){var l=h.id;var i=null;switch(j){case"text":i=this._fieldText(h);break;case"select":i=this._fieldSelect(h);break;case"data":i=this._fieldData(h);break;case"data_column":h.is_dynamic=false;i=this._fieldSelect(h);break;case"conditional":i=this._fieldConditional(h);break;case"hidden":i=this._fieldHidden(h);break;case"integer":i=this._fieldSlider(h);break;case"float":i=this._fieldSlider(h);break;case"boolean":i=this._fieldBoolean(h);break;case"genomebuild":i=this._fieldSelect(h);break;default:this.app.incompatible=true;if(h.options){i=this._fieldSelect(h)}else{i=this._fieldText(h)}console.debug("tools-form::_addRow() : Auto matched field type ("+j+").")}if(h.value!==undefined){i.value(h.value)}this.app.field_list[l]=i;var k=new e({label:h.label,optional:h.optional,help:h.help,field:i});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);return this.table.get(l)},_fieldConditional:function(h){var j=this;var k=[];for(var l in h.test_param.options){var m=h.test_param.options[l];k.push({label:m[0],value:m[1]})}return new g.Select.View({id:"field-"+h.id,data:k,onchange:function(u){for(var s in h.cases){var o=h.cases[s];var r=h.id+"-section-"+s;var n=j.table.get(r);var q=false;for(var p in o.inputs){var t=o.inputs[p].type;if(t&&t!=="hidden"){q=true;break}}if(o.value==u&&q){n.fadeIn("fast")}else{n.hide()}}}})},_fieldData:function(h){var i=this;var j=h.id;return new a.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(q){var o=q.values[0];var m=o.id;var p=o.src;var l=i.app.tree.references(j,"data_column");if(l.length<=0){console.debug("tool-form::field_data() - Data column parameters unavailable.");return}for(var n in l){var k=i.app.field_list[l[n]];k.wait&&k.wait()}i.app.content.getDetails({id:m,src:p,success:function(y){var B=null;if(y){console.debug("tool-form::field_data() - Selected content "+m+".");if(p=="hdca"&&y.elements&&y.elements.length>0){y=y.elements[0].object}B=y.metadata_column_types;if(!B){console.debug("tool-form::field_data() - FAILED: Could not find metadata for content "+m+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find content "+m+".")}for(var u in l){var w=i.app.input_list[l[u]];var x=i.app.field_list[l[u]];if(!w||!x){console.debug("tool-form::field_data() - FAILED: Column not found.")}var t=w.numerical;var s=[];for(var A in B){var z=B[A];var r=(parseInt(A)+1);var v="Text";if(z=="int"||z=="float"){v="Number"}if(z=="int"||z=="float"||!t){s.push({label:"Column: "+r+" ["+v+"]",value:r})}}if(x){x.update(s);if(!x.exists(x.value())){x.value(x.first())}x.show()}}}})}})},_fieldSelect:function(h){if(h.is_dynamic){this.app.incompatible=true}var j=[];for(var k in h.options){var l=h.options[k];j.push({label:l[0],value:l[1]})}var m=g.Select;switch(h.display){case"checkboxes":m=g.Checkbox;break;case"radio":m=g.Radio;break}return new m.View({id:"field-"+h.id,data:j,multiple:h.multiple})},_fieldText:function(h){return new g.Input({id:"field-"+h.id,area:h.area})},_fieldSlider:function(h){return new g.Slider.View({id:"field-"+h.id,precise:h.type=="float",min:h.min,max:h.max})},_fieldHidden:function(h){return new g.Hidden({id:"field-"+h.id})},_fieldBoolean:function(h){return new g.RadioButton.View({id:"field-"+h.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}]})}});return{View:f}});
\ No newline at end of file
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-select-content.js
--- a/static/scripts/packed/mvc/tools/tools-select-content.js
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -1,1 +1,1 @@
-define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(n,h){this.options=h;var g=this;this.setElement("<div/>");this.current="hda";this.button_new=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Select datasets",value:"hda"},{icon:"fa-files-o",label:"Select a collection",value:"hdca"}],onchange:function(i){g.current=i;g.refresh();g.trigger("change")}});var l=n.content.filterType({src:"hda",extensions:h.extensions});var k=[];for(var j in l){k.push({label:l[j].name,value:l[j].id})}this.select_datasets=new e.Select.View({multiple:true,data:k,value:k[0]&&k[0].value,onchange:function(){g.trigger("change")}});var m=n.content.filterType({src:"hdca",extensions:h.extensions});var f=[];for(var j in m){f.push({label:m[j].name,value:m[j].id})}this.select_collection=new e.Select.View({data:f,value:f[0]&&f[0].value,onchange:function(){g.trigger("change")}});this.$el.append(c.wrap(this.button_new.$el));this.$el.append(this.select_datasets.$el);this.$el.append(this.select_collection.$el);if(!this.options.multiple){this.$el.append(a.batchMode())}this.refresh();this.on("change",function(){if(h.onchange){h.onchange(g.value())}})},value:function(){var g=null;switch(this.current){case"hda":g=this.select_datasets;break;case"hdca":g=this.select_collection;break}var j=g.value();if(!(j instanceof Array)){j=[j]}var f={batch:!this.options.multiple,values:[]};for(var h in j){f.values.push({id:j[h],src:this.current})}return f},validate:function(){switch(this.current){case"hda":return this.select_datasets.validate();case"hdca":return this.select_collection.validate()}},refresh:function(){switch(this.current){case"hda":this.select_datasets.$el.fadeIn();this.select_collection.$el.hide();break;case"hdca":this.select_datasets.$el.hide();this.select_collection.$el.fadeIn();break}}});return{View:d}});
\ No newline at end of file
+define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(n,h){this.options=h;var g=this;this.setElement("<div/>");this.current="hda";this.button_new=new e.RadioButton.View({value:this.current,data:[{icon:"fa-file-o",label:"Select datasets",value:"hda"},{icon:"fa-files-o",label:"Select a collection",value:"hdca"}],onchange:function(i){g.current=i;g.refresh();g.trigger("change")}});var l=n.content.filterType({src:"hda",extensions:h.extensions});var k=[];for(var j in l){k.push({label:l[j].hid+": "+l[j].name,value:l[j].id})}this.select_datasets=new e.Select.View({multiple:true,data:k,value:k[0]&&k[0].value,onchange:function(){g.trigger("change")}});var m=n.content.filterType({src:"hdca",extensions:h.extensions});var f=[];for(var j in m){f.push({label:m[j].hid+": "+m[j].name,value:m[j].id})}this.select_collection=new e.Select.View({data:f,value:f[0]&&f[0].value,onchange:function(){g.trigger("change")}});this.$el.append(c.wrap(this.button_new.$el));this.$el.append(this.select_datasets.$el);this.$el.append(this.select_collection.$el);if(!this.options.multiple){this.$el.append(a.batchMode())}this.refresh();this.on("change",function(){if(h.onchange){h.onchange(g.value())}})},value:function(k){if(k!==undefined){if(k.values.length>0&&k.values[0]&&k.values[0].src){var j=[];for(var g in k.values){j.push(k.values[g].id)}this.current=k.values[0].src;this.refresh();switch(this.current){case"hda":this.select_datasets.value(j);break;case"hdca":this.select_collection.value(j[0]);break}}}var h=this._select().value();if(!(h instanceof Array)){h=[h]}var f={batch:!this.options.multiple,values:[]};for(var g in h){f.values.push({id:h[g],src:this.current})}return f},validate:function(){return this._select().validate()},refresh:function(){switch(this.current){case"hda":this.select_datasets.$el.fadeIn();this.select_collection.$el.hide();break;case"hdca":this.select_datasets.$el.hide();this.select_collection.$el.fadeIn();break}},_select:function(){switch(this.current){case"hdca":return this.select_collection;default:return this.select_datasets}}});return{View:d}});
\ No newline at end of file
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/tools/tools-template.js
--- a/static/scripts/packed/mvc/tools/tools-template.js
+++ b/static/scripts/packed/mvc/tools/tools-template.js
@@ -1,1 +1,1 @@
-define([],function(){return{help:function(a){return'<div class="toolHelp"><div class="toolHelpBody">'+a+"</div></div>"},citations:function(){return'<div id="citations"></div>'},success:function(c){if(!c.jobs||!c.jobs.length){console.debug("tools-template::success() - Failed jobs.");return}var a=c.jobs.length;var d="";if(a==1){d="1 job has"}else{d=a+" jobs have been"}var b='<div class="donemessagelarge"><p>'+d+" been successfully added to the queue - resulting in the following datasets:</p>";for(var e in c.outputs){b+='<p style="padding: 10px 20px;"><b>'+(parseInt(e)+1)+": "+c.outputs[e].name+"</b></p>"}b+="<p>You can check the status of queued jobs and view the resulting data by refreshing the History pane. When the job has been run the status will change from 'running' to 'finished' if completed successfully or 'error' if problems were encountered.</p></div>";return b},error:function(a){return'<div><p>Sorry, the server could not complete the request. Please contact the Galaxy Team if this error is persistent.</p><textarea class="ui-textarea" disabled style="color: black;" rows="6">'+JSON.stringify(a,undefined,4)+"</textarea></div>"},batchMode:function(){return'<div class="ui-table-form-info"><i class="fa fa-sitemap" style="font-size: 1.2em; padding: 2px 5px;"/>This is a batch mode input field. A separate job will be triggered for each dataset.';"</div>"}}});
\ No newline at end of file
+define([],function(){return{help:function(a){return'<div class="toolHelp"><div class="toolHelpBody">'+a+"</div></div>"},citations:function(){return'<div id="citations"></div>'},success:function(c){if(!c.jobs||!c.jobs.length){console.debug("tools-template::success() - Failed jobs.");return}var a=c.jobs.length;var d="";if(a==1){d="1 job has"}else{d=a+" jobs have been"}var b='<div class="donemessagelarge"><p>'+d+" been successfully added to the queue - resulting in the following datasets:</p>";for(var e in c.outputs){b+='<p style="padding: 10px 20px;"><b>'+(parseInt(e)+1)+": "+c.outputs[e].name+"</b></p>"}b+="<p>You can check the status of queued jobs and view the resulting data by refreshing the History pane. When the job has been run the status will change from 'running' to 'finished' if completed successfully or 'error' if problems were encountered.</p></div>";return b},error:function(a){return'<div><p>The server could not complete the request. Please contact the Galaxy Team if this error persists.</p><textarea class="ui-textarea" disabled style="color: black;" rows="6">'+JSON.stringify(a,undefined,4)+"</textarea></div>"},batchMode:function(){return'<div class="ui-table-form-info"><i class="fa fa-sitemap" style="font-size: 1.2em; padding: 2px 5px;"/>This is a batch mode input field. A separate job will be triggered for each dataset.';"</div>"}}});
\ No newline at end of file
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd static/scripts/packed/mvc/ui/ui-slider.js
--- a/static/scripts/packed/mvc/ui/ui-slider.js
+++ b/static/scripts/packed/mvc/ui/ui-slider.js
@@ -1,1 +1,1 @@
-define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",min:1,max:100,step:1},initialize:function(d){var c=this;this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.$slider=this.$el.find("#slider");this.$text=this.$el.find("#text");this.$slider.slider(this.options);this.$text.on("change",function(){c.value($(this).val())});this.$text.on("keydown",function(f){var e=f.which;console.log(e);if(!(e==8||e==9||e==13||e==37||e==39||e==189||(e>=48&&e<=57)||(c.options.step!=1&&$(this).val().indexOf(".")==-1)&&e==190)){f.preventDefault()}});this.$slider.on("slide",function(e,f){c.value(f.value)})},value:function(c){if(c!==undefined){c=Math.max(Math.min(c,this.options.max),this.options.min);if(this.options.onchange){this.options.onchange(c)}this.$slider.slider("value",c);this.$text.val(c)}return this.$text.val()},_template:function(c){return'<div id="'+c.id+'" class="ui-form-slider"><input id="text" type="text" class="ui-form-slider-text"/><div id="slider" class="ui-form-slider-element"/></div>'}});return{View:b}});
\ No newline at end of file
+define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{value:"",min:null,max:null,step:null,precise:false,split:10000},initialize:function(d){var c=this;this.options=a.merge(d,this.optionsDefault);this.setElement(this._template(this.options));this.useslider=this.options.max!==null&&this.options.min!==null&&this.options.max>this.options.min;if(this.options.step===null){this.options.step=1;if(this.options.precise&&this.useslider){this.options.step=(this.options.max-this.options.min)/this.options.split}}if(this.useslider){this.$slider=this.$el.find("#slider");this.$slider.slider(this.options);this.$slider.on("slide",function(e,f){c.value(f.value)})}else{this.$el.find(".ui-form-slider-text").css("width","100%")}this.$text=this.$el.find("#text");this.$text.on("change",function(){c.value($(this).val())});this.$text.on("keydown",function(f){var e=f.which;if(!(e==8||e==9||e==13||e==37||e==39||e==189||(e>=48&&e<=57)||(c.options.precise&&$(this).val().indexOf(".")==-1)&&e==190)){f.preventDefault()}})},value:function(c){if(c!==undefined){if(this.options.max!==null){c=Math.min(c,this.options.max)}if(this.options.min!==null){c=Math.max(c,this.options.min)}if(this.options.onchange){this.options.onchange(c)}this.$slider&&this.$slider.slider("value",c);this.$text.val(c)}return this.$text.val()},_template:function(c){return'<div id="'+c.id+'" class="ui-form-slider"><input id="text" type="text" class="ui-form-slider-text"/><div id="slider" class="ui-form-slider-element"/></div>'}});return{View:b}});
\ No newline at end of file
diff -r a83921df0dc2047c6874c6daeddbe3047c86cd4e -r 78124761ad558e4670c338fdbdbf371acb6b91bd templates/webapps/galaxy/tool_form_refresh.mako
--- a/templates/webapps/galaxy/tool_form_refresh.mako
+++ b/templates/webapps/galaxy/tool_form_refresh.mako
@@ -4,30 +4,55 @@
tool_model = tool.to_dict(trans)
tool_model['inputs'] = {}
- ## sanitize
+ ## convert value to jsonifiable value
+ def convert(v):
+ # check if value is numeric
+ isnumber = False
+ try:
+ float(v)
+ isnumber = True
+ except Exception:
+ pass
+
+ ## fix hda parsing
+ if isinstance(v, HistoryDatasetAssociation):
+ return {
+ 'id' : trans.security.encode_id(v.id),
+ 'src' : 'hda'
+ }
+ elif isinstance(v, basestring) or isnumber:
+ return v
+ else:
+ return None
+
+ ## ensures that input dictionary is jsonifiable
from collections import Iterable
from galaxy.model import HistoryDatasetAssociation
def sanitize(dict):
- # quotations for Infinity so its jsonifiable
+ ## quotations for Infinity so its jsonifiable
for name in dict:
if dict[name] == Infinity:
dict[name] = 'Infinity'
- value = dict['value'] if 'value' in dict else None;
- # check if value is numeric
- def isnumber(s):
- try:
- float(s)
- return True
- except Exception:
- return False
- # fix hda parsing
- if isinstance(value, HistoryDatasetAssociation):
+
+ ## get current value
+ value = dict['value'] if 'value' in dict else None
+
+ ## identify lists
+ if dict['type'] == 'data':
+ if isinstance(value, list):
+ value = [ convert(v) for v in value ]
+ else:
+ value = [ convert(value) ]
value = {
- 'id' : trans.security.encode_id(value.dataset_id),
- 'src' : 'hda'
+ 'batch' : dict['multiple'],
+ 'values' : value
}
- elif value and not (isinstance(value, basestring) or isnumber(value) or isinstance(value, Iterable)):
- value = 'Unsupported'
+ elif isinstance(value, list):
+ value = [ convert(v) for v in value ]
+ else:
+ value = convert(value)
+
+ ## update and return
dict['value'] = value
return dict
@@ -52,7 +77,7 @@
elif input.type == "conditional":
try:
test_param = group_inputs[input_index]['test_param']
- test_param['value'] = tool_state[test_param['name']]
+ test_param['value'] = group_state[test_param['name']]
except Exception:
pass
i = group_state['__current_case__']
@@ -65,7 +90,7 @@
except Exception:
pass
- ## update input value from tool state and sanitize dictionary
+ ## update input value from tool state
try:
group_inputs[input_index]['value'] = tool_state[group_inputs[input_index]['name']]
group_inputs[input_index] = sanitize(group_inputs[input_index])
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0
15 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/a83921df0dc2/
Changeset: a83921df0dc2
User: carlfeberhard
Date: 2014-10-15 18:12:14+00:00
Summary: Fix to 8f8341a
Affected #: 3 files
diff -r 8f8341ac47cd276cf0a2aa3d1c1098f7d3d58c75 -r a83921df0dc2047c6874c6daeddbe3047c86cd4e client/galaxy/scripts/mvc/history/history-structure-view.js
--- a/client/galaxy/scripts/mvc/history/history-structure-view.js
+++ b/client/galaxy/scripts/mvc/history/history-structure-view.js
@@ -48,7 +48,7 @@
});
// set the collection (HistoryContents) for the job to that json (setting historyId for proper ajax urls)
job.outputCollection.reset( outputModels );
- job.outputCollection.historyId = structure.model.id;
+ job.outputCollection.historyId = view.model.id;
//this.debug( job.outputCollection );
// create the bbone view for the job (to be positioned later accrd. to the layout) and cache
diff -r 8f8341ac47cd276cf0a2aa3d1c1098f7d3d58c75 -r a83921df0dc2047c6874c6daeddbe3047c86cd4e static/scripts/mvc/history/history-structure-view.js
--- a/static/scripts/mvc/history/history-structure-view.js
+++ b/static/scripts/mvc/history/history-structure-view.js
@@ -48,7 +48,7 @@
});
// set the collection (HistoryContents) for the job to that json (setting historyId for proper ajax urls)
job.outputCollection.reset( outputModels );
- job.outputCollection.historyId = structure.model.id;
+ job.outputCollection.historyId = view.model.id;
//this.debug( job.outputCollection );
// create the bbone view for the job (to be positioned later accrd. to the layout) and cache
diff -r 8f8341ac47cd276cf0a2aa3d1c1098f7d3d58c75 -r a83921df0dc2047c6874c6daeddbe3047c86cd4e static/scripts/packed/mvc/history/history-structure-view.js
--- a/static/scripts/packed/mvc/history/history-structure-view.js
+++ b/static/scripts/packed/mvc/history/history-structure-view.js
@@ -1,1 +1,1 @@
-define(["mvc/job/job-model","mvc/job/job-li","mvc/history/history-content-model","mvc/history/job-dag","mvc/base-mvc","utils/localization","libs/d3"],function(e,f,i,c,h,a){var b=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure-component",initialize:function(j){this.log(this+"(HistoryStructureComponent).initialize:",j);this.component=j.component;this._jobLiMap={};this._createJobModels();this.layout=this._createLayout(j.layoutOptions)},_createJobModels:function(){var j=this;j.component.eachVertex(function(o){var n=o.data.job,m=new e.Job(n);var l=_.map(m.get("outputs"),function(p){var r=p.src==="hda"?"dataset":"dataset_collection",q=i.typeIdStr(r,p.id);return j.model.contents.get(q)});m.outputCollection.reset(l);m.outputCollection.historyId=structure.model.id;var k=new f.JobListItemView({model:m,expanded:true});k.$el.appendTo(j.$el);j._jobLiMap[m.id]=k});return j.jobs},layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobHeight:308,jobWidthSpacing:320,linkAdjX:4,linkAdjY:0},_createLayout:function(l){l=_.defaults(_.clone(l||{}),this.layoutDefaults);var j=this,k=_.values(j.component.vertices),m=_.extend(l,{nodeMap:{},links:[],el:{width:0,height:0},svg:{width:0,height:0,top:0,left:0}});k.forEach(function(n,o){var p={name:n.name,x:0,y:0};m.nodeMap[n.name]=p});j.component.edges(function(o){var n={source:o.source,target:o.target};m.links.push(n)});return m},_updateLayout:function(){var k=this,l=k.layout;l.svg.height=l.paddingTop+(l.linkSpacing*_.size(l.nodeMap));l.el.height=l.svg.height+l.jobHeight;var j=l.paddingLeft,m=l.svg.height;_.each(l.nodeMap,function(o,n){o.x=j;o.y=m;j+=l.jobWidthSpacing});l.el.width=l.svg.width=Math.max(l.el.width,j);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY});return this.layout},render:function(k){this.log(this+".renderComponent:",k);var j=this;j.component.eachVertex(function(m){var l=j._jobLiMap[m.name];if(!l.$el.is(":visible")){l.render(0)}});j._updateLayout();j.$el.width(j.layout.el.width).height(j.layout.el.height);this.renderSVG();j.component.eachVertex(function(n){var m=j._jobLiMap[n.name],l=j.layout.nodeMap[m.model.id];m.$el.css({top:l.y,left:l.x})});return this},renderSVG:function(){var j=this,o=j.layout;var k=d3.select(this.el).select("svg");if(k.empty()){k=d3.select(this.el).append("svg")}k.attr("width",o.svg.width).attr("height",o.svg.height);function m(p){d3.select(this).classed("highlighted",true);j._jobLiMap[p.source].$el.addClass("highlighted");j._jobLiMap[p.target].$el.addClass("highlighted")}function l(p){d3.select(this).classed("highlighted",false);j._jobLiMap[p.source].$el.removeClass("highlighted");j._jobLiMap[p.target].$el.removeClass("highlighted")}var n=k.selectAll(".connection").data(o.links);n.enter().append("path").attr("class","connection").attr("id",function(p){return p.source+"-"+p.target}).on("mouseover",m).on("mouseout",l);n.transition().attr("d",function(p){return j._connectionPath(p)});return k.node()},_connectionPath:function(k){var l=0,j=((k.x2-k.x1)/this.layout.svg.width)*this.layout.svg.height;return["M",k.x1,",",k.y1," ","C",k.x1+l,",",k.y1-j," ",k.x2-l,",",k.y2-j," ",k.x2,",",k.y2].join("")},events:{"mouseover .job.list-item":function(j){this.highlightConnected(j.currentTarget,true)},"mouseout .job.list-item":function(j){this.highlightConnected(j.currentTarget,false)}},highlightConnected:function(p,k){k=k!==undefined?k:true;var j=this,l=j.component,n=k?jQuery.prototype.addClass:jQuery.prototype.removeClass,m=k?"connection highlighted":"connection";var o=n.call($(p),"highlighted"),q=o.attr("id").replace("job-","");l.edges({target:q}).forEach(function(r){n.call(j.$("#job-"+r.source),"highlighted");j.$("#"+r.source+"-"+q).attr("class",m)});l.vertices[q].eachEdge(function(r){n.call(j.$("#job-"+r.target),"highlighted");j.$("#"+q+"-"+r.target).attr("class",m)})},toString:function(){return"HistoryStructureComponent("+this.model.id+")"}});var g=b.extend({logger:console,className:b.prototype.className+" vertical",layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobWidth:308,jobHeight:308,initialSpacing:64,jobSpacing:16,linkAdjX:0,linkAdjY:4},_updateLayout:function(){var k=this,l=k.layout;l.svg.width=l.paddingLeft+(l.linkSpacing*_.size(l.nodeMap));l.el.width=l.svg.width+l.jobWidth;l.el.height=0;var j=l.svg.width,m=l.paddingTop;_.each(l.nodeMap,function(p,o){p.x=j;p.y=m;var n=k._jobLiMap[o];if(n.$el.is(":visible")){m+=n.$el.height()+l.jobSpacing}else{m+=l.initialSpacing+l.jobSpacing}});l.el.height=l.svg.height=Math.max(l.el.height,m);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY;k.debug("link:",n.x1,n.y1,n.x2,n.y2,n)});k.debug("el:",l.el);k.debug("svg:",l.svg);return l},_connectionPath:function(l){var k=0,j=((l.y2-l.y1)/this.layout.svg.height)*this.layout.svg.width;return["M",l.x1,",",l.y1," ","C",l.x1-j,",",l.y1+k," ",l.x2-j,",",l.y2-k," ",l.x2,",",l.y2].join("")},toString:function(){return"VerticalHistoryStructureComponent("+this.model.id+")"}});var d=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure",initialize:function(j){this.log(this+"(HistoryStructureView).initialize:",j,this.model);this.jobs=j.jobs;this._createDAG()},_createDAG:function(){this.dag=new c({historyContents:this.model.contents.toJSON(),jobs:this.jobs,excludeSetMetadata:true,excludeErroredJobs:true});this.log(this+".dag:",this.dag);this._createComponents()},_createComponents:function(){this.log(this+"._createComponents");var j=this;j.componentViews=j.dag.weakComponentGraphArray().map(function(k){return j._createComponent(k)})},_createComponent:function(j){this.log(this+"._createComponent:",j);return new b({model:this.model,component:j})},render:function(k){this.log(this+".render:",k);var j=this;j.$el.html(['<div class="controls"></div>','<div class="components"></div>'].join(""));j.componentViews.forEach(function(l){l.render().$el.appendTo(j.$components())});return j},$components:function(){return this.$(".components")},toString:function(){return"HistoryStructureView()"}});return d});
\ No newline at end of file
+define(["mvc/job/job-model","mvc/job/job-li","mvc/history/history-content-model","mvc/history/job-dag","mvc/base-mvc","utils/localization","libs/d3"],function(e,f,i,c,h,a){var b=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure-component",initialize:function(j){this.log(this+"(HistoryStructureComponent).initialize:",j);this.component=j.component;this._jobLiMap={};this._createJobModels();this.layout=this._createLayout(j.layoutOptions)},_createJobModels:function(){var j=this;j.component.eachVertex(function(o){var n=o.data.job,m=new e.Job(n);var l=_.map(m.get("outputs"),function(p){var r=p.src==="hda"?"dataset":"dataset_collection",q=i.typeIdStr(r,p.id);return j.model.contents.get(q)});m.outputCollection.reset(l);m.outputCollection.historyId=j.model.id;var k=new f.JobListItemView({model:m,expanded:true});k.$el.appendTo(j.$el);j._jobLiMap[m.id]=k});return j.jobs},layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobHeight:308,jobWidthSpacing:320,linkAdjX:4,linkAdjY:0},_createLayout:function(l){l=_.defaults(_.clone(l||{}),this.layoutDefaults);var j=this,k=_.values(j.component.vertices),m=_.extend(l,{nodeMap:{},links:[],el:{width:0,height:0},svg:{width:0,height:0,top:0,left:0}});k.forEach(function(n,o){var p={name:n.name,x:0,y:0};m.nodeMap[n.name]=p});j.component.edges(function(o){var n={source:o.source,target:o.target};m.links.push(n)});return m},_updateLayout:function(){var k=this,l=k.layout;l.svg.height=l.paddingTop+(l.linkSpacing*_.size(l.nodeMap));l.el.height=l.svg.height+l.jobHeight;var j=l.paddingLeft,m=l.svg.height;_.each(l.nodeMap,function(o,n){o.x=j;o.y=m;j+=l.jobWidthSpacing});l.el.width=l.svg.width=Math.max(l.el.width,j);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY});return this.layout},render:function(k){this.log(this+".renderComponent:",k);var j=this;j.component.eachVertex(function(m){var l=j._jobLiMap[m.name];if(!l.$el.is(":visible")){l.render(0)}});j._updateLayout();j.$el.width(j.layout.el.width).height(j.layout.el.height);this.renderSVG();j.component.eachVertex(function(n){var m=j._jobLiMap[n.name],l=j.layout.nodeMap[m.model.id];m.$el.css({top:l.y,left:l.x})});return this},renderSVG:function(){var j=this,o=j.layout;var k=d3.select(this.el).select("svg");if(k.empty()){k=d3.select(this.el).append("svg")}k.attr("width",o.svg.width).attr("height",o.svg.height);function m(p){d3.select(this).classed("highlighted",true);j._jobLiMap[p.source].$el.addClass("highlighted");j._jobLiMap[p.target].$el.addClass("highlighted")}function l(p){d3.select(this).classed("highlighted",false);j._jobLiMap[p.source].$el.removeClass("highlighted");j._jobLiMap[p.target].$el.removeClass("highlighted")}var n=k.selectAll(".connection").data(o.links);n.enter().append("path").attr("class","connection").attr("id",function(p){return p.source+"-"+p.target}).on("mouseover",m).on("mouseout",l);n.transition().attr("d",function(p){return j._connectionPath(p)});return k.node()},_connectionPath:function(k){var l=0,j=((k.x2-k.x1)/this.layout.svg.width)*this.layout.svg.height;return["M",k.x1,",",k.y1," ","C",k.x1+l,",",k.y1-j," ",k.x2-l,",",k.y2-j," ",k.x2,",",k.y2].join("")},events:{"mouseover .job.list-item":function(j){this.highlightConnected(j.currentTarget,true)},"mouseout .job.list-item":function(j){this.highlightConnected(j.currentTarget,false)}},highlightConnected:function(p,k){k=k!==undefined?k:true;var j=this,l=j.component,n=k?jQuery.prototype.addClass:jQuery.prototype.removeClass,m=k?"connection highlighted":"connection";var o=n.call($(p),"highlighted"),q=o.attr("id").replace("job-","");l.edges({target:q}).forEach(function(r){n.call(j.$("#job-"+r.source),"highlighted");j.$("#"+r.source+"-"+q).attr("class",m)});l.vertices[q].eachEdge(function(r){n.call(j.$("#job-"+r.target),"highlighted");j.$("#"+q+"-"+r.target).attr("class",m)})},toString:function(){return"HistoryStructureComponent("+this.model.id+")"}});var g=b.extend({logger:console,className:b.prototype.className+" vertical",layoutDefaults:{paddingTop:8,paddingLeft:20,linkSpacing:16,jobWidth:308,jobHeight:308,initialSpacing:64,jobSpacing:16,linkAdjX:0,linkAdjY:4},_updateLayout:function(){var k=this,l=k.layout;l.svg.width=l.paddingLeft+(l.linkSpacing*_.size(l.nodeMap));l.el.width=l.svg.width+l.jobWidth;l.el.height=0;var j=l.svg.width,m=l.paddingTop;_.each(l.nodeMap,function(p,o){p.x=j;p.y=m;var n=k._jobLiMap[o];if(n.$el.is(":visible")){m+=n.$el.height()+l.jobSpacing}else{m+=l.initialSpacing+l.jobSpacing}});l.el.height=l.svg.height=Math.max(l.el.height,m);l.links.forEach(function(n){var o=l.nodeMap[n.source],p=l.nodeMap[n.target];n.x1=o.x+l.linkAdjX;n.y1=o.y+l.linkAdjY;n.x2=p.x+l.linkAdjX;n.y2=p.y+l.linkAdjY;k.debug("link:",n.x1,n.y1,n.x2,n.y2,n)});k.debug("el:",l.el);k.debug("svg:",l.svg);return l},_connectionPath:function(l){var k=0,j=((l.y2-l.y1)/this.layout.svg.height)*this.layout.svg.width;return["M",l.x1,",",l.y1," ","C",l.x1-j,",",l.y1+k," ",l.x2-j,",",l.y2-k," ",l.x2,",",l.y2].join("")},toString:function(){return"VerticalHistoryStructureComponent("+this.model.id+")"}});var d=Backbone.View.extend(h.LoggableMixin).extend({className:"history-structure",initialize:function(j){this.log(this+"(HistoryStructureView).initialize:",j,this.model);this.jobs=j.jobs;this._createDAG()},_createDAG:function(){this.dag=new c({historyContents:this.model.contents.toJSON(),jobs:this.jobs,excludeSetMetadata:true,excludeErroredJobs:true});this.log(this+".dag:",this.dag);this._createComponents()},_createComponents:function(){this.log(this+"._createComponents");var j=this;j.componentViews=j.dag.weakComponentGraphArray().map(function(k){return j._createComponent(k)})},_createComponent:function(j){this.log(this+"._createComponent:",j);return new b({model:this.model,component:j})},render:function(k){this.log(this+".render:",k);var j=this;j.$el.html(['<div class="controls"></div>','<div class="components"></div>'].join(""));j.componentViews.forEach(function(l){l.render().$el.appendTo(j.$components())});return j},$components:function(){return this.$(".components")},toString:function(){return"HistoryStructureView()"}});return d});
\ No newline at end of file
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1
0