Skip to content

Commit

Permalink
Fixing PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anuprulez committed Jun 9, 2017
1 parent 3573f4d commit 785e3e5
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 78 deletions.
27 changes: 23 additions & 4 deletions client/galaxy/scripts/apps/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ var jQuery = require( 'jquery' ),
Tours = require( 'mvc/tours' ),
GridView = require( 'mvc/grid/grid-view' )
Workflows = require( 'mvc/workflow/workflow' ),
WorkflowsConfigureMenu = require( 'mvc/workflow/workflow-configure-menu' );
WorkflowsConfigureMenu = require( 'mvc/workflow/workflow-configure-menu' ),
ToolFormComposite = require( 'mvc/tool/tool-form-composite' ),
Utils = require( 'utils/utils' );

/** define the 'Analyze Data'/analysis/main/home page for Galaxy
* * has a masthead
Expand Down Expand Up @@ -128,11 +130,11 @@ window.app = function app( options, bootstrapped ){
},

show_run : function() {
this.page.display( new Workflows.Run_Workflow_View() );
this._loadWorkflow();
},

show_import_workflow : function() {
this.page.display( new Workflows.Import_Workflow_View() );
this.page.display( new Workflows.ImportWorkflowView() );
},

show_configure_menu : function(){
Expand Down Expand Up @@ -163,7 +165,7 @@ window.app = function app( options, bootstrapped ){
} else {
// show the workflow run form
if( params.workflow_id ){
this.page.display( new Workflows.Run_Workflow_View() )
this._loadWorkflow();
// load the center iframe with controller.action: galaxy.org/?m_c=history&m_a=list -> history/list
} else if( params.m_c ){
this._loadCenterIframe( params.m_c + '/' + params.m_a );
Expand All @@ -188,6 +190,23 @@ window.app = function app( options, bootstrapped ){
this.page.$( '#galaxy_main' ).prop( 'src', url );
},

/** load workflow by its url in run mode */
_loadWorkflow: function() {
var self = this;
self.page.$( '#galaxy-main' ).hide();
self.page.$( "#center-panel" ).show();
Utils.get({
url : Galaxy.root + 'workflow/run_workflow?id=' + Utils.getQueryString( 'id' ),
success : function( response ) {
var form = new ToolFormComposite.View( response );
self.page.$( "#center-panel" ).empty().append( form.$el )
},
error : function( response ) {
var $el_error = "<div class='response-message errormessage'><p>Error occurred while loading the resource.</p></div>";
self.page.$( "#center-panel" ).empty().append( $el_error );
}
});
}
});

// render and start the router
Expand Down
18 changes: 1 addition & 17 deletions client/galaxy/scripts/apps/panels/tool-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,8 @@ var ToolPanel = Backbone.View.extend({
_.each( this.stored_workflow_menu_entries, function( menu_entry ){
self.$( '#internal-workflows' ).append( self._templateWorkflowLink({
title : menu_entry.stored_workflow.name,
href : 'workflow/run?id=' + menu_entry.encoded_stored_workflow_id,
cls : 'workflow-menu-' + menu_entry.encoded_stored_workflow_id
href : 'workflow/run?id=' + menu_entry.encoded_stored_workflow_id
}));
self._registerWorkflowMenuClick( self, menu_entry.encoded_stored_workflow_id );
});
},

/** Open the items in workflow menu in the center panel */
_registerWorkflowMenuClick: function( self, workflow_id ) {
$( '.workflow-menu-' + workflow_id ).click(function( e ) {
var url = Galaxy.root + 'workflow/run_workflow?id=' + workflow_id;
$.getJSON(url, function( response ) {
var wf_parsed = JSON.parse( JSON.stringify( response ) );
var form = new ToolForm.View( wf_parsed[0] );
$( '#galaxy_main' ).hide();
$( "#center-panel" ).show();
$( "#center-panel" ).empty().append( form.$el );
});
});
},

Expand Down
37 changes: 5 additions & 32 deletions client/galaxy/scripts/mvc/workflow/workflow.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
/** Workflow view */
define( [ 'mvc/tool/tool-form-composite' ], function( ToolForm ) {

/** Get querystrings from url */
function get_querystring( key ) {
return decodeURIComponent( window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent( key ).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1") );
}
define( [ 'utils/utils' ], function( Utils ) {

/** Build messages after user action */
function build_messages( self ) {
var $el_message = self.$el.find( '.response-message' ),
status = get_querystring( 'status' ),
message = get_querystring( 'message' );
status = Utils.getQueryString( 'status' ),
message = Utils.getQueryString( 'message' );

if( message && message !== null && message !== "" ) {
$el_message.addClass( status + 'message' );
Expand Down Expand Up @@ -186,28 +181,7 @@ define( [ 'mvc/tool/tool-form-composite' ], function( ToolForm ) {
}
});

var Run_Workflow_View = Backbone.View.extend({

initialize: function( options ) {
this.setElement( '<div/>' );
this.run_workflow( options );
},

/** Open workflow to run */
run_workflow: function() {
var self = this,
id = get_querystring( 'id' ),
url = Galaxy.root + 'workflow/run_workflow?id=' + id;
$.getJSON(url, function( response ) {
var wf_parsed = JSON.parse( JSON.stringify( response ) );
var form = new ToolForm.View( wf_parsed[0] );
build_messages( self );
self.$el.empty().append( form.$el );
});
}
});

var Import_Workflow_View = Backbone.View.extend({
var ImportWorkflowView = Backbone.View.extend({

initialize: function() {
this.setElement( '<div/>' );
Expand Down Expand Up @@ -269,7 +243,6 @@ define( [ 'mvc/tool/tool-form-composite' ], function( ToolForm ) {

return {
View : View,
Run_Workflow_View : Run_Workflow_View,
Import_Workflow_View : Import_Workflow_View
ImportWorkflowView : ImportWorkflowView
};
});
10 changes: 8 additions & 2 deletions client/galaxy/scripts/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ define( [], function() {
+ minutes;
};

/** Get querystrings from url */
function getQueryString( key ) {
return decodeURIComponent( window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent( key ).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1") );
};

return {
cssLoadFile: cssLoadFile,
cssGetAttribute: cssGetAttribute,
Expand All @@ -293,6 +298,7 @@ define( [], function() {
deepeach: deepeach,
isJSON: isJSON,
clone: clone,
linkify: linkify
linkify: linkify,
getQueryString: getQueryString
};
});
});
10 changes: 5 additions & 5 deletions lib/galaxy/webapps/galaxy/controllers/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ def export_to_file( self, trans, id ):
return stored_dict

@web.expose
@web.json
def upload_import_workflow( self, trans, cntrller='workflow', **kwd ):
"""
Import a workflow by reading an url, uploading a file, opening and reading the contents
Expand Down Expand Up @@ -908,12 +909,12 @@ def upload_import_workflow( self, trans, cntrller='workflow', **kwd ):
redirect_url = url_for( '/' ) + 'workflow?status=' + status + '&message=%s' % escape( message )
return trans.response.send_redirect( redirect_url )
else:
return json.dumps({
return {
'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 Expand Up @@ -953,6 +954,7 @@ def build_from_current_history( self, trans, job_ids=None, dataset_ids=None, dat
url_for( controller='workflow', action='run', id=workflow_id ) ) )

@web.expose
@web.json
def run_workflow( self, trans, id, history_id=None, **kwargs ):
history = None
try:
Expand All @@ -970,9 +972,7 @@ def run_workflow( self, trans, id, history_id=None, **kwargs ):
workflow_contents_manager = workflows.WorkflowContentsManager( trans.app )
stored = workflow_manager.get_stored_accessible_workflow( trans, id )
workflow_dict = workflow_contents_manager.workflow_to_dict( trans, stored, style='run' )
wf_dict = list()
wf_dict.append( workflow_dict )
return json.dumps( wf_dict )
return workflow_dict

def get_item( self, trans, id ):
return self.get_stored_workflow( trans, id )
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.

Loading

0 comments on commit 785e3e5

Please sign in to comment.