From 040af8e79c99d9f002f18b8ea2614f66d44bda8c Mon Sep 17 00:00:00 2001 From: guerler Date: Mon, 2 Mar 2015 17:22:28 -0500 Subject: [PATCH] ToolForm: Augment tool form base class --- client/galaxy/scripts/mvc/form/form-view.js | 36 ++++ .../scripts/mvc/tools/tools-form-base.js | 156 +++++++++++++-- .../scripts/mvc/tools/tools-form-workflow.js | 92 ++------- client/galaxy/scripts/mvc/tools/tools-form.js | 188 ++---------------- static/scripts/mvc/form/form-view.js | 36 ++++ static/scripts/mvc/tools/tools-form-base.js | 156 +++++++++++++-- .../scripts/mvc/tools/tools-form-workflow.js | 92 ++------- static/scripts/mvc/tools/tools-form.js | 188 ++---------------- static/scripts/packed/mvc/form/form-view.js | 2 +- .../packed/mvc/tools/tools-form-base.js | 2 +- .../packed/mvc/tools/tools-form-workflow.js | 2 +- static/scripts/packed/mvc/tools/tools-form.js | 2 +- 12 files changed, 428 insertions(+), 524 deletions(-) diff --git a/client/galaxy/scripts/mvc/form/form-view.js b/client/galaxy/scripts/mvc/form/form-view.js index 5cccd7b04b3..2f9b2ae36f5 100644 --- a/client/galaxy/scripts/mvc/form/form-view.js +++ b/client/galaxy/scripts/mvc/form/form-view.js @@ -42,6 +42,42 @@ define(['utils/utils', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', this._build(); }, + /** Update available options */ + update: function(new_model){ + var self = this; + this.data.matchModel(new_model, function(input_id, node) { + var input = self.input_list[input_id]; + if (input && input.options) { + if (!_.isEqual(input.options, node.options)) { + // backup new options + input.options = node.options; + + // get/update field + var field = self.field_list[input_id]; + if (field.update) { + var new_options = []; + if ((['data', 'data_collection', 'drill_down']).indexOf(input.type) != -1) { + new_options = input.options; + } else { + for (var i in node.options) { + var opt = node.options[i]; + if (opt.length > 2) { + new_options.push({ + 'label': opt[0], + 'value': opt[1] + }); + } + } + } + field.update(new_options); + field.trigger('change'); + console.debug('Updating options for ' + input_id); + } + } + } + }); + }, + /** Set form into wait mode */ wait: function(active) { for (var i in this.input_list) { diff --git a/client/galaxy/scripts/mvc/tools/tools-form-base.js b/client/galaxy/scripts/mvc/tools/tools-form-base.js index 240563c83d8..c9c2cd9e879 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form-base.js +++ b/client/galaxy/scripts/mvc/tools/tools-form-base.js @@ -37,11 +37,9 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', // link this var self = this; - // configure options - this.options = Utils.merge(options, this.optionsDefault); - // merge form options - var form_options = Utils.merge({ + this.options = Utils.merge(options, this.options); + this.options = Utils.merge({ icon : 'fa-wrench', title : '' + options.name + ' ' + options.description + ' (Galaxy Tool Version ' + options.version + ')', operations : this._operations(), @@ -49,13 +47,13 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', // by resetting the deferred ajax queue the number of redundant calls is reduced self.deferred.reset(); self.deferred.execute(function(){ - self._updateModel($.extend(true, {}, self.form.data.create())); + self._updateModel(); }); } - }, options); + }, this.options); // create form - this.form = new Form(form_options); + this.form = new Form(this.options); // create footer this._footer(); @@ -65,6 +63,139 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', this.$el.append(this.form.$el); }, + /** Builds a new model through api call and recreates the entire form + */ + _buildModel: function(options) { + // link this + var self = this; + + // construct url + var build_url = galaxy_config.root + 'api/tools/' + options.id + '/build?'; + if (options.job_id) { + build_url += 'job_id=' + options.job_id; + } else { + if (options.dataset_id) { + build_url += 'dataset_id=' + options.dataset_id; + } else { + build_url += 'tool_version=' + options.version + '&'; + var loc = top.location.href; + var pos = loc.indexOf('?'); + if (loc.indexOf('tool_id=') != -1 && pos !== -1) { + build_url += loc.slice(pos + 1); + } + } + } + + // register process + var process_id = this.deferred.register(); + + // get initial model + Utils.request({ + type : 'GET', + url : build_url, + success : function(new_model) { + // rebuild form + self._buildForm(new_model['tool_model'] || new_model); + + // show version message + self.form.message.update({ + status : 'success', + message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.', + persistent : false + }); + + // process completed + self.deferred.done(process_id); + + // log success + console.debug('tools-form::initialize() - Initial tool model ready.'); + console.debug(new_model); + }, + error : function(response) { + // process completed + self.deferred.done(process_id); + + // log error + console.debug('tools-form::initialize() - Initial tool model request failed.'); + console.debug(response); + + // show error + var error_message = response.error || 'Uncaught error.'; + self.form.modal.show({ + title : 'Tool cannot be executed', + body : error_message, + buttons : { + 'Close' : function() { + self.form.modal.hide(); + } + } + }); + } + }); + }, + + /** Request a new model for an already created tool form and updates the form inputs + */ + _updateModel: function() { + // model url for request + var model_url = this.options.update_url; + + // link this + var self = this; + + // create the request dictionary + var form = this.form; + + // create the request dictionary + var current_state = { + tool_id : this.options.id, + tool_version : this.options.version, + inputs : $.extend(true, {}, self.form.data.create()) + } + + // set wait mode + form.wait(true); + + // register process + var process_id = this.deferred.register(); + + // log tool state + console.debug('tools-form-base::_updateModel() - Sending current state (see below).'); + console.debug(current_state); + + // post job + Utils.request({ + type : 'POST', + url : model_url, + data : current_state, + success : function(new_model) { + // update form with new model + self.form.update(new_model['tool_model'] || new_model); + + // custom update + self.options.update && self.options.update(new_model); + + // unset wait mode + form.wait(false); + + // log success + console.debug('tools-form-base::_updateModel() - Received new model (see below).'); + console.debug(new_model); + + // process completed + self.deferred.done(process_id); + }, + error : function(response) { + // process completed + self.deferred.done(process_id); + + // log error + console.debug('tools-form-base::_updateModel() - Refresh request failed.'); + console.debug(response); + } + }); + }, + // create tool operation menu _operations: function() { // link this @@ -87,12 +218,13 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', icon : 'fa-cube', onclick : function() { // here we update the tool version (some tools encode the version also in the id) - options.id = options.id.replace(options.version, this.version); - options.version = this.version; - - // rebuild the model and form + var id = options.id.replace(options.version, this.version); + var version = this.version; + // queue model request self.deferred.reset(); - self.deferred.execute(function(){self._buildModel()}); + self.deferred.execute(function() { + self._buildModel({id: id, version: version}) + }); } }); } diff --git a/client/galaxy/scripts/mvc/tools/tools-form-workflow.js b/client/galaxy/scripts/mvc/tools/tools-form-workflow.js index 416a6fbac67..f733a63e9dc 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form-workflow.js +++ b/client/galaxy/scripts/mvc/tools/tools-form-workflow.js @@ -18,17 +18,24 @@ define(['utils/utils', 'mvc/tools/tools-form-base'], this.post_job_actions = this.node.post_job_actions || {}; // initialize parameters - this.options = options; + options = Utils.merge(options, { + // set labels + text_enable : 'Set in Advance', + text_disable : 'Set at Runtime', - // set labels - this.options.text_enable = 'Set in Advance'; - this.options.text_disable = 'Set at Runtime'; + // configure workflow style + is_dynamic : false, + narrow : true, + initial_errors : true, + cls : 'ui-portlet-narrow', - // configure workflow style - this.options.is_dynamic = false; - this.options.narrow = true; - this.options.initial_errors = true; - this.options.cls_portlet = 'ui-portlet-narrow'; + // configure model update + update_url : galaxy_config.root + 'api/workflows/build_module', + update : function(data) { + self.node.update_field_data(data); + self.form.errors(data && data.tool_model) + } + }); // declare fields as optional Utils.deepeach(options.inputs, function(item) { @@ -257,73 +264,6 @@ define(['utils/utils', 'mvc/tools/tools-form-base'], // return final configuration return input_config; - }, - - /** Builds a new model through api call and recreates the entire form - */ - _buildModel: function() { - Galaxy.modal.show({ - title : 'Coming soon...', - body : 'This feature has not been implemented yet.', - buttons : { - 'Close' : function() { - Galaxy.modal.hide(); - } - } - }); - }, - - /** Request a new model for an already created tool form and updates the form inputs - */ - _updateModel: function(current_state) { - // link self - var self = this; - - // create the request dictionary - current_state = { - tool_id : this.options.id, - tool_version : this.options.version, - inputs : current_state - } - - // log tool state - console.debug('tools-form-workflow::_refreshForm() - Refreshing states.'); - console.debug(current_state); - - // register process - var process_id = this.deferred.register(); - - // build model url for request - var model_url = galaxy_config.root + 'api/workflows/build_module'; - - // post job - Utils.request({ - type : 'POST', - url : model_url, - data : current_state, - success : function(data) { - // update node in workflow module - self.node.update_field_data(data); - - // highlight errors - self.form.errors(data && data.tool_model); - - // process completed - self.deferred.done(process_id); - - // log success - console.debug('tools-form::_refreshForm() - States refreshed.'); - console.debug(data); - }, - error : function(response) { - // process completed - self.deferred.done(process_id); - - // log error - console.debug('tools-form::_refreshForm() - Refresh request failed.'); - console.debug(response); - } - }); } }); diff --git a/client/galaxy/scripts/mvc/tools/tools-form.js b/client/galaxy/scripts/mvc/tools/tools-form.js index ceca4af4e16..8cb59b07895 100644 --- a/client/galaxy/scripts/mvc/tools/tools-form.js +++ b/client/galaxy/scripts/mvc/tools/tools-form.js @@ -8,180 +8,24 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools var View = ToolFormBase.extend({ // initialize initialize: function(options) { + // create options dictionary var self = this; - options.buttons = { - execute : new Ui.Button({ - icon : 'fa-check', - tooltip : 'Execute: ' + options.name, - title : 'Execute', - cls : 'btn btn-primary', - floating : 'clear', - onclick : function() { - ToolJobs.submit(self.form, options); - } - }) - }; + options = Utils.merge(options, { + update_url : galaxy_config.root + 'api/tools/' + options.id + '/build', + buttons : { + execute : new Ui.Button({ + icon : 'fa-check', + tooltip : 'Execute: ' + options.name, + title : 'Execute', + cls : 'btn btn-primary', + floating : 'clear', + onclick : function() { + ToolJobs.submit(self.form, options); + } + }) + } + }); ToolFormBase.prototype.initialize.call(this, options); - }, - - /** Builds a new model through api call and recreates the entire form - */ - _buildModel: function() { - // link this - var self = this; - - // construct url - var model_url = galaxy_config.root + 'api/tools/' + this.options.id + '/build?'; - if (this.options.job_id) { - model_url += 'job_id=' + this.options.job_id; - } else { - if (this.options.dataset_id) { - model_url += 'dataset_id=' + this.options.dataset_id; - } else { - model_url += 'tool_version=' + this.options.version + '&'; - var loc = top.location.href; - var pos = loc.indexOf('?'); - if (loc.indexOf('tool_id=') != -1 && pos !== -1) { - model_url += loc.slice(pos + 1); - } - } - } - - // register process - var process_id = this.deferred.register(); - - // get initial model - Utils.request({ - type : 'GET', - url : model_url, - success : function(response) { - // build new tool form - self._buildForm(response); - - // notification - self.form.message.update({ - status : 'success', - message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.', - persistent : false - }); - - // process completed - self.deferred.done(process_id); - - // log success - console.debug('tools-form::initialize() - Initial tool model ready.'); - console.debug(response); - }, - error : function(response) { - // process completed - self.deferred.done(process_id); - - // log error - console.debug('tools-form::initialize() - Initial tool model request failed.'); - console.debug(response); - - // show error - var error_message = response.error || 'Uncaught error.'; - self.form.modal.show({ - title : 'Tool cannot be executed', - body : error_message, - buttons : { - 'Close' : function() { - self.form.modal.hide(); - } - } - }); - } - }); - }, - - /** Request a new model for an already created tool form and updates the form inputs - */ - _updateModel: function(current_state) { - // link this - var self = this; - - // create the request dictionary - var form = this.form; - - // create the request dictionary - var current_state = { - tool_id : this.options.id, - tool_version : this.options.version, - inputs : current_state - } - - // set wait mode - form.wait(true); - - // register process - var process_id = this.deferred.register(); - - // log tool state - console.debug('tools-form::_refreshForm() - Sending current state (see below).'); - console.debug(current_state); - - // build model url for request - var model_url = galaxy_config.root + 'api/tools/' + this.options.id + '/build'; - - // post job - Utils.request({ - type : 'POST', - url : model_url, - data : current_state, - success : function(new_model) { - // update form - form.data.matchModel(new_model, function(input_id, node) { - var input = form.input_list[input_id]; - if (input && input.options) { - if (!_.isEqual(input.options, node.options)) { - // backup new options - input.options = node.options; - - // get/update field - var field = form.field_list[input_id]; - if (field.update) { - var new_options = []; - if ((['data', 'data_collection', 'drill_down']).indexOf(input.type) != -1) { - new_options = input.options; - } else { - for (var i in node.options) { - var opt = node.options[i]; - if (opt.length > 2) { - new_options.push({ - 'label': opt[0], - 'value': opt[1] - }); - } - } - } - field.update(new_options); - field.trigger('change'); - console.debug('Updating options for ' + input_id); - } - } - } - }); - - // unset wait mode - form.wait(false); - - // log success - console.debug('tools-form::_refreshForm() - Received new model (see below).'); - console.debug(new_model); - - // process completed - self.deferred.done(process_id); - }, - error : function(response) { - // process completed - self.deferred.done(process_id); - - // log error - console.debug('tools-form::_refreshForm() - Refresh request failed.'); - console.debug(response); - } - }); } }); diff --git a/static/scripts/mvc/form/form-view.js b/static/scripts/mvc/form/form-view.js index 5cccd7b04b3..2f9b2ae36f5 100644 --- a/static/scripts/mvc/form/form-view.js +++ b/static/scripts/mvc/form/form-view.js @@ -42,6 +42,42 @@ define(['utils/utils', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc', this._build(); }, + /** Update available options */ + update: function(new_model){ + var self = this; + this.data.matchModel(new_model, function(input_id, node) { + var input = self.input_list[input_id]; + if (input && input.options) { + if (!_.isEqual(input.options, node.options)) { + // backup new options + input.options = node.options; + + // get/update field + var field = self.field_list[input_id]; + if (field.update) { + var new_options = []; + if ((['data', 'data_collection', 'drill_down']).indexOf(input.type) != -1) { + new_options = input.options; + } else { + for (var i in node.options) { + var opt = node.options[i]; + if (opt.length > 2) { + new_options.push({ + 'label': opt[0], + 'value': opt[1] + }); + } + } + } + field.update(new_options); + field.trigger('change'); + console.debug('Updating options for ' + input_id); + } + } + } + }); + }, + /** Set form into wait mode */ wait: function(active) { for (var i in this.input_list) { diff --git a/static/scripts/mvc/tools/tools-form-base.js b/static/scripts/mvc/tools/tools-form-base.js index 240563c83d8..c9c2cd9e879 100644 --- a/static/scripts/mvc/tools/tools-form-base.js +++ b/static/scripts/mvc/tools/tools-form-base.js @@ -37,11 +37,9 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', // link this var self = this; - // configure options - this.options = Utils.merge(options, this.optionsDefault); - // merge form options - var form_options = Utils.merge({ + this.options = Utils.merge(options, this.options); + this.options = Utils.merge({ icon : 'fa-wrench', title : '' + options.name + ' ' + options.description + ' (Galaxy Tool Version ' + options.version + ')', operations : this._operations(), @@ -49,13 +47,13 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', // by resetting the deferred ajax queue the number of redundant calls is reduced self.deferred.reset(); self.deferred.execute(function(){ - self._updateModel($.extend(true, {}, self.form.data.create())); + self._updateModel(); }); } - }, options); + }, this.options); // create form - this.form = new Form(form_options); + this.form = new Form(this.options); // create footer this._footer(); @@ -65,6 +63,139 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', this.$el.append(this.form.$el); }, + /** Builds a new model through api call and recreates the entire form + */ + _buildModel: function(options) { + // link this + var self = this; + + // construct url + var build_url = galaxy_config.root + 'api/tools/' + options.id + '/build?'; + if (options.job_id) { + build_url += 'job_id=' + options.job_id; + } else { + if (options.dataset_id) { + build_url += 'dataset_id=' + options.dataset_id; + } else { + build_url += 'tool_version=' + options.version + '&'; + var loc = top.location.href; + var pos = loc.indexOf('?'); + if (loc.indexOf('tool_id=') != -1 && pos !== -1) { + build_url += loc.slice(pos + 1); + } + } + } + + // register process + var process_id = this.deferred.register(); + + // get initial model + Utils.request({ + type : 'GET', + url : build_url, + success : function(new_model) { + // rebuild form + self._buildForm(new_model['tool_model'] || new_model); + + // show version message + self.form.message.update({ + status : 'success', + message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.', + persistent : false + }); + + // process completed + self.deferred.done(process_id); + + // log success + console.debug('tools-form::initialize() - Initial tool model ready.'); + console.debug(new_model); + }, + error : function(response) { + // process completed + self.deferred.done(process_id); + + // log error + console.debug('tools-form::initialize() - Initial tool model request failed.'); + console.debug(response); + + // show error + var error_message = response.error || 'Uncaught error.'; + self.form.modal.show({ + title : 'Tool cannot be executed', + body : error_message, + buttons : { + 'Close' : function() { + self.form.modal.hide(); + } + } + }); + } + }); + }, + + /** Request a new model for an already created tool form and updates the form inputs + */ + _updateModel: function() { + // model url for request + var model_url = this.options.update_url; + + // link this + var self = this; + + // create the request dictionary + var form = this.form; + + // create the request dictionary + var current_state = { + tool_id : this.options.id, + tool_version : this.options.version, + inputs : $.extend(true, {}, self.form.data.create()) + } + + // set wait mode + form.wait(true); + + // register process + var process_id = this.deferred.register(); + + // log tool state + console.debug('tools-form-base::_updateModel() - Sending current state (see below).'); + console.debug(current_state); + + // post job + Utils.request({ + type : 'POST', + url : model_url, + data : current_state, + success : function(new_model) { + // update form with new model + self.form.update(new_model['tool_model'] || new_model); + + // custom update + self.options.update && self.options.update(new_model); + + // unset wait mode + form.wait(false); + + // log success + console.debug('tools-form-base::_updateModel() - Received new model (see below).'); + console.debug(new_model); + + // process completed + self.deferred.done(process_id); + }, + error : function(response) { + // process completed + self.deferred.done(process_id); + + // log error + console.debug('tools-form-base::_updateModel() - Refresh request failed.'); + console.debug(response); + } + }); + }, + // create tool operation menu _operations: function() { // link this @@ -87,12 +218,13 @@ define(['utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view', icon : 'fa-cube', onclick : function() { // here we update the tool version (some tools encode the version also in the id) - options.id = options.id.replace(options.version, this.version); - options.version = this.version; - - // rebuild the model and form + var id = options.id.replace(options.version, this.version); + var version = this.version; + // queue model request self.deferred.reset(); - self.deferred.execute(function(){self._buildModel()}); + self.deferred.execute(function() { + self._buildModel({id: id, version: version}) + }); } }); } diff --git a/static/scripts/mvc/tools/tools-form-workflow.js b/static/scripts/mvc/tools/tools-form-workflow.js index 416a6fbac67..f733a63e9dc 100644 --- a/static/scripts/mvc/tools/tools-form-workflow.js +++ b/static/scripts/mvc/tools/tools-form-workflow.js @@ -18,17 +18,24 @@ define(['utils/utils', 'mvc/tools/tools-form-base'], this.post_job_actions = this.node.post_job_actions || {}; // initialize parameters - this.options = options; + options = Utils.merge(options, { + // set labels + text_enable : 'Set in Advance', + text_disable : 'Set at Runtime', - // set labels - this.options.text_enable = 'Set in Advance'; - this.options.text_disable = 'Set at Runtime'; + // configure workflow style + is_dynamic : false, + narrow : true, + initial_errors : true, + cls : 'ui-portlet-narrow', - // configure workflow style - this.options.is_dynamic = false; - this.options.narrow = true; - this.options.initial_errors = true; - this.options.cls_portlet = 'ui-portlet-narrow'; + // configure model update + update_url : galaxy_config.root + 'api/workflows/build_module', + update : function(data) { + self.node.update_field_data(data); + self.form.errors(data && data.tool_model) + } + }); // declare fields as optional Utils.deepeach(options.inputs, function(item) { @@ -257,73 +264,6 @@ define(['utils/utils', 'mvc/tools/tools-form-base'], // return final configuration return input_config; - }, - - /** Builds a new model through api call and recreates the entire form - */ - _buildModel: function() { - Galaxy.modal.show({ - title : 'Coming soon...', - body : 'This feature has not been implemented yet.', - buttons : { - 'Close' : function() { - Galaxy.modal.hide(); - } - } - }); - }, - - /** Request a new model for an already created tool form and updates the form inputs - */ - _updateModel: function(current_state) { - // link self - var self = this; - - // create the request dictionary - current_state = { - tool_id : this.options.id, - tool_version : this.options.version, - inputs : current_state - } - - // log tool state - console.debug('tools-form-workflow::_refreshForm() - Refreshing states.'); - console.debug(current_state); - - // register process - var process_id = this.deferred.register(); - - // build model url for request - var model_url = galaxy_config.root + 'api/workflows/build_module'; - - // post job - Utils.request({ - type : 'POST', - url : model_url, - data : current_state, - success : function(data) { - // update node in workflow module - self.node.update_field_data(data); - - // highlight errors - self.form.errors(data && data.tool_model); - - // process completed - self.deferred.done(process_id); - - // log success - console.debug('tools-form::_refreshForm() - States refreshed.'); - console.debug(data); - }, - error : function(response) { - // process completed - self.deferred.done(process_id); - - // log error - console.debug('tools-form::_refreshForm() - Refresh request failed.'); - console.debug(response); - } - }); } }); diff --git a/static/scripts/mvc/tools/tools-form.js b/static/scripts/mvc/tools/tools-form.js index ceca4af4e16..8cb59b07895 100644 --- a/static/scripts/mvc/tools/tools-form.js +++ b/static/scripts/mvc/tools/tools-form.js @@ -8,180 +8,24 @@ define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/tools/tools-form-base', 'mvc/tools var View = ToolFormBase.extend({ // initialize initialize: function(options) { + // create options dictionary var self = this; - options.buttons = { - execute : new Ui.Button({ - icon : 'fa-check', - tooltip : 'Execute: ' + options.name, - title : 'Execute', - cls : 'btn btn-primary', - floating : 'clear', - onclick : function() { - ToolJobs.submit(self.form, options); - } - }) - }; + options = Utils.merge(options, { + update_url : galaxy_config.root + 'api/tools/' + options.id + '/build', + buttons : { + execute : new Ui.Button({ + icon : 'fa-check', + tooltip : 'Execute: ' + options.name, + title : 'Execute', + cls : 'btn btn-primary', + floating : 'clear', + onclick : function() { + ToolJobs.submit(self.form, options); + } + }) + } + }); ToolFormBase.prototype.initialize.call(this, options); - }, - - /** Builds a new model through api call and recreates the entire form - */ - _buildModel: function() { - // link this - var self = this; - - // construct url - var model_url = galaxy_config.root + 'api/tools/' + this.options.id + '/build?'; - if (this.options.job_id) { - model_url += 'job_id=' + this.options.job_id; - } else { - if (this.options.dataset_id) { - model_url += 'dataset_id=' + this.options.dataset_id; - } else { - model_url += 'tool_version=' + this.options.version + '&'; - var loc = top.location.href; - var pos = loc.indexOf('?'); - if (loc.indexOf('tool_id=') != -1 && pos !== -1) { - model_url += loc.slice(pos + 1); - } - } - } - - // register process - var process_id = this.deferred.register(); - - // get initial model - Utils.request({ - type : 'GET', - url : model_url, - success : function(response) { - // build new tool form - self._buildForm(response); - - // notification - self.form.message.update({ - status : 'success', - message : 'Now you are using \'' + self.options.name + '\' version ' + self.options.version + '.', - persistent : false - }); - - // process completed - self.deferred.done(process_id); - - // log success - console.debug('tools-form::initialize() - Initial tool model ready.'); - console.debug(response); - }, - error : function(response) { - // process completed - self.deferred.done(process_id); - - // log error - console.debug('tools-form::initialize() - Initial tool model request failed.'); - console.debug(response); - - // show error - var error_message = response.error || 'Uncaught error.'; - self.form.modal.show({ - title : 'Tool cannot be executed', - body : error_message, - buttons : { - 'Close' : function() { - self.form.modal.hide(); - } - } - }); - } - }); - }, - - /** Request a new model for an already created tool form and updates the form inputs - */ - _updateModel: function(current_state) { - // link this - var self = this; - - // create the request dictionary - var form = this.form; - - // create the request dictionary - var current_state = { - tool_id : this.options.id, - tool_version : this.options.version, - inputs : current_state - } - - // set wait mode - form.wait(true); - - // register process - var process_id = this.deferred.register(); - - // log tool state - console.debug('tools-form::_refreshForm() - Sending current state (see below).'); - console.debug(current_state); - - // build model url for request - var model_url = galaxy_config.root + 'api/tools/' + this.options.id + '/build'; - - // post job - Utils.request({ - type : 'POST', - url : model_url, - data : current_state, - success : function(new_model) { - // update form - form.data.matchModel(new_model, function(input_id, node) { - var input = form.input_list[input_id]; - if (input && input.options) { - if (!_.isEqual(input.options, node.options)) { - // backup new options - input.options = node.options; - - // get/update field - var field = form.field_list[input_id]; - if (field.update) { - var new_options = []; - if ((['data', 'data_collection', 'drill_down']).indexOf(input.type) != -1) { - new_options = input.options; - } else { - for (var i in node.options) { - var opt = node.options[i]; - if (opt.length > 2) { - new_options.push({ - 'label': opt[0], - 'value': opt[1] - }); - } - } - } - field.update(new_options); - field.trigger('change'); - console.debug('Updating options for ' + input_id); - } - } - } - }); - - // unset wait mode - form.wait(false); - - // log success - console.debug('tools-form::_refreshForm() - Received new model (see below).'); - console.debug(new_model); - - // process completed - self.deferred.done(process_id); - }, - error : function(response) { - // process completed - self.deferred.done(process_id); - - // log error - console.debug('tools-form::_refreshForm() - Refresh request failed.'); - console.debug(response); - } - }); } }); diff --git a/static/scripts/packed/mvc/form/form-view.js b/static/scripts/packed/mvc/form/form-view.js index ed9ba59b4a5..83c454263a8 100644 --- a/static/scripts/packed/mvc/form/form-view.js +++ b/static/scripts/packed/mvc/form/form-view.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/form/form-section","mvc/form/form-data"],function(c,b,e,a,d){return Backbone.View.extend({initialize:function(f){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false,cls:"ui-portlet-limited"};this.options=c.merge(f,this.optionsDefault);console.debug(this.options);var g=parent.Galaxy;if(g&&g.modal){this.modal=g.modal}else{this.modal=new e.Modal.View()}this.setElement("
");this._build()},wait:function(j){for(var g in this.input_list){var h=this.field_list[g];var f=this.input_list[g];if(f.is_dynamic&&h.wait&&h.unwait){if(j){h.wait()}else{h.unwait()}}}},reciept:function(f){this.$el.empty();this.$el.append(f)},highlight:function(g,h,f){var i=this.element_list[g];if(i){i.error(h||"Please verify this parameter.");if(!f){$("html, body").animate({scrollTop:i.$el.offset().top-20},500)}}},errors:function(h){this.trigger("reset");if(h&&h.errors){var i=this.data.matchResponse(h.errors);for(var g in this.element_list){var f=this.element_list[g];if(i[g]){this.highlight(g,i[g],true)}}}},_build:function(){var f=this;this.off("change");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.data=new d(this);this._renderForm();this.data.create();if(this.options.initial_errors){this.errors(this.options)}var g=this.data.checksum();this.on("change",function(){var h=f.data.checksum();if(h!=g){g=h;f.options.onchange&&f.options.onchange()}});this.on("reset",function(){for(var h in this.element_list){this.element_list[h].reset()}})},_renderForm:function(){this.message=new e.Message();this.section=new a.View(this,{inputs:this.options.inputs});this.portlet=new b.View({icon:"fa-wrench",title:this.options.title,cls:this.options.cls,operations:this.options.operations,buttons:this.options.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(this.options.message){this.message.update({persistent:true,status:"warning",message:this.options.message})}console.debug("tools-form-base::initialize() - Completed.")}})}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc","mvc/form/form-section","mvc/form/form-data"],function(c,b,e,a,d){return Backbone.View.extend({initialize:function(f){this.optionsDefault={is_dynamic:true,narrow:false,initial_errors:false,cls:"ui-portlet-limited"};this.options=c.merge(f,this.optionsDefault);console.debug(this.options);var g=parent.Galaxy;if(g&&g.modal){this.modal=g.modal}else{this.modal=new e.Modal.View()}this.setElement("
");this._build()},update:function(f){var g=this;this.data.matchModel(f,function(j,n){var h=g.input_list[j];if(h&&h.options){if(!_.isEqual(h.options,n.options)){h.options=n.options;var o=g.field_list[j];if(o.update){var m=[];if((["data","data_collection","drill_down"]).indexOf(h.type)!=-1){m=h.options}else{for(var l in n.options){var k=n.options[l];if(k.length>2){m.push({label:k[0],value:k[1]})}}}o.update(m);o.trigger("change");console.debug("Updating options for "+j)}}}})},wait:function(j){for(var g in this.input_list){var h=this.field_list[g];var f=this.input_list[g];if(f.is_dynamic&&h.wait&&h.unwait){if(j){h.wait()}else{h.unwait()}}}},reciept:function(f){this.$el.empty();this.$el.append(f)},highlight:function(g,h,f){var i=this.element_list[g];if(i){i.error(h||"Please verify this parameter.");if(!f){$("html, body").animate({scrollTop:i.$el.offset().top-20},500)}}},errors:function(h){this.trigger("reset");if(h&&h.errors){var i=this.data.matchResponse(h.errors);for(var g in this.element_list){var f=this.element_list[g];if(i[g]){this.highlight(g,i[g],true)}}}},_build:function(){var f=this;this.off("change");this.off("reset");this.field_list={};this.input_list={};this.element_list={};this.data=new d(this);this._renderForm();this.data.create();if(this.options.initial_errors){this.errors(this.options)}var g=this.data.checksum();this.on("change",function(){var h=f.data.checksum();if(h!=g){g=h;f.options.onchange&&f.options.onchange()}});this.on("reset",function(){for(var h in this.element_list){this.element_list[h].reset()}})},_renderForm:function(){this.message=new e.Message();this.section=new a.View(this,{inputs:this.options.inputs});this.portlet=new b.View({icon:"fa-wrench",title:this.options.title,cls:this.options.cls,operations:this.options.operations,buttons:this.options.buttons});this.portlet.append(this.message.$el.addClass("ui-margin-top"));this.portlet.append(this.section.$el);this.$el.empty();this.$el.append(this.portlet.$el);if(this.options.message){this.message.update({persistent:true,status:"warning",message:this.options.message})}console.debug("tools-form-base::initialize() - Completed.")}})}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-form-base.js b/static/scripts/packed/mvc/tools/tools-form-base.js index 30937ea1873..ce1c640e3ca 100644 --- a/static/scripts/packed/mvc/tools/tools-form-base.js +++ b/static/scripts/packed/mvc/tools/tools-form-base.js @@ -1 +1 @@ -define(["utils/utils","utils/deferred","mvc/ui/ui-misc","mvc/form/form-view","mvc/tools/tools-template","mvc/citation/citation-model","mvc/citation/citation-view"],function(f,d,g,c,a,e,b){return Backbone.View.extend({initialize:function(h){var i=parent.Galaxy;if(i&&i.currUser){this.is_admin=i.currUser.get("is_admin")}else{this.is_admin=false}this.deferred=new d();this.setElement("
");this.container=h.container||"body";$(this.container).append(this.$el);this._buildForm(h)},_buildForm:function(i){var h=this;this.options=f.merge(i,this.optionsDefault);var j=f.merge({icon:"fa-wrench",title:""+i.name+" "+i.description+" (Galaxy Tool Version "+i.version+")",operations:this._operations(),onchange:function(k){h.deferred.reset();h.deferred.execute(function(){h._updateModel($.extend(true,{},h.form.data.create()))})}},i);this.form=new c(j);this._footer();this.$el.empty();this.$el.append(this.form.$el)},_operations:function(){var j=this;var k=this.options;var n=new g.ButtonMenu({icon:"fa-cubes",title:(!k.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(k.versions&&k.versions.length>1){for(var m in k.versions){var h=k.versions[m];if(h!=k.version){n.addMenu({title:"Switch to "+h,version:h,icon:"fa-cube",onclick:function(){k.id=k.id.replace(k.version,this.version);k.version=this.version;j.deferred.reset();j.deferred.execute(function(){j._buildModel()})}})}}}else{n.$el.hide()}var l=new g.ButtonMenu({icon:"fa-caret-down",title:(!k.narrow&&"Options")||null,tooltip:"View available options"});if(k.biostar_url){l.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(k.biostar_url+"/p/new/post/")}});l.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(k.biostar_url+"/local/search/page/?q="+k.name)}})}l.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+k.id)}});if(this.is_admin){l.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+k.id+"/download"}})}if(k.requirements&&k.requirements.length>0){l.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;j.form.message.update({persistent:true,message:a.requirements(k),status:"info"})}else{this.visible=false;j.form.message.update({message:""})}}})}if(k.sharable_url){l.addMenu({icon:"fa-external-link",title:"See in Tool Shed",tooltip:"Access the repository",onclick:function(){window.open(k.sharable_url)}})}return{menu:l,versions:n}},_footer:function(){var i=this.options;if(i.help!=""){this.form.$el.append(a.help(i))}if(i.citations){var k=$("
");var h=new e.ToolCitationCollection();h.tool_id=i.id;var j=new b.CitationListView({el:k,collection:h});j.render();h.fetch();this.form.$el.append(k)}}})}); \ No newline at end of file +define(["utils/utils","utils/deferred","mvc/ui/ui-misc","mvc/form/form-view","mvc/tools/tools-template","mvc/citation/citation-model","mvc/citation/citation-view"],function(f,d,g,c,a,e,b){return Backbone.View.extend({initialize:function(h){var i=parent.Galaxy;if(i&&i.currUser){this.is_admin=i.currUser.get("is_admin")}else{this.is_admin=false}this.deferred=new d();this.setElement("
");this.container=h.container||"body";$(this.container).append(this.$el);this._buildForm(h)},_buildForm:function(i){var h=this;this.options=f.merge(i,this.options);this.options=f.merge({icon:"fa-wrench",title:""+i.name+" "+i.description+" (Galaxy Tool Version "+i.version+")",operations:this._operations(),onchange:function(j){h.deferred.reset();h.deferred.execute(function(){h._updateModel()})}},this.options);this.form=new c(this.options);this._footer();this.$el.empty();this.$el.append(this.form.$el)},_buildModel:function(j){var i=this;var h=galaxy_config.root+"api/tools/"+j.id+"/build?";if(j.job_id){h+="job_id="+j.job_id}else{if(j.dataset_id){h+="dataset_id="+j.dataset_id}else{h+="tool_version="+j.version+"&";var l=top.location.href;var m=l.indexOf("?");if(l.indexOf("tool_id=")!=-1&&m!==-1){h+=l.slice(m+1)}}}var k=this.deferred.register();f.request({type:"GET",url:h,success:function(n){i._buildForm(n.tool_model||n);i.form.message.update({status:"success",message:"Now you are using '"+i.options.name+"' version "+i.options.version+".",persistent:false});i.deferred.done(k);console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(n)},error:function(n){i.deferred.done(k);console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(n);var o=n.error||"Uncaught error.";i.form.modal.show({title:"Tool cannot be executed",body:o,buttons:{Close:function(){i.form.modal.hide()}}})}})},_updateModel:function(){var j=this.options.update_url;var h=this;var k=this.form;var i={tool_id:this.options.id,tool_version:this.options.version,inputs:$.extend(true,{},h.form.data.create())};k.wait(true);var l=this.deferred.register();console.debug("tools-form-base::_updateModel() - Sending current state (see below).");console.debug(i);f.request({type:"POST",url:j,data:i,success:function(m){h.form.update(m.tool_model||m);h.options.update&&h.options.update(m);k.wait(false);console.debug("tools-form-base::_updateModel() - Received new model (see below).");console.debug(m);h.deferred.done(l)},error:function(m){h.deferred.done(l);console.debug("tools-form-base::_updateModel() - Refresh request failed.");console.debug(m)}})},_operations:function(){var j=this;var k=this.options;var n=new g.ButtonMenu({icon:"fa-cubes",title:(!k.narrow&&"Versions")||null,tooltip:"Select another tool version"});if(k.versions&&k.versions.length>1){for(var m in k.versions){var h=k.versions[m];if(h!=k.version){n.addMenu({title:"Switch to "+h,version:h,icon:"fa-cube",onclick:function(){var o=k.id.replace(k.version,this.version);var i=this.version;j.deferred.reset();j.deferred.execute(function(){j._buildModel({id:o,version:i})})}})}}}else{n.$el.hide()}var l=new g.ButtonMenu({icon:"fa-caret-down",title:(!k.narrow&&"Options")||null,tooltip:"View available options"});if(k.biostar_url){l.addMenu({icon:"fa-question-circle",title:"Question?",tooltip:"Ask a question about this tool (Biostar)",onclick:function(){window.open(k.biostar_url+"/p/new/post/")}});l.addMenu({icon:"fa-search",title:"Search",tooltip:"Search help for this tool (Biostar)",onclick:function(){window.open(k.biostar_url+"/local/search/page/?q="+k.name)}})}l.addMenu({icon:"fa-share",title:"Share",tooltip:"Share this tool",onclick:function(){prompt("Copy to clipboard: Ctrl+C, Enter",window.location.origin+galaxy_config.root+"root?tool_id="+k.id)}});if(this.is_admin){l.addMenu({icon:"fa-download",title:"Download",tooltip:"Download this tool",onclick:function(){window.location.href=galaxy_config.root+"api/tools/"+k.id+"/download"}})}if(k.requirements&&k.requirements.length>0){l.addMenu({icon:"fa-info-circle",title:"Requirements",tooltip:"Display tool requirements",onclick:function(){if(!this.visible){this.visible=true;j.form.message.update({persistent:true,message:a.requirements(k),status:"info"})}else{this.visible=false;j.form.message.update({message:""})}}})}if(k.sharable_url){l.addMenu({icon:"fa-external-link",title:"See in Tool Shed",tooltip:"Access the repository",onclick:function(){window.open(k.sharable_url)}})}return{menu:l,versions:n}},_footer:function(){var i=this.options;if(i.help!=""){this.form.$el.append(a.help(i))}if(i.citations){var k=$("
");var h=new e.ToolCitationCollection();h.tool_id=i.id;var j=new b.CitationListView({el:k,collection:h});j.render();h.fetch();this.form.$el.append(k)}}})}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-form-workflow.js b/static/scripts/packed/mvc/tools/tools-form-workflow.js index c336f62e9ac..bd91e2c82dd 100644 --- a/static/scripts/packed/mvc/tools/tools-form-workflow.js +++ b/static/scripts/packed/mvc/tools/tools-form-workflow.js @@ -1 +1 @@ -define(["utils/utils","mvc/tools/tools-form-base"],function(b,a){var c=a.extend({initialize:function(e){this.node=workflow.active_node;if(!this.node){console.debug("FAILED - tools-form-workflow:initialize() - Node not found in workflow.");return}this.post_job_actions=this.node.post_job_actions||{};this.options=e;this.options.text_enable="Set in Advance";this.options.text_disable="Set at Runtime";this.options.is_dynamic=false;this.options.narrow=true;this.options.initial_errors=true;this.options.cls_portlet="ui-portlet-narrow";b.deepeach(e.inputs,function(f){if(f.type){f.optional=(["data","data_hidden","hidden","repeat","conditional"]).indexOf(f.type)==-1}});b.deepeach(e.inputs,function(f){if(f.type){if(f.type=="conditional"){f.test_param.optional=false}}});var d=this;b.get({url:galaxy_config.root+"api/datatypes",cache:true,success:function(f){d.datatypes=f;d._makeSections(e.inputs);a.prototype.initialize.call(d,e)}})},_makeSections:function(d){d[b.uuid()]={label:"Annotation / Notes",name:"annotation",type:"text",area:true,help:"Add an annotation or note for this step. It will be shown with the workflow.",value:this.node.annotation};var f=this.node.output_terminals&&Object.keys(this.node.output_terminals)[0];if(f){d[b.uuid()]={name:"pja__"+f+"__EmailAction",label:"Email notification",type:"boolean",value:String(Boolean(this.post_job_actions["EmailAction"+f])),ignore:"false",help:"An email notification will be send when the job has completed.",payload:{host:window.location.host}};d[b.uuid()]={name:"pja__"+f+"__DeleteIntermediatesAction",label:"Output cleanup",type:"boolean",value:String(Boolean(this.post_job_actions["DeleteIntermediatesAction"+f])),ignore:"false",help:"Delete intermediate outputs if they are not used as input for another job."};for(var e in this.node.output_terminals){d[b.uuid()]=this._makeSection(e)}}},_makeSection:function(h){var g=[];for(key in this.datatypes){g.push({0:this.datatypes[key],1:this.datatypes[key]})}g.sort(function(j,i){return j.label>i.label?1:j.labelhere for more information.'},{action:"ChangeDatatypeAction",argument:"newtype",label:"Change datatype",type:"select",ignore:"__empty__",value:"__empty__",options:g,help:"This action will change the datatype of the output to the indicated value."},{action:"TagDatasetAction",argument:"tags",label:"Tags",type:"text",value:"",ignore:"",help:"This action will set tags for the dataset."},{label:"Assign columns",type:"section",inputs:[{action:"ColumnSetAction",argument:"chromCol",label:"Chrom column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"startCol",label:"Start column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"endCol",label:"End column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"strandCol",label:"Strand column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"nameCol",label:"Name column",type:"integer",value:"",ignore:""}],help:"This action will set column assignments in the output dataset. Blank fields are ignored."}]};var d=this;function e(n,o){o=o||[];o.push(n);for(var m in n.inputs){var k=n.inputs[m];if(k.action){k.name="pja__"+h+"__"+k.action;if(k.argument){k.name+="__"+k.argument}if(k.payload){for(var s in k.payload){var q=k.payload[s];k.payload[k.name+"__"+s]=q;delete q}}var r=d.post_job_actions[k.action+h];if(r){for(var l in o){o[l].expand=true}if(k.argument){k.value=r.action_arguments&&r.action_arguments[k.argument]||k.value}else{k.value="true"}}}if(k.inputs){e(k,o.slice(0))}}}e(f);return f},_buildModel:function(){Galaxy.modal.show({title:"Coming soon...",body:"This feature has not been implemented yet.",buttons:{Close:function(){Galaxy.modal.hide()}}})},_updateModel:function(e){var d=this;e={tool_id:this.options.id,tool_version:this.options.version,inputs:e};console.debug("tools-form-workflow::_refreshForm() - Refreshing states.");console.debug(e);var g=this.deferred.register();var f=galaxy_config.root+"api/workflows/build_module";b.request({type:"POST",url:f,data:e,success:function(h){d.node.update_field_data(h);d.form.errors(h&&h.tool_model);d.deferred.done(g);console.debug("tools-form::_refreshForm() - States refreshed.");console.debug(h)},error:function(h){d.deferred.done(g);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(h)}})}});return{View:c}}); \ No newline at end of file +define(["utils/utils","mvc/tools/tools-form-base"],function(b,a){var c=a.extend({initialize:function(e){this.node=workflow.active_node;if(!this.node){console.debug("FAILED - tools-form-workflow:initialize() - Node not found in workflow.");return}this.post_job_actions=this.node.post_job_actions||{};e=b.merge(e,{text_enable:"Set in Advance",text_disable:"Set at Runtime",is_dynamic:false,narrow:true,initial_errors:true,cls:"ui-portlet-narrow",update_url:galaxy_config.root+"api/workflows/build_module",update:function(f){d.node.update_field_data(f);d.form.errors(f&&f.tool_model)}});b.deepeach(e.inputs,function(f){if(f.type){f.optional=(["data","data_hidden","hidden","repeat","conditional"]).indexOf(f.type)==-1}});b.deepeach(e.inputs,function(f){if(f.type){if(f.type=="conditional"){f.test_param.optional=false}}});var d=this;b.get({url:galaxy_config.root+"api/datatypes",cache:true,success:function(f){d.datatypes=f;d._makeSections(e.inputs);a.prototype.initialize.call(d,e)}})},_makeSections:function(d){d[b.uuid()]={label:"Annotation / Notes",name:"annotation",type:"text",area:true,help:"Add an annotation or note for this step. It will be shown with the workflow.",value:this.node.annotation};var f=this.node.output_terminals&&Object.keys(this.node.output_terminals)[0];if(f){d[b.uuid()]={name:"pja__"+f+"__EmailAction",label:"Email notification",type:"boolean",value:String(Boolean(this.post_job_actions["EmailAction"+f])),ignore:"false",help:"An email notification will be send when the job has completed.",payload:{host:window.location.host}};d[b.uuid()]={name:"pja__"+f+"__DeleteIntermediatesAction",label:"Output cleanup",type:"boolean",value:String(Boolean(this.post_job_actions["DeleteIntermediatesAction"+f])),ignore:"false",help:"Delete intermediate outputs if they are not used as input for another job."};for(var e in this.node.output_terminals){d[b.uuid()]=this._makeSection(e)}}},_makeSection:function(h){var g=[];for(key in this.datatypes){g.push({0:this.datatypes[key],1:this.datatypes[key]})}g.sort(function(j,i){return j.label>i.label?1:j.labelhere for more information.'},{action:"ChangeDatatypeAction",argument:"newtype",label:"Change datatype",type:"select",ignore:"__empty__",value:"__empty__",options:g,help:"This action will change the datatype of the output to the indicated value."},{action:"TagDatasetAction",argument:"tags",label:"Tags",type:"text",value:"",ignore:"",help:"This action will set tags for the dataset."},{label:"Assign columns",type:"section",inputs:[{action:"ColumnSetAction",argument:"chromCol",label:"Chrom column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"startCol",label:"Start column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"endCol",label:"End column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"strandCol",label:"Strand column",type:"integer",value:"",ignore:""},{action:"ColumnSetAction",argument:"nameCol",label:"Name column",type:"integer",value:"",ignore:""}],help:"This action will set column assignments in the output dataset. Blank fields are ignored."}]};var d=this;function e(n,o){o=o||[];o.push(n);for(var m in n.inputs){var k=n.inputs[m];if(k.action){k.name="pja__"+h+"__"+k.action;if(k.argument){k.name+="__"+k.argument}if(k.payload){for(var s in k.payload){var q=k.payload[s];k.payload[k.name+"__"+s]=q;delete q}}var r=d.post_job_actions[k.action+h];if(r){for(var l in o){o[l].expand=true}if(k.argument){k.value=r.action_arguments&&r.action_arguments[k.argument]||k.value}else{k.value="true"}}}if(k.inputs){e(k,o.slice(0))}}}e(f);return f}});return{View:c}}); \ No newline at end of file diff --git a/static/scripts/packed/mvc/tools/tools-form.js b/static/scripts/packed/mvc/tools/tools-form.js index d9d894ce5f4..fd8cdb28a1e 100644 --- a/static/scripts/packed/mvc/tools/tools-form.js +++ b/static/scripts/packed/mvc/tools/tools-form.js @@ -1 +1 @@ -define(["utils/utils","mvc/ui/ui-misc","mvc/tools/tools-form-base","mvc/tools/tools-jobs"],function(c,e,b,a){var d=b.extend({initialize:function(g){var f=this;g.buttons={execute:new e.Button({icon:"fa-check",tooltip:"Execute: "+g.name,title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){a.submit(f.form,g)}})};b.prototype.initialize.call(this,g)},_buildModel:function(){var f=this;var g=galaxy_config.root+"api/tools/"+this.options.id+"/build?";if(this.options.job_id){g+="job_id="+this.options.job_id}else{if(this.options.dataset_id){g+="dataset_id="+this.options.dataset_id}else{g+="tool_version="+this.options.version+"&";var i=top.location.href;var j=i.indexOf("?");if(i.indexOf("tool_id=")!=-1&&j!==-1){g+=i.slice(j+1)}}}var h=this.deferred.register();c.request({type:"GET",url:g,success:function(k){f._buildForm(k);f.form.message.update({status:"success",message:"Now you are using '"+f.options.name+"' version "+f.options.version+".",persistent:false});f.deferred.done(h);console.debug("tools-form::initialize() - Initial tool model ready.");console.debug(k)},error:function(k){f.deferred.done(h);console.debug("tools-form::initialize() - Initial tool model request failed.");console.debug(k);var l=k.error||"Uncaught error.";f.form.modal.show({title:"Tool cannot be executed",body:l,buttons:{Close:function(){f.form.modal.hide()}}})}})},_updateModel:function(g){var f=this;var i=this.form;var g={tool_id:this.options.id,tool_version:this.options.version,inputs:g};i.wait(true);var j=this.deferred.register();console.debug("tools-form::_refreshForm() - Sending current state (see below).");console.debug(g);var h=galaxy_config.root+"api/tools/"+this.options.id+"/build";c.request({type:"POST",url:h,data:g,success:function(k){i.data.matchModel(k,function(m,q){var l=i.input_list[m];if(l&&l.options){if(!_.isEqual(l.options,q.options)){l.options=q.options;var r=i.field_list[m];if(r.update){var p=[];if((["data","data_collection","drill_down"]).indexOf(l.type)!=-1){p=l.options}else{for(var o in q.options){var n=q.options[o];if(n.length>2){p.push({label:n[0],value:n[1]})}}}r.update(p);r.trigger("change");console.debug("Updating options for "+m)}}}});i.wait(false);console.debug("tools-form::_refreshForm() - Received new model (see below).");console.debug(k);f.deferred.done(j)},error:function(k){f.deferred.done(j);console.debug("tools-form::_refreshForm() - Refresh request failed.");console.debug(k)}})}});return{View:d}}); \ No newline at end of file +define(["utils/utils","mvc/ui/ui-misc","mvc/tools/tools-form-base","mvc/tools/tools-jobs"],function(c,e,b,a){var d=b.extend({initialize:function(g){var f=this;g=c.merge(g,{update_url:galaxy_config.root+"api/tools/"+g.id+"/build",buttons:{execute:new e.Button({icon:"fa-check",tooltip:"Execute: "+g.name,title:"Execute",cls:"btn btn-primary",floating:"clear",onclick:function(){a.submit(f.form,g)}})}});b.prototype.initialize.call(this,g)}});return{View:d}}); \ No newline at end of file