[auth] UI changes
This commit is contained in:
@@ -137,7 +137,6 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
// This is bound to success handler for SwaggerApi
|
||||
// so it gets called when SwaggerApi completes loading
|
||||
render: function(){
|
||||
var authsModel;
|
||||
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
|
||||
this.mainView = new SwaggerUi.Views.MainView({
|
||||
model: this.api,
|
||||
@@ -145,14 +144,9 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
swaggerOptions: this.options,
|
||||
router: this
|
||||
}).render();
|
||||
if (!_.isEmpty(this.api.securityDefinitions)){
|
||||
authsModel = _.map(this.api.securityDefinitions, function (auth, name) {
|
||||
var result = {};
|
||||
result[name] = auth;
|
||||
return result;
|
||||
});
|
||||
if (!_.isEmpty(this.api.security)){
|
||||
this.authView = new SwaggerUi.Views.AuthButtonView({
|
||||
data: SwaggerUi.utils.parseSecurityDefinitions(authsModel),
|
||||
data: SwaggerUi.utils.parseSecurityDefinitions(this.api.security),
|
||||
router: this
|
||||
});
|
||||
$('#auth_container').append(this.authView.render().el);
|
||||
|
||||
@@ -7,18 +7,22 @@ SwaggerUi.Views.AuthButtonView = Backbone.View.extend({
|
||||
|
||||
tpls: {
|
||||
popup: Handlebars.templates.popup,
|
||||
authBtn: Handlebars.templates.auth_button
|
||||
authBtn: Handlebars.templates.auth_button,
|
||||
authBtnOperation: Handlebars.templates.auth_button_operation
|
||||
},
|
||||
|
||||
initialize: function(opts) {
|
||||
this.options = opts || {};
|
||||
this.options.data = this.options.data || {};
|
||||
this.isOperation = this.options.isOperation;
|
||||
this.router = this.options.router;
|
||||
this.auths = this.options.data.oauth2.concat(this.options.data.auths);
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.html(this.tpls.authBtn(this.model));
|
||||
var tplName = this.isOperation ? 'authBtnOperation' : 'authBtn';
|
||||
|
||||
this.$el.html(this.tpls[tplName](this.model));
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
SwaggerUi.Views.AuthView = Backbone.View.extend({
|
||||
events: {
|
||||
'click .auth_submit_button': 'authorizeClick',
|
||||
'click .auth_submit__button': 'authorizeClick',
|
||||
'click .auth_logout__button': 'logoutClick'
|
||||
},
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
var authsModel = SwaggerUi.utils.parseSecurityDefinitions(this.model.security);
|
||||
|
||||
authsModel.isLogout = !_.isEmpty(window.swaggerUi.api.clientAuthorizations.authz);
|
||||
this.authView = new SwaggerUi.Views.AuthButtonView({data: authsModel, router: this.router});
|
||||
this.authView = new SwaggerUi.Views.AuthButtonView({data: authsModel, router: this.router, isOperation: true});
|
||||
this.$('.authorize-wrapper').append(this.authView.render().el);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user