Skip to content

Commit

Permalink
Removing run mako from workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
anuprulez committed May 29, 2017
1 parent 64d6ffd commit a407a99
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 49 deletions.
9 changes: 7 additions & 2 deletions client/galaxy/scripts/apps/analysis.js
Expand Up @@ -79,7 +79,8 @@ window.app = function app( options, bootstrapped ){
'(/)user(/)' : 'show_user',
'(/)user(/)(:form_id)' : 'show_user_form',
'(/)workflow(/)' : 'show_workflows',
'(/)custom_builds' : 'show_custom_builds'
'(/)custom_builds' : 'show_custom_builds',
'(/)workflow/run(/)' : 'show_run',
},

require_login: [
Expand Down Expand Up @@ -115,6 +116,10 @@ window.app = function app( options, bootstrapped ){
this.page.display( new Workflows.View() );
},

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

show_custom_builds : function() {
var self = this;
var historyPanel = this.page.historyPanel.historyView;
Expand All @@ -139,7 +144,7 @@ window.app = function app( options, bootstrapped ){
} else {
// show the workflow run form
if( params.workflow_id ){
this._loadCenterIframe( 'workflow/run?id=' + params.workflow_id );
this.page.display( new Workflows.Run_Workflow_View() )
// 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 Down
32 changes: 29 additions & 3 deletions client/galaxy/scripts/apps/panels/tool-panel.js
@@ -1,6 +1,7 @@
var Tools = require( 'mvc/tool/tools' ),
Upload = require( 'mvc/upload/upload-view' ),
_l = require( 'utils/localization' );
_l = require( 'utils/localization' ),
ToolForm = require( 'mvc/tool/tool-form-composite' );

var ToolPanel = Backbone.View.extend({
initialize: function( page, options ) {
Expand Down Expand Up @@ -58,10 +59,26 @@ var ToolPanel = Backbone.View.extend({
href : 'workflow'
}));
_.each( this.stored_workflow_menu_entries, function( menu_entry ){
self.$( '#internal-workflows' ).append( self._templateTool({
self.$( '#internal-workflows' ).append( self._templateWorkflowLink({
title : menu_entry.stored_workflow.name,
href : 'workflow/run?id=' + menu_entry.encoded_stored_workflow_id
href : 'workflow/run?id=' + menu_entry.encoded_stored_workflow_id,
cls : 'workflow-menu-' + 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 All @@ -84,6 +101,15 @@ var ToolPanel = Backbone.View.extend({
].join('');
},

/** build links to workflows in toolpanel */
_templateWorkflowLink: function( wf ) {
return [
'<div class="toolTitle">',
'<a class="'+ wf.cls +' " href="', Galaxy.root, wf.href, '">', wf.title, '</a>',
'</div>'
].join('');
},

/** override to include inital menu dom and workflow section */
_template : function() {
return [
Expand Down
34 changes: 30 additions & 4 deletions client/galaxy/scripts/mvc/workflow/workflow.js
@@ -1,5 +1,5 @@
/** Workflow view */
define( [], function() {
define( [ 'mvc/tool/tool-form-composite' ], function( ToolForm ) {

/** View of the main workflow list page */
var View = Backbone.View.extend({
Expand Down Expand Up @@ -157,7 +157,7 @@ define( [], function() {
if( workflow.owner === Galaxy.user.attributes.username ) {
return '<ul class="dropdown-menu action-dpd">' +
'<li><a href="'+ Galaxy.root +'workflow/editor?id='+ workflow.id +'">Edit</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/run?id='+ workflow.id +'" target="galaxy_main">Run</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/run?id='+ workflow.id +'">Run</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/sharing?id='+ workflow.id +'">Share or Download</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/copy?id='+ workflow.id +'">Copy</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/rename?id='+ workflow.id +'">Rename</a></li>' +
Expand All @@ -168,7 +168,7 @@ define( [], function() {
else {
return '<ul class="dropdown-menu action-dpd">' +
'<li><a href="'+ Galaxy.root +'workflow/display_by_username_and_slug?username='+ workflow.owner +'&slug='+ workflow.slug +'">View</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/run?id='+ workflow.id +'" target="galaxy_main">Run</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/run?id='+ workflow.id +'">Run</a></li>' +
'<li><a href="'+ Galaxy.root +'workflow/copy?id='+ workflow.id +'">Copy</a></li>' +
'<li><a class="link-confirm-shared-'+ workflow.id +'" href="'+ Galaxy.root +'workflow/sharing?unshare_me=True&id='+ workflow.id +'">Remove</a></li>' +
'</ul>';
Expand All @@ -192,7 +192,33 @@ define( [], function() {
}
});

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 = self.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] );
self.$el.empty().append( form.$el );
});
},

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

return {
View : View
View : View,
Run_Workflow_View : Run_Workflow_View
};
});
1 change: 1 addition & 0 deletions lib/galaxy/webapps/galaxy/buildapp.py
Expand Up @@ -108,6 +108,7 @@ def paste_app_factory( global_conf, **kwargs ):
webapp.add_client_route( '/user' )
webapp.add_client_route( '/user/{form_id}' )
webapp.add_client_route( '/workflow' )
webapp.add_client_route( '/workflow/run' )
webapp.add_client_route( '/custom_builds' )

# ==== Done
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/webapps/galaxy/controllers/workflow.py
Expand Up @@ -948,7 +948,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
def run( self, trans, id, history_id=None, **kwargs ):
def run_workflow( self, trans, id, history_id=None, **kwargs ):
history = None
try:
if history_id is not None:
Expand All @@ -965,7 +965,9 @@ def run( 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' )
return trans.fill_template( 'workflow/run.mako', workflow_dict=workflow_dict )
wf_dict = list()
wf_dict.append( workflow_dict )
return json.dumps( wf_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.

0 comments on commit a407a99

Please sign in to comment.