[auth]: Api key, basic authorization in main view

This commit is contained in:
Anna Bodnia
2016-02-17 14:43:01 +02:00
parent 0e7b324d15
commit b9c4352186
12 changed files with 262 additions and 131 deletions

View File

@@ -3,52 +3,32 @@
SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to global SwaggerUi
events:{
'click #apikey_button' : 'toggleApiKeyContainer',
'click #apply_api_key' : 'applyApiKey'
'click .auth_submit_button' : 'applyApiKey'
},
initialize: function(opts){
template: Handlebars.templates.apikey_button_view,
initialize: function(opts) {
this.options = opts || {};
this.router = this.options.router;
},
render: function(){
var template = this.template();
$(this.el).html(template(this.model));
$(this.el).html(this.template(this.model));
return this;
},
applyApiKey: function(){
applyApiKey: function() {
var keyAuth = new SwaggerClient.ApiKeyAuthorization(
this.model.name,
$('#input_apiKey_entry').val(),
this.$('.input_apiKey_entry').val(),
this.model.in
);
this.router.api.clientAuthorizations.add(this.model.name, keyAuth);
this.router.load();
$('#apikey_container').show();
},
toggleApiKeyContainer: function(){
if ($('#apikey_container').length) {
var elem = $('#apikey_container').first();
if (elem.is(':visible')){
elem.hide();
} else {
// hide others
$('.auth_container').hide();
elem.show();
}
}
},
template: function(){
return Handlebars.templates.apikey_button_view;
//$('#apikey_container').show();
}
});