Skip to content

Commit

Permalink
Adding import functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
anuprulez committed May 31, 2017
1 parent 6dba0c7 commit 764933b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 55 deletions.
64 changes: 45 additions & 19 deletions client/galaxy/scripts/mvc/workflow/workflow.js
Expand Up @@ -227,28 +227,54 @@ define( [ 'mvc/tool/tool-form-composite', 'mvc/form/form-view', 'mvc/ui/ui-misc'
/** Open page to import workflow */
render: function() {
var self = this;
$.getJSON( Galaxy.root + 'workflow/get_import_workflow', function( options ) {
var form = new Form({
title : options.title,
icon : options.icon,
inputs : options.inputs,
operations: {
'submit': new Ui.ButtonIcon({
tooltip : 'Import workflow',
title : 'Import',
icon : 'fa-upload',
onclick : function() { self.import_workflow( form, options ) }
})
}
});
self.$el.empty().append( form.$el );
$.getJSON( Galaxy.root + 'workflow/upload_import_workflow', function( options ) {
self.$el.empty().append( self._mainTemplate( self, options ) );
});
},

/** Import a workflow */
import_workflow: function( form, options ) {
// TODO: Import workflow
}
/** Template for the import workflow page */
_mainTemplate: function( self, options ) {
return "<div class='toolForm'>" +
"<div class='toolFormTitle'>Import Galaxy workflow</div>" +
"<div class='toolFormBody'>" +
"<form name='import_workflow' id='import_workflow' action='"+ Galaxy.root + 'workflow/upload_import_workflow' +"' enctype='multipart/form-data' method='POST'>" +
"<div class='form-row'>" +
"<label>Galaxy workflow URL:</label>" +
"<input type='text' name='url' class='input-url' value='"+ options.url +"' size='40'>" +
"<div class='toolParamHelp' style='clear: both;'>" +
"If the workflow is accessible via a URL, enter the URL above and click <b>Import</b>." +
"</div>" +
"<div style='clear: both'></div>" +
"</div>" +
"<div class='form-row'>" +
"<label>Galaxy workflow file:</label>" +
"<div class='form-row-input'>" +
"<input type='file' name='file_data' class='input-file'/>" +
"</div>" +
"<div class='toolParamHelp' style='clear: both;'>" +
"If the workflow is in a file on your computer, choose it and then click <b>Import</b>." +
"</div>" +
"<div style='clear: both'></div>" +
"</div>" +
"<div class='form-row'>" +
"<input type='submit' class='primary-button wf-import' name='import_button' value='Import'>" +
"</div>" +
"</form>" +
"<hr/>" +
"<div class='form-row'>" +
"<label>Import a Galaxy workflow from myExperiment:</label>" +
"<div class='form-row-input'>" +
"<a href='" + options.myexperiment_target_url + "'> Visit myExperiment</a>" +
"</div>" +
"<div class='toolParamHelp' style='clear: both;'>" +
"Click the link above to visit myExperiment and browse for Galaxy workflows." +
"</div>" +
"<div style='clear: both'></div>" +
"</div>" +
"</div>" +
"</div>";
},

});

return {
Expand Down
38 changes: 7 additions & 31 deletions lib/galaxy/webapps/galaxy/controllers/workflow.py
Expand Up @@ -740,31 +740,7 @@ def export_to_file( self, trans, id ):
return stored_dict

@web.expose
def get_import_workflow( self, trans, **kwd ):
"""
Import/upload workflow page elements
"""
inputs = list()
input_url = { 'id': 'url_input',
'name': 'url',
'type': 'text',
'label': 'Galaxy workflow URL:',
'value': '',
'help': 'If the workflow is accessible via a URL, enter the URL above and click <b>Import</b>.' }
inputs.append(input_url)

input_file = { 'id': 'file_input',
'name': 'file_data',
'type': 'file',
'label': 'Galaxy workflow file:',
'help': 'If the workflow is in a file on your computer, choose it and then click <b>Import</b>.' }

inputs.append(input_file)
form = { 'title': 'Import Galaxy workflow', 'icon': 'fa fa-upload', 'inputs': inputs }
return json.dumps(form);

@web.expose
def save_import_workflow( self, trans, cntrller='workflow', **kwd ):
def upload_import_workflow( self, trans, cntrller='workflow', **kwd ):
"""
Import a workflow by reading an url, uploading a file, opening and reading the contents
of a local file, or receiving the textual representation of a workflow via http.
Expand Down Expand Up @@ -927,12 +903,12 @@ def save_import_workflow( self, trans, cntrller='workflow', **kwd ):
return self.list( trans )
if cntrller == 'api':
return status, message
return trans.fill_template( "workflow/import.mako",
url=url,
message=message,
status=status,
use_panels=True,
myexperiment_target_url=myexperiment_target_url )
return json.dumps({
'url' : url,
'message' : message,
'status' : status,
'myexperiment_target_url' : myexperiment_target_url
})

@web.expose
def build_from_current_history( self, trans, job_ids=None, dataset_ids=None, dataset_collection_ids=None, workflow_name=None, dataset_names=None, dataset_collection_names=None ):
Expand Down
2 changes: 1 addition & 1 deletion static/maps/mvc/workflow/workflow.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/analysis.bundled.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/scripts/bundled/libs.bundled.js.map

Large diffs are not rendered by default.

0 comments on commit 764933b

Please sign in to comment.