added view of registration token

pull/677/head^2
Justin Richer 2014-09-22 23:24:17 -04:00
parent 6d80a00d65
commit cf198cccc2
2 changed files with 55 additions and 2 deletions

View File

@ -170,6 +170,11 @@ var ClientModel = Backbone.Model.extend({
});
var RegistrationTokenModel = Backbone.Model.extend({
idAttribute: 'clientId',
urlRoot: 'api/tokens/access/registration'
});
var ClientCollection = Backbone.Collection.extend({
initialize: function() {
@ -208,6 +213,10 @@ var ClientView = Backbone.View.extend({
this.moreInfoTemplate = _.template($('#tmpl-client-more-info-block').html());
}
if (!this.registrationTokenTemplate) {
this.registrationTokenTemplate = _.template($('#tmpl-client-registration-token').html());
}
this.model.bind('change', this.render, this);
},
@ -241,7 +250,7 @@ var ClientView = Backbone.View.extend({
$('.clientid-full', this.el).hide();
this.$('.dynamically-registered').tooltip({title: 'This client was dynamically registered'});
this.$('.dynamically-registered').tooltip({title: 'This client was dynamically registered. Click to view registration access token'});
this.$('.allow-introspection').tooltip({title: 'This client can perform token introspection'});
this.updateMatched();
@ -249,6 +258,36 @@ var ClientView = Backbone.View.extend({
return this;
},
showRegistrationToken:function(e) {
e.preventDefault();
$('#modalAlertLabel').html('Registration Access Token');
var token = new RegistrationTokenModel({clientId: this.model.get('clientId')});
var _self = this;
token.fetch({success:function() {
var savedModel = {
clientId: _self.model.get('clientId'),
registrationToken: token.get('value')
};
$('#modalAlert .modal-body').html(_self.registrationTokenTemplate(savedModel));
},
error:function() {
$('#modalAlert .modal-body').html('There was a problem loading the registration access token for this client.');
}
});
$('#modalAlert').modal({
'backdrop': 'static',
'keyboard': true,
'show': true
});
},
updateMatched:function() {
//console.log(this.model.get('matches'));
@ -266,7 +305,8 @@ var ClientView = Backbone.View.extend({
"click .btn-delete":"deleteClient",
"click .btn-whitelist":"whiteListClient",
'click .toggleMoreInformation': 'toggleMoreInformation',
"click .clientid-substring":"showClientId"
"click .clientid-substring":"showClientId",
"click .dynamically-registered": 'showRegistrationToken'
},
editClient:function (e) {

View File

@ -747,3 +747,16 @@
<% } %>
</script>
<script type="text/html" id="tmpl-client-registration-token">
<div>
<strong>ID:</strong> <input type="text" readonly style="cursor: text" class="token-full input-xxlarge" value="<%- clientId %>" />
</div>
<div>
<strong>Registration Token:</strong>
<input type="text" id="registrationToken" readonly style="cursor: text" class="token-full input-xxlarge" value="<%- registrationToken %>" />
</div>
</script>