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: Replace error modal
by commits-noreply@bitbucket.org 08 Oct '14
by commits-noreply@bitbucket.org 08 Oct '14
08 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/f08384fff770/
Changeset: f08384fff770
User: guerler
Date: 2014-10-09 02:38:36+00:00
Summary: ToolForm: Replace error modal
Affected #: 3 files
diff -r 40742ec31f5cdbcf337df5ee1c47637e78168501 -r f08384fff7709c7edb3a3f8b6883bc398f3e78d8 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
@@ -57,17 +57,9 @@
self._foundError(input_id, error_messages[input_id]);
}
} else {
- // show modal with error message
- self.app.modal.show({
- title: response_full.statusText,
- body: ToolTemplate.error(job_def),
- closing_events: true,
- buttons: {
- 'Close': function() {
- self.app.modal.hide();
- }
- }
- });
+ // show error message with details
+ console.debug(job_def);
+ console.debug(response);
}
}
});
diff -r 40742ec31f5cdbcf337df5ee1c47637e78168501 -r f08384fff7709c7edb3a3f8b6883bc398f3e78d8 static/scripts/mvc/tools/tools-jobs.js
--- a/static/scripts/mvc/tools/tools-jobs.js
+++ b/static/scripts/mvc/tools/tools-jobs.js
@@ -57,17 +57,9 @@
self._foundError(input_id, error_messages[input_id]);
}
} else {
- // show modal with error message
- self.app.modal.show({
- title: response_full.statusText,
- body: ToolTemplate.error(job_def),
- closing_events: true,
- buttons: {
- 'Close': function() {
- self.app.modal.hide();
- }
- }
- });
+ // show error message with details
+ console.debug(job_def);
+ console.debug(response);
}
}
});
diff -r 40742ec31f5cdbcf337df5ee1c47637e78168501 -r f08384fff7709c7edb3a3f8b6883bc398f3e78d8 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{c.app.modal.show({title:g.statusText,body:a.error(d),closing_events:true,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.");if(this.valid){$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500);this.valid=false}},_validation:function(g){var c=g.inputs;this.valid=true;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&&!h.optional&&d&&d.validate&&!d.validate()){this._foundError(j)}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 this.valid},_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",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(d);console.debug(e)}}})},_foundError:function(c,d){var e=this.app.element_list[c];e.error(d||"Please verify this parameter.");if(this.valid){$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500);this.valid=false}},_validation:function(g){var c=g.inputs;this.valid=true;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&&!h.optional&&d&&d.validate&&!d.validate()){this._foundError(j)}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 this.valid},_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: guerler: ToolForm: Add close button to modal
by commits-noreply@bitbucket.org 08 Oct '14
by commits-noreply@bitbucket.org 08 Oct '14
08 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/40742ec31f5c/
Changeset: 40742ec31f5c
User: guerler
Date: 2014-10-09 02:31:32+00:00
Summary: ToolForm: Add close button to modal
Affected #: 3 files
diff -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 -r 40742ec31f5cdbcf337df5ee1c47637e78168501 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'});
+ this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }});
// post job
Utils.request({
diff -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 -r 40742ec31f5cdbcf337df5ee1c47637e78168501 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'});
+ this.app.modal.show({title: 'Please wait...', body: 'progress', buttons: { 'Close' : function () {self.app.modal.hide();} }});
// post job
Utils.request({
diff -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 -r 40742ec31f5cdbcf337df5ee1c47637e78168501 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"});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{c.app.modal.show({title:g.statusText,body:a.error(d),closing_events:true,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.");if(this.valid){$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500);this.valid=false}},_validation:function(g){var c=g.inputs;this.valid=true;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&&!h.optional&&d&&d.validate&&!d.validate()){this._foundError(j)}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 this.valid},_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",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{c.app.modal.show({title:g.statusText,body:a.error(d),closing_events:true,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.");if(this.valid){$(this.app.container).animate({scrollTop:e.$el.offset().top-20},500);this.valid=false}},_validation:function(g){var c=g.inputs;this.valid=true;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&&!h.optional&&d&&d.validate&&!d.validate()){this._foundError(j)}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 this.valid},_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: guerler: ToolForm: Fix empty collection
by commits-noreply@bitbucket.org 08 Oct '14
by commits-noreply@bitbucket.org 08 Oct '14
08 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/86825b18e71f/
Changeset: 86825b18e71f
User: guerler
Date: 2014-10-08 20:31:22+00:00
Summary: ToolForm: Fix empty collection
Affected #: 7 files
diff -r 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 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
@@ -86,16 +86,26 @@
/** Get details of a content by id.
*/
getDetails: function(options) {
+ // check id
+ if (!options.id || options.id === 'null') {
+ options.success && options.success();
+ return;
+ }
+
+ // create url
var api_url = this.base_url + '/datasets/' + options.id;
if (options.src == 'hdca') {
api_url = this.base_url + '/dataset_collections/' + options.id;
}
+
+ // request details
Utils.get({
url : api_url,
success : function(response) {
options.success && options.success(response);
},
error : function(response) {
+ options.success && options.success();
console.debug('tools-content::getDetails() - Ajax request for content failed.');
console.debug(response);
}
diff -r 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 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
@@ -447,11 +447,6 @@
id : content_id,
src : content_src,
success : function(content) {
- // select the first dataset to represent collections
- if (content_src == 'hdca' && content.elements && content.elements.length > 0) {
- content = content.elements[0].object;
- }
-
// meta data
var meta = null;
@@ -460,6 +455,11 @@
// log selection
console.debug('tool-form::field_data() - Selected content ' + content_id + '.');
+ // select the first dataset to represent collections
+ if (content_src == 'hdca' && content.elements && content.elements.length > 0) {
+ content = content.elements[0].object;
+ }
+
// get meta data
meta = content.metadata_column_types;
diff -r 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 lib/galaxy/webapps/galaxy/api/history_contents.py
--- a/lib/galaxy/webapps/galaxy/api/history_contents.py
+++ b/lib/galaxy/webapps/galaxy/api/history_contents.py
@@ -204,7 +204,7 @@
except Exception, e:
log.exception( "Error in history API at listing dataset collection: %s", e )
trans.response.status = 500
- return msg
+ return { 'error': str( e ) }
def __show_dataset( self, trans, id, **kwd ):
hda = self.mgrs.hdas.get( trans, self._decode_id( trans, id ), check_ownership=False, check_accessible=True )
diff -r 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 static/scripts/mvc/tools/tools-content.js
--- a/static/scripts/mvc/tools/tools-content.js
+++ b/static/scripts/mvc/tools/tools-content.js
@@ -86,16 +86,26 @@
/** Get details of a content by id.
*/
getDetails: function(options) {
+ // check id
+ if (!options.id || options.id === 'null') {
+ options.success && options.success();
+ return;
+ }
+
+ // create url
var api_url = this.base_url + '/datasets/' + options.id;
if (options.src == 'hdca') {
api_url = this.base_url + '/dataset_collections/' + options.id;
}
+
+ // request details
Utils.get({
url : api_url,
success : function(response) {
options.success && options.success(response);
},
error : function(response) {
+ options.success && options.success();
console.debug('tools-content::getDetails() - Ajax request for content failed.');
console.debug(response);
}
diff -r 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -447,11 +447,6 @@
id : content_id,
src : content_src,
success : function(content) {
- // select the first dataset to represent collections
- if (content_src == 'hdca' && content.elements && content.elements.length > 0) {
- content = content.elements[0].object;
- }
-
// meta data
var meta = null;
@@ -460,6 +455,11 @@
// log selection
console.debug('tool-form::field_data() - Selected content ' + content_id + '.');
+ // select the first dataset to represent collections
+ if (content_src == 'hdca' && content.elements && content.elements.length > 0) {
+ content = content.elements[0].object;
+ }
+
// get meta data
meta = content.metadata_column_types;
diff -r 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 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},getDetails:function(b){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){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;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},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 05f112a611b683c82acd6f5c4918cff299daf2c5 -r 86825b18e71f05e6eec2904edf9d9ba7b0490698 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"],function(d,b,g,c,a){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});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(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.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":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,help:h.help,$el:i.$el});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){if(p=="hdca"&&y.elements&&y.elements.length>0){y=y.elements[0].object}var B=null;if(y){console.debug("tool-form::field_data() - Selected content "+m+".");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){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"],function(d,b,g,c,a){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});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(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.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":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,help:h.help,$el:i.$el});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){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
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: Merged in martenson/galaxy-stable-pr/stable (pull request #520)
by commits-noreply@bitbucket.org 08 Oct '14
by commits-noreply@bitbucket.org 08 Oct '14
08 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/bde1c35ef8e5/
Changeset: bde1c35ef8e5
Branch: stable
User: jmchilton
Date: 2014-10-08 20:21:35+00:00
Summary: Merged in martenson/galaxy-stable-pr/stable (pull request #520)
[STABLE] missing import
Affected #: 1 file
diff -r e98b33105381ac94f590edee1859ab550d328833 -r bde1c35ef8e53d0436507c48ed9b08b1dc5b06a3 lib/tool_shed/metadata/repository_metadata_manager.py
--- a/lib/tool_shed/metadata/repository_metadata_manager.py
+++ b/lib/tool_shed/metadata/repository_metadata_manager.py
@@ -5,6 +5,7 @@
from galaxy import util
from galaxy.util import inflector
from galaxy.web.form_builder import SelectField
+from galaxy.model.orm import or_
from tool_shed.metadata import metadata_generator
from tool_shed.repository_types.metadata import TipOnly
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
2 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/3a193ffba363/
Changeset: 3a193ffba363
Branch: stable
User: martenson
Date: 2014-10-08 18:27:41+00:00
Summary: missing import
Affected #: 1 file
diff -r 007f6a80629a74650b72d67821a9505932d284f3 -r 3a193ffba363cf10224568986c2c1c192bc8bca1 lib/tool_shed/metadata/repository_metadata_manager.py
--- a/lib/tool_shed/metadata/repository_metadata_manager.py
+++ b/lib/tool_shed/metadata/repository_metadata_manager.py
@@ -5,6 +5,7 @@
from galaxy import util
from galaxy.util import inflector
from galaxy.web.form_builder import SelectField
+from galaxy.model.orm import or_
from tool_shed.metadata import metadata_generator
from tool_shed.repository_types.metadata import TipOnly
https://bitbucket.org/galaxy/galaxy-central/commits/bde1c35ef8e5/
Changeset: bde1c35ef8e5
Branch: stable
User: jmchilton
Date: 2014-10-08 20:21:35+00:00
Summary: Merged in martenson/galaxy-stable-pr/stable (pull request #520)
[STABLE] missing import
Affected #: 1 file
diff -r e98b33105381ac94f590edee1859ab550d328833 -r bde1c35ef8e53d0436507c48ed9b08b1dc5b06a3 lib/tool_shed/metadata/repository_metadata_manager.py
--- a/lib/tool_shed/metadata/repository_metadata_manager.py
+++ b/lib/tool_shed/metadata/repository_metadata_manager.py
@@ -5,6 +5,7 @@
from galaxy import util
from galaxy.util import inflector
from galaxy.web.form_builder import SelectField
+from galaxy.model.orm import or_
from tool_shed.metadata import metadata_generator
from tool_shed.repository_types.metadata import TipOnly
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: Temporary tool form activation.
by commits-noreply@bitbucket.org 08 Oct '14
by commits-noreply@bitbucket.org 08 Oct '14
08 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/05f112a611b6/
Changeset: 05f112a611b6
User: guerler
Date: 2014-10-08 19:50:57+00:00
Summary: ToolForm: Temporary tool form activation.
Affected #: 2 files
diff -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa -r 05f112a611b683c82acd6f5c4918cff299daf2c5 lib/galaxy/tools/__init__.py
--- a/lib/galaxy/tools/__init__.py
+++ b/lib/galaxy/tools/__init__.py
@@ -1235,7 +1235,7 @@
requires_setting_metadata = True
default_tool_action = DefaultToolAction
dict_collection_visible_keys = ( 'id', 'name', 'version', 'description' )
- default_template = 'tool_form.mako'
+ default_template = 'tool_form.api.mako'
def __init__( self, config_file, root, app, guid=None, repository_id=None ):
"""Load a tool from the config named by `config_file`"""
diff -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa -r 05f112a611b683c82acd6f5c4918cff299daf2c5 templates/webapps/galaxy/tool_form.mako
--- a/templates/webapps/galaxy/tool_form.mako
+++ b/templates/webapps/galaxy/tool_form.mako
@@ -1,4 +1,4 @@
-<%inherit file="/base.mako"/>
+##<%inherit file="/base.mako"/><%namespace file="/message.mako" import="render_msg" /><%namespace file="/base_panels.mako" import="overlay" />
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: Improve collection handling
by commits-noreply@bitbucket.org 08 Oct '14
by commits-noreply@bitbucket.org 08 Oct '14
08 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/a979bd1bb194/
Changeset: a979bd1bb194
User: guerler
Date: 2014-10-08 18:32:48+00:00
Summary: ToolForm: Improve collection handling
Affected #: 18 files
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa client/galaxy/scripts/mvc/tools/tools-content.js
--- /dev/null
+++ b/client/galaxy/scripts/mvc/tools/tools-content.js
@@ -0,0 +1,132 @@
+define(['utils/utils'], function(Utils){
+ return Backbone.Model.extend({
+ // initialize
+ initialize: function(options) {
+ // backup basic url
+ this.base_url = galaxy_config.root + 'api/histories/' + options.history_id + '/contents';
+
+ // prepare content obects
+ this.datatypes = {};
+ this.summary = {};
+
+ // link this
+ var self = this;
+
+ // request datatypes
+ Utils.get({
+ url : galaxy_config.root + 'api/datatypes/mapping',
+ cache : true,
+ success : function(response) {
+ // backup datatype dictionary
+ self.datatypes = response;
+
+ // get history summary
+ Utils.get({
+ url : self.base_url + '?deleted=false',
+ success : function(response) {
+ // backup summary
+ self.summary = response;
+
+ // log
+ console.debug('tools-content::initialize() - Completed.');
+
+ // callback
+ options.success && options.success();
+ },
+ error : function(response) {
+ // log request failure
+ console.debug('tools-content::initialize() - Ajax request for summary failed.');
+ console.debug(response);
+ }
+ });
+ },
+ error : function(response) {
+ // log request failure
+ console.debug('tools-content::initialize() - Ajax request for datatypes failed.');
+ console.debug(response);
+ }
+ });
+ },
+
+ /**
+ * Filters contents by data type.
+ */
+ filterType: function(options) {
+ // initialize parameters
+ options = options || {};
+ var result = [];
+
+ // identify content type
+ var history_content_type = 'dataset';
+ if (options.src== 'hdca') {
+ history_content_type = 'dataset_collection';
+ }
+
+ // search in summary
+ for (var i in this.summary) {
+ var content = this.summary[i];
+
+ // match datatypes
+ var found = false;
+ for (var i in options.extensions) {
+ if (this._matchType(options.extensions[i], content.extension)) {
+ found = true;
+ break;
+ }
+ }
+
+ // final match result
+ if ((content.history_content_type === history_content_type) && (found || !options.extensions)) {
+ result.push(content);
+ }
+ }
+ return result;
+ },
+
+ /** Get details of a content by id.
+ */
+ getDetails: function(options) {
+ var api_url = this.base_url + '/datasets/' + options.id;
+ if (options.src == 'hdca') {
+ api_url = this.base_url + '/dataset_collections/' + options.id;
+ }
+ Utils.get({
+ url : api_url,
+ success : function(response) {
+ options.success && options.success(response);
+ },
+ error : function(response) {
+ console.debug('tools-content::getDetails() - Ajax request for content failed.');
+ console.debug(response);
+ }
+ });
+ },
+
+ /** Check if datatypes match
+ */
+ _matchType: function(target, reference) {
+ // check if target class is available
+ var target_class = this.datatypes.ext_to_class_name[target];
+ if (!target_class) {
+ console.debug('tools-content::_matchType() - Specific target class unavailable. Accepting all formats.');
+ return true;
+ }
+
+ // check if reference class is available
+ var reference_class = this.datatypes.ext_to_class_name[reference];
+ if (!reference_class) {
+ console.debug('tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.');
+ return true;
+ }
+
+ // check reference group
+ var reference_group = this.datatypes.class_to_classes[reference_class];
+ if (reference_group[target_class]) {
+ return true;
+ }
+
+ // classes do not match
+ return false;
+ }
+ });
+});
\ No newline at end of file
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa client/galaxy/scripts/mvc/tools/tools-datasets.js
--- a/client/galaxy/scripts/mvc/tools/tools-datasets.js
+++ /dev/null
@@ -1,117 +0,0 @@
-define(['utils/utils'], function(Utils){
- return Backbone.Model.extend({
- // initialize
- initialize: function(options) {
- // prepare datasets obects
- this.datatypes = {};
- this.summary = {};
-
- // link this
- var self = this;
-
- // request datatypes
- Utils.get({
- url : galaxy_config.root + 'api/datatypes/mapping',
- cache : true,
- success : function(response) {
- // backup datatype dictionary
- self.datatypes = response;
-
- // get history summary
- Utils.get({
- url : galaxy_config.root + 'api/histories/' + options.history_id + '/contents?deleted=false',
- success : function(response) {
- // backup summary
- self.summary = response;
-
- // log
- console.debug('tools-datasets::initialize() - Completed.');
-
- // callback
- options.success && options.success();
- },
- error : function(response) {
- // log request failure
- console.debug('tools-datasets::initialize() - Ajax request for summary failed.');
- console.debug(response);
- }
- });
- },
- error : function(response) {
- // log request failure
- console.debug('tools-datasets::initialize() - Ajax request for datatypes failed.');
- console.debug(response);
- }
- });
- },
-
- /**
- * Filters datasets by data type.
- */
- filterType: function(options) {
- options = options || {};
- var result = [];
- for (var i in this.summary) {
- var dataset = this.summary[i];
-
- // match datatypes
- var found = false;
- for (var i in options.data_types) {
- if (this._matchType(options.data_types[i], dataset.extension)) {
- found = true;
- break;
- }
- }
-
- // final match result
- if ((dataset.history_content_type === options.content_type || !options.content_type) && (found || !options.data_types)) {
- result.push(dataset);
- }
- }
- return result;
- },
-
- /** Get details of a dataset by id.
- * @param{String} Dataset id
- */
- getDetails: function(dataset_id, callback) {
- Utils.get({
- url : galaxy_config.root + 'api/datasets/' + dataset_id,
- success : function(response) {
- callback && callback(response);
- },
- error : function(response) {
- console.debug('tools-datasets::getDetails() - Ajax request for dataset failed.');
- console.debug(response);
- }
- });
- },
-
- /** Check if datatypes match
- */
- _matchType: function(target, reference) {
- // check if target class is available
- var target_class = this.datatypes.ext_to_class_name[target];
- if (!target_class) {
- console.debug('tools-datasets::_matchType() - Specific target class unavailable. Accepting all formats.');
- return true;
- }
-
- // check if reference class is available
- var reference_class = this.datatypes.ext_to_class_name[reference];
- if (!reference_class) {
- console.debug('tools-datasets::_matchType() - Specific reference class unavailable. Accepting all formats.');
- return true;
- }
-
- // check reference group
- var reference_group = this.datatypes.class_to_classes[reference_class];
- if (reference_group[target_class]) {
- return true;
- }
-
- // classes do not match
- return false;
- }
- });
-});
\ No newline at end of file
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa 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
@@ -3,9 +3,9 @@
*/
define(['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-datasets', 'mvc/tools/tools-section', 'mvc/tools/tools-tree', 'mvc/tools/tools-jobs'],
+ 'mvc/tools', 'mvc/tools/tools-template', 'mvc/tools/tools-content', 'mvc/tools/tools-section', 'mvc/tools/tools-tree', 'mvc/tools/tools-jobs'],
function(Portlet, Ui, CitationModel, CitationView,
- Tools, ToolTemplate, ToolDatasets, ToolSection, ToolTree, ToolJobs) {
+ Tools, ToolTemplate, ToolContent, ToolSection, ToolTree, ToolJobs) {
// create tool model
var Model = Backbone.Model.extend({
@@ -61,8 +61,8 @@
// reset input element list, which contains the dom elements of each input element (includes also the input field)
this.element_list = {};
- // initialize datasets
- this.datasets = new ToolDatasets({
+ // initialize contents
+ this.content = new ToolContent({
history_id : this.options.history_id,
success : function() {
self._initializeToolForm();
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa 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
@@ -1,8 +1,8 @@
/**
This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function.
*/
-define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-dataset'],
- function(Utils, Table, Ui, Repeat, SelectDataset) {
+define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content'],
+ function(Utils, Table, Ui, Repeat, SelectContent) {
// input field element wrapper
var InputElement = Backbone.View.extend({
@@ -268,12 +268,12 @@
field = this._fieldSelect(input_def);
break;
- // dataset
+ // data selector
case 'data':
field = this._fieldData(input_def);
break;
- // dataset column
+ // data column
case 'data_column':
field = this._fieldSelect(input_def);
break;
@@ -417,13 +417,15 @@
var id = input_def.id;
// select field
- return new SelectDataset.View(this.app, {
+ return new SelectContent.View(this.app, {
id : 'field-' + id,
extensions : input_def.extensions,
multiple : input_def.multiple,
onchange : function(dict) {
- // pick the first dataset only (todo: maybe collect multiple meta information)
- var value = dict.values[0].id;
+ // pick the first content only (todo: maybe collect multiple meta information)
+ var content_def = dict.values[0];
+ var content_id = content_def.id;
+ var content_src = content_def.src;
// get referenced columns
var column_list = self.app.tree.references(id, 'data_column');
@@ -440,71 +442,80 @@
column_field.wait && column_field.wait();
}
- // find selected dataset
- self.app.datasets.getDetails(value, function(dataset) {
- // meta data
- var meta = null;
-
- // check dataset
- if (dataset) {
- // log selection
- console.debug('tool-form::field_data() - Selected dataset ' + value + '.');
-
- // get meta data
- meta = dataset.metadata_column_types;
-
- // check meta data
- if (!meta) {
- console.debug('tool-form::field_data() - FAILED: Could not find metadata for dataset ' + value + '.');
+ // find selected content
+ self.app.content.getDetails({
+ id : content_id,
+ src : content_src,
+ success : function(content) {
+ // select the first dataset to represent collections
+ if (content_src == 'hdca' && content.elements && content.elements.length > 0) {
+ content = content.elements[0].object;
}
- } else {
- console.debug('tool-form::field_data() - FAILED: Could not find dataset ' + value + '.');
- }
-
- // update referenced columns
- for (var i in column_list) {
- // get column input/field
- var column_input = self.app.input_list[column_list[i]];
- var column_field = self.app.field_list[column_list[i]];
- if (!column_input || !column_field) {
- console.debug('tool-form::field_data() - FAILED: Column not found.');
+
+ // meta data
+ var meta = null;
+
+ // check content
+ if (content) {
+ // log selection
+ console.debug('tool-form::field_data() - Selected content ' + content_id + '.');
+
+ // get meta data
+ meta = content.metadata_column_types;
+
+ // check meta data
+ if (!meta) {
+ console.debug('tool-form::field_data() - FAILED: Could not find metadata for content ' + content_id + '.');
+ }
+ } else {
+ console.debug('tool-form::field_data() - FAILED: Could not find content ' + content_id + '.');
}
-
- // is numerical?
- var numerical = column_input.numerical;
- // identify column options
- var columns = [];
- for (var key in meta) {
- // get column type
- var column_type = meta[key];
+ // update referenced columns
+ for (var i in column_list) {
+ // get column input/field
+ var column_input = self.app.input_list[column_list[i]];
+ var column_field = self.app.field_list[column_list[i]];
+ if (!column_input || !column_field) {
+ console.debug('tool-form::field_data() - FAILED: Column not found.');
+ }
+
+ // is numerical?
+ var numerical = column_input.numerical;
- // column index
- var column_index = (parseInt(key) + 1);
-
- // column type label
- var column_label = 'Text';
- if (column_type == 'int' || column_type == 'float') {
- column_label = 'Number';
+ // identify column options
+ var columns = [];
+ for (var key in meta) {
+ // get column type
+ var column_type = meta[key];
+
+ // column index
+ var column_index = (parseInt(key) + 1);
+
+ // column type label
+ var column_label = 'Text';
+ if (column_type == 'int' || column_type == 'float') {
+ column_label = 'Number';
+ }
+
+ // add to selection
+ if (column_type == 'int' || column_type == 'float' || !numerical) {
+ columns.push({
+ 'label' : 'Column: ' + column_index + ' [' + column_label + ']',
+ 'value' : column_index
+ });
+ }
}
- // add to selection
- if (column_type == 'int' || column_type == 'float' || !numerical) {
- columns.push({
- 'label' : 'Column: ' + column_index + ' [' + column_label + ']',
- 'value' : column_index
- });
+ // update field
+ if (column_field) {
+ column_field.update(columns);
+ if (!column_field.exists(column_field.value())) {
+ column_field.value(column_field.first());
+ }
+ column_field.show();
}
}
-
- // update field
- if (column_field) {
- column_field.update(columns);
- if (!column_field.exists(column_field.value())) {
- column_field.value(column_field.first());
- }
- column_field.show();
- }
}
});
}
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa client/galaxy/scripts/mvc/tools/tools-select-content.js
--- /dev/null
+++ b/client/galaxy/scripts/mvc/tools/tools-select-content.js
@@ -0,0 +1,172 @@
+// dependencies
+define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'mvc/tools/tools-template'], function(Utils, Ui, Tabs, ToolTemplate) {
+
+var View = Backbone.View.extend({
+ // initialize
+ initialize : function(app, options) {
+ // configure options
+ this.options = options;
+
+ // link this
+ var self = this;
+
+ // add element
+ this.setElement('<div/>');
+
+ // current selection
+ this.current = 'hda';
+
+ // create button
+ this.button_new = new Ui.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(value) {
+ self.current = value;
+ self.refresh();
+ self.trigger('change');
+ }
+ });
+
+ //
+ // datasets
+ //
+ var datasets = app.content.filterType({
+ src : 'hda',
+ extensions : options.extensions
+ });
+
+ // configure options fields
+ var dataset_options = [];
+ for (var i in datasets) {
+ dataset_options.push({
+ label: datasets[i].name,
+ value: datasets[i].id
+ });
+ }
+
+ // select field
+ this.select_datasets = new Ui.Select.View({
+ multiple : true,
+ data : dataset_options,
+ value : dataset_options[0] && dataset_options[0].value,
+ onchange : function() {
+ self.trigger('change');
+ }
+ });
+
+ //
+ // collections
+ //
+ var collections = app.content.filterType({
+ src : 'hdca',
+ extensions : options.extensions
+ });
+
+ // configure options fields
+ var collection_options = [];
+ for (var i in collections) {
+ collection_options.push({
+ label: collections[i].name,
+ value: collections[i].id
+ });
+ }
+
+ // create select field for collections
+ this.select_collection = new Ui.Select.View({
+ data : collection_options,
+ value : collection_options[0] && collection_options[0].value,
+ onchange : function() {
+ self.trigger('change');
+ }
+ });
+
+ // add elements to dom
+ this.$el.append(Utils.wrap(this.button_new.$el));
+ this.$el.append(this.select_datasets.$el);
+ this.$el.append(this.select_collection.$el);
+
+ // check for batch mode
+ if (!this.options.multiple) {
+ this.$el.append(ToolTemplate.batchMode());
+ }
+
+ // refresh view
+ this.refresh();
+
+ // add change event. fires on trigger
+ this.on('change', function() {
+ if (options.onchange) {
+ options.onchange(self.value());
+ }
+ });
+ },
+
+ /** 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;
+ }
+
+ // transform into an array
+ var id_list = select.value();
+ if (!(id_list instanceof Array)) {
+ id_list = [id_list];
+ }
+
+ // prepare result dict
+ var result = {
+ batch : !this.options.multiple,
+ values : []
+ }
+
+ // append to dataset ids
+ for (var i in id_list) {
+ result.values.push({
+ id : id_list[i],
+ src : this.current
+ });
+ }
+
+ // return
+ return result;
+ },
+
+ /** Validate current selection
+ */
+ validate: function() {
+ switch(this.current) {
+ case 'hda':
+ return this.select_datasets.validate();
+ case 'hdca':
+ return this.select_collection.validate();
+ }
+ },
+
+ /** Refreshes data selection view */
+ 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: View
+}
+
+});
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa client/galaxy/scripts/mvc/tools/tools-select-dataset.js
--- a/client/galaxy/scripts/mvc/tools/tools-select-dataset.js
+++ /dev/null
@@ -1,172 +0,0 @@
-// dependencies
-define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'mvc/tools/tools-template'], function(Utils, Ui, Tabs, ToolTemplate) {
-
-var View = Backbone.View.extend({
- // initialize
- initialize : function(app, options) {
- // configure options
- this.options = options;
-
- // link this
- var self = this;
-
- // add element
- this.setElement('<div/>');
-
- // current selection
- this.current = 'hda';
-
- // create button
- this.button_new = new Ui.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(value) {
- self.current = value;
- self.refresh();
- self.trigger('change');
- }
- });
-
- //
- // datasets
- //
- var datasets = app.datasets.filterType({
- content_type : 'dataset',
- data_types : options.extensions
- });
-
- // configure options fields
- var dataset_options = [];
- for (var i in datasets) {
- dataset_options.push({
- label: datasets[i].name,
- value: datasets[i].id
- });
- }
-
- // select field
- this.select_datasets = new Ui.Select.View({
- multiple : true,
- data : dataset_options,
- value : dataset_options[0] && dataset_options[0].value,
- onchange : function() {
- self.trigger('change');
- }
- });
-
- //
- // collections
- //
- var collections = app.datasets.filterType({
- content_type : 'collection',
- data_types : options.extensions
- });
-
- // configure options fields
- var collection_options = [];
- for (var i in collections) {
- collection_options.push({
- label: collections[i].name,
- value: collections[i].id
- });
- }
-
- // create select field for collections
- this.select_collection = new Ui.Select.View({
- data : collection_options,
- value : collection_options[0] && collection_options[0].value,
- onchange : function() {
- self.trigger('change');
- }
- });
-
- // add elements to dom
- this.$el.append(Utils.wrap(this.button_new.$el));
- this.$el.append(this.select_datasets.$el);
- this.$el.append(this.select_collection.$el);
-
- // check for batch mode
- if (!this.options.multiple) {
- this.$el.append(ToolTemplate.batchMode());
- }
-
- // refresh view
- this.refresh();
-
- // add change event. fires on trigger
- this.on('change', function() {
- if (options.onchange) {
- options.onchange(self.value());
- }
- });
- },
-
- /** 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;
- }
-
- // transform into an array
- var id_list = select.value();
- if (!(id_list instanceof Array)) {
- id_list = [id_list];
- }
-
- // prepare result dict
- var result = {
- batch : !this.options.multiple,
- values : []
- }
-
- // append to dataset ids
- for (var i in id_list) {
- result.values.push({
- id : id_list[i],
- src : this.current
- });
- }
-
- // return
- return result;
- },
-
- /** Validate current selection
- */
- validate: function() {
- switch(this.current) {
- case 'hda':
- return this.select_datasets.validate();
- case 'hdca':
- return this.select_collection.validate();
- }
- },
-
- /** Refreshes data selection view */
- 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: View
-}
-
-});
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/mvc/tools/tools-content.js
--- /dev/null
+++ b/static/scripts/mvc/tools/tools-content.js
@@ -0,0 +1,132 @@
+define(['utils/utils'], function(Utils){
+ return Backbone.Model.extend({
+ // initialize
+ initialize: function(options) {
+ // backup basic url
+ this.base_url = galaxy_config.root + 'api/histories/' + options.history_id + '/contents';
+
+ // prepare content obects
+ this.datatypes = {};
+ this.summary = {};
+
+ // link this
+ var self = this;
+
+ // request datatypes
+ Utils.get({
+ url : galaxy_config.root + 'api/datatypes/mapping',
+ cache : true,
+ success : function(response) {
+ // backup datatype dictionary
+ self.datatypes = response;
+
+ // get history summary
+ Utils.get({
+ url : self.base_url + '?deleted=false',
+ success : function(response) {
+ // backup summary
+ self.summary = response;
+
+ // log
+ console.debug('tools-content::initialize() - Completed.');
+
+ // callback
+ options.success && options.success();
+ },
+ error : function(response) {
+ // log request failure
+ console.debug('tools-content::initialize() - Ajax request for summary failed.');
+ console.debug(response);
+ }
+ });
+ },
+ error : function(response) {
+ // log request failure
+ console.debug('tools-content::initialize() - Ajax request for datatypes failed.');
+ console.debug(response);
+ }
+ });
+ },
+
+ /**
+ * Filters contents by data type.
+ */
+ filterType: function(options) {
+ // initialize parameters
+ options = options || {};
+ var result = [];
+
+ // identify content type
+ var history_content_type = 'dataset';
+ if (options.src== 'hdca') {
+ history_content_type = 'dataset_collection';
+ }
+
+ // search in summary
+ for (var i in this.summary) {
+ var content = this.summary[i];
+
+ // match datatypes
+ var found = false;
+ for (var i in options.extensions) {
+ if (this._matchType(options.extensions[i], content.extension)) {
+ found = true;
+ break;
+ }
+ }
+
+ // final match result
+ if ((content.history_content_type === history_content_type) && (found || !options.extensions)) {
+ result.push(content);
+ }
+ }
+ return result;
+ },
+
+ /** Get details of a content by id.
+ */
+ getDetails: function(options) {
+ var api_url = this.base_url + '/datasets/' + options.id;
+ if (options.src == 'hdca') {
+ api_url = this.base_url + '/dataset_collections/' + options.id;
+ }
+ Utils.get({
+ url : api_url,
+ success : function(response) {
+ options.success && options.success(response);
+ },
+ error : function(response) {
+ console.debug('tools-content::getDetails() - Ajax request for content failed.');
+ console.debug(response);
+ }
+ });
+ },
+
+ /** Check if datatypes match
+ */
+ _matchType: function(target, reference) {
+ // check if target class is available
+ var target_class = this.datatypes.ext_to_class_name[target];
+ if (!target_class) {
+ console.debug('tools-content::_matchType() - Specific target class unavailable. Accepting all formats.');
+ return true;
+ }
+
+ // check if reference class is available
+ var reference_class = this.datatypes.ext_to_class_name[reference];
+ if (!reference_class) {
+ console.debug('tools-content::_matchType() - Specific reference class unavailable. Accepting all formats.');
+ return true;
+ }
+
+ // check reference group
+ var reference_group = this.datatypes.class_to_classes[reference_class];
+ if (reference_group[target_class]) {
+ return true;
+ }
+
+ // classes do not match
+ return false;
+ }
+ });
+});
\ No newline at end of file
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/mvc/tools/tools-datasets.js
--- a/static/scripts/mvc/tools/tools-datasets.js
+++ /dev/null
@@ -1,117 +0,0 @@
-define(['utils/utils'], function(Utils){
- return Backbone.Model.extend({
- // initialize
- initialize: function(options) {
- // prepare datasets obects
- this.datatypes = {};
- this.summary = {};
-
- // link this
- var self = this;
-
- // request datatypes
- Utils.get({
- url : galaxy_config.root + 'api/datatypes/mapping',
- cache : true,
- success : function(response) {
- // backup datatype dictionary
- self.datatypes = response;
-
- // get history summary
- Utils.get({
- url : galaxy_config.root + 'api/histories/' + options.history_id + '/contents?deleted=false',
- success : function(response) {
- // backup summary
- self.summary = response;
-
- // log
- console.debug('tools-datasets::initialize() - Completed.');
-
- // callback
- options.success && options.success();
- },
- error : function(response) {
- // log request failure
- console.debug('tools-datasets::initialize() - Ajax request for summary failed.');
- console.debug(response);
- }
- });
- },
- error : function(response) {
- // log request failure
- console.debug('tools-datasets::initialize() - Ajax request for datatypes failed.');
- console.debug(response);
- }
- });
- },
-
- /**
- * Filters datasets by data type.
- */
- filterType: function(options) {
- options = options || {};
- var result = [];
- for (var i in this.summary) {
- var dataset = this.summary[i];
-
- // match datatypes
- var found = false;
- for (var i in options.data_types) {
- if (this._matchType(options.data_types[i], dataset.extension)) {
- found = true;
- break;
- }
- }
-
- // final match result
- if ((dataset.history_content_type === options.content_type || !options.content_type) && (found || !options.data_types)) {
- result.push(dataset);
- }
- }
- return result;
- },
-
- /** Get details of a dataset by id.
- * @param{String} Dataset id
- */
- getDetails: function(dataset_id, callback) {
- Utils.get({
- url : galaxy_config.root + 'api/datasets/' + dataset_id,
- success : function(response) {
- callback && callback(response);
- },
- error : function(response) {
- console.debug('tools-datasets::getDetails() - Ajax request for dataset failed.');
- console.debug(response);
- }
- });
- },
-
- /** Check if datatypes match
- */
- _matchType: function(target, reference) {
- // check if target class is available
- var target_class = this.datatypes.ext_to_class_name[target];
- if (!target_class) {
- console.debug('tools-datasets::_matchType() - Specific target class unavailable. Accepting all formats.');
- return true;
- }
-
- // check if reference class is available
- var reference_class = this.datatypes.ext_to_class_name[reference];
- if (!reference_class) {
- console.debug('tools-datasets::_matchType() - Specific reference class unavailable. Accepting all formats.');
- return true;
- }
-
- // check reference group
- var reference_group = this.datatypes.class_to_classes[reference_class];
- if (reference_group[target_class]) {
- return true;
- }
-
- // classes do not match
- return false;
- }
- });
-});
\ No newline at end of file
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -3,9 +3,9 @@
*/
define(['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-datasets', 'mvc/tools/tools-section', 'mvc/tools/tools-tree', 'mvc/tools/tools-jobs'],
+ 'mvc/tools', 'mvc/tools/tools-template', 'mvc/tools/tools-content', 'mvc/tools/tools-section', 'mvc/tools/tools-tree', 'mvc/tools/tools-jobs'],
function(Portlet, Ui, CitationModel, CitationView,
- Tools, ToolTemplate, ToolDatasets, ToolSection, ToolTree, ToolJobs) {
+ Tools, ToolTemplate, ToolContent, ToolSection, ToolTree, ToolJobs) {
// create tool model
var Model = Backbone.Model.extend({
@@ -61,8 +61,8 @@
// reset input element list, which contains the dom elements of each input element (includes also the input field)
this.element_list = {};
- // initialize datasets
- this.datasets = new ToolDatasets({
+ // initialize contents
+ this.content = new ToolContent({
history_id : this.options.history_id,
success : function() {
self._initializeToolForm();
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/mvc/tools/tools-section.js
--- a/static/scripts/mvc/tools/tools-section.js
+++ b/static/scripts/mvc/tools/tools-section.js
@@ -1,8 +1,8 @@
/**
This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections. New input elements can be plugged in by adding cases to the switch block defined in the _addRow() function.
*/
-define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-dataset'],
- function(Utils, Table, Ui, Repeat, SelectDataset) {
+define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-misc', 'mvc/tools/tools-repeat', 'mvc/tools/tools-select-content'],
+ function(Utils, Table, Ui, Repeat, SelectContent) {
// input field element wrapper
var InputElement = Backbone.View.extend({
@@ -268,12 +268,12 @@
field = this._fieldSelect(input_def);
break;
- // dataset
+ // data selector
case 'data':
field = this._fieldData(input_def);
break;
- // dataset column
+ // data column
case 'data_column':
field = this._fieldSelect(input_def);
break;
@@ -417,13 +417,15 @@
var id = input_def.id;
// select field
- return new SelectDataset.View(this.app, {
+ return new SelectContent.View(this.app, {
id : 'field-' + id,
extensions : input_def.extensions,
multiple : input_def.multiple,
onchange : function(dict) {
- // pick the first dataset only (todo: maybe collect multiple meta information)
- var value = dict.values[0].id;
+ // pick the first content only (todo: maybe collect multiple meta information)
+ var content_def = dict.values[0];
+ var content_id = content_def.id;
+ var content_src = content_def.src;
// get referenced columns
var column_list = self.app.tree.references(id, 'data_column');
@@ -440,71 +442,80 @@
column_field.wait && column_field.wait();
}
- // find selected dataset
- self.app.datasets.getDetails(value, function(dataset) {
- // meta data
- var meta = null;
-
- // check dataset
- if (dataset) {
- // log selection
- console.debug('tool-form::field_data() - Selected dataset ' + value + '.');
-
- // get meta data
- meta = dataset.metadata_column_types;
-
- // check meta data
- if (!meta) {
- console.debug('tool-form::field_data() - FAILED: Could not find metadata for dataset ' + value + '.');
+ // find selected content
+ self.app.content.getDetails({
+ id : content_id,
+ src : content_src,
+ success : function(content) {
+ // select the first dataset to represent collections
+ if (content_src == 'hdca' && content.elements && content.elements.length > 0) {
+ content = content.elements[0].object;
}
- } else {
- console.debug('tool-form::field_data() - FAILED: Could not find dataset ' + value + '.');
- }
-
- // update referenced columns
- for (var i in column_list) {
- // get column input/field
- var column_input = self.app.input_list[column_list[i]];
- var column_field = self.app.field_list[column_list[i]];
- if (!column_input || !column_field) {
- console.debug('tool-form::field_data() - FAILED: Column not found.');
+
+ // meta data
+ var meta = null;
+
+ // check content
+ if (content) {
+ // log selection
+ console.debug('tool-form::field_data() - Selected content ' + content_id + '.');
+
+ // get meta data
+ meta = content.metadata_column_types;
+
+ // check meta data
+ if (!meta) {
+ console.debug('tool-form::field_data() - FAILED: Could not find metadata for content ' + content_id + '.');
+ }
+ } else {
+ console.debug('tool-form::field_data() - FAILED: Could not find content ' + content_id + '.');
}
-
- // is numerical?
- var numerical = column_input.numerical;
- // identify column options
- var columns = [];
- for (var key in meta) {
- // get column type
- var column_type = meta[key];
+ // update referenced columns
+ for (var i in column_list) {
+ // get column input/field
+ var column_input = self.app.input_list[column_list[i]];
+ var column_field = self.app.field_list[column_list[i]];
+ if (!column_input || !column_field) {
+ console.debug('tool-form::field_data() - FAILED: Column not found.');
+ }
+
+ // is numerical?
+ var numerical = column_input.numerical;
- // column index
- var column_index = (parseInt(key) + 1);
-
- // column type label
- var column_label = 'Text';
- if (column_type == 'int' || column_type == 'float') {
- column_label = 'Number';
+ // identify column options
+ var columns = [];
+ for (var key in meta) {
+ // get column type
+ var column_type = meta[key];
+
+ // column index
+ var column_index = (parseInt(key) + 1);
+
+ // column type label
+ var column_label = 'Text';
+ if (column_type == 'int' || column_type == 'float') {
+ column_label = 'Number';
+ }
+
+ // add to selection
+ if (column_type == 'int' || column_type == 'float' || !numerical) {
+ columns.push({
+ 'label' : 'Column: ' + column_index + ' [' + column_label + ']',
+ 'value' : column_index
+ });
+ }
}
- // add to selection
- if (column_type == 'int' || column_type == 'float' || !numerical) {
- columns.push({
- 'label' : 'Column: ' + column_index + ' [' + column_label + ']',
- 'value' : column_index
- });
+ // update field
+ if (column_field) {
+ column_field.update(columns);
+ if (!column_field.exists(column_field.value())) {
+ column_field.value(column_field.first());
+ }
+ column_field.show();
}
}
-
- // update field
- if (column_field) {
- column_field.update(columns);
- if (!column_field.exists(column_field.value())) {
- column_field.value(column_field.first());
- }
- column_field.show();
- }
}
});
}
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/mvc/tools/tools-select-content.js
--- /dev/null
+++ b/static/scripts/mvc/tools/tools-select-content.js
@@ -0,0 +1,172 @@
+// dependencies
+define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'mvc/tools/tools-template'], function(Utils, Ui, Tabs, ToolTemplate) {
+
+var View = Backbone.View.extend({
+ // initialize
+ initialize : function(app, options) {
+ // configure options
+ this.options = options;
+
+ // link this
+ var self = this;
+
+ // add element
+ this.setElement('<div/>');
+
+ // current selection
+ this.current = 'hda';
+
+ // create button
+ this.button_new = new Ui.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(value) {
+ self.current = value;
+ self.refresh();
+ self.trigger('change');
+ }
+ });
+
+ //
+ // datasets
+ //
+ var datasets = app.content.filterType({
+ src : 'hda',
+ extensions : options.extensions
+ });
+
+ // configure options fields
+ var dataset_options = [];
+ for (var i in datasets) {
+ dataset_options.push({
+ label: datasets[i].name,
+ value: datasets[i].id
+ });
+ }
+
+ // select field
+ this.select_datasets = new Ui.Select.View({
+ multiple : true,
+ data : dataset_options,
+ value : dataset_options[0] && dataset_options[0].value,
+ onchange : function() {
+ self.trigger('change');
+ }
+ });
+
+ //
+ // collections
+ //
+ var collections = app.content.filterType({
+ src : 'hdca',
+ extensions : options.extensions
+ });
+
+ // configure options fields
+ var collection_options = [];
+ for (var i in collections) {
+ collection_options.push({
+ label: collections[i].name,
+ value: collections[i].id
+ });
+ }
+
+ // create select field for collections
+ this.select_collection = new Ui.Select.View({
+ data : collection_options,
+ value : collection_options[0] && collection_options[0].value,
+ onchange : function() {
+ self.trigger('change');
+ }
+ });
+
+ // add elements to dom
+ this.$el.append(Utils.wrap(this.button_new.$el));
+ this.$el.append(this.select_datasets.$el);
+ this.$el.append(this.select_collection.$el);
+
+ // check for batch mode
+ if (!this.options.multiple) {
+ this.$el.append(ToolTemplate.batchMode());
+ }
+
+ // refresh view
+ this.refresh();
+
+ // add change event. fires on trigger
+ this.on('change', function() {
+ if (options.onchange) {
+ options.onchange(self.value());
+ }
+ });
+ },
+
+ /** 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;
+ }
+
+ // transform into an array
+ var id_list = select.value();
+ if (!(id_list instanceof Array)) {
+ id_list = [id_list];
+ }
+
+ // prepare result dict
+ var result = {
+ batch : !this.options.multiple,
+ values : []
+ }
+
+ // append to dataset ids
+ for (var i in id_list) {
+ result.values.push({
+ id : id_list[i],
+ src : this.current
+ });
+ }
+
+ // return
+ return result;
+ },
+
+ /** Validate current selection
+ */
+ validate: function() {
+ switch(this.current) {
+ case 'hda':
+ return this.select_datasets.validate();
+ case 'hdca':
+ return this.select_collection.validate();
+ }
+ },
+
+ /** Refreshes data selection view */
+ 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: View
+}
+
+});
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/mvc/tools/tools-select-dataset.js
--- a/static/scripts/mvc/tools/tools-select-dataset.js
+++ /dev/null
@@ -1,172 +0,0 @@
-// dependencies
-define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'mvc/tools/tools-template'], function(Utils, Ui, Tabs, ToolTemplate) {
-
-var View = Backbone.View.extend({
- // initialize
- initialize : function(app, options) {
- // configure options
- this.options = options;
-
- // link this
- var self = this;
-
- // add element
- this.setElement('<div/>');
-
- // current selection
- this.current = 'hda';
-
- // create button
- this.button_new = new Ui.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(value) {
- self.current = value;
- self.refresh();
- self.trigger('change');
- }
- });
-
- //
- // datasets
- //
- var datasets = app.datasets.filterType({
- content_type : 'dataset',
- data_types : options.extensions
- });
-
- // configure options fields
- var dataset_options = [];
- for (var i in datasets) {
- dataset_options.push({
- label: datasets[i].name,
- value: datasets[i].id
- });
- }
-
- // select field
- this.select_datasets = new Ui.Select.View({
- multiple : true,
- data : dataset_options,
- value : dataset_options[0] && dataset_options[0].value,
- onchange : function() {
- self.trigger('change');
- }
- });
-
- //
- // collections
- //
- var collections = app.datasets.filterType({
- content_type : 'collection',
- data_types : options.extensions
- });
-
- // configure options fields
- var collection_options = [];
- for (var i in collections) {
- collection_options.push({
- label: collections[i].name,
- value: collections[i].id
- });
- }
-
- // create select field for collections
- this.select_collection = new Ui.Select.View({
- data : collection_options,
- value : collection_options[0] && collection_options[0].value,
- onchange : function() {
- self.trigger('change');
- }
- });
-
- // add elements to dom
- this.$el.append(Utils.wrap(this.button_new.$el));
- this.$el.append(this.select_datasets.$el);
- this.$el.append(this.select_collection.$el);
-
- // check for batch mode
- if (!this.options.multiple) {
- this.$el.append(ToolTemplate.batchMode());
- }
-
- // refresh view
- this.refresh();
-
- // add change event. fires on trigger
- this.on('change', function() {
- if (options.onchange) {
- options.onchange(self.value());
- }
- });
- },
-
- /** 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;
- }
-
- // transform into an array
- var id_list = select.value();
- if (!(id_list instanceof Array)) {
- id_list = [id_list];
- }
-
- // prepare result dict
- var result = {
- batch : !this.options.multiple,
- values : []
- }
-
- // append to dataset ids
- for (var i in id_list) {
- result.values.push({
- id : id_list[i],
- src : this.current
- });
- }
-
- // return
- return result;
- },
-
- /** Validate current selection
- */
- validate: function() {
- switch(this.current) {
- case 'hda':
- return this.select_datasets.validate();
- case 'hdca':
- return this.select_collection.validate();
- }
- },
-
- /** Refreshes data selection view */
- 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: View
-}
-
-});
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/packed/mvc/tools/tools-content.js
--- /dev/null
+++ b/static/scripts/packed/mvc/tools/tools-content.js
@@ -0,0 +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},getDetails:function(b){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){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 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/packed/mvc/tools/tools-datasets.js
--- a/static/scripts/packed/mvc/tools/tools-datasets.js
+++ /dev/null
@@ -1,1 +0,0 @@
-define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(c){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:galaxy_config.root+"api/histories/"+c.history_id+"/contents?deleted=false",success:function(e){b.summary=e;console.debug("tools-datasets::initialize() - Completed.");c.success&&c.success()},error:function(e){console.debug("tools-datasets::initialize() - Ajax request for summary failed.");console.debug(e)}})},error:function(d){console.debug("tools-datasets::initialize() - Ajax request for datatypes failed.");console.debug(d)}})},filterType:function(c){c=c||{};var b=[];for(var d in this.summary){var f=this.summary[d];var e=false;for(var d in c.data_types){if(this._matchType(c.data_types[d],f.extension)){e=true;break}}if((f.history_content_type===c.content_type||!c.content_type)&&(e||!c.data_types)){b.push(f)}}return b},getDetails:function(b,c){a.get({url:galaxy_config.root+"api/datasets/"+b,success:function(d){c&&c(d)},error:function(d){console.debug("tools-datasets::getDetails() - Ajax request for dataset failed.");console.debug(d)}})},_matchType:function(f,b){var c=this.datatypes.ext_to_class_name[f];if(!c){console.debug("tools-datasets::_matchType() - Specific target class unavailable. Accepting all formats.");return true}var d=this.datatypes.ext_to_class_name[b];if(!d){console.debug("tools-datasets::_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 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa 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(["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-datasets","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(h,l,j,a,f,d,i,k,c,g){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(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.model=new e({id:n.id,job_id:n.job_id});this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.datasets=new i({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},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.")},_initializeToolForm:function(){var n=this;var p=new l.ButtonIcon({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/")}});var q=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});var o={button_question:p,button_search:q,button_share:m};if(Galaxy.currUser.get("is_admin")){o.button_download=new l.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.model.fetch({error:function(r){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new h.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),operations:o,buttons:{execute:new l.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!n.options.biostar_url){p.$el.hide();q.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var r=new j.ToolCitationCollection();r.tool_id=n.options.id;var s=new a.CitationListView({collection:r});s.render();r.fetch()}n.portlet.append(n.section.$el);n.refresh()}})}});return{View:b}});
\ No newline at end of file
+define(["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,l,j,a,f,d,g,k,c,h){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(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.model=new e({id:n.id,job_id:n.job_id});this.tree=new c(this);this.job_handler=new h(this);this.field_list={};this.input_list={};this.element_list={};this.content=new g({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},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.")},_initializeToolForm:function(){var n=this;var p=new l.ButtonIcon({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/")}});var q=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});var o={button_question:p,button_search:q,button_share:m};if(Galaxy.currUser.get("is_admin")){o.button_download=new l.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.model.fetch({error:function(r){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new i.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),operations:o,buttons:{execute:new l.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!n.options.biostar_url){p.$el.hide();q.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var r=new j.ToolCitationCollection();r.tool_id=n.options.id;var s=new a.CitationListView({collection:r});s.render();r.fetch()}n.portlet.append(n.section.$el);n.refresh()}})}});return{View:b}});
\ No newline at end of file
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa 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-dataset"],function(d,a,g,c,b){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});var f=Backbone.View.extend({initialize:function(i,h){this.app=i;this.inputs=h.inputs;h.cls_tr="section-row";this.table=new a.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(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.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":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,help:h.help,$el:i.$el});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 b.View(this.app,{id:"field-"+j,extensions:h.extensions,multiple:h.multiple,onchange:function(o){var n=o.values[0].id;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 m in l){var k=i.app.field_list[l[m]];k.wait&&k.wait()}i.app.datasets.getDetails(n,function(r){var z=null;if(r){console.debug("tool-form::field_data() - Selected dataset "+n+".");z=r.metadata_column_types;if(!z){console.debug("tool-form::field_data() - FAILED: Could not find metadata for dataset "+n+".")}}else{console.debug("tool-form::field_data() - FAILED: Could not find dataset "+n+".")}for(var t in l){var v=i.app.input_list[l[t]];var w=i.app.field_list[l[t]];if(!v||!w){console.debug("tool-form::field_data() - FAILED: Column not found.")}var s=v.numerical;var q=[];for(var y in z){var x=z[y];var p=(parseInt(y)+1);var u="Text";if(x=="int"||x=="float"){u="Number"}if(x=="int"||x=="float"||!s){q.push({label:"Column: "+p+" ["+u+"]",value:p})}}if(w){w.update(q);if(!w.exists(w.value())){w.value(w.first())}w.show()}}})}})},_fieldSelect:function(h){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"],function(d,b,g,c,a){var e=Backbone.View.extend({initialize:function(h){this.setElement(this._template(h))},error:function(h){this.$el.find(".ui-table-form-error-text").html(h);this.$el.find(".ui-table-form-error").fadeIn();this.$el.addClass("ui-error")},reset:function(){this.$el.find(".ui-table-form-error").hide();this.$el.removeClass("ui-error")},_template:function(h){var i=$('<div class="ui-table-element"/>');i.append('<div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"></div>');if(h.label){i.append('<div class="ui-table-form-title-strong">'+h.label+"</div>")}i.append(h.$el);if(h.help){i.append('<div class="ui-table-form-info">'+h.help+"</div>")}return i}});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(h){var j=this;var n=0;var m=new c.View({title_new:h.title,max:h.max,onnew:function(){var i=h.id+"-section-"+(n++);var q=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:i,title:h.title,$el:q.$el,ondel:function(){m.del(i);m.retitle(h.title);j.app.refresh()}});m.retitle(h.title);j.app.refresh()}});for(var l=0;l<h.min;l++){var k=h.id+"-section-"+(n++);var p=new f(j.app,{inputs:h.inputs,cls:"ui-table-plain"});m.add({id:k,title:h.title,$el:p.$el})}m.retitle(h.title);var o=new e({label:h.title,help:h.help,$el:m.$el});o.$el.addClass("ui-table-form-section");this.table.add(o.$el);this.table.append(h.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":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,help:h.help,$el:i.$el});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){if(p=="hdca"&&y.elements&&y.elements.length>0){y=y.elements[0].object}var B=null;if(y){console.debug("tool-form::field_data() - Selected content "+m+".");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){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
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/packed/mvc/tools/tools-select-content.js
--- /dev/null
+++ b/static/scripts/packed/mvc/tools/tools-select-content.js
@@ -0,0 +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
diff -r 0e99c30878af56e23f447854a7ae70b412a9d627 -r a979bd1bb19498aa93eb7da56f7a392bea14dfaa static/scripts/packed/mvc/tools/tools-select-dataset.js
--- a/static/scripts/packed/mvc/tools/tools-select-dataset.js
+++ /dev/null
@@ -1,1 +0,0 @@
-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.datasets.filterType({content_type:"dataset",data_types: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.datasets.filterType({content_type:"collection",data_types: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
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 automated form switching
by commits-noreply@bitbucket.org 07 Oct '14
by commits-noreply@bitbucket.org 07 Oct '14
07 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/0e99c30878af/
Changeset: 0e99c30878af
User: guerler
Date: 2014-10-07 18:39:33+00:00
Summary: ToolForm: Fix automated form switching
Affected #: 3 files
diff -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 -r 0e99c30878af56e23f447854a7ae70b412a9d627 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
@@ -217,9 +217,6 @@
citations.fetch();
}
- // configure portlet and form table
- self.setElement(self.portlet.content());
-
// append tool section
self.portlet.append(self.section.$el);
diff -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 -r 0e99c30878af56e23f447854a7ae70b412a9d627 static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -217,9 +217,6 @@
citations.fetch();
}
- // configure portlet and form table
- self.setElement(self.portlet.content());
-
// append tool section
self.portlet.append(self.section.$el);
diff -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 -r 0e99c30878af56e23f447854a7ae70b412a9d627 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(["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-datasets","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(h,l,j,a,f,d,i,k,c,g){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(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.model=new e({id:n.id,job_id:n.job_id});this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.datasets=new i({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},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.")},_initializeToolForm:function(){var n=this;var p=new l.ButtonIcon({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/")}});var q=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});var o={button_question:p,button_search:q,button_share:m};if(Galaxy.currUser.get("is_admin")){o.button_download=new l.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.model.fetch({error:function(r){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new h.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),operations:o,buttons:{execute:new l.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!n.options.biostar_url){p.$el.hide();q.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var r=new j.ToolCitationCollection();r.tool_id=n.options.id;var s=new a.CitationListView({collection:r});s.render();r.fetch()}n.setElement(n.portlet.content());n.portlet.append(n.section.$el);n.refresh()}})}});return{View:b}});
\ No newline at end of file
+define(["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-datasets","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(h,l,j,a,f,d,i,k,c,g){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(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.model=new e({id:n.id,job_id:n.job_id});this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.datasets=new i({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},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.")},_initializeToolForm:function(){var n=this;var p=new l.ButtonIcon({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/")}});var q=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});var o={button_question:p,button_search:q,button_share:m};if(Galaxy.currUser.get("is_admin")){o.button_download=new l.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.model.fetch({error:function(r){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new h.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),operations:o,buttons:{execute:new l.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!n.options.biostar_url){p.$el.hide();q.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var r=new j.ToolCitationCollection();r.tool_id=n.options.id;var s=new a.CitationListView({collection:r});s.render();r.fetch()}n.portlet.append(n.section.$el);n.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: Add download button, prepare for activation
by commits-noreply@bitbucket.org 07 Oct '14
by commits-noreply@bitbucket.org 07 Oct '14
07 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/f94fbe948b7a/
Changeset: f94fbe948b7a
User: guerler
Date: 2014-10-07 17:52:53+00:00
Summary: ToolForm: Add download button, prepare for activation
Affected #: 5 files
diff -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 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
@@ -42,7 +42,8 @@
// load tool model
this.model = new Model({
- id : options.id
+ id : options.id,
+ job_id : options.job_id
});
// creates a tree/json structure from the input form
@@ -93,7 +94,7 @@
}
// log
- console.debug('tools-form::refresh() - Recreated tree structure. Refresh.');
+ console.debug('tools-form::refresh() - Recreated data structure. Refresh.');
},
// initialize tool form
@@ -131,6 +132,26 @@
}
});
+ // default operations
+ var operations = {
+ button_question: button_question,
+ button_search: button_search,
+ button_share: button_share
+ }
+
+ // add admin operations
+ if (Galaxy.currUser.get('is_admin')) {
+ // create download button
+ operations['button_download'] = new Ui.ButtonIcon({
+ icon : 'fa-download',
+ title : 'Download',
+ tooltip : 'Download this tool',
+ onclick : function() {
+ window.location.href = galaxy_config.root + 'api/tools/' + self.options.id + '/download';
+ }
+ });
+ }
+
// fetch model and render form
this.model.fetch({
error: function(response) {
@@ -155,6 +176,7 @@
self.portlet = new Portlet.View({
icon : 'fa-wrench',
title: '<b>' + self.model.get('name') + '</b> ' + self.model.get('description'),
+ operations: operations,
buttons: {
execute: new Ui.ButtonIcon({
icon : 'fa-check',
@@ -165,11 +187,6 @@
self.job_handler.submit();
}
})
- },
- operations: {
- button_question: button_question,
- button_search: button_search,
- button_share: button_share
}
});
diff -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 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
@@ -264,6 +264,7 @@
toolbox=self.get_toolbox(),
tool_version_select_field=tool_version_select_field,
tool=tool,
+ job=job,
util=galaxy.util,
add_frame=add_frame,
tool_id_version_message=tool_id_version_message,
diff -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 static/scripts/mvc/tools/tools-form.js
--- a/static/scripts/mvc/tools/tools-form.js
+++ b/static/scripts/mvc/tools/tools-form.js
@@ -42,7 +42,8 @@
// load tool model
this.model = new Model({
- id : options.id
+ id : options.id,
+ job_id : options.job_id
});
// creates a tree/json structure from the input form
@@ -93,7 +94,7 @@
}
// log
- console.debug('tools-form::refresh() - Recreated tree structure. Refresh.');
+ console.debug('tools-form::refresh() - Recreated data structure. Refresh.');
},
// initialize tool form
@@ -131,6 +132,26 @@
}
});
+ // default operations
+ var operations = {
+ button_question: button_question,
+ button_search: button_search,
+ button_share: button_share
+ }
+
+ // add admin operations
+ if (Galaxy.currUser.get('is_admin')) {
+ // create download button
+ operations['button_download'] = new Ui.ButtonIcon({
+ icon : 'fa-download',
+ title : 'Download',
+ tooltip : 'Download this tool',
+ onclick : function() {
+ window.location.href = galaxy_config.root + 'api/tools/' + self.options.id + '/download';
+ }
+ });
+ }
+
// fetch model and render form
this.model.fetch({
error: function(response) {
@@ -155,6 +176,7 @@
self.portlet = new Portlet.View({
icon : 'fa-wrench',
title: '<b>' + self.model.get('name') + '</b> ' + self.model.get('description'),
+ operations: operations,
buttons: {
execute: new Ui.ButtonIcon({
icon : 'fa-check',
@@ -165,11 +187,6 @@
self.job_handler.submit();
}
})
- },
- operations: {
- button_question: button_question,
- button_search: button_search,
- button_share: button_share
}
});
diff -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 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(["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-datasets","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(h,l,j,a,f,d,i,k,c,g){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(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.model=new e({id:n.id});this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.datasets=new i({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},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 tree structure. Refresh.")},_initializeToolForm:function(){var n=this;var o=new l.ButtonIcon({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/")}});var p=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});this.model.fetch({error:function(q){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new h.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),buttons:{execute:new l.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){n.job_handler.submit()}})},operations:{button_question:o,button_search:p,button_share:m}});if(!n.options.biostar_url){o.$el.hide();p.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var q=new j.ToolCitationCollection();q.tool_id=n.options.id;var r=new a.CitationListView({collection:q});r.render();q.fetch()}n.setElement(n.portlet.content());n.portlet.append(n.section.$el);n.refresh()}})}});return{View:b}});
\ No newline at end of file
+define(["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-datasets","mvc/tools/tools-section","mvc/tools/tools-tree","mvc/tools/tools-jobs"],function(h,l,j,a,f,d,i,k,c,g){var e=Backbone.Model.extend({initialize:function(m){this.url=galaxy_config.root+"api/tools/"+m.id+"?io_details=true"}});var b=Backbone.View.extend({container:"body",initialize:function(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.model=new e({id:n.id,job_id:n.job_id});this.tree=new c(this);this.job_handler=new g(this);this.field_list={};this.input_list={};this.element_list={};this.datasets=new i({history_id:this.options.history_id,success:function(){m._initializeToolForm()}})},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.")},_initializeToolForm:function(){var n=this;var p=new l.ButtonIcon({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/")}});var q=new l.ButtonIcon({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(n.options.biostar_url+"/t/"+n.options.id+"/")}});var m=new l.ButtonIcon({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",galaxy_config.root+"root?tool_id="+n.options.id)}});var o={button_question:p,button_search:q,button_share:m};if(Galaxy.currUser.get("is_admin")){o.button_download=new l.ButtonIcon({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+n.options.id+"/download"}})}this.model.fetch({error:function(r){console.debug("tools-form::_initializeToolForm() : Attempt to fetch tool model failed.")},success:function(){n.section=new k.View(n,{inputs:n.model.get("inputs"),cls:"ui-table-plain"});if(n.incompatible){n.$el.hide();$("#tool-form-classic").show();return}n.portlet=new h.View({icon:"fa-wrench",title:"<b>"+n.model.get("name")+"</b> "+n.model.get("description"),operations:o,buttons:{execute:new l.ButtonIcon({icon:"fa-check",tooltip:"Execute the tool",title:"Execute",floating:"clear",onclick:function(){n.job_handler.submit()}})}});if(!n.options.biostar_url){p.$el.hide();q.$el.hide()}n.$el.append(n.portlet.$el);if(n.options.help!=""){n.$el.append(d.help(n.options.help))}if(n.options.citations){n.$el.append(d.citations());var r=new j.ToolCitationCollection();r.tool_id=n.options.id;var s=new a.CitationListView({collection:r});s.render();r.fetch()}n.setElement(n.portlet.content());n.portlet.append(n.section.$el);n.refresh()}})}});return{View:b}});
\ No newline at end of file
diff -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 -r f94fbe948b7a37b386ee8e3f5591ec7e70d94d16 templates/webapps/galaxy/tool_form.api.mako
--- a/templates/webapps/galaxy/tool_form.api.mako
+++ b/templates/webapps/galaxy/tool_form.api.mako
@@ -27,7 +27,8 @@
'help' : tool_help,
'citations' : tool_citations,
'biostar_url' : trans.app.config.biostar_url,
- 'history_id' : trans.security.encode_id( trans.history.id )
+ 'history_id' : trans.security.encode_id( trans.history.id ),
+ 'job_id' : trans.security.encode_id( job.id ) if job else None
}
%>
${h.js("libs/bibtex", "libs/jquery/jquery-ui")}
@@ -40,14 +41,6 @@
});
</script>
-##%if tool.tool_shed_repository:
-## <% tool_url = tool.tool_shed_repository.get_sharable_url( tool.app ) %>
-## %if tool_url:
-## <br/>
-## ${ render_msg( 'This tool was installed from a ToolShed, you may be able to find additional information by following this link: <a href="%s" target="_blank">%s</a>' % ( tool_url, tool_url ), 'info' ) }
-## %endif
-##%endif
-
## classic tool form
<div id="tool-form-classic" style="display: none;"><%include file="tool_form.mako"/>
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: Method for using local network (e.g. NFS) to distribute cached docker images across clusters.
by commits-noreply@bitbucket.org 07 Oct '14
by commits-noreply@bitbucket.org 07 Oct '14
07 Oct '14
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/a3cff55b129f/
Changeset: a3cff55b129f
User: jmchilton
Date: 2014-10-07 17:28:43+00:00
Summary: Method for using local network (e.g. NFS) to distribute cached docker images across clusters.
General idea and outline for short caching script embedded in containers.py from Kyle Ellrott.
Affected #: 4 files
diff -r 6b7782f17e84b357c968c7e8e14d1f50c3668008 -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 lib/galaxy/config.py
--- a/lib/galaxy/config.py
+++ b/lib/galaxy/config.py
@@ -143,6 +143,7 @@
self.cluster_files_directory = os.path.abspath( kwargs.get( "cluster_files_directory", "database/pbs" ) )
self.job_working_directory = resolve_path( kwargs.get( "job_working_directory", "database/job_working_directory" ), self.root )
self.cleanup_job = kwargs.get( "cleanup_job", "always" )
+ self.container_image_cache_path = self.resolve_path( kwargs.get( "container_image_cache_path", "database/container_images" ) )
self.outputs_to_working_directory = string_as_bool( kwargs.get( 'outputs_to_working_directory', False ) )
self.output_size_limit = int( kwargs.get( 'output_size_limit', 0 ) )
self.retry_job_output_collection = int( kwargs.get( 'retry_job_output_collection', 0 ) )
@@ -640,7 +641,8 @@
app_info = containers.AppInfo(
galaxy_root_dir,
default_file_path=file_path,
- outputs_to_working_directory=self.config.outputs_to_working_directory
+ outputs_to_working_directory=self.config.outputs_to_working_directory,
+ container_image_cache_path=self.config.container_image_cache_path,
)
self.container_finder = galaxy.tools.deps.containers.ContainerFinder(app_info)
diff -r 6b7782f17e84b357c968c7e8e14d1f50c3668008 -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 lib/galaxy/tools/deps/containers.py
--- a/lib/galaxy/tools/deps/containers.py
+++ b/lib/galaxy/tools/deps/containers.py
@@ -13,6 +13,29 @@
DEFAULT_CONTAINER_TYPE = "docker"
+LOAD_CACHED_IMAGE_COMMAND_TEMPLATE = '''
+python << EOF
+import re, tarfile, json, subprocess
+t = tarfile.TarFile("${cached_image_file}")
+meta_str = t.extractfile('repositories').read()
+meta = json.loads(meta_str)
+tag, tag_value = meta.items()[0]
+rev, rev_value = tag_value.items()[0]
+cmd = "${images_cmd}"
+proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
+stdo, stde = proc.communicate()
+found = False
+for line in stdo.split("\\n"):
+ tmp = re.split(r'\s+', line)
+ if tmp[0] == tag and tmp[1] == rev and tmp[2] == rev_value:
+ found = True
+if not found:
+ print "Loading image"
+ cmd = "cat ${cached_image_file} | ${load_cmd}"
+ subprocess.check_call(cmd, shell=True)
+EOF
+'''
+
class ContainerFinder(object):
@@ -117,11 +140,18 @@
class AppInfo(object):
- def __init__(self, galaxy_root_dir=None, default_file_path=None, outputs_to_working_directory=False):
+ def __init__(
+ self,
+ galaxy_root_dir=None,
+ default_file_path=None,
+ outputs_to_working_directory=False,
+ container_image_cache_path=None,
+ ):
self.galaxy_root_dir = galaxy_root_dir
self.default_file_path = default_file_path
# TODO: Vary default value for docker_volumes based on this...
self.outputs_to_working_directory = outputs_to_working_directory
+ self.container_image_cache_path = container_image_cache_path
class ToolInfo(object):
@@ -199,7 +229,12 @@
host=prop("host", docker_util.DEFAULT_HOST),
)
- cache_command = docker_util.build_docker_cache_command(self.container_id, **docker_host_props)
+ cached_image_file = self.__get_cached_image_file()
+ if not cached_image_file:
+ # TODO: Add option to cache it once here and create cached_image_file.
+ cache_command = docker_util.build_docker_cache_command(self.container_id, **docker_host_props)
+ else:
+ cache_command = self.__cache_from_file_command(cached_image_file, docker_host_props)
run_command = docker_util.build_docker_run_command(
command,
self.container_id,
@@ -213,6 +248,29 @@
)
return "%s\n%s" % (cache_command, run_command)
+ def __cache_from_file_command(self, cached_image_file, docker_host_props):
+ images_cmd = docker_util.build_docker_images_command(truncate=False, **docker_host_props)
+ load_cmd = docker_util.build_docker_load_command(**docker_host_props)
+
+ return string.Template(LOAD_CACHED_IMAGE_COMMAND_TEMPLATE).safe_substitute(
+ cached_image_file=cached_image_file,
+ images_cmd=images_cmd,
+ load_cmd=load_cmd
+ )
+
+ def __get_cached_image_file(self):
+ container_id = self.container_id
+ cache_directory = os.path.abspath(self.__get_destination_overridable_property("container_image_cache_path"))
+ cache_path = docker_cache_path(cache_directory, container_id)
+ return cache_path if os.path.exists(cache_path) else None
+
+ def __get_destination_overridable_property(self, name):
+ prop_name = "docker_%s" % name
+ if prop_name in self.destination_info:
+ return self.destination_info[prop_name]
+ else:
+ return getattr(self.app_info, name)
+
def __expand_str(self, value):
if not value:
return value
@@ -248,6 +306,12 @@
return template.safe_substitute(variables)
+def docker_cache_path(cache_directory, container_id):
+ file_container_id = container_id.replace("/", "_slash_")
+ cache_file_name = "docker_%s.tar" % file_container_id
+ return os.path.join(cache_directory, cache_file_name)
+
+
CONTAINER_CLASSES = dict(
docker=DockerContainer,
)
diff -r 6b7782f17e84b357c968c7e8e14d1f50c3668008 -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 lib/galaxy/tools/deps/docker_util.py
--- a/lib/galaxy/tools/deps/docker_util.py
+++ b/lib/galaxy/tools/deps/docker_util.py
@@ -55,14 +55,11 @@
def build_command(
image,
docker_build_path,
- docker_cmd=DEFAULT_DOCKER_COMMAND,
- sudo=DEFAULT_SUDO,
- sudo_cmd=DEFAULT_SUDO_COMMAND,
- host=DEFAULT_HOST,
+ **kwds
):
if os.path.isfile(docker_build_path):
docker_build_path = os.path.dirname(os.path.abspath(docker_build_path))
- build_command_parts = __docker_prefix(docker_cmd, sudo, sudo_cmd, host)
+ build_command_parts = __docker_prefix(**kwds)
build_command_parts.extend(["build", "-t", image, docker_build_path])
return build_command_parts
@@ -70,34 +67,42 @@
def build_save_image_command(
image,
destination,
- docker_cmd=DEFAULT_DOCKER_COMMAND,
- sudo=DEFAULT_SUDO,
- sudo_cmd=DEFAULT_SUDO_COMMAND,
- host=DEFAULT_HOST,
+ **kwds
):
- build_command_parts = __docker_prefix(docker_cmd, sudo, sudo_cmd, host)
+ build_command_parts = __docker_prefix(**kwds)
build_command_parts.extend(["save", "-o", destination, image])
return build_command_parts
def build_docker_cache_command(
image,
- docker_cmd=DEFAULT_DOCKER_COMMAND,
- sudo=DEFAULT_SUDO,
- sudo_cmd=DEFAULT_SUDO_COMMAND,
- host=DEFAULT_HOST,
+ **kwds
):
- inspect_command_parts = __docker_prefix(docker_cmd, sudo, sudo_cmd, host)
+ inspect_command_parts = __docker_prefix(**kwds)
inspect_command_parts.extend(["inspect", image])
inspect_image_command = " ".join(inspect_command_parts)
- pull_command_parts = __docker_prefix(docker_cmd, sudo, sudo_cmd, host)
+ pull_command_parts = __docker_prefix(**kwds)
pull_command_parts.extend(["pull", image])
pull_image_command = " ".join(pull_command_parts)
cache_command = "%s > /dev/null 2>&1\n[ $? -ne 0 ] && %s > /dev/null 2>&1\n" % (inspect_image_command, pull_image_command)
return cache_command
+def build_docker_images_command(truncate=True, **kwds):
+ images_command_parts = __docker_prefix(**kwds)
+ images_command_parts.append("images")
+ if not truncate:
+ images_command_parts.append("--no-trunc")
+ return " ".join(images_command_parts)
+
+
+def build_docker_load_command(**kwds):
+ load_command_parts = __docker_prefix(**kwds)
+ load_command_parts.append("load")
+ return " ".join(load_command_parts)
+
+
def build_docker_run_command(
container_command,
image,
@@ -116,7 +121,12 @@
auto_rm=DEFAULT_AUTO_REMOVE,
host=DEFAULT_HOST,
):
- command_parts = __docker_prefix(docker_cmd, sudo, sudo_cmd, host)
+ command_parts = __docker_prefix(
+ docker_cmd=docker_cmd,
+ sudo=sudo,
+ sudo_cmd=sudo_cmd,
+ host=host
+ )
command_parts.append("run")
if interactive:
command_parts.append("-i")
@@ -144,7 +154,13 @@
return " ".join(command_parts)
-def __docker_prefix(docker_cmd, sudo, sudo_cmd, host):
+def __docker_prefix(
+ docker_cmd=DEFAULT_DOCKER_COMMAND,
+ sudo=DEFAULT_SUDO,
+ sudo_cmd=DEFAULT_SUDO_COMMAND,
+ host=DEFAULT_HOST,
+ **kwds
+):
""" Prefix to issue a docker command.
"""
command_parts = []
diff -r 6b7782f17e84b357c968c7e8e14d1f50c3668008 -r a3cff55b129fcbf9b8e359ff0f71cb844a7e9277 lib/galaxy/tools/deps/dockerfiles.py
--- a/lib/galaxy/tools/deps/dockerfiles.py
+++ b/lib/galaxy/tools/deps/dockerfiles.py
@@ -2,6 +2,7 @@
from ..deps import commands
from ..deps import docker_util
+from ..deps.containers import docker_cache_path
from ..deps.requirements import parse_requirements_from_xml
from ...tools import loader_directory
@@ -20,11 +21,13 @@
def dockerfile_build(path, dockerfile=None, error=log.error, **kwds):
expected_container_names = set()
+ tool_directories = set()
for (tool_path, tool_xml) in loader_directory.load_tool_elements_from_path(path):
requirements, containers = parse_requirements_from_xml(tool_xml)
for container in containers:
if container.type == "docker":
expected_container_names.add(container.identifier)
+ tool_directories.add(os.path.dirname(tool_path))
break
if len(expected_container_names) == 0:
@@ -34,9 +37,8 @@
error("Multiple different docker identifiers found for selected tools [%s]", expected_container_names)
image_identifier = expected_container_names.pop()
- if dockerfile is None:
- dockerfile = "Dockerfile"
+ dockerfile = __find_dockerfile(dockerfile, tool_directories)
docker_command_parts = docker_util.build_command(
image_identifier,
dockerfile,
@@ -45,10 +47,24 @@
commands.execute(docker_command_parts)
docker_image_cache = kwds['docker_image_cache']
if docker_image_cache:
- destination = os.path.join(docker_image_cache, image_identifier + ".tar")
+ destination = docker_cache_path(docker_image_cache, image_identifier)
save_image_command_parts = docker_util.build_save_image_command(
image_identifier,
destination,
**docker_host_args(**kwds)
)
commands.execute(save_image_command_parts)
+
+
+def __find_dockerfile(dockerfile, tool_directories):
+ if dockerfile is not None:
+ return dockerfile
+ search_directories = ["."]
+ if len(tool_directories) == 1:
+ tool_directory = tool_directories.pop()
+ search_directories.insert(0, tool_directory)
+ for directory in search_directories:
+ potential_dockerfile = os.path.join(directory, "Dockerfile")
+ if os.path.exists(potential_dockerfile):
+ return potential_dockerfile
+ raise Exception("Could not find dockerfile to build.")
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