diff --git a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js index 3407c4988..b6f840923 100644 --- a/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js +++ b/openid-connect-server-webapp/src/main/webapp/resources/js/admin.js @@ -962,8 +962,8 @@ var AppRouter = Backbone.Router.extend({ this.updateSidebar('user/profile'); - this.userProfileView = new UserProfileView({model: getUserInfo()}); - $('#content').html(this.userProfileView.render().el); + var view = new UserProfileView({model: getUserInfo()}); + $('#content').html(view.render().el); setPageTitle($.t('admin.user-profile.show')); diff --git a/uma-server-webapp/src/main/webapp/WEB-INF/tags/footer.tag b/uma-server-webapp/src/main/webapp/WEB-INF/tags/footer.tag index d5888ef7c..a7ff9499e 100644 --- a/uma-server-webapp/src/main/webapp/WEB-INF/tags/footer.tag +++ b/uma-server-webapp/src/main/webapp/WEB-INF/tags/footer.tag @@ -30,6 +30,7 @@ + diff --git a/uma-server-webapp/src/main/webapp/resources/js/admin.js b/uma-server-webapp/src/main/webapp/resources/js/admin.js index 5c58dcb74..6456ae550 100644 --- a/uma-server-webapp/src/main/webapp/resources/js/admin.js +++ b/uma-server-webapp/src/main/webapp/resources/js/admin.js @@ -165,8 +165,6 @@ var ListWidgetView = Backbone.View.extend({ tagName: "div", - childView:ListWidgetChildView, - events:{ "click .btn-add-list-item":"addItem", "keypress":function (e) { @@ -226,7 +224,7 @@ var ListWidgetView = Backbone.View.extend({ this.$el.html(this.template({placeholder:this.options.placeholder, helpBlockText:this.options.helpBlockText})); - _self = this; + var _self = this; if (_.size(this.collection.models) == 0 && _.size(this.options.autocomplete) == 0) { $("tbody", _self.el).html($('#tmpl-list-widget-child-empty').html()); @@ -256,7 +254,7 @@ var ListWidgetView = Backbone.View.extend({ checked = false; } - var el = new this.childView({model:model, toggle: true, checked: checked, collection: _self.collection}).render().el; + var el = new ListWidgetChildView({model:model, toggle: true, checked: checked, collection: _self.collection}).render().el; $("tbody", _self.el).append(el); }, this); @@ -265,8 +263,7 @@ var ListWidgetView = Backbone.View.extend({ // now render everything not in the autocomplete list _.each(values.models, function (model) { - - var el = new this.childView({model:model, collection: _self.collection}).render().el; + var el = new ListWidgetChildView({model:model, collection: _self.collection}).render().el; $("tbody", _self.el).append(el); }, this); } @@ -277,18 +274,6 @@ var ListWidgetView = Backbone.View.extend({ }); -var BlackListModel = Backbone.Model.extend({ - idAttribute: 'id', - - urlRoot: 'api/blacklist' -}); - -var BlackListCollection = Backbone.Collection.extend({ - initialize: function() { }, - - url: "api/blacklist" -}); - var BreadCrumbView = Backbone.View.extend({ tagName: 'ul', @@ -329,125 +314,6 @@ var BreadCrumbView = Backbone.View.extend({ }); -var BlackListListView = Backbone.View.extend({ - tagName: 'span', - - initialize:function(options) { - this.options = options; - if (!this.template) { - this.template = _.template($('#tmpl-blacklist-form').html()); - } - }, - - load:function(callback) { - if (this.model.isFetched) { - callback(); - return; - } - - $('#loadingbox').sheet('show'); - $('#loading').html( - '' + $.t('admin.blacklist') + ' ' - ); - - $.when(this.model.fetchIfNeeded()).done(function() { - $('#loading-blacklist').addClass('label-success'); - $('#loadingbox').sheet('hide'); - callback(); - }); - }, - - events: { - "click .refresh-table":"refreshTable" - }, - - refreshTable:function(e) { - e.preventDefault(); - var _self = this; - $('#loadingbox').sheet('show'); - $('#loading').html( - '' + $.t('admin.blacklist') + ' ' - ); - - $.when(this.model.fetch()).done(function() { - $('#loadingbox').sheet('hide'); - _self.render(); - }); - }, - - render:function (eventName) { - - $(this.el).html(this.template(this.model.toJSON())); - - $('#blacklist .controls', this.el).html(new BlackListWidgetView({ - type: 'uri', - placeholder: 'http://', - collection: this.model - }).render().el); - - $(this.el).i18n(); - return this; - } -}); - -var BlackListWidgetView = ListWidgetView.extend({ - - childView: ListWidgetChildView.extend({ - render:function(options) { - this.options = options; - var uri = this.model.get('uri'); - - this.$el.html(this.template({item: uri})); - - if (uri.length > 30) { - this.$el.tooltip({title:uri}); - } - return this; - - } - }), - - addItem:function(e) { - e.preventDefault(); - - var input_value = $("input", this.el).val().trim(); - - if (input_value === "") { - return; - } - - // TODO: URI/pattern validation, check against existing clients - - var item = new BlackListModel({ - uri: input_value - }); - - var _self = this; // closures... - - item.save({}, { - success:function() { - _self.collection.add(item); - }, - error:function(error, response) { - //Pull out the response text. - var responseJson = JSON.parse(response.responseText); - - //Display an alert with an error message - $('#modalAlert div.modal-header').html(responseJson.error); - $('#modalAlert div.modal-body').html(responseJson.error_description); - - $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog - "backdrop" : "static", - "keyboard" : true, - "show" : true // ensure the modal is shown immediately - }); - } - }); - - } - -}); - // Stats table var StatsModel = Backbone.Model.extend({ @@ -469,12 +335,29 @@ var UserProfileView = Backbone.View.extend({ render:function() { $(this.el).html($('#tmpl-user-profile').html()); + + var t = this.template; _.each(this.model, function (value, key) { if (key && value) { - $('dl', this.el).append( - this.template({key: key, value: value}) - ); + + if (typeof(value) === 'object') { + + var el = this.el; + var k = key; + + _.each(value, function (value, key) { + $('dl', el).append( + t({key: key, value: value, category: k}) + ); + }); + } else if (typeof(value) === 'array') { + // TODO: handle array types + } else { + $('dl', this.el).append( + t({key: key, value: value}) + ); + } } }, this); @@ -621,6 +504,7 @@ var AppRouter = Backbone.Router.extend({ grantTypes: ["authorization_code"], responseTypes: ["code"], subjectType: "PUBLIC", + jwksType: "URI", contacts: contacts }, { silent: true }); @@ -659,6 +543,16 @@ var AppRouter = Backbone.Router.extend({ }, { silent: true }); } + if (client.get("jwks")) { + client.set({ + jwksType: "VAL" + }, { silent: true }); + } else { + client.set({ + jwksType: "URI" + }, { silent: true }); + } + client.set({ generateClientSecret:false, displayClientSecret:false @@ -780,7 +674,6 @@ var AppRouter = Backbone.Router.extend({ this.updateSidebar('user/approved'); var view = new ApprovedSiteListView({model:this.approvedSiteList, clientList: this.clientList, systemScopeList: this.systemScopeList}); - view.load( function(collection, response, options) { $('#content').html(view.render().el); @@ -836,7 +729,7 @@ var AppRouter = Backbone.Router.extend({ this.updateSidebar('admin/blacklist'); - var view = new BlackListListView({model:this.blackListList}); + var view = new BlackListListView({collection: this.blackListList}); view.load( function(collection, response, options) { @@ -1230,11 +1123,17 @@ $(function () { $.get('resources/template/dynreg.html', _load), $.get('resources/template/rsreg.html', _load), $.get('resources/template/token.html', _load), + $.get('resources/template/blacklist.html', _load), $.get('resources/template/policy.html', _load) ).done(function() { $.ajaxSetup({cache:false}); app = new AppRouter(); + app.on('route', function(name, args) { + // scroll to top of page on new route selection + $("html, body").animate({ scrollTop: 0 }, "slow"); + }); + // grab all hashed URLs and send them through the app router instead $(document).on('click', 'a[href^="manage/#"]', function(event) { event.preventDefault();