mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add shared base router
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
var jQuery = require( 'jquery' ),
|
||||
$ = jQuery,
|
||||
GalaxyApp = require( 'galaxy' ).GalaxyApp,
|
||||
QUERY_STRING = require( 'utils/query-string-parsing' ),
|
||||
AdminPanel = require( './panels/admin-panel' ),
|
||||
GridView = require( 'mvc/grid/grid-view' ),
|
||||
Ui = require( 'mvc/ui/ui-misc' ),
|
||||
Router = require( 'layout/router' ),
|
||||
Page = require( 'layout/page' );
|
||||
|
||||
window.app = function app( options, bootstrapped ){
|
||||
@@ -13,39 +13,7 @@ window.app = function app( options, bootstrapped ){
|
||||
Galaxy.params = Galaxy.config.params;
|
||||
|
||||
/** Routes */
|
||||
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( page, options ){
|
||||
this.page = page;
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
/** helper to push a new navigation state */
|
||||
push: function( url, data ) {
|
||||
data = data || {};
|
||||
data.__identifer = Math.random().toString( 36 ).substr( 2 );
|
||||
if ( !$.isEmptyObject( data ) ) {
|
||||
url += url.indexOf( '?' ) == -1 ? '?' : '&';
|
||||
url += $.param( data , true );
|
||||
}
|
||||
this.navigate( url, { 'trigger': true } );
|
||||
},
|
||||
|
||||
/** override to parse query string into obj and send to each route */
|
||||
execute: function( callback, args, name ){
|
||||
Galaxy.debug( 'router execute:', callback, args, name );
|
||||
var queryObj = QUERY_STRING.parse( args.pop() );
|
||||
args.push( queryObj );
|
||||
if( callback ){
|
||||
if ( this.authenticate( args, name ) ) {
|
||||
callback.apply( this, args );
|
||||
} else {
|
||||
this.page.display( new Ui.Message( { status: 'danger', message: 'You must be logged in as admin user to make this request.', persistent: true } ) );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
var AdminRouter = Router.extend({
|
||||
routes: {
|
||||
'(/)admin(/)user' : 'show_user'
|
||||
},
|
||||
@@ -63,7 +31,7 @@ window.app = function app( options, bootstrapped ){
|
||||
_.extend( options.config, { active_view : 'admin' } );
|
||||
Galaxy.page = new Page.View( _.extend( options, {
|
||||
Left : AdminPanel,
|
||||
Router : Router
|
||||
Router : AdminRouter
|
||||
} ) );
|
||||
|
||||
// start the router - which will call any of the routes above
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
var jQuery = require( 'jquery' ),
|
||||
$ = jQuery,
|
||||
QUERY_STRING = require( 'utils/query-string-parsing' ),
|
||||
Ui = require( 'mvc/ui/ui-misc' );
|
||||
|
||||
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( page, options ){
|
||||
this.page = page;
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
/** helper to push a new navigation state */
|
||||
push: function( url, data ) {
|
||||
data = data || {};
|
||||
data.__identifer = Math.random().toString( 36 ).substr( 2 );
|
||||
if ( !$.isEmptyObject( data ) ) {
|
||||
url += url.indexOf( '?' ) == -1 ? '?' : '&';
|
||||
url += $.param( data , true );
|
||||
}
|
||||
this.navigate( url, { 'trigger': true } );
|
||||
},
|
||||
|
||||
/** override to parse query string into obj and send to each route */
|
||||
execute: function( callback, args, name ){
|
||||
Galaxy.debug( 'router execute:', callback, args, name );
|
||||
var queryObj = QUERY_STRING.parse( args.pop() );
|
||||
args.push( queryObj );
|
||||
if( callback ){
|
||||
if ( this.authenticate( args, name ) ) {
|
||||
callback.apply( this, args );
|
||||
} else {
|
||||
this.access_denied();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
authenticate: function( args, name ) {
|
||||
return true;
|
||||
},
|
||||
|
||||
access_denied: function() {
|
||||
this.page.display( new Ui.Message( { status: 'danger', message: 'You must be logged in with proper credentials to make this request.', persistent: true } ) );
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Router
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"router.js","sources":["../../src/layout/router.js"],"names":["jQuery","require","$","QUERY_STRING","Ui","Router","Backbone","extend","initialize","page","options","this","push","url","data","__identifer","Math","random","toString","substr","isEmptyObject","indexOf","param","navigate","trigger","execute","callback","args","name","Galaxy","debug","queryObj","parse","pop","authenticate","apply","access_denied","display","Message","status","message","persistent","module","exports"],"mappings":"AAAA,GAAIA,QAASC,QAAS,UAClBC,EAAIF,OACJG,aAAeF,QAAS,8BACxBG,GAAKH,QAAS,kBAEdI,OAASC,SAASD,OAAOE,QAGzBC,WAAa,SAAUC,EAAMC,GACzBC,KAAKF,KAAOA,EACZE,KAAKD,QAAUA,GAInBE,KAAM,SAAUC,EAAKC,GACjBA,EAAOA,MACPA,EAAKC,YAAcC,KAAKC,SAASC,SAAU,IAAKC,OAAQ,GAClDjB,EAAEkB,cAAeN,KACnBD,GAA6B,IAAtBA,EAAIQ,QAAS,KAAc,IAAM,IACxCR,GAAOX,EAAEoB,MAAOR,GAAO,IAE3BH,KAAKY,SAAUV,GAAOW,SAAW,KAIrCC,QAAS,SAAUC,EAAUC,EAAMC,GAC/BC,OAAOC,MAAO,kBAAmBJ,EAAUC,EAAMC,EACjD,IAAIG,GAAW5B,aAAa6B,MAAOL,EAAKM,MACxCN,GAAKf,KAAMmB,GACPL,IACKf,KAAKuB,aAAcP,EAAMC,GAC1BF,EAASS,MAAOxB,KAAMgB,GAEtBhB,KAAKyB,kBAKjBF,aAAc,WACV,OAAO,GAGXE,cAAe,WACXzB,KAAKF,KAAK4B,QAAS,GAAIjC,IAAGkC,SAAWC,OAAQ,SAAUC,QAAS,sEAAuEC,YAAY,OAI3JC,QAAOC,QAAUtC"}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+32437
-21
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +1,49 @@
|
||||
webpackJsonp([5],[function(e,i,n){(function(e,i){var a=n(1),t=a,r=n(40).GalaxyApp,o=n(5),l=n(41);window.app=function(n,c){window.Galaxy=new r(n,c),Galaxy.debug("login app");var p=encodeURI(n.redirect);if(!n.show_welcome_with_login){var d=a.param({use_panels:"True",redirect:p});return void(window.location.href=Galaxy.root+"user/login?"+d)}var w=e.View.extend({initialize:function(i){this.page=i,this.model=new e.Model({title:o("Login required")}),this.setElement(this._template())},render:function(){this.page.$("#galaxy_main").prop("src",n.welcome_url)},_template:function(){var e=n.root+"user/login?"+t.param({redirect:p});return'<iframe src="'+e+'" frameborder="0" style="width: 100%; height: 100%;"/>'}});t(function(){Galaxy.page=new l.View(i.extend(n,{Right:w}))})}}).call(i,n(3),n(2))}]);
|
||||
webpackJsonp([6],[
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(Backbone, _) {var jQuery = __webpack_require__(3),
|
||||
$ = jQuery,
|
||||
GalaxyApp = __webpack_require__(4).GalaxyApp,
|
||||
_l = __webpack_require__(7),
|
||||
Page = __webpack_require__(26);
|
||||
|
||||
window.app = function app(options, bootstrapped) {
|
||||
window.Galaxy = new GalaxyApp(options, bootstrapped);
|
||||
Galaxy.debug('login app');
|
||||
var redirect = encodeURI(options.redirect);
|
||||
|
||||
// TODO: remove iframe for user login (at least) and render login page from here
|
||||
// then remove this redirect
|
||||
if (!options.show_welcome_with_login) {
|
||||
var params = jQuery.param({ use_panels: 'True', redirect: redirect });
|
||||
window.location.href = Galaxy.root + 'user/login?' + params;
|
||||
return;
|
||||
}
|
||||
|
||||
var LoginPage = Backbone.View.extend({
|
||||
initialize: function (page) {
|
||||
this.page = page;
|
||||
this.model = new Backbone.Model({ title: _l('Login required') });
|
||||
this.setElement(this._template());
|
||||
},
|
||||
render: function () {
|
||||
this.page.$('#galaxy_main').prop('src', options.welcome_url);
|
||||
},
|
||||
_template: function () {
|
||||
var login_url = options.root + 'user/login?' + $.param({ redirect: redirect });
|
||||
return '<iframe src="' + login_url + '" frameborder="0" style="width: 100%; height: 100%;"/>';
|
||||
}
|
||||
});
|
||||
|
||||
$(function () {
|
||||
Galaxy.page = new Page.View(_.extend(options, {
|
||||
Right: LoginPage
|
||||
}));
|
||||
});
|
||||
};
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(1)))
|
||||
|
||||
/***/ }
|
||||
]);
|
||||
//# sourceMappingURL=login.bundled.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["webpack:///login.bundled.js","webpack:///./galaxy/scripts/apps/login.js"],"names":["webpackJsonp","module","exports","__webpack_require__","Backbone","_","jQuery","$","GalaxyApp","_l","Page","window","app","options","bootstrapped","Galaxy","debug","redirect","encodeURI","show_welcome_with_login","params","param","use_panels","location","href","root","LoginPage","View","extend","initialize","page","this","model","Model","title","setElement","_template","render","prop","welcome_url","login_url","Right","call"],"mappings":"AAAAA,cAAc,IAER,SAASC,EAAQC,EAASC,ICFhC,SAAAC,EAAAC,GAAA,GAAIC,GAASH,EAAS,GAClBI,EAAID,EACJE,EAAYL,EAAS,IAAWK,UAChCC,EAAKN,EAAS,GACdO,EAAOP,EAAS,GAEpBQ,QAAOC,IAAM,SAAcC,EAASC,GAChCH,OAAOI,OAAS,GAAIP,GAAWK,EAASC,GACxCC,OAAOC,MAAO,YACd,IAAIC,GAAWC,UAAWL,EAAQI,SAIlC,KAAKJ,EAAQM,wBAAyB,CAClC,GAAIC,GAASd,EAAOe,OAAQC,WAAa,OAAQL,SAAWA,GAE5D,aADAN,OAAOY,SAASC,KAAOT,OAAOU,KAAO,cAAgBL,GAIzD,GAAIM,GAAYtB,EAASuB,KAAKC,QAC1BC,WAAY,SAAUC,GAClBC,KAAKD,KAAOA,EACZC,KAAKC,MAAQ,GAAI5B,GAAS6B,OAAQC,MAAQzB,EAAI,oBAC9CsB,KAAKI,WAAYJ,KAAKK,cAE1BC,OAAQ,WACJN,KAAKD,KAAKvB,EAAG,gBAAiB+B,KAAM,MAAOzB,EAAQ0B,cAEvDH,UAAY,WACR,GAAII,GAAY3B,EAAQY,KAAO,cAAgBlB,EAAEc,OAASJ,SAAWA,GACrE,OAAO,gBAAkBuB,EAAY,2DAI7CjC,GAAE,WACEQ,OAAOe,KAAO,GAAIpB,GAAKiB,KAAMtB,EAAEuB,OAAQf,GACnC4B,MAAQf,UDQUgB,KAAKxC,EAASC,EAAoB,GAAIA,EAAoB","file":"login.bundled.js","sourcesContent":["webpackJsonp([5],[\n/* 0 */\n/***/ function(module, exports, __webpack_require__) {\n\n\t/* WEBPACK VAR INJECTION */(function(Backbone, _) {var jQuery = __webpack_require__(1),\n\t $ = jQuery,\n\t GalaxyApp = __webpack_require__(40).GalaxyApp,\n\t _l = __webpack_require__(5),\n\t Page = __webpack_require__(41);\n\t\n\twindow.app = function app(options, bootstrapped) {\n\t window.Galaxy = new GalaxyApp(options, bootstrapped);\n\t Galaxy.debug('login app');\n\t var redirect = encodeURI(options.redirect);\n\t\n\t // TODO: remove iframe for user login (at least) and render login page from here\n\t // then remove this redirect\n\t if (!options.show_welcome_with_login) {\n\t var params = jQuery.param({ use_panels: 'True', redirect: redirect });\n\t window.location.href = Galaxy.root + 'user/login?' + params;\n\t return;\n\t }\n\t\n\t var LoginPage = Backbone.View.extend({\n\t initialize: function (page) {\n\t this.page = page;\n\t this.model = new Backbone.Model({ title: _l('Login required') });\n\t this.setElement(this._template());\n\t },\n\t render: function () {\n\t this.page.$('#galaxy_main').prop('src', options.welcome_url);\n\t },\n\t _template: function () {\n\t var login_url = options.root + 'user/login?' + $.param({ redirect: redirect });\n\t return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n\t }\n\t });\n\t\n\t $(function () {\n\t Galaxy.page = new Page.View(_.extend(options, {\n\t Right: LoginPage\n\t }));\n\t });\n\t};\n\t/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3), __webpack_require__(2)))\n\n/***/ }\n]);\n\n\n// WEBPACK FOOTER //\n// login.bundled.js","var jQuery = require( 'jquery' ),\n $ = jQuery,\n GalaxyApp = require( 'galaxy' ).GalaxyApp,\n _l = require( 'utils/localization' ),\n Page = require( 'layout/page' );\n\nwindow.app = function app( options, bootstrapped ){\n window.Galaxy = new GalaxyApp( options, bootstrapped );\n Galaxy.debug( 'login app' );\n var redirect = encodeURI( options.redirect );\n\n // TODO: remove iframe for user login (at least) and render login page from here\n // then remove this redirect\n if( !options.show_welcome_with_login ){\n var params = jQuery.param({ use_panels : 'True', redirect : redirect });\n window.location.href = Galaxy.root + 'user/login?' + params;\n return;\n }\n\n var LoginPage = Backbone.View.extend({\n initialize: function( page ) {\n this.page = page;\n this.model = new Backbone.Model({ title : _l( 'Login required' ) } );\n this.setElement( this._template() );\n },\n render: function() {\n this.page.$( '#galaxy_main' ).prop( 'src', options.welcome_url );\n },\n _template : function() {\n var login_url = options.root + 'user/login?' + $.param( { redirect : redirect } );\n return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n }\n });\n\n $(function(){\n Galaxy.page = new Page.View( _.extend( options, {\n Right : LoginPage\n } ) );\n });\n};\n\n\n\n// WEBPACK FOOTER //\n// ./galaxy/scripts/apps/login.js"],"sourceRoot":""}
|
||||
{"version":3,"sources":["webpack:///./galaxy/scripts/apps/login.js"],"names":["jQuery","require","$","GalaxyApp","_l","Page","window","app","options","bootstrapped","Galaxy","debug","redirect","encodeURI","show_welcome_with_login","params","param","use_panels","location","href","root","LoginPage","Backbone","View","extend","initialize","page","model","Model","title","setElement","_template","render","prop","welcome_url","login_url","_","Right"],"mappings":";;;;AAAA,wDAAIA,SAAS,mBAAAC,CAAS,CAAT,CAAb;AAAA,KACIC,IAAIF,MADR;AAAA,KAEIG,YAAY,mBAAAF,CAAS,CAAT,EAAoBE,SAFpC;AAAA,KAGIC,KAAK,mBAAAH,CAAS,CAAT,CAHT;AAAA,KAIII,OAAO,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mB;AAC5C6B,oBAAQhB;AADoC,UAAnB,CAAf,CAAd;AAGH,MAJD;AAKH,EAjCD,C","file":"login.bundled.js","sourcesContent":["var jQuery = require( 'jquery' ),\n $ = jQuery,\n GalaxyApp = require( 'galaxy' ).GalaxyApp,\n _l = require( 'utils/localization' ),\n Page = require( 'layout/page' );\n\nwindow.app = function app( options, bootstrapped ){\n window.Galaxy = new GalaxyApp( options, bootstrapped );\n Galaxy.debug( 'login app' );\n var redirect = encodeURI( options.redirect );\n\n // TODO: remove iframe for user login (at least) and render login page from here\n // then remove this redirect\n if( !options.show_welcome_with_login ){\n var params = jQuery.param({ use_panels : 'True', redirect : redirect });\n window.location.href = Galaxy.root + 'user/login?' + params;\n return;\n }\n\n var LoginPage = Backbone.View.extend({\n initialize: function( page ) {\n this.page = page;\n this.model = new Backbone.Model({ title : _l( 'Login required' ) } );\n this.setElement( this._template() );\n },\n render: function() {\n this.page.$( '#galaxy_main' ).prop( 'src', options.welcome_url );\n },\n _template : function() {\n var login_url = options.root + 'user/login?' + $.param( { redirect : redirect } );\n return '<iframe src=\"' + login_url + '\" frameborder=\"0\" style=\"width: 100%; height: 100%;\"/>';\n }\n });\n\n $(function(){\n Galaxy.page = new Page.View( _.extend( options, {\n Right : LoginPage\n } ) );\n });\n};\n\n\n\n// WEBPACK FOOTER //\n// ./galaxy/scripts/apps/login.js"],"sourceRoot":""}
|
||||
@@ -0,0 +1,2 @@
|
||||
var jQuery=require("jquery"),$=jQuery,QUERY_STRING=require("utils/query-string-parsing"),Ui=require("mvc/ui/ui-misc"),Router=Backbone.Router.extend({initialize:function(a,b){this.page=a,this.options=b},push:function(a,b){b=b||{},b.__identifer=Math.random().toString(36).substr(2),$.isEmptyObject(b)||(a+=-1==a.indexOf("?")?"?":"&",a+=$.param(b,!0)),this.navigate(a,{trigger:!0})},execute:function(a,b,c){Galaxy.debug("router execute:",a,b,c);var d=QUERY_STRING.parse(b.pop());b.push(d),a&&(this.authenticate(b,c)?a.apply(this,b):this.access_denied())},authenticate:function(){return!0},access_denied:function(){this.page.display(new Ui.Message({status:"danger",message:"You must be logged in with proper credentials to make this request.",persistent:!0}))}});module.exports=Router;
|
||||
//# sourceMappingURL=../../maps/layout/router.js.map
|
||||
Reference in New Issue
Block a user