Skip to content

Commit

Permalink
Merge remote-tracking branch 'bgruening/convertworkflowmako' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Jun 21, 2017
2 parents 6a0401e + 8a09836 commit 9b9e2aa
Show file tree
Hide file tree
Showing 43 changed files with 261 additions and 259 deletions.
35 changes: 32 additions & 3 deletions client/galaxy/scripts/apps/analysis.js
Expand Up @@ -13,7 +13,10 @@ var jQuery = require( 'jquery' ),
PageList = require( 'mvc/page/page-list' ),
Workflows = require( 'mvc/workflow/workflow' ),
HistoryList = require( 'mvc/history/history-list' ),
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' ),
Ui = require( 'mvc/ui/ui-misc' );

/** define the 'Analyze Data'/analysis/main/home page for Galaxy
* * has a masthead
Expand Down Expand Up @@ -83,10 +86,12 @@ window.app = function app( options, bootstrapped ){
'(/)user(/)' : 'show_user',
'(/)user(/)(:form_id)' : 'show_user_form',
'(/)workflow(/)' : 'show_workflows',
'(/)workflow/run(/)' : 'show_run',
'(/)pages(/)(:action_id)' : 'show_pages',
'(/)histories(/)list(/)' : 'show_histories',
'(/)datasets(/)list(/)' : 'show_datasets',
'(/)workflow/configure_menu(/)' : 'show_configure_menu',
'(/)workflow/import_workflow' : 'show_import_workflow',
'(/)custom_builds' : 'show_custom_builds'
},

Expand Down Expand Up @@ -141,6 +146,14 @@ window.app = function app( options, bootstrapped ){
this.page.display( new Workflows.View() );
},

show_run : function() {
this._loadWorkflow();
},

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

show_configure_menu : function(){
this.page.display( new WorkflowsConfigureMenu.View() );
},
Expand Down Expand Up @@ -169,7 +182,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._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 @@ -194,6 +207,22 @@ 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;
Utils.get({
url: Galaxy.root + 'api/workflows/' + Utils.getQueryString( 'id' ) + '/download',
data: { 'style': 'run' },
success: function( response ) {
self.page.display( new ToolFormComposite.View( response ) );
},
error: function( response ) {
var error_msg = "Error occurred while loading the resource.",
options = { 'message': error_msg, 'status': 'error', 'persistent': true, 'cls': 'errormessage' };
self.page.display( new Ui.Message( options ) );
}
});
}
});

// render and start the router
Expand All @@ -211,4 +240,4 @@ window.app = function app( options, bootstrapped ){
pushState : true,
});
});
};
};
14 changes: 12 additions & 2 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,7 +59,7 @@ 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
}));
Expand All @@ -84,6 +85,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
5 changes: 2 additions & 3 deletions client/galaxy/scripts/layout/page.js
Expand Up @@ -19,18 +19,19 @@ define( [ 'layout/masthead', 'layout/panel', 'mvc/ui/ui-modal' ], function( Mast
Galaxy.display = this.display = function( view ) { self.center.display( view ) };
Galaxy.router = this.router = options.Router && new options.Router( self, options );
this.masthead = new Masthead.View( this.config );
this.center = new Panel.CenterPanel();

// build page template
this.$el.attr( 'scroll', 'no' );
this.$el.html( this._template() );
this.$( '#masthead' ).replaceWith( this.masthead.$el );
this.$( '#center' ).append( this.center.$el );
this.$el.append( this.masthead.frame.$el );
this.$el.append( this.modal.$el );
this.$messagebox = this.$( '#messagebox' );
this.$inactivebox = this.$( '#inactivebox' );

// build panels
this.center = new Panel.CenterPanel();
this.panels = {};
_.each( this._panelids, function( panel_id ) {
var panel_class_name = panel_id.charAt( 0 ).toUpperCase() + panel_id.slice( 1 );
Expand Down Expand Up @@ -98,8 +99,6 @@ define( [ 'layout/masthead', 'layout/panel', 'mvc/ui/ui-modal' ], function( Mast
/** Render panels */
renderPanels : function() {
var self = this;
this.center.setElement( '#center' );
this.center.render();
_.each( this._panelids, function( panel_id ) {
var panel = self.panels[ panel_id ];
if ( panel ) {
Expand Down
64 changes: 19 additions & 45 deletions client/galaxy/scripts/layout/panel.js
Expand Up @@ -189,29 +189,20 @@ define( [ 'jquery', 'libs/underscore', 'libs/backbone' ], function( $, _, Backbo
var CenterPanel = Backbone.View.extend({

initialize : function( options ){
/** previous view contained in the center panel - cached for removal later */
this.prev = null;
this.setElement( $( this.template() ) );
this.$frame = this.$( '.center-frame' );
this.$panel = this.$( '.center-panel' );
this.$frame.on( 'load', _.bind( this._iframeChangeHandler, this ) );
},

render : function(){
this.$el.html( this.template() );
// ?: doesn't work/listen in events map
this.$( '#galaxy_main' ).on( 'load', _.bind( this._iframeChangeHandler, this ) );
},

/** */
_iframeChangeHandler : function( ev ){
/** Display iframe if its target url changes, hide center panel */
_iframeChangeHandler : function( ev ) {
var iframe = ev.currentTarget;
var location = iframe.contentWindow && iframe.contentWindow.location;
if( location && location.host ){
// show the iframe and hide MVCview div, remove any views in the MVCview div
if( location && location.host ) {
$( iframe ).show();
if( this.prev ){
this.prev.remove();
}
this.$( '#center-panel' ).hide();
// TODO: move to Galaxy
Galaxy.trigger( 'galaxy_main:load', {
this.$panel.empty().hide();
Galaxy.trigger( 'center-frame:load', {
fullpath: location.pathname + location.search + location.hash,
pathname: location.pathname,
search : location.search,
Expand All @@ -220,43 +211,26 @@ define( [ 'jquery', 'libs/underscore', 'libs/backbone' ], function( $, _, Backbo
}
},

/** */
/** Display a view in the center panel, hide iframe */
display: function( view ) {
// we need to display an MVC view: hide the iframe and show the other center panel
// first checking for any onbeforeunload handlers on the iframe
var contentWindow = this.$( '#galaxy_main' )[ 0 ].contentWindow || {};
var contentWindow = this.$frame[ 0 ].contentWindow || {};
var message = contentWindow.onbeforeunload && contentWindow.onbeforeunload();
if ( !message || confirm( message ) ) {
contentWindow.onbeforeunload = undefined;
// remove any previous views
if( this.prev ){
this.prev.remove();
}
this.prev = view;
this.$( '#galaxy_main' ).attr( 'src', 'about:blank' ).hide();
this.$( '#center-panel' ).scrollTop( 0 ).append( view.$el ).show();
this.$frame.attr( 'src', 'about:blank' ).hide();
this.$panel.empty().scrollTop( 0 ).append( view.$el ).show();
Galaxy.trigger( 'center-panel:load', view );

} else {
if( view ){
view.remove();
}
}
},

template: function(){
return [
//TODO: remove inline styling
'<div style="position: absolute; width: 100%; height: 100%">',
'<iframe name="galaxy_main" id="galaxy_main" frameborder="0" ',
'style="position: absolute; width: 100%; height: 100%;"/>',
'<div id="center-panel" ',
'style="display: none; position: absolute; width: 100%; height: 100%; padding: 10px; overflow: auto;"/>',
'</div>'
].join('');
template: function() {
return '<div class="center-container">' +
'<iframe id="galaxy_main" name="galaxy_main" frameborder="0" class="center-frame" />' +
'<div class="center-panel" />' +
'</div>';
},

toString : function(){ return 'CenterPanel' }
toString : function() { return 'CenterPanel' }
});

return {
Expand Down
Expand Up @@ -338,7 +338,7 @@ var CurrentHistoryView = _super.extend(/** @lends CurrentHistoryView.prototype *
// compare the url to the following list and if there's a match
// pull the id from url and indicate in the history view that
// the dataset with that id is the 'current'ly active dataset
'galaxy_main:load': function( data ){
'center-frame:load': function( data ){
var pathToMatch = data.fullpath;
var hdaId = null;
var useToURLRegexMap = {
Expand Down
8 changes: 4 additions & 4 deletions client/galaxy/scripts/mvc/tool/tool-form-base.js
Expand Up @@ -22,16 +22,16 @@ define( [ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view
});
}
// destroy dom elements
this.$el.on( 'remove', function() { self.remove() } );
this.$el.on( 'remove', function() { self._destroy() } );
},

/** Wait for deferred build processes before removal */
remove: function() {
_destroy: function() {
var self = this;
this.$el.hide();
this.$el.off().hide();
this.deferred.execute( function() {
FormBase.prototype.remove.call( self );
Galaxy.emit.debug( 'tool-form-base::remove()', 'Destroy view.' );
Galaxy.emit.debug( 'tool-form-base::_destroy()', 'Destroy view.' );
});
},

Expand Down
6 changes: 2 additions & 4 deletions client/galaxy/scripts/mvc/tool/tool-form-composite.js
Expand Up @@ -15,17 +15,14 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
$( 'body' ).append( this.$el );
this._configure();
this.render();
this._refresh();
this.$el.on( 'click', function() { self._refresh() } );
this.$steps.scroll( function() { self._refresh() } );
$( window ).resize( function() { self._refresh() } );
},

/** Refresh height of scrollable div below header, handle scrolling by lazy loading steps */
_refresh: function( step_index ) {
var margin = _.reduce( this.$el.children(), function( memo, child ) {
return memo + $( child ).outerHeight();
}, 0 ) - this.$steps.height() + 25;
}, 0 ) - this.$steps.height() + 90;
this.$steps.css( 'height', $( window ).height() - margin );
},

Expand Down Expand Up @@ -314,6 +311,7 @@ define([ 'utils/utils', 'utils/deferred', 'mvc/ui/ui-misc', 'mvc/form/form-view'
}
self.forms[ step.index ] = form;
self._append( self.$steps, form.$el );
self._refresh();
step.needs_refresh && self._refreshStep( step );
form.portlet[ !self.show_progress ? 'enable' : 'disable' ]();
self.show_progress && self.execute_btn.model.set( { wait : true,
Expand Down
9 changes: 9 additions & 0 deletions client/galaxy/scripts/mvc/user/user-preferences.js
Expand Up @@ -65,6 +65,14 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
window.location.href = Galaxy.root + 'custom_builds';
}
},
'configure_menu': {
title : 'Configure workflow menu',
description : 'Configure your workflow items which appear in the Tool panel.',
icon : 'fa-cog',
onclick : function() {
window.location.href = Galaxy.root + 'workflow/configure_menu';
}
},
'logout': {
title : 'Sign out',
description : 'Click here to sign out of all sessions.',
Expand Down Expand Up @@ -119,6 +127,7 @@ define( [ 'mvc/form/form-view', 'mvc/ui/ui-misc' ], function( Form, Ui ) {
if( config.enable_openid && !config.use_remote_user ) {
self._addLink( 'openids' );
}
self._addLink( 'configure_menu' );
self._addLink( 'logout' );
self.$preferences.append( self._templateFooter( data ) );
self.$el.empty().append( self.$preferences );
Expand Down
6 changes: 3 additions & 3 deletions client/galaxy/scripts/mvc/workflow/workflow-configure-menu.js
Expand Up @@ -80,7 +80,7 @@ define( [], function() {
data: JSON.stringify( { 'workflow_ids': ids } ),
contentType : 'application/json'
}).done( function( response ) {
window.location = Galaxy.root + 'workflow?status='+ response.status +'&message=' + response.message;
window.location = Galaxy.root + 'user';
});
});
},
Expand Down Expand Up @@ -121,8 +121,8 @@ define( [], function() {
tableHtml = tableHtml + '<a class="action-button wf-save-menu wf-action fa fa-floppy-o" href="#" title="Save">' +
'<span>Save</span>' +
'</a>' +
'<a class="action-button wf-back wf-action fa fa-arrow-left" href="'+ Galaxy.root +'workflow" title="Back to workflow">' +
'<span>Back to workflow</span>' +
'<a class="action-button wf-back wf-action fa fa-arrow-left" href="'+ Galaxy.root +'user" title="Back to User Preferences">' +
'<span>Back to User Preferences</span>' +
'</a>';
return tableHtml;
},
Expand Down

0 comments on commit 9b9e2aa

Please sign in to comment.