Skip to content

Commit

Permalink
Reduce global usage in router
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed May 9, 2017
1 parent 50f1713 commit d90c75b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 25 deletions.
29 changes: 16 additions & 13 deletions client/galaxy/scripts/apps/analysis.js
Expand Up @@ -38,10 +38,11 @@ window.app = function app( options, bootstrapped ){
});

/** Routes */
Galaxy.router = new ( Backbone.Router.extend({
var Router = Backbone.Router.extend({
// TODO: not many client routes at this point - fill and remove from server.
// since we're at root here, this may be the last to be routed entirely on the client.
initialize : function( options ){
initialize : function( page, options ){
this.page = page;
this.options = options;
},

Expand Down Expand Up @@ -85,7 +86,7 @@ window.app = function app( options, bootstrapped ){
],

loginRequired: function() {
Galaxy.display( new routingMessage({type: 'error', message: "You must be logged in to make this request."}) );
this.page.display( new routingMessage({type: 'error', message: "You must be logged in to make this request."}) );
},

authenticate: function( args, name ) {
Expand All @@ -96,25 +97,26 @@ window.app = function app( options, bootstrapped ){
if ( tour_id ){
Tours.giveTour( tour_id );
} else {
Galaxy.display( new Tours.ToursView() );
this.page.display( new Tours.ToursView() );
}
},

show_user : function(){
Galaxy.display( new UserPreferences.View() );
this.page.display( new UserPreferences.View() );
},

show_user_form : function( form_id ) {
Galaxy.display( new UserPreferences.Forms( { form_id: form_id, user_id: Galaxy.params.id } ) );
this.page.display( new UserPreferences.Forms( { form_id: form_id, user_id: Galaxy.params.id } ) );
},

show_custom_builds : function() {
var self = this;
if ( !Galaxy.currHistoryPanel || !Galaxy.currHistoryPanel.model || !Galaxy.currHistoryPanel.model.id ) {
var historyPanel = this.page.historyPanel.historyView;
if ( !historyPanel || !historyPanel.model || !historyPanel.model.id ) {
window.setTimeout(function() { self.show_custom_builds() }, 500)
return;
}
Galaxy.display( new CustomBuilds.View() );
this.page.display( new CustomBuilds.View() );
},

/** */
Expand All @@ -123,7 +125,7 @@ window.app = function app( options, bootstrapped ){
// load a tool by id (tool_id) or rerun a previous tool execution (job_id)
if( params.tool_id || params.job_id ) {
if ( params.tool_id === 'upload1' ) {
Galaxy.upload.show();
this.page.toolPanel.upload.show();
this._loadCenterIframe( 'welcome' );
} else {
this._loadToolForm( params );
Expand All @@ -146,7 +148,7 @@ window.app = function app( options, bootstrapped ){
_loadToolForm : function( params ){
//TODO: load tool form code async
params.id = params.tool_id;
Galaxy.display( new ToolForm.View( params ) );
this.page.display( new ToolForm.View( params ) );
},

/** load the center panel iframe using the given url */
Expand All @@ -156,14 +158,15 @@ window.app = function app( options, bootstrapped ){
$( '#galaxy_main' ).prop( 'src', url );
},

}))( options );
});

// render and start the router
$(function(){

Galaxy.page = new Page( _.extend( options, {
Left : ToolPanel,
Right : HistoryPanel
Left : ToolPanel,
Right : HistoryPanel,
Router : Router
} ) );

// start the router - which will call any of the routes above
Expand Down
2 changes: 1 addition & 1 deletion client/galaxy/scripts/apps/history-panel.js
Expand Up @@ -84,7 +84,7 @@ var HistoryPanel = Backbone.View.extend({
].join('');
},

toString : function() { return 'HistoryPanel' }
toString : function() { return 'historyPanel' }
});

module.exports = HistoryPanel;
2 changes: 1 addition & 1 deletion client/galaxy/scripts/apps/tool-panel.js
Expand Up @@ -94,7 +94,7 @@ var ToolPanel = Backbone.View.extend({
].join('');
},

toString : function() { return 'ToolPanel' }
toString : function() { return 'toolPanel' }
});

module.exports = ToolPanel;
7 changes: 4 additions & 3 deletions client/galaxy/scripts/layout/page.js
Expand Up @@ -17,7 +17,7 @@ define( [ 'layout/masthead', 'layout/panel', 'mvc/ui/ui-modal' ], function( Mast
// attach global objects, build mastheads
Galaxy.modal = this.modal = new Modal.View();
Galaxy.display = this.display = function( view ) { self.center.display( view ) };
//Galaxy.router = this.router = new options.Router( self, options );
Galaxy.router = this.router = options.Router && new options.Router( self, options );
this.masthead = new Masthead.View( this.options );

// build page template
Expand All @@ -36,11 +36,12 @@ define( [ 'layout/masthead', 'layout/panel', 'mvc/ui/ui-modal' ], function( Mast
var panel_class_name = panel_id.charAt( 0 ).toUpperCase() + panel_id.slice( 1 );
var panel_class = options[ panel_class_name ];
if ( panel_class ) {
self[ panel_id ] = new panel_class( self, options );
var panel_instance = new panel_class( self, options );
self[ panel_instance.toString() ] = panel_instance;
self.panels[ panel_id ] = new Panel.SidePanel({
id : panel_id,
el : self.$( '#' + panel_id ),
view : self[ panel_id ]
view : panel_instance
});
}
});
Expand Down
8 changes: 4 additions & 4 deletions 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

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 d90c75b

Please sign in to comment.