auto format and cleanup javascript
parent
bd72b4138d
commit
78b9b6ced4
|
@ -53,7 +53,8 @@ Backbone.Collection.prototype.fetchIfNeeded = function(options) {
|
|||
}
|
||||
};
|
||||
|
||||
var URIModel = Backbone.Model.extend({
|
||||
var URIModel = Backbone.Model
|
||||
.extend({
|
||||
|
||||
validate: function(attrs) {
|
||||
|
||||
|
@ -67,15 +68,10 @@ var URIModel = Backbone.Model.extend({
|
|||
|
||||
});
|
||||
|
||||
|
||||
/*
|
||||
* Backbone JS Reusable ListWidget
|
||||
* Options
|
||||
* {
|
||||
* collection: Backbone JS Collection
|
||||
* type: ('uri'|'default')
|
||||
* autocomplete: ['item1','item2'] List of auto complete items
|
||||
* }
|
||||
* Backbone JS Reusable ListWidget Options { collection: Backbone JS Collection
|
||||
* type: ('uri'|'default') autocomplete: ['item1','item2'] List of auto complete
|
||||
* items }
|
||||
*
|
||||
*/
|
||||
var ListWidgetChildView = Backbone.View.extend({
|
||||
|
@ -93,7 +89,8 @@ var ListWidgetChildView = Backbone.View.extend({
|
|||
// this.$el.tooltip('delete');
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
error: app.errorHandlerView.handleError()
|
||||
});
|
||||
|
||||
|
@ -111,7 +108,10 @@ var ListWidgetChildView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
initialize: function(options) {
|
||||
this.options = {toggle: false, checked: false};
|
||||
this.options = {
|
||||
toggle: false,
|
||||
checked: false
|
||||
};
|
||||
_.extend(this.options, options);
|
||||
if (!this.template) {
|
||||
this.template = _.template($('#tmpl-list-widget-child').html());
|
||||
|
@ -120,14 +120,19 @@ var ListWidgetChildView = Backbone.View.extend({
|
|||
|
||||
render: function() {
|
||||
|
||||
var data = {model: this.model.toJSON(), opt: this.options};
|
||||
var data = {
|
||||
model: this.model.toJSON(),
|
||||
opt: this.options
|
||||
};
|
||||
|
||||
this.$el.html(this.template(data));
|
||||
|
||||
$('.item-full', this.el).hide();
|
||||
|
||||
if (this.model.get('item').length > 30) {
|
||||
this.$el.tooltip({title:$.t('admin.list-widget.tooltip')});
|
||||
this.$el.tooltip({
|
||||
title: $.t('admin.list-widget.tooltip')
|
||||
});
|
||||
|
||||
var _self = this;
|
||||
|
||||
|
@ -139,8 +144,6 @@ var ListWidgetChildView = Backbone.View.extend({
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
}
|
||||
|
@ -185,9 +188,13 @@ var ListWidgetView = Backbone.View.extend({
|
|||
var model;
|
||||
|
||||
if (this.options.type == 'uri') {
|
||||
model = new URIModel({item:input_value});
|
||||
model = new URIModel({
|
||||
item: input_value
|
||||
});
|
||||
} else {
|
||||
model = new Backbone.Model({item:input_value});
|
||||
model = new Backbone.Model({
|
||||
item: input_value
|
||||
});
|
||||
model.validate = function(attrs) {
|
||||
if (!attrs.item) {
|
||||
return "value can't be null";
|
||||
|
@ -196,7 +203,9 @@ var ListWidgetView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
// if it's valid and doesn't already exist
|
||||
if (model.get("item") != null && this.collection.where({item: input_value}).length < 1) {
|
||||
if (model.get("item") != null && this.collection.where({
|
||||
item: input_value
|
||||
}).length < 1) {
|
||||
this.collection.add(model);
|
||||
} else {
|
||||
// else add a visual error indicator
|
||||
|
@ -206,8 +215,10 @@ var ListWidgetView = Backbone.View.extend({
|
|||
|
||||
render: function(eventName) {
|
||||
|
||||
this.$el.html(this.template({placeholder:this.options.placeholder,
|
||||
helpBlockText:this.options.helpBlockText}));
|
||||
this.$el.html(this.template({
|
||||
placeholder: this.options.placeholder,
|
||||
helpBlockText: this.options.helpBlockText
|
||||
}));
|
||||
|
||||
var _self = this;
|
||||
|
||||
|
@ -218,7 +229,8 @@ var ListWidgetView = Backbone.View.extend({
|
|||
// make a copy of our collection to work from
|
||||
var values = this.collection.clone();
|
||||
|
||||
// look through our autocomplete values (if we have them) and render them all as checkboxes
|
||||
// look through our autocomplete values (if we have them) and render
|
||||
// them all as checkboxes
|
||||
if (this.options.autocomplete) {
|
||||
_.each(this.options.autocomplete, function(option) {
|
||||
var found = _.find(values.models, function(element) {
|
||||
|
@ -232,23 +244,35 @@ var ListWidgetView = Backbone.View.extend({
|
|||
// if we found the element, check the box
|
||||
model = found;
|
||||
checked = true;
|
||||
// and remove it from the list of items to be rendered later
|
||||
values.remove(found, {silent: true});
|
||||
// and remove it from the list of items to be rendered
|
||||
// later
|
||||
values.remove(found, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
model = new Backbone.Model({item:option});
|
||||
model = new Backbone.Model({
|
||||
item: option
|
||||
});
|
||||
checked = false;
|
||||
}
|
||||
|
||||
var el = new ListWidgetChildView({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);
|
||||
}
|
||||
|
||||
|
||||
// now render everything not in the autocomplete list
|
||||
_.each(values.models, function(model) {
|
||||
var el = new ListWidgetChildView({model:model, collection: _self.collection}).render().el;
|
||||
var el = new ListWidgetChildView({
|
||||
model: model,
|
||||
collection: _self.collection
|
||||
}).render().el;
|
||||
$("tbody", _self.el).append(el);
|
||||
}, this);
|
||||
}
|
||||
|
@ -283,11 +307,20 @@ var BreadCrumbView = Backbone.View.extend({
|
|||
// go through each of the breadcrumb models
|
||||
_.each(this.collection.models, function(crumb, index) {
|
||||
|
||||
// if it's the last index in the crumbs then render the link inactive
|
||||
// if it's the last index in the crumbs then render the link
|
||||
// inactive
|
||||
if (index == parent.collection.size() - 1) {
|
||||
crumb.set({active:true}, {silent:true});
|
||||
crumb.set({
|
||||
active: true
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
crumb.set({active:false}, {silent:true});
|
||||
crumb.set({
|
||||
active: false
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
this.$el.append(this.template(crumb.toJSON()));
|
||||
|
@ -298,7 +331,6 @@ var BreadCrumbView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// User Profile
|
||||
|
||||
var UserProfileView = Backbone.View.extend({
|
||||
|
@ -326,16 +358,19 @@ var UserProfileView = Backbone.View.extend({
|
|||
var k = key;
|
||||
|
||||
_.each(value, function(value, key) {
|
||||
$('dl', el).append(
|
||||
t({key: key, value: value, category: k})
|
||||
);
|
||||
$('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})
|
||||
);
|
||||
$('dl', this.el).append(t({
|
||||
key: key,
|
||||
value: value
|
||||
}));
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
|
@ -377,10 +412,17 @@ var ErrorHandlerView = Backbone.View.extend({
|
|||
console.log(message.log);
|
||||
}
|
||||
|
||||
_self.showErrorMessage(
|
||||
_self.headerTemplate({message: message, model: model, response: response, options: options}),
|
||||
_self.template({message: message, model: model, response: response, options: options})
|
||||
);
|
||||
_self.showErrorMessage(_self.headerTemplate({
|
||||
message: message,
|
||||
model: model,
|
||||
response: response,
|
||||
options: options
|
||||
}), _self.template({
|
||||
message: message,
|
||||
model: model,
|
||||
response: response,
|
||||
options: options
|
||||
}));
|
||||
|
||||
$('#modalAlert .modal-body .page-reload').on('click', _self.reloadPage);
|
||||
|
||||
|
@ -404,7 +446,6 @@ var ErrorHandlerView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
// Router
|
||||
var AppRouter = Backbone.Router.extend({
|
||||
|
||||
|
@ -416,9 +457,13 @@ var AppRouter = Backbone.Router.extend({
|
|||
|
||||
root: function() {
|
||||
if (isAdmin()) {
|
||||
this.navigate('admin/clients', {trigger: true});
|
||||
this.navigate('admin/clients', {
|
||||
trigger: true
|
||||
});
|
||||
} else {
|
||||
this.navigate('user/approved', {trigger: true});
|
||||
this.navigate('user/approved', {
|
||||
trigger: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -442,9 +487,10 @@ var AppRouter = Backbone.Router.extend({
|
|||
|
||||
notImplemented: function() {
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}]);
|
||||
|
||||
this.updateSidebar('none');
|
||||
|
||||
|
@ -473,10 +519,11 @@ $(function () {
|
|||
};
|
||||
|
||||
// load templates and append them to the body
|
||||
$.when.apply(null, ui.templates.map(loader)
|
||||
).done(function() {
|
||||
$.when.apply(null, ui.templates.map(loader)).done(function() {
|
||||
console.log('done');
|
||||
$.ajaxSetup({cache:false});
|
||||
$.ajaxSetup({
|
||||
cache: false
|
||||
});
|
||||
app = new AppRouter();
|
||||
|
||||
_.each(ui.routes.reverse(), function(route) {
|
||||
|
@ -486,20 +533,27 @@ $(function () {
|
|||
|
||||
app.on('route', function(name, args) {
|
||||
// scroll to top of page on new route selection
|
||||
$("html, body").animate({ scrollTop: 0 }, "slow");
|
||||
$("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();
|
||||
app.navigate(this.hash.slice(1), {trigger: true});
|
||||
app.navigate(this.hash.slice(1), {
|
||||
trigger: true
|
||||
});
|
||||
});
|
||||
|
||||
var base = $('base').attr('href');
|
||||
$.getJSON(base + '.well-known/openid-configuration', function(data) {
|
||||
app.serverConfiguration = data;
|
||||
var baseUrl = $.url(app.serverConfiguration.issuer);
|
||||
Backbone.history.start({pushState: true, root: baseUrl.attr('relative') + 'manage/'});
|
||||
Backbone.history.start({
|
||||
pushState: true,
|
||||
root: baseUrl.attr('relative') + 'manage/'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -509,13 +563,13 @@ $(function () {
|
|||
$('#modalAlert div.modal-header').html($.t('error.title'));
|
||||
$('#modalAlert div.modal-body').html($.t('error.message') + message + ' <br /> ' + [filename, lineno, colno, error]);
|
||||
|
||||
$("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog
|
||||
$("#modalAlert").modal({ // wire up the actual modal functionality
|
||||
// and show the dialog
|
||||
"backdrop": "static",
|
||||
"keyboard": true,
|
||||
"show" : true // ensure the modal is shown immediately
|
||||
"show": true
|
||||
// ensure the modal is shown immediately
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ var BlackListModel = Backbone.Model.extend({
|
|||
});
|
||||
|
||||
var BlackListCollection = Backbone.Collection.extend({
|
||||
initialize: function() { },
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
url: "api/blacklist"
|
||||
});
|
||||
|
@ -40,12 +41,14 @@ var BlackListListView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> ');
|
||||
|
||||
$.when(this.collection.fetchIfNeeded({success:function(e) {$('#loading-blacklist').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.collection.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-blacklist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -62,9 +65,7 @@ var BlackListListView = Backbone.View.extend({
|
|||
|
||||
var _self = this;
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> ');
|
||||
|
||||
$.when(this.collection.fetch()).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
|
@ -88,7 +89,9 @@ var BlackListListView = Backbone.View.extend({
|
|||
|
||||
var _self = this;
|
||||
_.each(this.collection.models, function(blacklist) {
|
||||
var view = new BlackListWidgetView({model: blacklist});
|
||||
var view = new BlackListWidgetView({
|
||||
model: blacklist
|
||||
});
|
||||
view.parentView = _self;
|
||||
$("#blacklist-table", _self.el).append(view.render().el);
|
||||
}, this);
|
||||
|
@ -159,7 +162,8 @@ var BlackListWidgetView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
|
||||
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
|
@ -180,9 +184,10 @@ var BlackListWidgetView = Backbone.View.extend({
|
|||
|
||||
});
|
||||
|
||||
|
||||
ui.routes.push({path: "admin/blacklist", name: "blackList", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "admin/blacklist",
|
||||
name: "blackList",
|
||||
callback: function() {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -190,21 +195,24 @@ ui.routes.push({path: "admin/blacklist", name: "blackList", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.manage-blacklist'), href:"manage/#admin/blacklist"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.manage-blacklist'),
|
||||
href: "manage/#admin/blacklist"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/blacklist');
|
||||
|
||||
var view = new BlackListListView({collection: this.blackListList});
|
||||
var view = new BlackListListView({
|
||||
collection: this.blackListList
|
||||
});
|
||||
|
||||
view.load(
|
||||
function(collection, response, options) {
|
||||
view.load(function(collection, response, options) {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('admin.manage-blacklist'));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -166,22 +166,27 @@ var ClientModel = Backbone.Model.extend({
|
|||
} else {
|
||||
// there's no search term, we always match
|
||||
|
||||
this.unset('matches', {silent: true});
|
||||
this.unset('matches', {
|
||||
silent: true
|
||||
});
|
||||
// console.log('no term');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
var matchString = matches.join(' | ');
|
||||
|
||||
if (matches.length > 0) {
|
||||
this.set({
|
||||
matches: matchString
|
||||
}, {silent: true});
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
return true;
|
||||
} else {
|
||||
this.unset('matches', {silent: true});
|
||||
this.unset('matches', {
|
||||
silent: true
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -208,7 +213,9 @@ var ClientCollection = Backbone.Collection.extend({
|
|||
url: "api/clients",
|
||||
|
||||
getByClientId: function(clientId) {
|
||||
var clients = this.where({clientId: clientId});
|
||||
var clients = this.where({
|
||||
clientId: clientId
|
||||
});
|
||||
if (clients.length == 1) {
|
||||
return clients[0];
|
||||
} else {
|
||||
|
@ -268,19 +275,31 @@ var ClientView = Backbone.View.extend({
|
|||
hoverCreationDate = creationDate.format("LLL");
|
||||
}
|
||||
|
||||
|
||||
var json = {client: this.model.toJSON(), whiteList: this.options.whiteList,
|
||||
displayCreationDate: displayCreationDate, hoverCreationDate: hoverCreationDate};
|
||||
var json = {
|
||||
client: this.model.toJSON(),
|
||||
whiteList: this.options.whiteList,
|
||||
displayCreationDate: displayCreationDate,
|
||||
hoverCreationDate: hoverCreationDate
|
||||
};
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('scope'), systemScopes: this.options.systemScopeList}));
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({
|
||||
scopes: this.model.get('scope'),
|
||||
systemScopes: this.options.systemScopeList
|
||||
}));
|
||||
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({client: this.model.toJSON()}));
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({
|
||||
client: this.model.toJSON()
|
||||
}));
|
||||
|
||||
$('.clientid-full', this.el).hide();
|
||||
|
||||
this.$('.dynamically-registered').tooltip({title: $.t('client.client-table.dynamically-registered-tooltip')});
|
||||
this.$('.allow-introspection').tooltip({title: $.t('client.client-table.allow-introspection-tooltip')});
|
||||
this.$('.dynamically-registered').tooltip({
|
||||
title: $.t('client.client-table.dynamically-registered-tooltip')
|
||||
});
|
||||
this.$('.allow-introspection').tooltip({
|
||||
title: $.t('client.client-table.allow-introspection-tooltip')
|
||||
});
|
||||
|
||||
this.updateMatched();
|
||||
this.updateStats();
|
||||
|
@ -293,7 +312,9 @@ var ClientView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
updateStats: function(eventName) {
|
||||
$('.count', this.el).html(this.countTemplate({count: this.options.clientStat.get('approvedSiteCount')}));
|
||||
$('.count', this.el).html(this.countTemplate({
|
||||
count: this.options.clientStat.get('approvedSiteCount')
|
||||
}));
|
||||
},
|
||||
|
||||
showRegistrationToken: function(e) {
|
||||
|
@ -301,10 +322,13 @@ var ClientView = Backbone.View.extend({
|
|||
|
||||
$('#modalAlertLabel').html($.t('client.client-form.registration-access-token'));
|
||||
|
||||
var token = new RegistrationTokenModel({clientId: this.model.get('clientId')});
|
||||
var token = new RegistrationTokenModel({
|
||||
clientId: this.model.get('clientId')
|
||||
});
|
||||
|
||||
var _self = this;
|
||||
token.fetch({success:function() {
|
||||
token.fetch({
|
||||
success: function() {
|
||||
var savedModel = {
|
||||
clientId: _self.model.get('clientId'),
|
||||
registrationToken: token.get('value')
|
||||
|
@ -314,11 +338,14 @@ var ClientView = Backbone.View.extend({
|
|||
|
||||
$('#modalAlert .modal-body #rotate-token').click(function(e) {
|
||||
if (confirm($.t('client.client-form.rotate-registration-token-confirm'))) {
|
||||
token.save(null, {success: function() {
|
||||
token.save(null, {
|
||||
success: function() {
|
||||
console.log('token:' + token.get('value'));
|
||||
$('#modalAlert .modal-body #registrationToken').val(token.get('value'));
|
||||
},
|
||||
error: app.errorHandlerView.handleError({message: $.t('client.client-form.rotate-registration-token-error')})
|
||||
error: app.errorHandlerView.handleError({
|
||||
message: $.t('client.client-form.rotate-registration-token-error')
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -331,7 +358,10 @@ var ClientView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
},
|
||||
error:app.errorHandlerView.handleError({log: "An error occurred when fetching the registration token", message: $.t('client.client-form.registration-token-error')})
|
||||
error: app.errorHandlerView.handleError({
|
||||
log: "An error occurred when fetching the registration token",
|
||||
message: $.t('client.client-form.registration-token-error')
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
|
@ -359,17 +389,23 @@ var ClientView = Backbone.View.extend({
|
|||
|
||||
editClient: function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('admin/client/' + this.model.id, {trigger: true});
|
||||
app.navigate('admin/client/' + this.model.id, {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
whiteListClient: function(e) {
|
||||
e.preventDefault();
|
||||
if (this.options.whiteList == null) {
|
||||
// create a new one
|
||||
app.navigate('admin/whitelist/new/' + this.model.get('id'), {trigger: true});
|
||||
app.navigate('admin/whitelist/new/' + this.model.get('id'), {
|
||||
trigger: true
|
||||
});
|
||||
} else {
|
||||
// edit the existing one
|
||||
app.navigate('admin/whitelist/' + this.options.whiteList.get('id'), {trigger: true});
|
||||
app.navigate('admin/whitelist/' + this.options.whiteList.get('id'), {
|
||||
trigger: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -380,7 +416,8 @@ var ClientView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
$(this).slideUp("fast", function() { // slide up
|
||||
|
@ -389,7 +426,9 @@ var ClientView = Backbone.View.extend({
|
|||
});
|
||||
});
|
||||
},
|
||||
error:app.errorHandlerView.handleError({log: "An error occurred when deleting a client"})
|
||||
error: app.errorHandlerView.handleError({
|
||||
log: "An error occurred when deleting a client"
|
||||
})
|
||||
});
|
||||
|
||||
_self.parentView.delegateEvents();
|
||||
|
@ -439,24 +478,30 @@ var ClientListView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
load: function(callback) {
|
||||
if (this.model.isFetched &&
|
||||
this.options.whiteListList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
if (this.model.isFetched && this.options.whiteListList.isFetched && this.options.systemScopeList.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-clients">' + $.t("common.clients") + '</span> ' +
|
||||
'<span class="label" id="loading-whitelist">' + $.t("whitelist.whitelist") + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-clients">' + $.t("common.clients") + '</span> ' + '<span class="label" id="loading-whitelist">' + $.t("whitelist.whitelist") + '</span> ' + '<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> ');
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.whiteListList.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.whiteListList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-whitelist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -474,7 +519,9 @@ var ClientListView = Backbone.View.extend({
|
|||
newClient: function(e) {
|
||||
e.preventDefault();
|
||||
this.remove();
|
||||
app.navigate('admin/client/new', {trigger: true});
|
||||
app.navigate('admin/client/new', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
render: function(eventName) {
|
||||
|
@ -490,7 +537,8 @@ var ClientListView = Backbone.View.extend({
|
|||
renderInner: function(eventName) {
|
||||
|
||||
// set up the rows to render
|
||||
// (note that this doesn't render until visibility is determined in togglePlaceholder)
|
||||
// (note that this doesn't render until visibility is determined in
|
||||
// togglePlaceholder)
|
||||
|
||||
_.each(this.filteredModel.models, function(client, index) {
|
||||
var clientStat = this.getStat(client.get('clientId'));
|
||||
|
@ -522,7 +570,9 @@ var ClientListView = Backbone.View.extend({
|
|||
|
||||
getStat: function(index) {
|
||||
if (!this.stats[index]) {
|
||||
this.stats[index] = new ClientStatsModel({id: index});
|
||||
this.stats[index] = new ClientStatsModel({
|
||||
id: index
|
||||
});
|
||||
}
|
||||
return this.stats[index];
|
||||
},
|
||||
|
@ -565,7 +615,9 @@ var ClientListView = Backbone.View.extend({
|
|||
changePage: function(event, num) {
|
||||
console.log('Page changed: ' + num);
|
||||
|
||||
$('.paginator', this.el).bootpag({page:num});
|
||||
$('.paginator', this.el).bootpag({
|
||||
page: num
|
||||
});
|
||||
var _self = this;
|
||||
|
||||
_.each(this.filteredModel.models, function(client, index) {
|
||||
|
@ -591,8 +643,8 @@ var ClientListView = Backbone.View.extend({
|
|||
success: function(e) {
|
||||
|
||||
},
|
||||
error:app.errorHandlerView.handleError()}))
|
||||
.done(function(e) {
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function(e) {
|
||||
view.updateStats();
|
||||
});
|
||||
}
|
||||
|
@ -601,32 +653,35 @@ var ClientListView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
/*
|
||||
$('#client-table tbody tr', this.el).each(function(index, element) {
|
||||
if (Math.ceil((index + 1) / 10) != num) {
|
||||
// hide the element
|
||||
$(element).hide();
|
||||
} else {
|
||||
// show the element
|
||||
$(element).show();
|
||||
}
|
||||
});
|
||||
* $('#client-table tbody tr', this.el).each(function(index, element) {
|
||||
* if (Math.ceil((index + 1) / 10) != num) { // hide the element
|
||||
* $(element).hide(); } else { // show the element $(element).show(); }
|
||||
* });
|
||||
*/
|
||||
},
|
||||
|
||||
refreshTable: function(e) {
|
||||
e.preventDefault();
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-clients">' + $.t("common.clients") + '</span> ' +
|
||||
'<span class="label" id="loading-whitelist">' + $.t("whitelist.whitelist") + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-clients">' + $.t("common.clients") + '</span> ' + '<span class="label" id="loading-whitelist">' + $.t("whitelist.whitelist") + '</span> ' + '<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> ');
|
||||
|
||||
var _self = this;
|
||||
$.when(this.model.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.whiteListList.fetch({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.whiteListList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-whitelist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
_self.render();
|
||||
});
|
||||
|
@ -652,7 +707,6 @@ var ClientListView = Backbone.View.extend({
|
|||
this.searchTable();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
var ClientFormView = Backbone.View.extend({
|
||||
|
@ -706,25 +760,31 @@ var ClientFormView = Backbone.View.extend({
|
|||
|
||||
cancel: function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('admin/clients', {trigger: true});
|
||||
app.navigate('admin/clients', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
load: function(callback) {
|
||||
if (this.model.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
if (this.model.isFetched && this.options.systemScopeList.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> ');
|
||||
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.model.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -745,16 +805,16 @@ var ClientFormView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set up the form based on the current state of the tokenEndpointAuthMethod parameter
|
||||
* Set up the form based on the current state of the tokenEndpointAuthMethod
|
||||
* parameter
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
toggleClientCredentials: function() {
|
||||
|
||||
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
||||
|
||||
if (tokenEndpointAuthMethod == 'SECRET_BASIC'
|
||||
|| tokenEndpointAuthMethod == 'SECRET_POST'
|
||||
|| tokenEndpointAuthMethod == 'SECRET_JWT') {
|
||||
if (tokenEndpointAuthMethod == 'SECRET_BASIC' || tokenEndpointAuthMethod == 'SECRET_POST' || tokenEndpointAuthMethod == 'SECRET_JWT') {
|
||||
|
||||
// client secret is required, show all the bits
|
||||
$('#clientSecretPanel', this.el).show();
|
||||
|
@ -765,9 +825,9 @@ var ClientFormView = Backbone.View.extend({
|
|||
$('#clientSecretPanel', this.el).hide();
|
||||
}
|
||||
|
||||
// show or hide the signing algorithm method depending on what's selected
|
||||
if (tokenEndpointAuthMethod == 'PRIVATE_KEY'
|
||||
|| tokenEndpointAuthMethod == 'SECRET_JWT') {
|
||||
// show or hide the signing algorithm method depending on what's
|
||||
// selected
|
||||
if (tokenEndpointAuthMethod == 'PRIVATE_KEY' || tokenEndpointAuthMethod == 'SECRET_JWT') {
|
||||
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
||||
} else {
|
||||
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
||||
|
@ -795,6 +855,7 @@ var ClientFormView = Backbone.View.extend({
|
|||
|
||||
/**
|
||||
* Set up the form based on the "Generate" checkbox
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
toggleGenerateClientSecret: function() {
|
||||
|
@ -814,6 +875,7 @@ var ClientFormView = Backbone.View.extend({
|
|||
|
||||
/**
|
||||
* Handle whether or not to display the client secret
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
toggleDisplayClientSecret: function() {
|
||||
|
@ -844,7 +906,8 @@ var ClientFormView = Backbone.View.extend({
|
|||
}
|
||||
},
|
||||
|
||||
// returns "null" if given the value "default" as a string, otherwise returns input value. useful for parsing the JOSE algorithm dropdowns
|
||||
// returns "null" if given the value "default" as a string, otherwise
|
||||
// returns input value. useful for parsing the JOSE algorithm dropdowns
|
||||
defaultToNull: function(value) {
|
||||
if (value == 'default') {
|
||||
return null;
|
||||
|
@ -935,12 +998,11 @@ var ClientFormView = Backbone.View.extend({
|
|||
// whether or not the client secret changed
|
||||
var secretChanged = false;
|
||||
|
||||
if (tokenEndpointAuthMethod == 'SECRET_BASIC'
|
||||
|| tokenEndpointAuthMethod == 'SECRET_POST'
|
||||
|| tokenEndpointAuthMethod == 'SECRET_JWT') {
|
||||
if (tokenEndpointAuthMethod == 'SECRET_BASIC' || tokenEndpointAuthMethod == 'SECRET_POST' || tokenEndpointAuthMethod == 'SECRET_JWT') {
|
||||
|
||||
if (!generateClientSecret) {
|
||||
// if it's required but we're not generating it, send the value to preserve it
|
||||
// if it's required but we're not generating it, send the value
|
||||
// to preserve it
|
||||
clientSecret = $('#clientSecret input').val();
|
||||
|
||||
// if it's not the same as before, offer to display it
|
||||
|
@ -978,7 +1040,8 @@ var ClientFormView = Backbone.View.extend({
|
|||
}
|
||||
}
|
||||
|
||||
// make sure that the subject identifier is consistent with the redirect URIs
|
||||
// make sure that the subject identifier is consistent with the redirect
|
||||
// URIs
|
||||
var subjectType = $('#subjectType input').filter(':checked').val();
|
||||
var redirectUris = this.redirectUrisCollection.pluck("item");
|
||||
var sectorIdentifierUri = $('#sectorIdentifierUri input').val();
|
||||
|
@ -1011,8 +1074,6 @@ var ClientFormView = Backbone.View.extend({
|
|||
jwks = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var attrs = {
|
||||
clientName: this.emptyToNull($('#clientName input').val()),
|
||||
clientId: this.emptyToNull($('#clientId input').val()),
|
||||
|
@ -1115,9 +1176,13 @@ var ClientFormView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
app.clientList.add(_self.model);
|
||||
app.navigate('admin/clients', {trigger:true});
|
||||
app.navigate('admin/clients', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
error:app.errorHandlerView.handleError({log: "An error occurred when saving a client"})
|
||||
error: app.errorHandlerView.handleError({
|
||||
log: "An error occurred when saving a client"
|
||||
})
|
||||
});
|
||||
|
||||
return false;
|
||||
|
@ -1125,7 +1190,10 @@ var ClientFormView = Backbone.View.extend({
|
|||
|
||||
render: function(eventName) {
|
||||
|
||||
var data = {client: this.model.toJSON(), heartMode: heartMode};
|
||||
var data = {
|
||||
client: this.model.toJSON(),
|
||||
heartMode: heartMode
|
||||
};
|
||||
$(this.el).html(this.template(data));
|
||||
|
||||
var _self = this;
|
||||
|
@ -1135,92 +1203,112 @@ var ClientFormView = Backbone.View.extend({
|
|||
|
||||
// build and bind registered redirect URI collection and view
|
||||
_.each(this.model.get("redirectUris"), function(redirectUri) {
|
||||
_self.redirectUrisCollection.add(new URIModel({item:redirectUri}));
|
||||
_self.redirectUrisCollection.add(new URIModel({
|
||||
item: redirectUri
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
var redirUriView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.redirect-uris-help'),
|
||||
collection: this.redirectUrisCollection});
|
||||
collection: this.redirectUrisCollection
|
||||
});
|
||||
$("#redirectUris .controls", this.el).html(redirUriView.render().el);
|
||||
this.listWidgetViews.push(redirUriView);
|
||||
|
||||
// build and bind scopes
|
||||
_.each(this.model.get("scope"), function(scope) {
|
||||
_self.scopeCollection.add(new Backbone.Model({item:scope}));
|
||||
_self.scopeCollection.add(new Backbone.Model({
|
||||
item: scope
|
||||
}));
|
||||
});
|
||||
|
||||
var scopeView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.scope-placeholder'),
|
||||
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.pluck("value"))),
|
||||
helpBlockText: $.t('client.client-form.scope-help'),
|
||||
collection: this.scopeCollection});
|
||||
collection: this.scopeCollection
|
||||
});
|
||||
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||
this.listWidgetViews.push(scopeView);
|
||||
|
||||
// build and bind contacts
|
||||
_.each(this.model.get('contacts'), function(contact) {
|
||||
_self.contactsCollection.add(new Backbone.Model({item:contact}));
|
||||
_self.contactsCollection.add(new Backbone.Model({
|
||||
item: contact
|
||||
}));
|
||||
});
|
||||
|
||||
var contactsView = new ListWidgetView({
|
||||
placeholder: $.t("client.client-form.contacts-placeholder"),
|
||||
helpBlockText: $.t("client.client-form.contacts-help"),
|
||||
collection: this.contactsCollection});
|
||||
collection: this.contactsCollection
|
||||
});
|
||||
$("#contacts .controls", this.el).html(contactsView.render().el);
|
||||
this.listWidgetViews.push(contactsView);
|
||||
|
||||
// build and bind post-logout redirect URIs
|
||||
_.each(this.model.get('postLogoutRedirectUris'), function(postLogoutRedirectUri) {
|
||||
_self.postLogoutRedirectUrisCollection.add(new URIModel({item:postLogoutRedirectUri}));
|
||||
_self.postLogoutRedirectUrisCollection.add(new URIModel({
|
||||
item: postLogoutRedirectUri
|
||||
}));
|
||||
});
|
||||
|
||||
var postLogoutRedirectUrisView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.post-logout-help'),
|
||||
collection: this.postLogoutRedirectUrisCollection});
|
||||
collection: this.postLogoutRedirectUrisCollection
|
||||
});
|
||||
$('#postLogoutRedirectUris .controls', this.el).html(postLogoutRedirectUrisView.render().el);
|
||||
this.listWidgetViews.push(postLogoutRedirectUrisView);
|
||||
|
||||
// build and bind claims redirect URIs
|
||||
_.each(this.model.get('claimsRedirectUris'), function(claimsRedirectUri) {
|
||||
_self.claimsRedirectUrisCollection.add(new URIModel({item:claimsRedirectUri}));
|
||||
_self.claimsRedirectUrisCollection.add(new URIModel({
|
||||
item: claimsRedirectUri
|
||||
}));
|
||||
});
|
||||
|
||||
var claimsRedirectUrisView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.claims-redirect-uris-help'),
|
||||
collection: this.claimsRedirectUrisCollection});
|
||||
collection: this.claimsRedirectUrisCollection
|
||||
});
|
||||
$('#claimsRedirectUris .controls', this.el).html(claimsRedirectUrisView.render().el);
|
||||
this.listWidgetViews.push(claimsRedirectUrisView);
|
||||
|
||||
// build and bind request URIs
|
||||
_.each(this.model.get('requestUris'), function(requestUri) {
|
||||
_self.requestUrisCollection.add(new URIModel({item:requestUri}));
|
||||
_self.requestUrisCollection.add(new URIModel({
|
||||
item: requestUri
|
||||
}));
|
||||
});
|
||||
|
||||
var requestUriView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.request-uri-help'),
|
||||
collection: this.requestUrisCollection});
|
||||
collection: this.requestUrisCollection
|
||||
});
|
||||
$('#requestUris .controls', this.el).html(requestUriView.render().el);
|
||||
this.listWidgetViews.push(requestUriView);
|
||||
|
||||
// build and bind default ACR values
|
||||
_.each(this.model.get('defaultACRvalues'), function(defaultACRvalue) {
|
||||
_self.defaultACRvaluesCollection.add(new Backbone.Model({item:defaultACRvalue}));
|
||||
_self.defaultACRvaluesCollection.add(new Backbone.Model({
|
||||
item: defaultACRvalue
|
||||
}));
|
||||
});
|
||||
|
||||
var defaultAcrView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.acr-values-placeholder'),
|
||||
// TODO: autocomplete from spec
|
||||
helpBlockText: $.t('client.client-form.acr-values-help'),
|
||||
collection: this.defaultACRvaluesCollection});
|
||||
collection: this.defaultACRvaluesCollection
|
||||
});
|
||||
$('#defaultAcrValues .controls', this.el).html(defaultAcrView.render().el);
|
||||
this.listWidgetViews.push(defaultAcrView);
|
||||
|
||||
|
@ -1267,9 +1355,10 @@ var ClientFormView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
ui.routes.push({path: "admin/clients", name: "listClients", callback:
|
||||
function () {
|
||||
ui.routes.push({
|
||||
path: "admin/clients",
|
||||
name: "listClients",
|
||||
callback: function() {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -1277,14 +1366,21 @@ ui.routes.push({path: "admin/clients", name: "listClients", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('client.manage'), href:"manage/#admin/clients"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('client.manage'),
|
||||
href: "manage/#admin/clients"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/clients');
|
||||
|
||||
var view = new ClientListView({model:this.clientList, systemScopeList: this.systemScopeList, whiteListList: this.whiteListList});
|
||||
var view = new ClientListView({
|
||||
model: this.clientList,
|
||||
systemScopeList: this.systemScopeList,
|
||||
whiteListList: this.whiteListList
|
||||
});
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
|
@ -1295,8 +1391,10 @@ ui.routes.push({path: "admin/clients", name: "listClients", callback:
|
|||
|
||||
});
|
||||
|
||||
ui.routes.push({path: "admin/client/new", name: "newClient", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "admin/client/new",
|
||||
name: "newClient",
|
||||
callback: function() {
|
||||
console.log("newClient");
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -1304,17 +1402,25 @@ ui.routes.push({path: "admin/client/new", name: "newClient", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('client.manage'), href:"manage/#admin/clients"},
|
||||
{text:$.t('client.client-form.new'), href:""}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('client.manage'),
|
||||
href: "manage/#admin/clients"
|
||||
}, {
|
||||
text: $.t('client.client-form.new'),
|
||||
href: ""
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/clients');
|
||||
|
||||
var client = new ClientModel();
|
||||
|
||||
var view = new ClientFormView({model:client, systemScopeList: this.systemScopeList});
|
||||
var view = new ClientFormView({
|
||||
model: client,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
view.load(function() {
|
||||
var userInfo = getUserInfo();
|
||||
var contacts = [];
|
||||
|
@ -1340,9 +1446,12 @@ ui.routes.push({path: "admin/client/new", name: "newClient", callback:
|
|||
subjectType: "PUBLIC",
|
||||
jwksType: "URI",
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
// set up this new client to require a secret and have us autogenerate one
|
||||
// set up this new client to require a secret and have us
|
||||
// autogenerate one
|
||||
client.set({
|
||||
tokenEndpointAuthMethod: "SECRET_BASIC",
|
||||
generateClientSecret: true,
|
||||
|
@ -1358,18 +1467,21 @@ ui.routes.push({path: "admin/client/new", name: "newClient", callback:
|
|||
subjectType: "PUBLIC",
|
||||
jwksType: "URI",
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('client.client-form.new'));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "admin/client/:id", name: "editClient", callback:
|
||||
function(id) {
|
||||
ui.routes.push({
|
||||
path: "admin/client/:id",
|
||||
name: "editClient",
|
||||
callback: function(id) {
|
||||
console.log("editClient " + id);
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -1377,41 +1489,59 @@ ui.routes.push({path: "admin/client/:id", name: "editClient", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('client.manage'), href:"manage/#admin/clients"},
|
||||
{text:$.t('client.client-form.edit'), href:"manage/#admin/client/" + id}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('client.manage'),
|
||||
href: "manage/#admin/clients"
|
||||
}, {
|
||||
text: $.t('client.client-form.edit'),
|
||||
href: "manage/#admin/client/" + id
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/clients');
|
||||
|
||||
var client = this.clientList.get(id);
|
||||
if (!client) {
|
||||
client = new ClientModel({id:id});
|
||||
client = new ClientModel({
|
||||
id: id
|
||||
});
|
||||
}
|
||||
|
||||
var view = new ClientFormView({model:client, systemScopeList: app.systemScopeList});
|
||||
var view = new ClientFormView({
|
||||
model: client,
|
||||
systemScopeList: app.systemScopeList
|
||||
});
|
||||
view.load(function() {
|
||||
if ($.inArray("refresh_token", client.get("grantTypes")) != -1) {
|
||||
client.set({
|
||||
allowRefresh: true
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
if (client.get("jwks")) {
|
||||
client.set({
|
||||
jwksType: "VAL"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
client.set({
|
||||
jwksType: "URI"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
client.set({
|
||||
generateClientSecret: false,
|
||||
displayClientSecret: false
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('client.client-form.edit'));
|
||||
|
|
|
@ -108,8 +108,12 @@ var DynRegRootView = Backbone.View.extend({
|
|||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -124,7 +128,9 @@ var DynRegRootView = Backbone.View.extend({
|
|||
newReg: function(e) {
|
||||
e.preventDefault();
|
||||
this.remove();
|
||||
app.navigate('dev/dynreg/new', {trigger: true});
|
||||
app.navigate('dev/dynreg/new', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
editReg: function(e) {
|
||||
|
@ -149,28 +155,42 @@ var DynRegRootView = Backbone.View.extend({
|
|||
}
|
||||
client.set({
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
if (client.get("jwks")) {
|
||||
client.set({
|
||||
jwksType: "VAL"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
client.set({
|
||||
jwksType: "URI"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
var view = new DynRegEditView({model: client, systemScopeList: app.systemScopeList});
|
||||
var view = new DynRegEditView({
|
||||
model: client,
|
||||
systemScopeList: app.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('dynreg.edit-dynamically-registered'));
|
||||
app.navigate('dev/dynreg/edit', {trigger: true});
|
||||
app.navigate('dev/dynreg/edit', {
|
||||
trigger: true
|
||||
});
|
||||
self.remove();
|
||||
});
|
||||
}, error:app.errorHandlerView.handleError({message: $.t('dynreg.invalid-access-token')})
|
||||
},
|
||||
error: app.errorHandlerView.handleError({
|
||||
message: $.t('dynreg.invalid-access-token')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -206,8 +226,12 @@ var DynRegEditView = Backbone.View.extend({
|
|||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -224,7 +248,9 @@ var DynRegEditView = Backbone.View.extend({
|
|||
|
||||
cancel: function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('dev/dynreg', {trigger: true});
|
||||
app.navigate('dev/dynreg', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
deleteClient: function(e) {
|
||||
|
@ -234,12 +260,17 @@ var DynRegEditView = Backbone.View.extend({
|
|||
var self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
self.remove();
|
||||
app.navigate('dev/dynreg', {trigger: true});
|
||||
app.navigate('dev/dynreg', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
error:app.errorHandlerView.handleError({"log": "An error occurred when deleting a client"})
|
||||
error: app.errorHandlerView.handleError({
|
||||
"log": "An error occurred when deleting a client"
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -258,16 +289,18 @@ var DynRegEditView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set up the form based on the current state of the tokenEndpointAuthMethod parameter
|
||||
* Set up the form based on the current state of the tokenEndpointAuthMethod
|
||||
* parameter
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
toggleClientCredentials: function() {
|
||||
|
||||
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
||||
|
||||
// show or hide the signing algorithm method depending on what's selected
|
||||
if (tokenEndpointAuthMethod == 'private_key_jwt'
|
||||
|| tokenEndpointAuthMethod == 'client_secret_jwt') {
|
||||
// show or hide the signing algorithm method depending on what's
|
||||
// selected
|
||||
if (tokenEndpointAuthMethod == 'private_key_jwt' || tokenEndpointAuthMethod == 'client_secret_jwt') {
|
||||
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
||||
} else {
|
||||
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
||||
|
@ -308,7 +341,9 @@ var DynRegEditView = Backbone.View.extend({
|
|||
|
||||
},
|
||||
|
||||
// returns "null" if given the value "default" as a string, otherwise returns input value. useful for parsing the JOSE algorithm dropdowns
|
||||
// returns "null" if given the value "default" as a string,
|
||||
// otherwise returns input value. useful for parsing the JOSE
|
||||
// algorithm dropdowns
|
||||
defaultToNull: function(value) {
|
||||
if (value == 'default') {
|
||||
return null;
|
||||
|
@ -336,7 +371,8 @@ var DynRegEditView = Backbone.View.extend({
|
|||
'refresh_token': 'refresh_token'
|
||||
},
|
||||
|
||||
// maps from a form-friendly name to the real response type parameter name
|
||||
// maps from a form-friendly name to the real response type
|
||||
// parameter name
|
||||
responseMap: {
|
||||
'code': 'code',
|
||||
'token': 'token',
|
||||
|
@ -384,7 +420,8 @@ var DynRegEditView = Backbone.View.extend({
|
|||
}
|
||||
}
|
||||
|
||||
// make sure that the subject identifier is consistent with the redirect URIs
|
||||
// make sure that the subject identifier is consistent with the
|
||||
// redirect URIs
|
||||
var subjectType = $('#subjectType input').filter(':checked').val();
|
||||
var redirectUris = this.redirectUrisCollection.pluck("item");
|
||||
var sectorIdentifierUri = $('#sectorIdentifierUri input').val();
|
||||
|
@ -467,7 +504,9 @@ var DynRegEditView = Backbone.View.extend({
|
|||
this.model.save(attrs, {
|
||||
success: function() {
|
||||
// switch to an "edit" view
|
||||
app.navigate('dev/dynreg/edit', {trigger: true});
|
||||
app.navigate('dev/dynreg/edit', {
|
||||
trigger: true
|
||||
});
|
||||
_self.remove();
|
||||
|
||||
var userInfo = getUserInfo();
|
||||
|
@ -477,19 +516,28 @@ var DynRegEditView = Backbone.View.extend({
|
|||
}
|
||||
_self.model.set({
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
if (_self.model.get("jwks")) {
|
||||
_self.model.set({
|
||||
jwksType: "VAL"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
_self.model.set({
|
||||
jwksType: "URI"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
var view = new DynRegEditView({model: _self.model, systemScopeList: _self.options.systemScopeList});
|
||||
var view = new DynRegEditView({
|
||||
model: _self.model,
|
||||
systemScopeList: _self.options.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
// reload
|
||||
|
@ -497,14 +545,20 @@ var DynRegEditView = Backbone.View.extend({
|
|||
view.delegateEvents();
|
||||
});
|
||||
},
|
||||
error:app.errorHandlerView.handleError({log: "An error occurred when saving a client"})
|
||||
error: app.errorHandlerView.handleError({
|
||||
log: "An error occurred when saving a client"
|
||||
})
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var data = {client: this.model.toJSON(), userInfo: getUserInfo(), heartMode: heartMode};
|
||||
var data = {
|
||||
client: this.model.toJSON(),
|
||||
userInfo: getUserInfo(),
|
||||
heartMode: heartMode
|
||||
};
|
||||
$(this.el).html(this.template(data));
|
||||
|
||||
this.listWidgetViews = [];
|
||||
|
@ -513,14 +567,17 @@ var DynRegEditView = Backbone.View.extend({
|
|||
|
||||
// build and bind registered redirect URI collection and view
|
||||
_.each(this.model.get("redirect_uris"), function(redirectUri) {
|
||||
_self.redirectUrisCollection.add(new URIModel({item:redirectUri}));
|
||||
_self.redirectUrisCollection.add(new URIModel({
|
||||
item: redirectUri
|
||||
}));
|
||||
});
|
||||
|
||||
var redirectUriView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.redirect-uris-help'),
|
||||
collection: this.redirectUrisCollection});
|
||||
collection: this.redirectUrisCollection
|
||||
});
|
||||
$("#redirectUris .controls", this.el).html(redirectUriView.render().el);
|
||||
this.listWidgetViews.push(redirectUriView);
|
||||
|
||||
|
@ -528,78 +585,96 @@ var DynRegEditView = Backbone.View.extend({
|
|||
var scopes = this.model.get("scope");
|
||||
var scopeSet = scopes ? scopes.split(" ") : [];
|
||||
_.each(scopeSet, function(scope) {
|
||||
_self.scopeCollection.add(new Backbone.Model({item:scope}));
|
||||
_self.scopeCollection.add(new Backbone.Model({
|
||||
item: scope
|
||||
}));
|
||||
});
|
||||
|
||||
var scopeView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.scope-placeholder'),
|
||||
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.unrestrictedScopes().pluck("value"))),
|
||||
helpBlockText: $.t('client.client-form.scope-help'),
|
||||
collection: this.scopeCollection});
|
||||
collection: this.scopeCollection
|
||||
});
|
||||
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||
this.listWidgetViews.push(scopeView);
|
||||
|
||||
// build and bind contacts
|
||||
_.each(this.model.get('contacts'), function(contact) {
|
||||
_self.contactsCollection.add(new Backbone.Model({item:contact}));
|
||||
_self.contactsCollection.add(new Backbone.Model({
|
||||
item: contact
|
||||
}));
|
||||
});
|
||||
|
||||
var contactView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.contacts-placeholder'),
|
||||
helpBlockText: $.t('client.client-form.contacts-help'),
|
||||
collection: this.contactsCollection});
|
||||
collection: this.contactsCollection
|
||||
});
|
||||
$("#contacts .controls div", this.el).html(contactView.render().el);
|
||||
this.listWidgetViews.push(contactView);
|
||||
|
||||
// build and bind post-logout redirect URIs
|
||||
_.each(this.model.get('post_logout_redirect_uris'), function(postLogoutRedirectUri) {
|
||||
_self.postLogoutRedirectUrisCollection.add(new URIModel({item:postLogoutRedirectUri}));
|
||||
_self.postLogoutRedirectUrisCollection.add(new URIModel({
|
||||
item: postLogoutRedirectUri
|
||||
}));
|
||||
});
|
||||
|
||||
var postLogoutRedirectUrisView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.post-logout-help'),
|
||||
collection: this.postLogoutRedirectUrisCollection});
|
||||
collection: this.postLogoutRedirectUrisCollection
|
||||
});
|
||||
$('#postLogoutRedirectUris .controls', this.el).html(postLogoutRedirectUrisView.render().el);
|
||||
this.listWidgetViews.push(postLogoutRedirectUrisView);
|
||||
|
||||
// build and bind claims redirect URIs
|
||||
_.each(this.model.get('claimsRedirectUris'), function(claimsRedirectUri) {
|
||||
_self.claimsRedirectUrisCollection.add(new URIModel({item:claimsRedirectUri}));
|
||||
_self.claimsRedirectUrisCollection.add(new URIModel({
|
||||
item: claimsRedirectUri
|
||||
}));
|
||||
});
|
||||
|
||||
var claimsRedirectUrisView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.claims-redirect-uris-help'),
|
||||
collection: this.claimsRedirectUrisCollection});
|
||||
collection: this.claimsRedirectUrisCollection
|
||||
});
|
||||
$('#claimsRedirectUris .controls', this.el).html(claimsRedirectUrisView.render().el);
|
||||
this.listWidgetViews.push(claimsRedirectUrisView);
|
||||
|
||||
// build and bind request URIs
|
||||
_.each(this.model.get('request_uris'), function(requestUri) {
|
||||
_self.requestUrisCollection.add(new URIModel({item:requestUri}));
|
||||
_self.requestUrisCollection.add(new URIModel({
|
||||
item: requestUri
|
||||
}));
|
||||
});
|
||||
|
||||
var requestUriView = new ListWidgetView({
|
||||
type: 'uri',
|
||||
placeholder: 'https://',
|
||||
helpBlockText: $.t('client.client-form.request-uri-help'),
|
||||
collection: this.requestUrisCollection});
|
||||
collection: this.requestUrisCollection
|
||||
});
|
||||
$('#requestUris .controls', this.el).html(requestUriView.render().el);
|
||||
this.listWidgetViews.push(requestUriView);
|
||||
|
||||
// build and bind default ACR values
|
||||
_.each(this.model.get('default_acr_values'), function(defaultAcrValue) {
|
||||
_self.defaultAcrValuesCollection.add(new Backbone.Model({item:defaultAcrValue}));
|
||||
_self.defaultAcrValuesCollection.add(new Backbone.Model({
|
||||
item: defaultAcrValue
|
||||
}));
|
||||
});
|
||||
|
||||
var defaultAcrView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.acr-values-placeholder'),
|
||||
// TODO: autocomplete from spec
|
||||
helpBlockText: $.t('client.client-form.acr-values-help'),
|
||||
collection: this.defaultAcrValuesCollection});
|
||||
collection: this.defaultAcrValuesCollection
|
||||
});
|
||||
$('#defaultAcrValues .controls', this.el).html(defaultAcrView.render().el);
|
||||
this.listWidgetViews.push(defaultAcrView);
|
||||
|
||||
|
@ -623,23 +698,29 @@ var DynRegEditView = Backbone.View.extend({
|
|||
content: $.t('common.not-yet-implemented-content')
|
||||
});
|
||||
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ui.routes.push({path: "dev/dynreg", name: "dynReg", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "dev/dynreg",
|
||||
name: "dynReg",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.self-service-client'), href:"manage/#dev/dynreg"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.self-service-client'),
|
||||
href: "manage/#dev/dynreg"
|
||||
}]);
|
||||
|
||||
var view = new DynRegRootView({systemScopeList: this.systemScopeList});
|
||||
var view = new DynRegRootView({
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
this.updateSidebar('dev/dynreg');
|
||||
|
||||
|
@ -652,20 +733,30 @@ ui.routes.push({path: "dev/dynreg", name: "dynReg", callback:
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "dev/dynreg/new", name: "newDynReg", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "dev/dynreg/new",
|
||||
name: "newDynReg",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.self-service-client'), href:"manage/#dev/dynreg"},
|
||||
{text:$.t('dynreg.new-client'), href:"manage/#dev/dynreg/new"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.self-service-client'),
|
||||
href: "manage/#dev/dynreg"
|
||||
}, {
|
||||
text: $.t('dynreg.new-client'),
|
||||
href: "manage/#dev/dynreg/new"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('dev/dynreg');
|
||||
|
||||
var client = new DynRegClient();
|
||||
var view = new DynRegEditView({model: client, systemScopeList:this.systemScopeList});
|
||||
var view = new DynRegEditView({
|
||||
model: client,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
|
||||
|
@ -685,7 +776,9 @@ ui.routes.push({path: "dev/dynreg/new", name: "newDynReg", callback:
|
|||
response_types: ["code"],
|
||||
subject_type: "public",
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
client.set({
|
||||
require_auth_time: true,
|
||||
|
@ -696,7 +789,9 @@ ui.routes.push({path: "dev/dynreg/new", name: "newDynReg", callback:
|
|||
response_types: ["code"],
|
||||
subject_type: "public",
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
$('#content').html(view.render().el);
|
||||
|
@ -708,20 +803,28 @@ ui.routes.push({path: "dev/dynreg/new", name: "newDynReg", callback:
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "dev/dynreg/edit", name: "editDynReg", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "dev/dynreg/edit",
|
||||
name: "editDynReg",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.self-service-client'), href:"manage/#dev/dynreg"},
|
||||
{text:$.t('dynreg.edit-existing'), href:"manage/#dev/dynreg/edit"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.self-service-client'),
|
||||
href: "manage/#dev/dynreg"
|
||||
}, {
|
||||
text: $.t('dynreg.edit-existing'),
|
||||
href: "manage/#dev/dynreg/edit"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('dev/dynreg');
|
||||
|
||||
setPageTitle($.t('dynreg.edit-existing'));
|
||||
// note that this doesn't actually load the client, that's supposed to happen elsewhere...
|
||||
// note that this doesn't actually load the client, that's supposed to
|
||||
// happen elsewhere...
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -17,20 +17,21 @@
|
|||
var ApprovedSiteModel = Backbone.Model.extend({
|
||||
idAttribute: 'id',
|
||||
|
||||
initialize: function() { },
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
urlRoot: 'api/approved'
|
||||
|
||||
});
|
||||
|
||||
var ApprovedSiteCollection = Backbone.Collection.extend({
|
||||
initialize: function() { },
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
model: ApprovedSiteModel,
|
||||
url: 'api/approved'
|
||||
});
|
||||
|
||||
|
||||
var ApprovedSiteListView = Backbone.View.extend({
|
||||
tagName: 'span',
|
||||
|
||||
|
@ -39,24 +40,30 @@ var ApprovedSiteListView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
load: function(callback) {
|
||||
if (this.model.isFetched &&
|
||||
this.options.clientList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
if (this.model.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-grants">' + $.t('grant.grant-table.approved-sites') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-grants">' + $.t('grant.grant-table.approved-sites') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-grants').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-grants').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -79,7 +86,11 @@ var ApprovedSiteListView = Backbone.View.extend({
|
|||
|
||||
if (client != null) {
|
||||
|
||||
var view = new ApprovedSiteView({model: approvedSite, client: client, systemScopeList: this.options.systemScopeList});
|
||||
var view = new ApprovedSiteView({
|
||||
model: approvedSite,
|
||||
client: client,
|
||||
systemScopeList: this.options.systemScopeList
|
||||
});
|
||||
view.parentView = _self;
|
||||
$('#grant-table', this.el).append(view.render().el);
|
||||
approvedSiteCount = approvedSiteCount + 1;
|
||||
|
@ -109,16 +120,24 @@ var ApprovedSiteListView = Backbone.View.extend({
|
|||
e.preventDefault();
|
||||
var _self = this;
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-grants">' + $.t('grant.grant-table.approved-sites') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-grants">' + $.t('grant.grant-table.approved-sites') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetch({success:function(e) {$('#loading-grants').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-grants').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
_self.render();
|
||||
});
|
||||
|
@ -188,21 +207,38 @@ var ApprovedSiteView = Backbone.View.extend({
|
|||
hoverTimeoutDate = timeoutDate.format("LLL");
|
||||
}
|
||||
|
||||
var formattedDate = {
|
||||
displayCreationDate: displayCreationDate,
|
||||
hoverCreationDate: hoverCreationDate,
|
||||
displayAccessDate: displayAccessDate,
|
||||
hoverAccessDate: hoverAccessDate,
|
||||
displayTimeoutDate: displayTimeoutDate,
|
||||
hoverTimeoutDate: hoverTimeoutDate
|
||||
};
|
||||
|
||||
var formattedDate = {displayCreationDate: displayCreationDate, hoverCreationDate: hoverCreationDate,
|
||||
displayAccessDate: displayAccessDate, hoverAccessDate: hoverAccessDate,
|
||||
displayTimeoutDate: displayTimeoutDate, hoverTimeoutDate: hoverTimeoutDate};
|
||||
|
||||
var json = {grant: this.model.toJSON(), client: this.options.client.toJSON(), formattedDate: formattedDate};
|
||||
var json = {
|
||||
grant: this.model.toJSON(),
|
||||
client: this.options.client.toJSON(),
|
||||
formattedDate: formattedDate
|
||||
};
|
||||
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('allowedScopes'), systemScopes: this.options.systemScopeList}));
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({
|
||||
scopes: this.model.get('allowedScopes'),
|
||||
systemScopes: this.options.systemScopeList
|
||||
}));
|
||||
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({client: this.options.client.toJSON()}));
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({
|
||||
client: this.options.client.toJSON()
|
||||
}));
|
||||
|
||||
this.$('.dynamically-registered').tooltip({title: $.t('grant.grant-table.dynamically-registered')});
|
||||
this.$('.tokens').tooltip({title: $.t('grant.grant-table.active-tokens')});
|
||||
this.$('.dynamically-registered').tooltip({
|
||||
title: $.t('grant.grant-table.dynamically-registered')
|
||||
});
|
||||
this.$('.tokens').tooltip({
|
||||
title: $.t('grant.grant-table.active-tokens')
|
||||
});
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
},
|
||||
|
@ -218,7 +254,8 @@ var ApprovedSiteView = Backbone.View.extend({
|
|||
var self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
$(this).slideUp("fast", function() { // slide up
|
||||
|
@ -258,24 +295,32 @@ var ApprovedSiteView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "user/approved", name: "approvedSites", callback:
|
||||
ui.routes.push({
|
||||
path: "user/approved",
|
||||
name: "approvedSites",
|
||||
callback:
|
||||
|
||||
function() {
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('grant.manage-approved-sites'), href:"manage/#user/approve"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('grant.manage-approved-sites'),
|
||||
href: "manage/#user/approve"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('user/approved');
|
||||
|
||||
var view = new ApprovedSiteListView({model:this.approvedSiteList, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
||||
view.load(
|
||||
function(collection, response, options) {
|
||||
var view = new ApprovedSiteListView({
|
||||
model: this.approvedSiteList,
|
||||
clientList: this.clientList,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
view.load(function(collection, response, options) {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('grant.manage-approved-sites'));
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -14,18 +14,25 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*******************************************************************************/
|
||||
ui.routes.push({path: "user/profile", name: "profile", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "user/profile",
|
||||
name: "profile",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.user-profile.show'), href:"manage/#user/profile"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.user-profile.show'),
|
||||
href: "manage/#user/profile"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('user/profile');
|
||||
|
||||
var view = new UserProfileView({model: getUserInfo()});
|
||||
var view = new UserProfileView({
|
||||
model: getUserInfo()
|
||||
});
|
||||
$('#content').html(view.render().el);
|
||||
|
||||
setPageTitle($.t('admin.user-profile.show'));
|
||||
|
|
|
@ -75,8 +75,12 @@ var ResRegRootView = Backbone.View.extend({
|
|||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -91,7 +95,9 @@ var ResRegRootView = Backbone.View.extend({
|
|||
newReg: function(e) {
|
||||
e.preventDefault();
|
||||
this.remove();
|
||||
app.navigate('dev/resource/new', {trigger: true});
|
||||
app.navigate('dev/resource/new', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
editReg: function(e) {
|
||||
|
@ -112,24 +118,35 @@ var ResRegRootView = Backbone.View.extend({
|
|||
if (client.get("jwks")) {
|
||||
client.set({
|
||||
jwksType: "VAL"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
client.set({
|
||||
jwksType: "URI"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
var view = new ResRegEditView({model: client, systemScopeList: app.systemScopeList});
|
||||
var view = new ResRegEditView({
|
||||
model: client,
|
||||
systemScopeList: app.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('rsreg.new'));
|
||||
app.navigate('dev/resource/edit', {trigger: true});
|
||||
app.navigate('dev/resource/edit', {
|
||||
trigger: true
|
||||
});
|
||||
self.remove();
|
||||
});
|
||||
},
|
||||
error:app.errorHandlerView.handleError({message: $.t('dynreg.invalid-access-token')})
|
||||
error: app.errorHandlerView.handleError({
|
||||
message: $.t('dynreg.invalid-access-token')
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -163,8 +180,12 @@ var ResRegEditView = Backbone.View.extend({
|
|||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -181,7 +202,9 @@ var ResRegEditView = Backbone.View.extend({
|
|||
|
||||
cancel: function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('dev/resource', {trigger: true});
|
||||
app.navigate('dev/resource', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
deleteClient: function(e) {
|
||||
|
@ -191,10 +214,13 @@ var ResRegEditView = Backbone.View.extend({
|
|||
var self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
self.remove();
|
||||
app.navigate('dev/resource', {trigger: true});
|
||||
app.navigate('dev/resource', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
});
|
||||
|
@ -215,16 +241,18 @@ var ResRegEditView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
/**
|
||||
* Set up the form based on the current state of the tokenEndpointAuthMethod parameter
|
||||
* Set up the form based on the current state of the tokenEndpointAuthMethod
|
||||
* parameter
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
toggleClientCredentials: function() {
|
||||
|
||||
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
||||
|
||||
// show or hide the signing algorithm method depending on what's selected
|
||||
if (tokenEndpointAuthMethod == 'private_key_jwt'
|
||||
|| tokenEndpointAuthMethod == 'client_secret_jwt') {
|
||||
// show or hide the signing algorithm method depending on what's
|
||||
// selected
|
||||
if (tokenEndpointAuthMethod == 'private_key_jwt' || tokenEndpointAuthMethod == 'client_secret_jwt') {
|
||||
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
||||
} else {
|
||||
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
||||
|
@ -265,7 +293,9 @@ var ResRegEditView = Backbone.View.extend({
|
|||
|
||||
},
|
||||
|
||||
// returns "null" if given the value "default" as a string, otherwise returns input value. useful for parsing the JOSE algorithm dropdowns
|
||||
// returns "null" if given the value "default" as a string,
|
||||
// otherwise returns input value. useful for parsing the JOSE
|
||||
// algorithm dropdowns
|
||||
defaultToNull: function(value) {
|
||||
if (value == 'default') {
|
||||
return null;
|
||||
|
@ -346,20 +376,29 @@ var ResRegEditView = Backbone.View.extend({
|
|||
this.model.save(attrs, {
|
||||
success: function() {
|
||||
// switch to an "edit" view
|
||||
app.navigate('dev/resource/edit', {trigger: true});
|
||||
app.navigate('dev/resource/edit', {
|
||||
trigger: true
|
||||
});
|
||||
_self.remove();
|
||||
|
||||
if (_self.model.get("jwks")) {
|
||||
_self.model.set({
|
||||
jwksType: "VAL"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
} else {
|
||||
_self.model.set({
|
||||
jwksType: "URI"
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
|
||||
var view = new ResRegEditView({model: _self.model, systemScopeList: _self.options.systemScopeList});
|
||||
var view = new ResRegEditView({
|
||||
model: _self.model,
|
||||
systemScopeList: _self.options.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
// reload
|
||||
|
@ -374,7 +413,10 @@ var ResRegEditView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
render: function() {
|
||||
$(this.el).html(this.template({client: this.model.toJSON(), userInfo: getUserInfo()}));
|
||||
$(this.el).html(this.template({
|
||||
client: this.model.toJSON(),
|
||||
userInfo: getUserInfo()
|
||||
}));
|
||||
|
||||
this.listWidgetViews = [];
|
||||
|
||||
|
@ -384,30 +426,35 @@ var ResRegEditView = Backbone.View.extend({
|
|||
var scopes = this.model.get("scope");
|
||||
var scopeSet = scopes ? scopes.split(" ") : [];
|
||||
_.each(scopeSet, function(scope) {
|
||||
_self.scopeCollection.add(new Backbone.Model({item:scope}));
|
||||
_self.scopeCollection.add(new Backbone.Model({
|
||||
item: scope
|
||||
}));
|
||||
});
|
||||
|
||||
var scopeView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.scope-placeholder'),
|
||||
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.unrestrictedScopes().pluck("value"))),
|
||||
helpBlockText: $.t('rsreg.client-form.scope-help'),
|
||||
collection: this.scopeCollection});
|
||||
collection: this.scopeCollection
|
||||
});
|
||||
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||
this.listWidgetViews.push(scopeView);
|
||||
|
||||
// build and bind contacts
|
||||
_.each(this.model.get('contacts'), function(contact) {
|
||||
_self.contactsCollection.add(new Backbone.Model({item:contact}));
|
||||
_self.contactsCollection.add(new Backbone.Model({
|
||||
item: contact
|
||||
}));
|
||||
});
|
||||
|
||||
var contactView = new ListWidgetView({
|
||||
placeholder: $.t('client.client-form.contacts-placeholder'),
|
||||
helpBlockText: $.t('client.client-form.contacts-help'),
|
||||
collection: this.contactsCollection});
|
||||
collection: this.contactsCollection
|
||||
});
|
||||
$("#contacts .controls", this.el).html(contactView.render().el);
|
||||
this.listWidgetViews.push(contactView);
|
||||
|
||||
|
||||
this.toggleClientCredentials();
|
||||
this.previewLogo();
|
||||
this.toggleJWKSetType();
|
||||
|
@ -421,25 +468,31 @@ var ResRegEditView = Backbone.View.extend({
|
|||
content: $.t('common.not-yet-implemented-content')
|
||||
});
|
||||
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ui.routes.push({path: "dev/resource", name: "resReg", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "dev/resource",
|
||||
name: "resReg",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.self-service-resource'), href:"manage/#dev/resource"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.self-service-resource'),
|
||||
href: "manage/#dev/resource"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('dev/resource');
|
||||
|
||||
var view = new ResRegRootView({systemScopeList: this.systemScopeList});
|
||||
var view = new ResRegRootView({
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
|
||||
|
@ -449,20 +502,30 @@ ui.routes.push({path: "dev/resource", name: "resReg", callback:
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "dev/resource/new", name: "newResReg", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "dev/resource/new",
|
||||
name: "newResReg",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.self-service-resource'), href:"manage/#dev/resource"},
|
||||
{text:$.t('rsreg.new'), href:"manage/#dev/resource/new"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.self-service-resource'),
|
||||
href: "manage/#dev/resource"
|
||||
}, {
|
||||
text: $.t('rsreg.new'),
|
||||
href: "manage/#dev/resource/new"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('dev/resource');
|
||||
|
||||
var client = new ResRegClient();
|
||||
var view = new ResRegEditView({model: client, systemScopeList:this.systemScopeList});
|
||||
var view = new ResRegEditView({
|
||||
model: client,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
|
||||
|
@ -476,7 +539,9 @@ ui.routes.push({path: "dev/resource/new", name: "newResReg", callback:
|
|||
scope: _.uniq(_.flatten(app.systemScopeList.defaultUnrestrictedScopes().pluck("value"))).join(" "),
|
||||
token_endpoint_auth_method: 'client_secret_basic',
|
||||
contacts: contacts
|
||||
}, { silent: true });
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
|
@ -487,20 +552,28 @@ ui.routes.push({path: "dev/resource/new", name: "newResReg", callback:
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "dev/resource/edit", name: "editResReg", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "dev/resource/edit",
|
||||
name: "editResReg",
|
||||
callback: function() {
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('admin.self-service-resource'), href:"manage/#dev/resource"},
|
||||
{text:$.t('rsreg.edit'), href:"manage/#dev/resource/edit"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('admin.self-service-resource'),
|
||||
href: "manage/#dev/resource"
|
||||
}, {
|
||||
text: $.t('rsreg.edit'),
|
||||
href: "manage/#dev/resource/edit"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('dev/resource');
|
||||
|
||||
setPageTitle($.t('rsreg.edit'));
|
||||
// note that this doesn't actually load the client, that's supposed to happen elsewhere...
|
||||
// note that this doesn't actually load the client, that's supposed to
|
||||
// happen elsewhere...
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -58,7 +58,9 @@ var SystemScopeCollection = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
getByValue: function(value) {
|
||||
var scopes = this.where({value: value});
|
||||
var scopes = this.where({
|
||||
value: value
|
||||
});
|
||||
if (scopes.length == 1) {
|
||||
return scopes[0];
|
||||
} else {
|
||||
|
@ -90,14 +92,20 @@ var SystemScopeView = Backbone.View.extend({
|
|||
|
||||
editScope: function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('admin/scope/' + this.model.id, {trigger: true});
|
||||
app.navigate('admin/scope/' + this.model.id, {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
render: function(eventName) {
|
||||
this.$el.html(this.template(this.model.toJSON()));
|
||||
|
||||
$('.restricted', this.el).tooltip({title: $.t('scope.system-scope-table.tooltip-restricted')});
|
||||
$('.default', this.el).tooltip({title: $.t('scope.system-scope-table.tooltip-default')});
|
||||
$('.restricted', this.el).tooltip({
|
||||
title: $.t('scope.system-scope-table.tooltip-restricted')
|
||||
});
|
||||
$('.default', this.el).tooltip({
|
||||
title: $.t('scope.system-scope-table.tooltip-default')
|
||||
});
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
|
@ -110,7 +118,8 @@ var SystemScopeView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
|
||||
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
|
@ -149,12 +158,14 @@ var SystemScopeListView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -167,18 +178,22 @@ var SystemScopeListView = Backbone.View.extend({
|
|||
|
||||
newScope: function(e) {
|
||||
this.remove();
|
||||
app.navigate('admin/scope/new', {trigger: true});
|
||||
app.navigate('admin/scope/new', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
refreshTable: function(e) {
|
||||
var _self = this;
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
_self.render();
|
||||
});
|
||||
|
@ -202,7 +217,9 @@ var SystemScopeListView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
_.each(this.model.models, function(scope) {
|
||||
var view = new SystemScopeView({model: scope});
|
||||
var view = new SystemScopeView({
|
||||
model: scope
|
||||
});
|
||||
view.parentView = _self;
|
||||
$("#scope-table", _self.el).append(view.render().el);
|
||||
}, this);
|
||||
|
@ -213,7 +230,8 @@ var SystemScopeListView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
var SystemScopeFormView = Backbone.View.extend({
|
||||
var SystemScopeFormView = Backbone.View
|
||||
.extend({
|
||||
tagName: 'span',
|
||||
|
||||
initialize: function(options) {
|
||||
|
@ -229,28 +247,11 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
if (!this.bootstrapIcons) {
|
||||
this.bootstrapIcons = [];
|
||||
|
||||
var iconList = ['glass', 'music', 'search', 'envelope', 'heart', 'star', 'star-empty',
|
||||
'user', 'film', 'th-large', 'th', 'th-list', 'ok', 'remove', 'zoom-in',
|
||||
'zoom-out', 'off', 'signal', 'cog', 'trash', 'home', 'file', 'time', 'road',
|
||||
'download-alt', 'download', 'upload', 'inbox', 'play-circle', 'repeat',
|
||||
'refresh', 'list-alt', 'lock', 'flag', 'headphones', 'volume-off',
|
||||
'volume-down', 'volume-up', 'qrcode', 'barcode', 'tag', 'tags', 'book',
|
||||
'bookmark', 'print', 'camera', 'font', 'bold', 'italic', 'text-height',
|
||||
'text-width', 'align-left', 'align-center', 'align-right', 'align-justify',
|
||||
'list', 'indent-left', 'indent-right', 'facetime-video', 'picture', 'pencil',
|
||||
'map-marker', 'adjust', 'tint', 'edit', 'share', 'check', 'move', 'step-backward',
|
||||
'fast-backward', 'backward', 'play', 'pause', 'stop', 'forward', 'fast-forward',
|
||||
'step-forward', 'eject', 'chevron-left', 'chevron-right', 'plus-sign',
|
||||
'minus-sign', 'remove-sign', 'ok-sign', 'question-sign', 'info-sign',
|
||||
'screenshot', 'remove-circle', 'ok-circle', 'ban-circle', 'arrow-left',
|
||||
'arrow-right', 'arrow-up', 'arrow-down', 'share-alt', 'resize-full', 'resize-small',
|
||||
'plus', 'minus', 'asterisk', 'exclamation-sign', 'gift', 'leaf', 'fire',
|
||||
'eye-open', 'eye-close', 'warning-sign', 'plane', 'calendar', 'random',
|
||||
'comment', 'magnet', 'chevron-up', 'chevron-down', 'retweet', 'shopping-cart',
|
||||
'folder-close', 'folder-open', 'resize-vertical', 'resize-horizontal',
|
||||
'hdd', 'bullhorn', 'bell', 'certificate', 'thumbs-up', 'thumbs-down',
|
||||
'hand-right', 'hand-left', 'hand-up', 'hand-down', 'circle-arrow-right',
|
||||
'circle-arrow-left', 'circle-arrow-up', 'circle-arrow-down', 'globe',
|
||||
var iconList = ['glass', 'music', 'search', 'envelope', 'heart', 'star', 'star-empty', 'user', 'film', 'th-large', 'th', 'th-list', 'ok', 'remove', 'zoom-in', 'zoom-out', 'off', 'signal', 'cog', 'trash', 'home', 'file', 'time', 'road', 'download-alt', 'download', 'upload', 'inbox', 'play-circle', 'repeat', 'refresh', 'list-alt', 'lock',
|
||||
'flag', 'headphones', 'volume-off', 'volume-down', 'volume-up', 'qrcode', 'barcode', 'tag', 'tags', 'book', 'bookmark', 'print', 'camera', 'font', 'bold', 'italic', 'text-height', 'text-width', 'align-left', 'align-center', 'align-right', 'align-justify', 'list', 'indent-left', 'indent-right', 'facetime-video', 'picture',
|
||||
'pencil', 'map-marker', 'adjust', 'tint', 'edit', 'share', 'check', 'move', 'step-backward', 'fast-backward', 'backward', 'play', 'pause', 'stop', 'forward', 'fast-forward', 'step-forward', 'eject', 'chevron-left', 'chevron-right', 'plus-sign', 'minus-sign', 'remove-sign', 'ok-sign', 'question-sign', 'info-sign', 'screenshot',
|
||||
'remove-circle', 'ok-circle', 'ban-circle', 'arrow-left', 'arrow-right', 'arrow-up', 'arrow-down', 'share-alt', 'resize-full', 'resize-small', 'plus', 'minus', 'asterisk', 'exclamation-sign', 'gift', 'leaf', 'fire', 'eye-open', 'eye-close', 'warning-sign', 'plane', 'calendar', 'random', 'comment', 'magnet', 'chevron-up',
|
||||
'chevron-down', 'retweet', 'shopping-cart', 'folder-close', 'folder-open', 'resize-vertical', 'resize-horizontal', 'hdd', 'bullhorn', 'bell', 'certificate', 'thumbs-up', 'thumbs-down', 'hand-right', 'hand-left', 'hand-up', 'hand-down', 'circle-arrow-right', 'circle-arrow-left', 'circle-arrow-up', 'circle-arrow-down', 'globe',
|
||||
'wrench', 'tasks', 'filter', 'briefcase', 'fullscreen'];
|
||||
|
||||
var size = 3;
|
||||
|
@ -263,7 +264,11 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
|
||||
events: {
|
||||
'click .btn-save': 'saveScope',
|
||||
'click .btn-cancel': function() {app.navigate('admin/scope', {trigger: true}); },
|
||||
'click .btn-cancel': function() {
|
||||
app.navigate('admin/scope', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
'click .btn-icon': 'selectIcon'
|
||||
},
|
||||
|
||||
|
@ -274,12 +279,14 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> ');
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -310,7 +317,9 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
this.model.save({}, {
|
||||
success: function() {
|
||||
app.systemScopeList.add(_self.model);
|
||||
app.navigate('admin/scope', {trigger: true});
|
||||
app.navigate('admin/scope', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
});
|
||||
|
@ -339,7 +348,9 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
this.$el.html(this.template(this.model.toJSON()));
|
||||
|
||||
_.each(this.bootstrapIcons, function(items) {
|
||||
$("#iconSelector .modal-body", this.el).append(this.iconTemplate({items:items}));
|
||||
$("#iconSelector .modal-body", this.el).append(this.iconTemplate({
|
||||
items: items
|
||||
}));
|
||||
}, this);
|
||||
|
||||
$(this.el).i18n();
|
||||
|
@ -347,8 +358,10 @@ var SystemScopeFormView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "admin/scope", name: "siteScope", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "admin/scope",
|
||||
name: "siteScope",
|
||||
callback: function() {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -356,14 +369,19 @@ ui.routes.push({path: "admin/scope", name: "siteScope", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('scope.manage'), href:"manage/#admin/scope"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('scope.manage'),
|
||||
href: "manage/#admin/scope"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/scope');
|
||||
|
||||
var view = new SystemScopeListView({model:this.systemScopeList});
|
||||
var view = new SystemScopeListView({
|
||||
model: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
|
@ -374,9 +392,10 @@ ui.routes.push({path: "admin/scope", name: "siteScope", callback:
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "admin/scope/new", name:"newScope", callback:
|
||||
function() {
|
||||
|
||||
ui.routes.push({
|
||||
path: "admin/scope/new",
|
||||
name: "newScope",
|
||||
callback: function() {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -384,17 +403,24 @@ ui.routes.push({path: "admin/scope/new", name:"newScope", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('scope.manage'), href:"manage/#admin/scope"},
|
||||
{text:$.t('scope.system-scope-form.new'), href:"manage/#admin/scope/new"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('scope.manage'),
|
||||
href: "manage/#admin/scope"
|
||||
}, {
|
||||
text: $.t('scope.system-scope-form.new'),
|
||||
href: "manage/#admin/scope/new"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/scope');
|
||||
|
||||
var scope = new SystemScopeModel();
|
||||
|
||||
var view = new SystemScopeFormView({model:scope});
|
||||
var view = new SystemScopeFormView({
|
||||
model: scope
|
||||
});
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('scope.system-scope-form.new'));
|
||||
|
@ -403,8 +429,10 @@ ui.routes.push({path: "admin/scope/new", name:"newScope", callback:
|
|||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "admin/scope/:id", name: "editScope", callback:
|
||||
function(sid) {
|
||||
ui.routes.push({
|
||||
path: "admin/scope/:id",
|
||||
name: "editScope",
|
||||
callback: function(sid) {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -412,20 +440,29 @@ ui.routes.push({path: "admin/scope/:id", name: "editScope", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('scope.manage'), href:"manage/#admin/scope"},
|
||||
{text:$.t('scope.system-scope-form.edit'), href:"manage/#admin/scope/" + sid}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('scope.manage'),
|
||||
href: "manage/#admin/scope"
|
||||
}, {
|
||||
text: $.t('scope.system-scope-form.edit'),
|
||||
href: "manage/#admin/scope/" + sid
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/scope');
|
||||
|
||||
var scope = this.systemScopeList.get(sid);
|
||||
if (!scope) {
|
||||
scope = new SystemScopeModel({id: sid});
|
||||
scope = new SystemScopeModel({
|
||||
id: sid
|
||||
});
|
||||
}
|
||||
|
||||
var view = new SystemScopeFormView({model:scope});
|
||||
var view = new SystemScopeFormView({
|
||||
model: scope
|
||||
});
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('scope.system-scope-form.new'));
|
||||
|
|
|
@ -81,7 +81,11 @@ var AccessTokenView = Backbone.View.extend({
|
|||
expirationDate = moment(expirationDate).calendar();
|
||||
}
|
||||
|
||||
var json = {token: this.model.toJSON(), client: this.options.client.toJSON(), formattedExpiration: expirationDate};
|
||||
var json = {
|
||||
token: this.model.toJSON(),
|
||||
client: this.options.client.toJSON(),
|
||||
formattedExpiration: expirationDate
|
||||
};
|
||||
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
|
@ -89,9 +93,14 @@ var AccessTokenView = Backbone.View.extend({
|
|||
$('.token-full', this.el).hide();
|
||||
|
||||
// show scopes
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('scopes'), systemScopes: this.options.systemScopeList}));
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({
|
||||
scopes: this.model.get('scopes'),
|
||||
systemScopes: this.options.systemScopeList
|
||||
}));
|
||||
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({client: this.options.client.toJSON()}));
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({
|
||||
client: this.options.client.toJSON()
|
||||
}));
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
|
@ -105,13 +114,15 @@ var AccessTokenView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
|
||||
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
$(this).slideUp("fast", function() { // slide up
|
||||
$(this).remove(); // then remove from the DOM
|
||||
// refresh the table in case we removed an id token, too
|
||||
// refresh the table in case we removed an id token,
|
||||
// too
|
||||
_self.parentView.refreshTable();
|
||||
});
|
||||
});
|
||||
|
@ -218,7 +229,12 @@ var RefreshTokenView = Backbone.View.extend({
|
|||
expirationDate = moment(expirationDate).calendar();
|
||||
}
|
||||
|
||||
var json = {token: this.model.toJSON(), client: this.options.client.toJSON(), formattedExpiration: expirationDate, accessTokenCount: this.options.accessTokenCount};
|
||||
var json = {
|
||||
token: this.model.toJSON(),
|
||||
client: this.options.client.toJSON(),
|
||||
formattedExpiration: expirationDate,
|
||||
accessTokenCount: this.options.accessTokenCount
|
||||
};
|
||||
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
|
@ -226,9 +242,14 @@ var RefreshTokenView = Backbone.View.extend({
|
|||
$('.token-full', this.el).hide();
|
||||
|
||||
// show scopes
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('scopes'), systemScopes: this.options.systemScopeList}));
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({
|
||||
scopes: this.model.get('scopes'),
|
||||
systemScopes: this.options.systemScopeList
|
||||
}));
|
||||
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({client: this.options.client.toJSON()}));
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({
|
||||
client: this.options.client.toJSON()
|
||||
}));
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
|
@ -243,13 +264,15 @@ var RefreshTokenView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
|
||||
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
$(this).slideUp("fast", function() { // slide up
|
||||
$(this).remove(); // then remove from the DOM
|
||||
// refresh the table in case the access tokens have changed, too
|
||||
// refresh the table in case the access tokens have
|
||||
// changed, too
|
||||
_self.parentView.refreshTable();
|
||||
});
|
||||
});
|
||||
|
@ -305,27 +328,37 @@ var TokenListView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
load: function(callback) {
|
||||
if (this.model.access.isFetched &&
|
||||
this.model.refresh.isFetched &&
|
||||
this.options.clientList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
if (this.model.access.isFetched && this.model.refresh.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-access">' + $.t('token.token-table.access-tokens') + '</span> ' +
|
||||
'<span class="label" id="loading-refresh">' + $.t('token.token-table.refresh-tokens') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
'<span class="label" id="loading-access">' + $.t('token.token-table.access-tokens') + '</span> ' + '<span class="label" id="loading-refresh">' + $.t('token.token-table.refresh-tokens') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">'
|
||||
+ $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.access.fetchIfNeeded({success:function(e) {$('#loading-access').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.model.refresh.fetchIfNeeded({success:function(e) {$('#loading-refresh').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.access.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-access').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.model.refresh.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-refresh').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -333,7 +366,9 @@ var TokenListView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
changePageAccess: function(event, num) {
|
||||
$('.paginator-access', this.el).bootpag({page: num});
|
||||
$('.paginator-access', this.el).bootpag({
|
||||
page: num
|
||||
});
|
||||
$('#access-token-table tbody tr', this.el).each(function(index, element) {
|
||||
if (Math.ceil((index + 1) / 10) != num) {
|
||||
$(element).hide();
|
||||
|
@ -344,7 +379,9 @@ var TokenListView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
changePageRefresh: function(event, num) {
|
||||
$('.paginator-refresh', this.el).bootpag({page: num});
|
||||
$('.paginator-refresh', this.el).bootpag({
|
||||
page: num
|
||||
});
|
||||
$('#refresh-token-table tbody tr', this.el).each(function(index, element) {
|
||||
if (Math.ceil((index + 1) / 10) != num) {
|
||||
$(element).hide();
|
||||
|
@ -357,17 +394,30 @@ var TokenListView = Backbone.View.extend({
|
|||
refreshTable: function(e) {
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-access">' + $.t('token.token-table.access-tokens') + '</span> ' +
|
||||
'<span class="label" id="loading-refresh">' + $.t('token.token-table.refresh-tokens') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
'<span class="label" id="loading-access">' + $.t('token.token-table.access-tokens') + '</span> ' + '<span class="label" id="loading-refresh">' + $.t('token.token-table.refresh-tokens') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">'
|
||||
+ $.t('common.scopes') + '</span> ');
|
||||
var _self = this;
|
||||
$.when(this.model.access.fetch({success:function(e) {$('#loading-access').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.model.refresh.fetch({success:function(e) {$('#loading-refresh').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
||||
.done(function(){
|
||||
$.when(this.model.access.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-access').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.model.refresh.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-refresh').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
_self.render();
|
||||
$('#loadingbox').sheet('hide');
|
||||
});
|
||||
|
@ -418,7 +468,11 @@ var TokenListView = Backbone.View.extend({
|
|||
_.each(this.model.access.models, function(token, index) {
|
||||
// look up client
|
||||
var client = _self.options.clientList.getByClientId(token.get('clientId'));
|
||||
var view = new AccessTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList});
|
||||
var view = new AccessTokenView({
|
||||
model: token,
|
||||
client: client,
|
||||
systemScopeList: _self.options.systemScopeList
|
||||
});
|
||||
view.parentView = _self;
|
||||
var element = view.render().el;
|
||||
$('#access-token-table', _self.el).append(element);
|
||||
|
@ -456,7 +510,12 @@ var TokenListView = Backbone.View.extend({
|
|||
_.each(this.model.refresh.models, function(token, index) {
|
||||
// look up client
|
||||
var client = _self.options.clientList.getByClientId(token.get('clientId'));
|
||||
var view = new RefreshTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList, accessTokenCount: refreshCount[token.get('id')]});
|
||||
var view = new RefreshTokenView({
|
||||
model: token,
|
||||
client: client,
|
||||
systemScopeList: _self.options.systemScopeList,
|
||||
accessTokenCount: refreshCount[token.get('id')]
|
||||
});
|
||||
view.parentView = _self;
|
||||
var element = view.render().el;
|
||||
$('#refresh-token-table', _self.el).append(element);
|
||||
|
@ -467,9 +526,9 @@ var TokenListView = Backbone.View.extend({
|
|||
});
|
||||
|
||||
/*
|
||||
_.each(this.model.models, function (scope) {
|
||||
$("#scope-table", this.el).append(new SystemScopeView({model: scope}).render().el);
|
||||
}, this);
|
||||
* _.each(this.model.models, function (scope) { $("#scope-table",
|
||||
* this.el).append(new SystemScopeView({model: scope}).render().el); },
|
||||
* this);
|
||||
*/
|
||||
|
||||
this.togglePlaceholder();
|
||||
|
@ -478,25 +537,34 @@ var TokenListView = Backbone.View.extend({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
ui.routes.push({path: "user/tokens", name: "tokens", callback:
|
||||
function() {
|
||||
ui.routes.push({
|
||||
path: "user/tokens",
|
||||
name: "tokens",
|
||||
callback: function() {
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('token.manage'), href:"manage/#user/tokens"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('token.manage'),
|
||||
href: "manage/#user/tokens"
|
||||
}]);
|
||||
|
||||
this.updateSidebar('user/tokens');
|
||||
|
||||
var view = new TokenListView({model: {access: this.accessTokensList, refresh: this.refreshTokensList}, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
||||
var view = new TokenListView({
|
||||
model: {
|
||||
access: this.accessTokensList,
|
||||
refresh: this.refreshTokensList
|
||||
},
|
||||
clientList: this.clientList,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(
|
||||
function(collection, response, options) {
|
||||
view.load(function(collection, response, options) {
|
||||
$('#content').html(view.render().el);
|
||||
setPageTitle($.t('token.manage'));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,7 +18,8 @@ var WhiteListModel = Backbone.Model.extend({
|
|||
|
||||
idAttribute: "id",
|
||||
|
||||
initialize: function () { },
|
||||
initialize: function() {
|
||||
},
|
||||
|
||||
urlRoot: "api/whitelist"
|
||||
|
||||
|
@ -30,7 +31,9 @@ var WhiteListCollection = Backbone.Collection.extend({
|
|||
},
|
||||
|
||||
getByClientId: function(clientId) {
|
||||
var clients = this.where({clientId: clientId});
|
||||
var clients = this.where({
|
||||
clientId: clientId
|
||||
});
|
||||
if (clients.length == 1) {
|
||||
return clients[0];
|
||||
} else {
|
||||
|
@ -51,24 +54,30 @@ var WhiteListListView = Backbone.View.extend({
|
|||
},
|
||||
|
||||
load: function(callback) {
|
||||
if (this.model.isFetched &&
|
||||
this.options.clientList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
if (this.model.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-whitelist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -90,7 +99,11 @@ var WhiteListListView = Backbone.View.extend({
|
|||
|
||||
// if there's no client ID, this is an error!
|
||||
if (client != null) {
|
||||
var view = new WhiteListView({model: whiteList, client: client, systemScopeList: _self.options.systemScopeList});
|
||||
var view = new WhiteListView({
|
||||
model: whiteList,
|
||||
client: client,
|
||||
systemScopeList: _self.options.systemScopeList
|
||||
});
|
||||
view.parentView = _self;
|
||||
$('#whitelist-table', _self.el).append(view.render().el);
|
||||
}
|
||||
|
@ -116,16 +129,24 @@ var WhiteListListView = Backbone.View.extend({
|
|||
e.preventDefault();
|
||||
var _self = this;
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetch({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-whitelist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetch({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
_self.render();
|
||||
});
|
||||
|
@ -154,15 +175,25 @@ var WhiteListView = Backbone.View.extend({
|
|||
|
||||
render: function(eventName) {
|
||||
|
||||
var json = {whiteList: this.model.toJSON(), client: this.options.client.toJSON()};
|
||||
var json = {
|
||||
whiteList: this.model.toJSON(),
|
||||
client: this.options.client.toJSON()
|
||||
};
|
||||
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({scopes: this.model.get('allowedScopes'), systemScopes: this.options.systemScopeList}));
|
||||
$('.scope-list', this.el).html(this.scopeTemplate({
|
||||
scopes: this.model.get('allowedScopes'),
|
||||
systemScopes: this.options.systemScopeList
|
||||
}));
|
||||
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({client: this.options.client.toJSON()}));
|
||||
$('.client-more-info-block', this.el).html(this.moreInfoTemplate({
|
||||
client: this.options.client.toJSON()
|
||||
}));
|
||||
|
||||
this.$('.dynamically-registered').tooltip({title: $.t('common.dynamically-registered')});
|
||||
this.$('.dynamically-registered').tooltip({
|
||||
title: $.t('common.dynamically-registered')
|
||||
});
|
||||
|
||||
$(this.el).i18n();
|
||||
return this;
|
||||
|
@ -176,7 +207,9 @@ var WhiteListView = Backbone.View.extend({
|
|||
|
||||
editWhitelist: function(e) {
|
||||
e.preventDefault();
|
||||
app.navigate('admin/whitelist/' + this.model.get('id'), {trigger: true});
|
||||
app.navigate('admin/whitelist/' + this.model.get('id'), {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
|
||||
deleteWhitelist: function(e) {
|
||||
|
@ -186,7 +219,8 @@ var WhiteListView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
|
||||
this.model.destroy({
|
||||
dataType: false, processData: false,
|
||||
dataType: false,
|
||||
processData: false,
|
||||
success: function() {
|
||||
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||
$(this).slideUp("fast", function() { // slide up
|
||||
|
@ -246,23 +280,30 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
|
||||
if (this.options.client) {
|
||||
// we know what client we're dealing with already
|
||||
if (this.model.isFetched &&
|
||||
this.options.client.isFetched) {
|
||||
if (this.model.isFetched && this.options.client.isFetched) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.client.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-whitelist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.client.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
$('#loadingbox').sheet('hide');
|
||||
callback();
|
||||
});
|
||||
|
@ -270,9 +311,7 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
} else {
|
||||
// we need to get the client information from the list
|
||||
|
||||
if (this.model.isFetched &&
|
||||
this.options.clientList.isFetched &&
|
||||
this.options.systemScopeList.isFetched) {
|
||||
if (this.model.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||
|
||||
var client = this.options.clientList.getByClientId(this.model.get('clientId'));
|
||||
this.options.client = client;
|
||||
|
@ -282,18 +321,26 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
}
|
||||
|
||||
$('#loadingbox').sheet('show');
|
||||
$('#loading').html(
|
||||
'<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' +
|
||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
||||
);
|
||||
$('#loading').html('<span class="label" id="loading-whitelist">' + $.t('whitelist.whitelist') + '</span> ' + '<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' + '<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||
|
||||
var _self = this;
|
||||
|
||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
||||
.done(function() {
|
||||
$.when(this.model.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-whitelist').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.clientList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-clients').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
}), this.options.systemScopeList.fetchIfNeeded({
|
||||
success: function(e) {
|
||||
$('#loading-scopes').addClass('label-success');
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
})).done(function() {
|
||||
|
||||
var client = _self.options.clientList.getByClientId(_self.model.get('clientId'));
|
||||
_self.options.client = client;
|
||||
|
@ -304,9 +351,6 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
events: {
|
||||
|
@ -327,7 +371,11 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
// process allowed scopes
|
||||
var allowedScopes = this.scopeCollection.pluck("item");
|
||||
|
||||
this.model.set({clientId: this.options.client.get('clientId')}, {silent: true});
|
||||
this.model.set({
|
||||
clientId: this.options.client.get('clientId')
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
var valid = this.model.set({
|
||||
allowedScopes: allowedScopes
|
||||
|
@ -338,7 +386,9 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
this.model.save({}, {
|
||||
success: function() {
|
||||
app.whiteListList.add(_self.model);
|
||||
app.navigate('admin/whitelists', {trigger:true});
|
||||
app.navigate('admin/whitelists', {
|
||||
trigger: true
|
||||
});
|
||||
},
|
||||
error: app.errorHandlerView.handleError()
|
||||
});
|
||||
|
@ -353,16 +403,23 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
// TODO: figure out where we came from and go back there instead
|
||||
if (this.model.get('id') == null) {
|
||||
// if it's a new whitelist entry, go back to the client listing page
|
||||
app.navigate('admin/clients', {trigger:true});
|
||||
app.navigate('admin/clients', {
|
||||
trigger: true
|
||||
});
|
||||
} else {
|
||||
// if we're editing a whitelist, go back to the whitelists page
|
||||
app.navigate('admin/whitelists', {trigger:true});
|
||||
app.navigate('admin/whitelists', {
|
||||
trigger: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
render: function(eventName) {
|
||||
|
||||
var json = {whiteList: this.model.toJSON(), client: this.options.client.toJSON()};
|
||||
var json = {
|
||||
whiteList: this.model.toJSON(),
|
||||
client: this.options.client.toJSON()
|
||||
};
|
||||
|
||||
this.$el.html(this.template(json));
|
||||
|
||||
|
@ -371,14 +428,17 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
var _self = this;
|
||||
// build and bind scopes
|
||||
_.each(this.model.get("allowedScopes"), function(scope) {
|
||||
_self.scopeCollection.add(new Backbone.Model({item:scope}));
|
||||
_self.scopeCollection.add(new Backbone.Model({
|
||||
item: scope
|
||||
}));
|
||||
});
|
||||
|
||||
var scopeView = new ListWidgetView({
|
||||
placeholder: $.t('whitelist.whitelist-form.scope-placeholder'),
|
||||
autocomplete: this.options.client.get("scope"),
|
||||
helpBlockText: $.t('whitelist.whitelist-form.scope-help'),
|
||||
collection: this.scopeCollection});
|
||||
collection: this.scopeCollection
|
||||
});
|
||||
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||
this.listWidgetViews.push(scopeView);
|
||||
|
||||
|
@ -389,9 +449,10 @@ var WhiteListFormView = Backbone.View.extend({
|
|||
|
||||
});
|
||||
|
||||
|
||||
ui.routes.push({path: "admin/whitelists", name: "whiteList", callback:
|
||||
function () {
|
||||
ui.routes.push({
|
||||
path: "admin/whitelists",
|
||||
name: "whiteList",
|
||||
callback: function() {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -401,28 +462,33 @@ ui.routes.push({path: "admin/whitelists", name: "whiteList", callback:
|
|||
this.updateSidebar('admin/whitelists');
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('whitelist.manage'),
|
||||
href: "manage/#admin/whitelists"
|
||||
}]);
|
||||
|
||||
var view = new WhiteListListView({model:this.whiteListList, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
||||
var view = new WhiteListListView({
|
||||
model: this.whiteListList,
|
||||
clientList: this.clientList,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(
|
||||
function() {
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('whitelist.manage'));
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ui.routes.push({path: "admin/whitelist/new/:cid", name: "newWhitelist", callback:
|
||||
function(cid) {
|
||||
|
||||
ui.routes.push({
|
||||
path: "admin/whitelist/new/:cid",
|
||||
name: "newWhitelist",
|
||||
callback: function(cid) {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -430,11 +496,16 @@ ui.routes.push({path: "admin/whitelist/new/:cid", name: "newWhitelist", callback
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"},
|
||||
{text:$.t('whitelist.new'), href:"manage/#admin/whitelist/new/" + cid}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('whitelist.manage'),
|
||||
href: "manage/#admin/whitelists"
|
||||
}, {
|
||||
text: $.t('whitelist.new'),
|
||||
href: "manage/#admin/whitelist/new/" + cid
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/whitelists');
|
||||
|
||||
|
@ -442,29 +513,38 @@ ui.routes.push({path: "admin/whitelist/new/:cid", name: "newWhitelist", callback
|
|||
|
||||
var client = this.clientList.get(cid);
|
||||
if (!client) {
|
||||
client = new ClientModel({id: cid});
|
||||
client = new ClientModel({
|
||||
id: cid
|
||||
});
|
||||
}
|
||||
|
||||
var view = new WhiteListFormView({model: whiteList, client: client, systemScopeList: this.systemScopeList});
|
||||
var view = new WhiteListFormView({
|
||||
model: whiteList,
|
||||
client: client,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(
|
||||
function() {
|
||||
view.load(function() {
|
||||
|
||||
// set the scopes on the model now that everything's loaded
|
||||
whiteList.set({allowedScopes: client.get('scope')}, {silent: true});
|
||||
whiteList.set({
|
||||
allowedScopes: client.get('scope')
|
||||
}, {
|
||||
silent: true
|
||||
});
|
||||
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('whitelist.manage'));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ui.routes.push({path: "admin/whitelist/:id", name: "editWhitelist", callback:
|
||||
function(id) {
|
||||
ui.routes.push({
|
||||
path: "admin/whitelist/:id",
|
||||
name: "editWhitelist",
|
||||
callback: function(id) {
|
||||
|
||||
if (!isAdmin()) {
|
||||
this.root();
|
||||
|
@ -472,28 +552,37 @@ ui.routes.push({path: "admin/whitelist/:id", name: "editWhitelist", callback:
|
|||
}
|
||||
|
||||
this.breadCrumbView.collection.reset();
|
||||
this.breadCrumbView.collection.add([
|
||||
{text:$.t('admin.home'), href:""},
|
||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"},
|
||||
{text:$.t('whitelist.edit'), href:"manage/#admin/whitelist/" + id}
|
||||
]);
|
||||
this.breadCrumbView.collection.add([{
|
||||
text: $.t('admin.home'),
|
||||
href: ""
|
||||
}, {
|
||||
text: $.t('whitelist.manage'),
|
||||
href: "manage/#admin/whitelists"
|
||||
}, {
|
||||
text: $.t('whitelist.edit'),
|
||||
href: "manage/#admin/whitelist/" + id
|
||||
}]);
|
||||
|
||||
this.updateSidebar('admin/whitelists');
|
||||
|
||||
var whiteList = this.whiteListList.get(id);
|
||||
if (!whiteList) {
|
||||
whiteList = new WhiteListModel({id: id});
|
||||
whiteList = new WhiteListModel({
|
||||
id: id
|
||||
});
|
||||
}
|
||||
|
||||
var view = new WhiteListFormView({model: whiteList, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
||||
var view = new WhiteListFormView({
|
||||
model: whiteList,
|
||||
clientList: this.clientList,
|
||||
systemScopeList: this.systemScopeList
|
||||
});
|
||||
|
||||
view.load(
|
||||
function() {
|
||||
view.load(function() {
|
||||
$('#content').html(view.render().el);
|
||||
view.delegateEvents();
|
||||
setPageTitle($.t('whitelist.manage'));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue