[auth] Fixed applying api key

This commit is contained in:
Anna Bodnia
2016-02-24 15:09:19 +02:00
parent aa4a6a9979
commit e44a14b71b
14 changed files with 276 additions and 159 deletions

View File

@@ -28,7 +28,6 @@ SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to gl
);
this.router.api.clientAuthorizations.add(this.model.name, keyAuth);
this.router.load();
//$('#apikey_container').show();
}
});

View File

@@ -10,7 +10,10 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
authBtn: Handlebars.templates.auth_button
},
initialize: function(){},
initialize: function(opts) {
this.options = opts || {};
this.router = this.options.router;
},
render: function () {
this.$el.html(this.tpls.authBtn());
@@ -22,7 +25,7 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
var authsModel;
e.preventDefault();
authsModel = {title: 'Please authorize', content: this.renderAuths()};
authsModel = {title: 'Available authorizations', content: this.renderAuths()};
this.popup = new SwaggerUi.Views.PopupView({model: authsModel});
this.popup.render();
@@ -47,6 +50,6 @@ SwaggerUi.Views.AuthView = Backbone.View.extend({
}
}
return el.html();
return el;
}
});

View File

@@ -88,7 +88,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
this.model.securityDefinitions = this.model.securityDefinitions || {};
if (this.model.securityDefinitions) {
this.authView = new SwaggerUi.Views.AuthView({model: this.model.securityDefinitions});
this.authView = new SwaggerUi.Views.AuthView({model: this.model.securityDefinitions, router: this.router});
this.$('.authorize-wrapper').append(this.authView.render().el);
}

View File

@@ -8,6 +8,11 @@ SwaggerUi.Views.PopupView = Backbone.View.extend({
template: Handlebars.templates.popup,
className: 'api-popup-dialog',
selectors: {
content: '.api-popup-content',
main : '#swagger-ui-container'
},
initialize: function(){},
render: function () {
@@ -17,7 +22,8 @@ SwaggerUi.Views.PopupView = Backbone.View.extend({
dh = $win.height();
st = $win.scrollTop();
this.$el.html(this.template(this.model));
$(document.body).append(this.el);
this.$(this.selectors.content).append(this.model.content);
$(this.selectors.main).first().append(this.el);
dlgWd = this.$el.outerWidth();
dlgHt = this.$el.outerHeight();
top = (dh -dlgHt)/2 + st;