auto format and cleanup javascript
parent
bd72b4138d
commit
78b9b6ced4
|
@ -53,9 +53,10 @@ Backbone.Collection.prototype.fetchIfNeeded = function(options) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var URIModel = Backbone.Model.extend({
|
var URIModel = Backbone.Model
|
||||||
|
.extend({
|
||||||
|
|
||||||
validate: function(attrs){
|
validate: function(attrs) {
|
||||||
|
|
||||||
var expression = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;
|
var expression = /^(?:([a-z0-9+.-]+:\/\/)((?:(?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(:(?:\d*))?(\/(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?|([a-z0-9+.-]+:)(\/?(?:[a-z0-9-._~!$&'()*+,;=:@]|%[0-9A-F]{2})+(?:[a-z0-9-._~!$&'()*+,;=:@\/]|%[0-9A-F]{2})*)?)(\?(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?(#(?:[a-z0-9-._~!$&'()*+,;=:\/?@]|%[0-9A-F]{2})*)?$/i;
|
||||||
var regex = new RegExp(expression);
|
var regex = new RegExp(expression);
|
||||||
|
@ -65,41 +66,37 @@ var URIModel = Backbone.Model.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Backbone JS Reusable ListWidget
|
* Backbone JS Reusable ListWidget Options { collection: Backbone JS Collection
|
||||||
* Options
|
* type: ('uri'|'default') autocomplete: ['item1','item2'] List of auto complete
|
||||||
* {
|
* items }
|
||||||
* collection: Backbone JS Collection
|
*
|
||||||
* type: ('uri'|'default')
|
|
||||||
* autocomplete: ['item1','item2'] List of auto complete items
|
|
||||||
* }
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
var ListWidgetChildView = Backbone.View.extend({
|
var ListWidgetChildView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .btn-delete-list-item":'deleteItem',
|
"click .btn-delete-list-item": 'deleteItem',
|
||||||
"change .checkbox-list-item":'toggleCheckbox'
|
"change .checkbox-list-item": 'toggleCheckbox'
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteItem:function (e) {
|
deleteItem: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
//this.$el.tooltip('delete');
|
// this.$el.tooltip('delete');
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
error:app.errorHandlerView.handleError()
|
processData: false,
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleCheckbox:function(e) {
|
toggleCheckbox: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopImmediatePropagation();
|
e.stopImmediatePropagation();
|
||||||
if ($(e.target).is(':checked')) {
|
if ($(e.target).is(':checked')) {
|
||||||
|
@ -110,24 +107,32 @@ var ListWidgetChildView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = {toggle: false, checked: false};
|
this.options = {
|
||||||
|
toggle: false,
|
||||||
|
checked: false
|
||||||
|
};
|
||||||
_.extend(this.options, options);
|
_.extend(this.options, options);
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-list-widget-child').html());
|
this.template = _.template($('#tmpl-list-widget-child').html());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function () {
|
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));
|
this.$el.html(this.template(data));
|
||||||
|
|
||||||
$('.item-full', this.el).hide();
|
$('.item-full', this.el).hide();
|
||||||
|
|
||||||
if (this.model.get('item').length > 30) {
|
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;
|
var _self = this;
|
||||||
|
|
||||||
|
@ -139,8 +144,6 @@ var ListWidgetChildView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -150,9 +153,9 @@ var ListWidgetView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: "div",
|
tagName: "div",
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .btn-add-list-item":"addItem",
|
"click .btn-add-list-item": "addItem",
|
||||||
"keypress":function (e) {
|
"keypress": function(e) {
|
||||||
// trap the enter key
|
// trap the enter key
|
||||||
if (e.which == 13) {
|
if (e.which == 13) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -162,7 +165,7 @@ var ListWidgetView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
|
@ -173,30 +176,36 @@ var ListWidgetView = Backbone.View.extend({
|
||||||
this.collection.bind('remove', this.render, this);
|
this.collection.bind('remove', this.render, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
addItem:function(e) {
|
addItem: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var input_value = $("input", this.el).val().trim();
|
var input_value = $("input", this.el).val().trim();
|
||||||
|
|
||||||
if (input_value === ""){
|
if (input_value === "") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var model;
|
var model;
|
||||||
|
|
||||||
if (this.options.type == 'uri') {
|
if (this.options.type == 'uri') {
|
||||||
model = new URIModel({item:input_value});
|
model = new URIModel({
|
||||||
|
item: input_value
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
model = new Backbone.Model({item:input_value});
|
model = new Backbone.Model({
|
||||||
|
item: input_value
|
||||||
|
});
|
||||||
model.validate = function(attrs) {
|
model.validate = function(attrs) {
|
||||||
if(!attrs.item) {
|
if (!attrs.item) {
|
||||||
return "value can't be null";
|
return "value can't be null";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's valid and doesn't already exist
|
// 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);
|
this.collection.add(model);
|
||||||
} else {
|
} else {
|
||||||
// else add a visual error indicator
|
// else add a visual error indicator
|
||||||
|
@ -204,10 +213,12 @@ var ListWidgetView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
|
|
||||||
this.$el.html(this.template({placeholder:this.options.placeholder,
|
this.$el.html(this.template({
|
||||||
helpBlockText:this.options.helpBlockText}));
|
placeholder: this.options.placeholder,
|
||||||
|
helpBlockText: this.options.helpBlockText
|
||||||
|
}));
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
|
@ -218,7 +229,8 @@ var ListWidgetView = Backbone.View.extend({
|
||||||
// make a copy of our collection to work from
|
// make a copy of our collection to work from
|
||||||
var values = this.collection.clone();
|
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) {
|
if (this.options.autocomplete) {
|
||||||
_.each(this.options.autocomplete, function(option) {
|
_.each(this.options.autocomplete, function(option) {
|
||||||
var found = _.find(values.models, function(element) {
|
var found = _.find(values.models, function(element) {
|
||||||
|
@ -232,23 +244,35 @@ var ListWidgetView = Backbone.View.extend({
|
||||||
// if we found the element, check the box
|
// if we found the element, check the box
|
||||||
model = found;
|
model = found;
|
||||||
checked = true;
|
checked = true;
|
||||||
// and remove it from the list of items to be rendered later
|
// and remove it from the list of items to be rendered
|
||||||
values.remove(found, {silent: true});
|
// later
|
||||||
|
values.remove(found, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
model = new Backbone.Model({item:option});
|
model = new Backbone.Model({
|
||||||
|
item: option
|
||||||
|
});
|
||||||
checked = false;
|
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);
|
$("tbody", _self.el).append(el);
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// now render everything not in the autocomplete list
|
// now render everything not in the autocomplete list
|
||||||
_.each(values.models, function (model) {
|
_.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);
|
$("tbody", _self.el).append(el);
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +287,7 @@ var BreadCrumbView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'ul',
|
tagName: 'ul',
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
|
@ -275,19 +299,28 @@ var BreadCrumbView = Backbone.View.extend({
|
||||||
this.collection.bind('add', this.render, this);
|
this.collection.bind('add', this.render, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function () {
|
render: function() {
|
||||||
|
|
||||||
this.$el.empty();
|
this.$el.empty();
|
||||||
var parent = this;
|
var parent = this;
|
||||||
|
|
||||||
// go through each of the breadcrumb models
|
// go through each of the breadcrumb models
|
||||||
_.each(this.collection.models, function (crumb, index) {
|
_.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) {
|
if (index == parent.collection.size() - 1) {
|
||||||
crumb.set({active:true}, {silent:true});
|
crumb.set({
|
||||||
|
active: true
|
||||||
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
crumb.set({active:false}, {silent:true});
|
crumb.set({
|
||||||
|
active: false
|
||||||
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$el.append(this.template(crumb.toJSON()));
|
this.$el.append(this.template(crumb.toJSON()));
|
||||||
|
@ -298,44 +331,46 @@ var BreadCrumbView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// User Profile
|
// User Profile
|
||||||
|
|
||||||
var UserProfileView = Backbone.View.extend({
|
var UserProfileView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-user-profile-element').html());
|
this.template = _.template($('#tmpl-user-profile-element').html());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
render: function() {
|
||||||
|
|
||||||
$(this.el).html($('#tmpl-user-profile').html());
|
$(this.el).html($('#tmpl-user-profile').html());
|
||||||
|
|
||||||
var t = this.template;
|
var t = this.template;
|
||||||
|
|
||||||
_.each(this.model, function (value, key) {
|
_.each(this.model, function(value, key) {
|
||||||
if (key && value) {
|
if (key && value) {
|
||||||
|
|
||||||
if (typeof(value) === 'object') {
|
if (typeof (value) === 'object') {
|
||||||
|
|
||||||
var el = this.el;
|
var el = this.el;
|
||||||
var k = key;
|
var k = key;
|
||||||
|
|
||||||
_.each(value, function (value, key) {
|
_.each(value, function(value, key) {
|
||||||
$('dl', el).append(
|
$('dl', el).append(t({
|
||||||
t({key: key, value: value, category: k})
|
key: key,
|
||||||
);
|
value: value,
|
||||||
|
category: k
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
} else if (typeof(value) === 'array') {
|
} else if (typeof (value) === 'array') {
|
||||||
// TODO: handle array types
|
// TODO: handle array types
|
||||||
} else {
|
} else {
|
||||||
$('dl', this.el).append(
|
$('dl', this.el).append(t({
|
||||||
t({key: key, value: value})
|
key: key,
|
||||||
);
|
value: value
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
@ -348,7 +383,7 @@ var UserProfileView = Backbone.View.extend({
|
||||||
// error handler
|
// error handler
|
||||||
var ErrorHandlerView = Backbone.View.extend({
|
var ErrorHandlerView = Backbone.View.extend({
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-error-box').html());
|
this.template = _.template($('#tmpl-error-box').html());
|
||||||
|
@ -358,12 +393,12 @@ var ErrorHandlerView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
reloadPage:function(event) {
|
reloadPage: function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleError:function(message) {
|
handleError: function(message) {
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
message = {};
|
message = {};
|
||||||
|
@ -377,17 +412,24 @@ var ErrorHandlerView = Backbone.View.extend({
|
||||||
console.log(message.log);
|
console.log(message.log);
|
||||||
}
|
}
|
||||||
|
|
||||||
_self.showErrorMessage(
|
_self.showErrorMessage(_self.headerTemplate({
|
||||||
_self.headerTemplate({message: message, model: model, response: response, options: options}),
|
message: message,
|
||||||
_self.template({message: message, model: model, response: response, options: options})
|
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);
|
$('#modalAlert .modal-body .page-reload').on('click', _self.reloadPage);
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showErrorMessage:function(header, message) {
|
showErrorMessage: function(header, message) {
|
||||||
// hide the sheet if it's visible
|
// hide the sheet if it's visible
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
|
|
||||||
|
@ -404,28 +446,31 @@ var ErrorHandlerView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Router
|
// Router
|
||||||
var AppRouter = Backbone.Router.extend({
|
var AppRouter = Backbone.Router.extend({
|
||||||
|
|
||||||
routes:{
|
routes: {
|
||||||
|
|
||||||
"": "root"
|
"": "root"
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
root:function() {
|
root: function() {
|
||||||
if (isAdmin()) {
|
if (isAdmin()) {
|
||||||
this.navigate('admin/clients', {trigger: true});
|
this.navigate('admin/clients', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.navigate('user/approved', {trigger: true});
|
this.navigate('user/approved', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize:function () {
|
initialize: function() {
|
||||||
|
|
||||||
this.breadCrumbView = new BreadCrumbView({
|
this.breadCrumbView = new BreadCrumbView({
|
||||||
collection:new Backbone.Collection()
|
collection: new Backbone.Collection()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.breadCrumbView.render();
|
this.breadCrumbView.render();
|
||||||
|
@ -440,18 +485,19 @@ var AppRouter = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
notImplemented:function(){
|
notImplemented: function() {
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""}
|
text: $.t('admin.home'),
|
||||||
]);
|
href: ""
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('none');
|
this.updateSidebar('none');
|
||||||
|
|
||||||
$('#content').html("<h2>Not implemented yet.</h2>");
|
$('#content').html("<h2>Not implemented yet.</h2>");
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSidebar:function(item) {
|
updateSidebar: function(item) {
|
||||||
$('.sidebar-nav li.active').removeClass('active');
|
$('.sidebar-nav li.active').removeClass('active');
|
||||||
|
|
||||||
$('.sidebar-nav li a[href^="manage/#' + item + '"]').parent().addClass('active');
|
$('.sidebar-nav li a[href^="manage/#' + item + '"]').parent().addClass('active');
|
||||||
|
@ -463,20 +509,21 @@ var AppRouter = Backbone.Router.extend({
|
||||||
var app = null;
|
var app = null;
|
||||||
|
|
||||||
// main
|
// main
|
||||||
$(function () {
|
$(function() {
|
||||||
|
|
||||||
var loader = function(source) {
|
var loader = function(source) {
|
||||||
return $.get(source, function (templates) {
|
return $.get(source, function(templates) {
|
||||||
console.log('Loading file: ' + source);
|
console.log('Loading file: ' + source);
|
||||||
$('#templates').append(templates);
|
$('#templates').append(templates);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// load templates and append them to the body
|
// load templates and append them to the body
|
||||||
$.when.apply(null, ui.templates.map(loader)
|
$.when.apply(null, ui.templates.map(loader)).done(function() {
|
||||||
).done(function() {
|
|
||||||
console.log('done');
|
console.log('done');
|
||||||
$.ajaxSetup({cache:false});
|
$.ajaxSetup({
|
||||||
|
cache: false
|
||||||
|
});
|
||||||
app = new AppRouter();
|
app = new AppRouter();
|
||||||
|
|
||||||
_.each(ui.routes.reverse(), function(route) {
|
_.each(ui.routes.reverse(), function(route) {
|
||||||
|
@ -486,36 +533,43 @@ $(function () {
|
||||||
|
|
||||||
app.on('route', function(name, args) {
|
app.on('route', function(name, args) {
|
||||||
// scroll to top of page on new route selection
|
// 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
|
// grab all hashed URLs and send them through the app router instead
|
||||||
$(document).on('click', 'a[href^="manage/#"]', function(event) {
|
$(document).on('click', 'a[href^="manage/#"]', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
app.navigate(this.hash.slice(1), {trigger: true});
|
app.navigate(this.hash.slice(1), {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var base = $('base').attr('href');
|
var base = $('base').attr('href');
|
||||||
$.getJSON(base + '.well-known/openid-configuration', function(data) {
|
$.getJSON(base + '.well-known/openid-configuration', function(data) {
|
||||||
app.serverConfiguration = data;
|
app.serverConfiguration = data;
|
||||||
var baseUrl = $.url(app.serverConfiguration.issuer);
|
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/'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onerror = function ( message, filename, lineno, colno, error ){
|
window.onerror = function(message, filename, lineno, colno, error) {
|
||||||
console.log(message);
|
console.log(message);
|
||||||
//Display an alert with an error message
|
// Display an alert with an error message
|
||||||
$('#modalAlert div.modal-header').html($.t('error.title'));
|
$('#modalAlert div.modal-header').html($.t('error.title'));
|
||||||
$('#modalAlert div.modal-body').html($.t('error.message') + message + ' <br /> ' + [filename, lineno, colno, error]);
|
$('#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
|
||||||
"backdrop" : "static",
|
// and show the dialog
|
||||||
"keyboard" : true,
|
"backdrop": "static",
|
||||||
"show" : true // ensure the modal is shown immediately
|
"keyboard": true,
|
||||||
|
"show": true
|
||||||
|
// ensure the modal is shown immediately
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ var BlackListModel = Backbone.Model.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
var BlackListCollection = Backbone.Collection.extend({
|
var BlackListCollection = Backbone.Collection.extend({
|
||||||
initialize: function() { },
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
url: "api/blacklist"
|
url: "api/blacklist"
|
||||||
});
|
});
|
||||||
|
@ -29,42 +30,42 @@ var BlackListCollection = Backbone.Collection.extend({
|
||||||
var BlackListListView = Backbone.View.extend({
|
var BlackListListView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.collection.isFetched) {
|
if (this.collection.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html('<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> ');
|
||||||
'<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()}))
|
$.when(this.collection.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-blacklist').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
"click .refresh-table":"refreshTable",
|
"click .refresh-table": "refreshTable",
|
||||||
"click .btn-add":"addItem",
|
"click .btn-add": "addItem",
|
||||||
"submit #add-blacklist form":"addItem"
|
"submit #add-blacklist form": "addItem"
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTable:function(e) {
|
refreshTable: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html('<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> ');
|
||||||
'<span class="label" id="loading-blacklist">' + $.t('admin.blacklist') + '</span> '
|
|
||||||
);
|
|
||||||
|
|
||||||
$.when(this.collection.fetch()).done(function() {
|
$.when(this.collection.fetch()).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
|
@ -72,7 +73,7 @@ var BlackListListView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePlaceholder:function() {
|
togglePlaceholder: function() {
|
||||||
if (this.collection.length > 0) {
|
if (this.collection.length > 0) {
|
||||||
$('#blacklist-table', this.el).show();
|
$('#blacklist-table', this.el).show();
|
||||||
$('#blacklist-table-empty', this.el).hide();
|
$('#blacklist-table-empty', this.el).hide();
|
||||||
|
@ -82,13 +83,15 @@ var BlackListListView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
|
|
||||||
$(this.el).html($('#tmpl-blacklist-table').html());
|
$(this.el).html($('#tmpl-blacklist-table').html());
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
_.each(this.collection.models, function(blacklist) {
|
_.each(this.collection.models, function(blacklist) {
|
||||||
var view = new BlackListWidgetView({model: blacklist});
|
var view = new BlackListWidgetView({
|
||||||
|
model: blacklist
|
||||||
|
});
|
||||||
view.parentView = _self;
|
view.parentView = _self;
|
||||||
$("#blacklist-table", _self.el).append(view.render().el);
|
$("#blacklist-table", _self.el).append(view.render().el);
|
||||||
}, this);
|
}, this);
|
||||||
|
@ -99,7 +102,7 @@ var BlackListListView = Backbone.View.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
addItem:function(e) {
|
addItem: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var input_value = $("#blacklist-uri", this.el).val().trim();
|
var input_value = $("#blacklist-uri", this.el).val().trim();
|
||||||
|
@ -117,11 +120,11 @@ var BlackListListView = Backbone.View.extend({
|
||||||
var _self = this; // closures...
|
var _self = this; // closures...
|
||||||
|
|
||||||
item.save({}, {
|
item.save({}, {
|
||||||
success:function() {
|
success: function() {
|
||||||
_self.collection.add(item);
|
_self.collection.add(item);
|
||||||
_self.render();
|
_self.render();
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -132,7 +135,7 @@ var BlackListWidgetView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
|
@ -140,7 +143,7 @@ var BlackListWidgetView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
render: function() {
|
||||||
|
|
||||||
this.$el.html(this.template(this.model.toJSON()));
|
this.$el.html(this.template(this.model.toJSON()));
|
||||||
|
|
||||||
|
@ -148,28 +151,29 @@ var BlackListWidgetView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
'click .btn-delete':'deleteBlacklist'
|
'click .btn-delete': 'deleteBlacklist'
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteBlacklist:function (e) {
|
deleteBlacklist: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t("blacklist.confirm"))) {
|
if (confirm($.t("blacklist.confirm"))) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
|
success: function() {
|
||||||
|
|
||||||
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||||
$(this).slideUp("fast", function () { //slide up
|
$(this).slideUp("fast", function() { // slide up
|
||||||
$(this).remove(); //then remove from the DOM
|
$(this).remove(); // then remove from the DOM
|
||||||
_self.parentView.togglePlaceholder();
|
_self.parentView.togglePlaceholder();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
_self.parentView.delegateEvents();
|
_self.parentView.delegateEvents();
|
||||||
|
@ -180,9 +184,10 @@ var BlackListWidgetView = Backbone.View.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.routes.push({
|
||||||
ui.routes.push({path: "admin/blacklist", name: "blackList", callback:
|
path: "admin/blacklist",
|
||||||
function() {
|
name: "blackList",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -190,21 +195,24 @@ ui.routes.push({path: "admin/blacklist", name: "blackList", callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.manage-blacklist'), href:"manage/#admin/blacklist"}
|
href: ""
|
||||||
]);
|
}, {
|
||||||
|
text: $.t('admin.manage-blacklist'),
|
||||||
|
href: "manage/#admin/blacklist"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('admin/blacklist');
|
this.updateSidebar('admin/blacklist');
|
||||||
|
|
||||||
var view = new BlackListListView({collection: this.blackListList});
|
var view = new BlackListListView({
|
||||||
|
collection: this.blackListList
|
||||||
|
});
|
||||||
|
|
||||||
view.load(
|
view.load(function(collection, response, options) {
|
||||||
function(collection, response, options) {
|
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
setPageTitle($.t('admin.manage-blacklist'));
|
setPageTitle($.t('admin.manage-blacklist'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,61 +17,61 @@
|
||||||
var DynRegClient = Backbone.Model.extend({
|
var DynRegClient = Backbone.Model.extend({
|
||||||
idAttribute: "client_id",
|
idAttribute: "client_id",
|
||||||
|
|
||||||
defaults:{
|
defaults: {
|
||||||
client_id:null,
|
client_id: null,
|
||||||
client_secret:null,
|
client_secret: null,
|
||||||
redirect_uris:[],
|
redirect_uris: [],
|
||||||
client_name:null,
|
client_name: null,
|
||||||
client_uri:null,
|
client_uri: null,
|
||||||
logo_uri:null,
|
logo_uri: null,
|
||||||
contacts:[],
|
contacts: [],
|
||||||
tos_uri:null,
|
tos_uri: null,
|
||||||
token_endpoint_auth_method:null,
|
token_endpoint_auth_method: null,
|
||||||
scope:null,
|
scope: null,
|
||||||
grant_types:[],
|
grant_types: [],
|
||||||
response_types:[],
|
response_types: [],
|
||||||
policy_uri:null,
|
policy_uri: null,
|
||||||
|
|
||||||
jwks_uri:null,
|
jwks_uri: null,
|
||||||
jwks:null,
|
jwks: null,
|
||||||
jwksType:'URI',
|
jwksType: 'URI',
|
||||||
|
|
||||||
application_type:null,
|
application_type: null,
|
||||||
sector_identifier_uri:null,
|
sector_identifier_uri: null,
|
||||||
subject_type:null,
|
subject_type: null,
|
||||||
|
|
||||||
request_object_signing_alg:null,
|
request_object_signing_alg: null,
|
||||||
|
|
||||||
userinfo_signed_response_alg:null,
|
userinfo_signed_response_alg: null,
|
||||||
userinfo_encrypted_response_alg:null,
|
userinfo_encrypted_response_alg: null,
|
||||||
userinfo_encrypted_response_enc:null,
|
userinfo_encrypted_response_enc: null,
|
||||||
|
|
||||||
id_token_signed_response_alg:null,
|
id_token_signed_response_alg: null,
|
||||||
id_token_encrypted_response_alg:null,
|
id_token_encrypted_response_alg: null,
|
||||||
id_token_encrypted_response_enc:null,
|
id_token_encrypted_response_enc: null,
|
||||||
|
|
||||||
default_max_age:null,
|
default_max_age: null,
|
||||||
require_auth_time:false,
|
require_auth_time: false,
|
||||||
default_acr_values:null,
|
default_acr_values: null,
|
||||||
|
|
||||||
initiate_login_uri:null,
|
initiate_login_uri: null,
|
||||||
post_logout_redirect_uris:null,
|
post_logout_redirect_uris: null,
|
||||||
|
|
||||||
claims_redirect_uris:[],
|
claims_redirect_uris: [],
|
||||||
|
|
||||||
request_uris:[],
|
request_uris: [],
|
||||||
|
|
||||||
software_statement:null,
|
software_statement: null,
|
||||||
software_id:null,
|
software_id: null,
|
||||||
software_version:null,
|
software_version: null,
|
||||||
|
|
||||||
code_challenge_method:null,
|
code_challenge_method: null,
|
||||||
|
|
||||||
registration_access_token:null,
|
registration_access_token: null,
|
||||||
registration_client_uri:null
|
registration_client_uri: null
|
||||||
},
|
},
|
||||||
|
|
||||||
sync: function(method, model, options){
|
sync: function(method, model, options) {
|
||||||
if (model.get('registration_access_token')) {
|
if (model.get('registration_access_token')) {
|
||||||
var headers = options.headers ? options.headers : {};
|
var headers = options.headers ? options.headers : {};
|
||||||
headers['Authorization'] = 'Bearer ' + model.get('registration_access_token');
|
headers['Authorization'] = 'Bearer ' + model.get('registration_access_token');
|
||||||
|
@ -81,7 +81,7 @@ var DynRegClient = Backbone.Model.extend({
|
||||||
return this.constructor.__super__.sync(method, model, options);
|
return this.constructor.__super__.sync(method, model, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
urlRoot:'register'
|
urlRoot: 'register'
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,17 +89,17 @@ var DynRegRootView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click #newreg":"newReg",
|
"click #newreg": "newReg",
|
||||||
"click #editreg":"editReg"
|
"click #editreg": "editReg"
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.options.systemScopeList.isFetched) {
|
if (this.options.systemScopeList.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -108,26 +108,32 @@ var DynRegRootView = Backbone.View.extend({
|
||||||
$('#loadingbox').sheet('show');
|
$('#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.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
render: function() {
|
||||||
$(this.el).html($('#tmpl-dynreg').html());
|
$(this.el).html($('#tmpl-dynreg').html());
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
newReg:function(e) {
|
newReg: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.remove();
|
this.remove();
|
||||||
app.navigate('dev/dynreg/new', {trigger: true});
|
app.navigate('dev/dynreg/new', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
editReg:function(e) {
|
editReg: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var clientId = $('#clientId').val();
|
var clientId = $('#clientId').val();
|
||||||
var token = $('#regtoken').val();
|
var token = $('#regtoken').val();
|
||||||
|
@ -144,33 +150,47 @@ var DynRegRootView = Backbone.View.extend({
|
||||||
|
|
||||||
var userInfo = getUserInfo();
|
var userInfo = getUserInfo();
|
||||||
var contacts = client.get("contacts");
|
var contacts = client.get("contacts");
|
||||||
if (userInfo != null && userInfo.email != null && ! _.contains(contacts, userInfo.email)) {
|
if (userInfo != null && userInfo.email != null && !_.contains(contacts, userInfo.email)) {
|
||||||
contacts.push(userInfo.email);
|
contacts.push(userInfo.email);
|
||||||
}
|
}
|
||||||
client.set({
|
client.set({
|
||||||
contacts: contacts
|
contacts: contacts
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
|
||||||
if (client.get("jwks")) {
|
if (client.get("jwks")) {
|
||||||
client.set({
|
client.set({
|
||||||
jwksType: "VAL"
|
jwksType: "VAL"
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
client.set({
|
client.set({
|
||||||
jwksType: "URI"
|
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() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
view.delegateEvents();
|
view.delegateEvents();
|
||||||
setPageTitle($.t('dynreg.edit-dynamically-registered'));
|
setPageTitle($.t('dynreg.edit-dynamically-registered'));
|
||||||
app.navigate('dev/dynreg/edit', {trigger: true});
|
app.navigate('dev/dynreg/edit', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
self.remove();
|
self.remove();
|
||||||
});
|
});
|
||||||
}, error:app.errorHandlerView.handleError({message: $.t('dynreg.invalid-access-token')})
|
},
|
||||||
|
error: app.errorHandlerView.handleError({
|
||||||
|
message: $.t('dynreg.invalid-access-token')
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +200,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-dynreg-client-form').html());
|
this.template = _.template($('#tmpl-dynreg-client-form').html());
|
||||||
|
@ -197,7 +217,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
this.listWidgetViews = [];
|
this.listWidgetViews = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.options.systemScopeList.isFetched) {
|
if (this.options.systemScopeList.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -206,40 +226,51 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
$('#loadingbox').sheet('show');
|
$('#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.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .btn-save":"saveClient",
|
"click .btn-save": "saveClient",
|
||||||
"click .btn-cancel":"cancel",
|
"click .btn-cancel": "cancel",
|
||||||
"click .btn-delete":"deleteClient",
|
"click .btn-delete": "deleteClient",
|
||||||
"change #logoUri input":"previewLogo",
|
"change #logoUri input": "previewLogo",
|
||||||
"change #tokenEndpointAuthMethod input:radio":"toggleClientCredentials",
|
"change #tokenEndpointAuthMethod input:radio": "toggleClientCredentials",
|
||||||
"change #jwkSelector input:radio":"toggleJWKSetType"
|
"change #jwkSelector input:radio": "toggleJWKSetType"
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel:function(e) {
|
cancel: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
app.navigate('dev/dynreg', {trigger: true});
|
app.navigate('dev/dynreg', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteClient:function (e) {
|
deleteClient: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t('client.client-table.confirm'))) {
|
if (confirm($.t('client.client-table.confirm'))) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
|
success: function() {
|
||||||
self.remove();
|
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"
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -247,27 +278,29 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
previewLogo:function() {
|
previewLogo: function() {
|
||||||
if ($('#logoUri input', this.el).val()) {
|
if ($('#logoUri input', this.el).val()) {
|
||||||
$('#logoPreview', this.el).empty();
|
$('#logoPreview', this.el).empty();
|
||||||
$('#logoPreview', this.el).attr('src', $('#logoUri input', this.el).val());
|
$('#logoPreview', this.el).attr('src', $('#logoUri input', this.el).val());
|
||||||
} else {
|
} else {
|
||||||
//$('#logoBlock', this.el).hide();
|
// $('#logoBlock', this.el).hide();
|
||||||
$('#logoPreview', this.el).attr('src', 'resources/images/logo_placeholder.gif');
|
$('#logoPreview', this.el).attr('src', 'resources/images/logo_placeholder.gif');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @param event
|
||||||
*/
|
*/
|
||||||
toggleClientCredentials:function() {
|
toggleClientCredentials: function() {
|
||||||
|
|
||||||
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
||||||
|
|
||||||
// show or hide the signing algorithm method depending on what's selected
|
// show or hide the signing algorithm method depending on what's
|
||||||
if (tokenEndpointAuthMethod == 'private_key_jwt'
|
// selected
|
||||||
|| tokenEndpointAuthMethod == 'client_secret_jwt') {
|
if (tokenEndpointAuthMethod == 'private_key_jwt' || tokenEndpointAuthMethod == 'client_secret_jwt') {
|
||||||
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
||||||
} else {
|
} else {
|
||||||
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
||||||
|
@ -277,7 +310,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
/**
|
/**
|
||||||
* Set up the form based on the JWK Set selector
|
* Set up the form based on the JWK Set selector
|
||||||
*/
|
*/
|
||||||
toggleJWKSetType:function() {
|
toggleJWKSetType: function() {
|
||||||
var jwkSelector = $('#jwkSelector input:radio', this.el).filter(':checked').val();
|
var jwkSelector = $('#jwkSelector input:radio', this.el).filter(':checked').val();
|
||||||
|
|
||||||
if (jwkSelector == 'URI') {
|
if (jwkSelector == 'URI') {
|
||||||
|
@ -293,13 +326,13 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
disableUnsupportedJOSEItems:function(serverSupported, query) {
|
disableUnsupportedJOSEItems: function(serverSupported, query) {
|
||||||
var supported = ['default'];
|
var supported = ['default'];
|
||||||
if (serverSupported) {
|
if (serverSupported) {
|
||||||
supported = _.union(supported, serverSupported);
|
supported = _.union(supported, serverSupported);
|
||||||
}
|
}
|
||||||
$(query, this.$el).each(function(idx) {
|
$(query, this.$el).each(function(idx) {
|
||||||
if(_.contains(supported, $(this).val())) {
|
if (_.contains(supported, $(this).val())) {
|
||||||
$(this).prop('disabled', false);
|
$(this).prop('disabled', false);
|
||||||
} else {
|
} else {
|
||||||
$(this).prop('disabled', true);
|
$(this).prop('disabled', true);
|
||||||
|
@ -308,8 +341,10 @@ 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,
|
||||||
defaultToNull:function(value) {
|
// otherwise returns input value. useful for parsing the JOSE
|
||||||
|
// algorithm dropdowns
|
||||||
|
defaultToNull: function(value) {
|
||||||
if (value == 'default') {
|
if (value == 'default') {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -318,7 +353,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
// returns "null" if the given value is falsy
|
// returns "null" if the given value is falsy
|
||||||
emptyToNull:function(value) {
|
emptyToNull: function(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
return value;
|
return value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -327,7 +362,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
// maps from a form-friendly name to the real grant parameter name
|
// maps from a form-friendly name to the real grant parameter name
|
||||||
grantMap:{
|
grantMap: {
|
||||||
'authorization_code': 'authorization_code',
|
'authorization_code': 'authorization_code',
|
||||||
'password': 'password',
|
'password': 'password',
|
||||||
'implicit': 'implicit',
|
'implicit': 'implicit',
|
||||||
|
@ -336,8 +371,9 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
'refresh_token': 'refresh_token'
|
'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
|
||||||
responseMap:{
|
// parameter name
|
||||||
|
responseMap: {
|
||||||
'code': 'code',
|
'code': 'code',
|
||||||
'token': 'token',
|
'token': 'token',
|
||||||
'idtoken': 'id_token',
|
'idtoken': 'id_token',
|
||||||
|
@ -347,7 +383,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
'code-token-idtoken': 'code token id_token'
|
'code-token-idtoken': 'code token id_token'
|
||||||
},
|
},
|
||||||
|
|
||||||
saveClient:function (e) {
|
saveClient: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$('.control-group').removeClass('error');
|
$('.control-group').removeClass('error');
|
||||||
|
@ -362,7 +398,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
// build the grant type object
|
// build the grant type object
|
||||||
var grantTypes = [];
|
var grantTypes = [];
|
||||||
$.each(this.grantMap, function(index,type) {
|
$.each(this.grantMap, function(index, type) {
|
||||||
if ($('#grantTypes-' + index).is(':checked')) {
|
if ($('#grantTypes-' + index).is(':checked')) {
|
||||||
grantTypes.push(type);
|
grantTypes.push(type);
|
||||||
}
|
}
|
||||||
|
@ -370,7 +406,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
// build the response type object
|
// build the response type object
|
||||||
var responseTypes = [];
|
var responseTypes = [];
|
||||||
$.each(this.responseMap, function(index,type) {
|
$.each(this.responseMap, function(index, type) {
|
||||||
if ($('#responseTypes-' + index).is(':checked')) {
|
if ($('#responseTypes-' + index).is(':checked')) {
|
||||||
responseTypes.push(type);
|
responseTypes.push(type);
|
||||||
}
|
}
|
||||||
|
@ -384,12 +420,13 @@ 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 subjectType = $('#subjectType input').filter(':checked').val();
|
||||||
var redirectUris = this.redirectUrisCollection.pluck("item");
|
var redirectUris = this.redirectUrisCollection.pluck("item");
|
||||||
var sectorIdentifierUri = $('#sectorIdentifierUri input').val();
|
var sectorIdentifierUri = $('#sectorIdentifierUri input').val();
|
||||||
if (subjectType == 'PAIRWISE' && redirectUris.length > 1 && sectorIdentifierUri == '') {
|
if (subjectType == 'PAIRWISE' && redirectUris.length > 1 && sectorIdentifierUri == '') {
|
||||||
//Display an alert with an error message
|
// Display an alert with an error message
|
||||||
app.errorHandlerView.showErrorMessage($.t("client.client-form.error.consistency"), $.t("client.client-form.error.pairwise-sector"));
|
app.errorHandlerView.showErrorMessage($.t("client.client-form.error.consistency"), $.t("client.client-form.error.pairwise-sector"));
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -418,9 +455,9 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var attrs = {
|
var attrs = {
|
||||||
client_name:this.emptyToNull($('#clientName input').val()),
|
client_name: this.emptyToNull($('#clientName input').val()),
|
||||||
redirect_uris: redirectUris,
|
redirect_uris: redirectUris,
|
||||||
logo_uri:this.emptyToNull($('#logoUri input').val()),
|
logo_uri: this.emptyToNull($('#logoUri input').val()),
|
||||||
grant_types: grantTypes,
|
grant_types: grantTypes,
|
||||||
scope: scopes,
|
scope: scopes,
|
||||||
client_secret: null, // never send a client secret
|
client_secret: null, // never send a client secret
|
||||||
|
@ -457,7 +494,7 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
};
|
};
|
||||||
|
|
||||||
// set all empty strings to nulls
|
// set all empty strings to nulls
|
||||||
for (var key in attrs) {
|
for ( var key in attrs) {
|
||||||
if (attrs[key] === "") {
|
if (attrs[key] === "") {
|
||||||
attrs[key] = null;
|
attrs[key] = null;
|
||||||
}
|
}
|
||||||
|
@ -465,31 +502,42 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.model.save(attrs, {
|
this.model.save(attrs, {
|
||||||
success:function () {
|
success: function() {
|
||||||
// switch to an "edit" view
|
// switch to an "edit" view
|
||||||
app.navigate('dev/dynreg/edit', {trigger: true});
|
app.navigate('dev/dynreg/edit', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
_self.remove();
|
_self.remove();
|
||||||
|
|
||||||
var userInfo = getUserInfo();
|
var userInfo = getUserInfo();
|
||||||
var contacts = _self.model.get("contacts");
|
var contacts = _self.model.get("contacts");
|
||||||
if (userInfo != null && userInfo.email != null && ! _.contains(contacts, userInfo.email)) {
|
if (userInfo != null && userInfo.email != null && !_.contains(contacts, userInfo.email)) {
|
||||||
contacts.push(userInfo.email);
|
contacts.push(userInfo.email);
|
||||||
}
|
}
|
||||||
_self.model.set({
|
_self.model.set({
|
||||||
contacts: contacts
|
contacts: contacts
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
|
||||||
if (_self.model.get("jwks")) {
|
if (_self.model.get("jwks")) {
|
||||||
_self.model.set({
|
_self.model.set({
|
||||||
jwksType: "VAL"
|
jwksType: "VAL"
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
_self.model.set({
|
_self.model.set({
|
||||||
jwksType: "URI"
|
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() {
|
view.load(function() {
|
||||||
// reload
|
// reload
|
||||||
|
@ -497,14 +545,20 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
view.delegateEvents();
|
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;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
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.el).html(this.template(data));
|
||||||
|
|
||||||
this.listWidgetViews = [];
|
this.listWidgetViews = [];
|
||||||
|
@ -512,94 +566,115 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
// build and bind registered redirect URI collection and view
|
// build and bind registered redirect URI collection and view
|
||||||
_.each(this.model.get("redirect_uris"), function (redirectUri) {
|
_.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({
|
var redirectUriView = new ListWidgetView({
|
||||||
type:'uri',
|
type: 'uri',
|
||||||
placeholder: 'https://',
|
placeholder: 'https://',
|
||||||
helpBlockText: $.t('client.client-form.redirect-uris-help'),
|
helpBlockText: $.t('client.client-form.redirect-uris-help'),
|
||||||
collection: this.redirectUrisCollection});
|
collection: this.redirectUrisCollection
|
||||||
$("#redirectUris .controls",this.el).html(redirectUriView.render().el);
|
});
|
||||||
|
$("#redirectUris .controls", this.el).html(redirectUriView.render().el);
|
||||||
this.listWidgetViews.push(redirectUriView);
|
this.listWidgetViews.push(redirectUriView);
|
||||||
|
|
||||||
// build and bind scopes
|
// build and bind scopes
|
||||||
var scopes = this.model.get("scope");
|
var scopes = this.model.get("scope");
|
||||||
var scopeSet = scopes ? scopes.split(" ") : [];
|
var scopeSet = scopes ? scopes.split(" ") : [];
|
||||||
_.each(scopeSet, function (scope) {
|
_.each(scopeSet, function(scope) {
|
||||||
_self.scopeCollection.add(new Backbone.Model({item:scope}));
|
_self.scopeCollection.add(new Backbone.Model({
|
||||||
|
item: scope
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
var scopeView = new ListWidgetView({
|
var scopeView = new ListWidgetView({
|
||||||
placeholder: $.t('client.client-form.scope-placeholder'),
|
placeholder: $.t('client.client-form.scope-placeholder'),
|
||||||
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.unrestrictedScopes().pluck("value"))),
|
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.unrestrictedScopes().pluck("value"))),
|
||||||
helpBlockText: $.t('client.client-form.scope-help'),
|
helpBlockText: $.t('client.client-form.scope-help'),
|
||||||
collection: this.scopeCollection});
|
collection: this.scopeCollection
|
||||||
$("#scope .controls",this.el).html(scopeView.render().el);
|
});
|
||||||
|
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||||
this.listWidgetViews.push(scopeView);
|
this.listWidgetViews.push(scopeView);
|
||||||
|
|
||||||
// build and bind contacts
|
// build and bind contacts
|
||||||
_.each(this.model.get('contacts'), function (contact) {
|
_.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({
|
var contactView = new ListWidgetView({
|
||||||
placeholder: $.t('client.client-form.contacts-placeholder'),
|
placeholder: $.t('client.client-form.contacts-placeholder'),
|
||||||
helpBlockText: $.t('client.client-form.contacts-help'),
|
helpBlockText: $.t('client.client-form.contacts-help'),
|
||||||
collection: this.contactsCollection});
|
collection: this.contactsCollection
|
||||||
|
});
|
||||||
$("#contacts .controls div", this.el).html(contactView.render().el);
|
$("#contacts .controls div", this.el).html(contactView.render().el);
|
||||||
this.listWidgetViews.push(contactView);
|
this.listWidgetViews.push(contactView);
|
||||||
|
|
||||||
// build and bind post-logout redirect URIs
|
// build and bind post-logout redirect URIs
|
||||||
_.each(this.model.get('post_logout_redirect_uris'), function(postLogoutRedirectUri) {
|
_.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({
|
var postLogoutRedirectUrisView = new ListWidgetView({
|
||||||
type: 'uri',
|
type: 'uri',
|
||||||
placeholder: 'https://',
|
placeholder: 'https://',
|
||||||
helpBlockText: $.t('client.client-form.post-logout-help'),
|
helpBlockText: $.t('client.client-form.post-logout-help'),
|
||||||
collection: this.postLogoutRedirectUrisCollection});
|
collection: this.postLogoutRedirectUrisCollection
|
||||||
|
});
|
||||||
$('#postLogoutRedirectUris .controls', this.el).html(postLogoutRedirectUrisView.render().el);
|
$('#postLogoutRedirectUris .controls', this.el).html(postLogoutRedirectUrisView.render().el);
|
||||||
this.listWidgetViews.push(postLogoutRedirectUrisView);
|
this.listWidgetViews.push(postLogoutRedirectUrisView);
|
||||||
|
|
||||||
// build and bind claims redirect URIs
|
// build and bind claims redirect URIs
|
||||||
_.each(this.model.get('claimsRedirectUris'), function(claimsRedirectUri) {
|
_.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({
|
var claimsRedirectUrisView = new ListWidgetView({
|
||||||
type: 'uri',
|
type: 'uri',
|
||||||
placeholder: 'https://',
|
placeholder: 'https://',
|
||||||
helpBlockText: $.t('client.client-form.claims-redirect-uris-help'),
|
helpBlockText: $.t('client.client-form.claims-redirect-uris-help'),
|
||||||
collection: this.claimsRedirectUrisCollection});
|
collection: this.claimsRedirectUrisCollection
|
||||||
|
});
|
||||||
$('#claimsRedirectUris .controls', this.el).html(claimsRedirectUrisView.render().el);
|
$('#claimsRedirectUris .controls', this.el).html(claimsRedirectUrisView.render().el);
|
||||||
this.listWidgetViews.push(claimsRedirectUrisView);
|
this.listWidgetViews.push(claimsRedirectUrisView);
|
||||||
|
|
||||||
// build and bind request URIs
|
// build and bind request URIs
|
||||||
_.each(this.model.get('request_uris'), function (requestUri) {
|
_.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({
|
var requestUriView = new ListWidgetView({
|
||||||
type: 'uri',
|
type: 'uri',
|
||||||
placeholder: 'https://',
|
placeholder: 'https://',
|
||||||
helpBlockText: $.t('client.client-form.request-uri-help'),
|
helpBlockText: $.t('client.client-form.request-uri-help'),
|
||||||
collection: this.requestUrisCollection});
|
collection: this.requestUrisCollection
|
||||||
|
});
|
||||||
$('#requestUris .controls', this.el).html(requestUriView.render().el);
|
$('#requestUris .controls', this.el).html(requestUriView.render().el);
|
||||||
this.listWidgetViews.push(requestUriView);
|
this.listWidgetViews.push(requestUriView);
|
||||||
|
|
||||||
// build and bind default ACR values
|
// build and bind default ACR values
|
||||||
_.each(this.model.get('default_acr_values'), function (defaultAcrValue) {
|
_.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({
|
var defaultAcrView = new ListWidgetView({
|
||||||
placeholder: $.t('client.client-form.acr-values-placeholder'),
|
placeholder: $.t('client.client-form.acr-values-placeholder'),
|
||||||
// TODO: autocomplete from spec
|
// TODO: autocomplete from spec
|
||||||
helpBlockText: $.t('client.client-form.acr-values-help'),
|
helpBlockText: $.t('client.client-form.acr-values-help'),
|
||||||
collection: this.defaultAcrValuesCollection});
|
collection: this.defaultAcrValuesCollection
|
||||||
|
});
|
||||||
$('#defaultAcrValues .controls', this.el).html(defaultAcrView.render().el);
|
$('#defaultAcrValues .controls', this.el).html(defaultAcrView.render().el);
|
||||||
this.listWidgetViews.push(defaultAcrView);
|
this.listWidgetViews.push(defaultAcrView);
|
||||||
|
|
||||||
|
@ -623,23 +698,29 @@ var DynRegEditView = Backbone.View.extend({
|
||||||
content: $.t('common.not-yet-implemented-content')
|
content: $.t('common.not-yet-implemented-content')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.routes.push({path: "dev/dynreg", name: "dynReg", callback:
|
ui.routes.push({
|
||||||
function() {
|
path: "dev/dynreg",
|
||||||
|
name: "dynReg",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.self-service-client'), href:"manage/#dev/dynreg"}
|
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');
|
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:
|
ui.routes.push({
|
||||||
function() {
|
path: "dev/dynreg/new",
|
||||||
|
name: "newDynReg",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.self-service-client'), href:"manage/#dev/dynreg"},
|
href: ""
|
||||||
{text:$.t('dynreg.new-client'), href:"manage/#dev/dynreg/new"}
|
}, {
|
||||||
]);
|
text: $.t('admin.self-service-client'),
|
||||||
|
href: "manage/#dev/dynreg"
|
||||||
|
}, {
|
||||||
|
text: $.t('dynreg.new-client'),
|
||||||
|
href: "manage/#dev/dynreg/new"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('dev/dynreg');
|
this.updateSidebar('dev/dynreg');
|
||||||
|
|
||||||
var client = new DynRegClient();
|
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() {
|
view.load(function() {
|
||||||
|
|
||||||
|
@ -677,26 +768,30 @@ ui.routes.push({path: "dev/dynreg/new", name: "newDynReg", callback:
|
||||||
|
|
||||||
if (heartMode) {
|
if (heartMode) {
|
||||||
client.set({
|
client.set({
|
||||||
require_auth_time:true,
|
require_auth_time: true,
|
||||||
default_max_age:60000,
|
default_max_age: 60000,
|
||||||
scope: _.uniq(_.flatten(app.systemScopeList.defaultUnrestrictedScopes().pluck("value"))).join(" "),
|
scope: _.uniq(_.flatten(app.systemScopeList.defaultUnrestrictedScopes().pluck("value"))).join(" "),
|
||||||
token_endpoint_auth_method: 'private_key_jwt',
|
token_endpoint_auth_method: 'private_key_jwt',
|
||||||
grant_types: ["authorization_code"],
|
grant_types: ["authorization_code"],
|
||||||
response_types: ["code"],
|
response_types: ["code"],
|
||||||
subject_type: "public",
|
subject_type: "public",
|
||||||
contacts: contacts
|
contacts: contacts
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
client.set({
|
client.set({
|
||||||
require_auth_time:true,
|
require_auth_time: true,
|
||||||
default_max_age:60000,
|
default_max_age: 60000,
|
||||||
scope: _.uniq(_.flatten(app.systemScopeList.defaultUnrestrictedScopes().pluck("value"))).join(" "),
|
scope: _.uniq(_.flatten(app.systemScopeList.defaultUnrestrictedScopes().pluck("value"))).join(" "),
|
||||||
token_endpoint_auth_method: 'client_secret_basic',
|
token_endpoint_auth_method: 'client_secret_basic',
|
||||||
grant_types: ["authorization_code"],
|
grant_types: ["authorization_code"],
|
||||||
response_types: ["code"],
|
response_types: ["code"],
|
||||||
subject_type: "public",
|
subject_type: "public",
|
||||||
contacts: contacts
|
contacts: contacts
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#content').html(view.render().el);
|
$('#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:
|
ui.routes.push({
|
||||||
function() {
|
path: "dev/dynreg/edit",
|
||||||
|
name: "editDynReg",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.self-service-client'), href:"manage/#dev/dynreg"},
|
href: ""
|
||||||
{text:$.t('dynreg.edit-existing'), href:"manage/#dev/dynreg/edit"}
|
}, {
|
||||||
]);
|
text: $.t('admin.self-service-client'),
|
||||||
|
href: "manage/#dev/dynreg"
|
||||||
|
}, {
|
||||||
|
text: $.t('dynreg.edit-existing'),
|
||||||
|
href: "manage/#dev/dynreg/edit"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('dev/dynreg');
|
this.updateSidebar('dev/dynreg');
|
||||||
|
|
||||||
setPageTitle($.t('dynreg.edit-existing'));
|
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,56 +17,63 @@
|
||||||
var ApprovedSiteModel = Backbone.Model.extend({
|
var ApprovedSiteModel = Backbone.Model.extend({
|
||||||
idAttribute: 'id',
|
idAttribute: 'id',
|
||||||
|
|
||||||
initialize: function() { },
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
urlRoot: 'api/approved'
|
urlRoot: 'api/approved'
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var ApprovedSiteCollection = Backbone.Collection.extend({
|
var ApprovedSiteCollection = Backbone.Collection.extend({
|
||||||
initialize: function() { },
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
model: ApprovedSiteModel,
|
model: ApprovedSiteModel,
|
||||||
url: 'api/approved'
|
url: 'api/approved'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var ApprovedSiteListView = Backbone.View.extend({
|
var ApprovedSiteListView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.model.isFetched &&
|
if (this.model.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||||
this.options.clientList.isFetched &&
|
|
||||||
this.options.systemScopeList.isFetched) {
|
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#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> ');
|
||||||
'<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()}),
|
$.when(this.model.fetchIfNeeded({
|
||||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
$('#loading-grants').addClass('label-success');
|
||||||
.done(function() {
|
},
|
||||||
|
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');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
"click .refresh-table":"refreshTable"
|
"click .refresh-table": "refreshTable"
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
$(this.el).html($('#tmpl-grant-table').html());
|
$(this.el).html($('#tmpl-grant-table').html());
|
||||||
|
|
||||||
var approvedSiteCount = 0;
|
var approvedSiteCount = 0;
|
||||||
|
@ -79,7 +86,11 @@ var ApprovedSiteListView = Backbone.View.extend({
|
||||||
|
|
||||||
if (client != null) {
|
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;
|
view.parentView = _self;
|
||||||
$('#grant-table', this.el).append(view.render().el);
|
$('#grant-table', this.el).append(view.render().el);
|
||||||
approvedSiteCount = approvedSiteCount + 1;
|
approvedSiteCount = approvedSiteCount + 1;
|
||||||
|
@ -93,7 +104,7 @@ var ApprovedSiteListView = Backbone.View.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePlaceholder:function() {
|
togglePlaceholder: function() {
|
||||||
// count entries
|
// count entries
|
||||||
if (this.model.length > 0) {
|
if (this.model.length > 0) {
|
||||||
$('#grant-table', this.el).show();
|
$('#grant-table', this.el).show();
|
||||||
|
@ -105,20 +116,28 @@ var ApprovedSiteListView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTable:function(e) {
|
refreshTable: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var _self = this;
|
var _self = this;
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#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> ');
|
||||||
'<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()}),
|
$.when(this.model.fetch({
|
||||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error:app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
$('#loading-grants').addClass('label-success');
|
||||||
.done(function() {
|
},
|
||||||
|
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');
|
$('#loadingbox').sheet('hide');
|
||||||
_self.render();
|
_self.render();
|
||||||
});
|
});
|
||||||
|
@ -178,7 +197,7 @@ var ApprovedSiteView = Backbone.View.extend({
|
||||||
var hoverTimeoutDate = "";
|
var hoverTimeoutDate = "";
|
||||||
if (timeoutDate == null) {
|
if (timeoutDate == null) {
|
||||||
displayTimeoutDate = $.t('grant.grant-table.never');
|
displayTimeoutDate = $.t('grant.grant-table.never');
|
||||||
} else if(moment(timeoutDate).isValid()) {
|
} else if (moment(timeoutDate).isValid()) {
|
||||||
timeoutDate = moment(timeoutDate);
|
timeoutDate = moment(timeoutDate);
|
||||||
if (moment().diff(timeoutDate, 'months') < 6) {
|
if (moment().diff(timeoutDate, 'months') < 6) {
|
||||||
displayTimeoutDate = timeoutDate.fromNow();
|
displayTimeoutDate = timeoutDate.fromNow();
|
||||||
|
@ -188,21 +207,38 @@ var ApprovedSiteView = Backbone.View.extend({
|
||||||
hoverTimeoutDate = timeoutDate.format("LLL");
|
hoverTimeoutDate = timeoutDate.format("LLL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var formattedDate = {
|
||||||
|
displayCreationDate: displayCreationDate,
|
||||||
|
hoverCreationDate: hoverCreationDate,
|
||||||
|
displayAccessDate: displayAccessDate,
|
||||||
|
hoverAccessDate: hoverAccessDate,
|
||||||
|
displayTimeoutDate: displayTimeoutDate,
|
||||||
|
hoverTimeoutDate: hoverTimeoutDate
|
||||||
|
};
|
||||||
|
|
||||||
var formattedDate = {displayCreationDate: displayCreationDate, hoverCreationDate: hoverCreationDate,
|
var json = {
|
||||||
displayAccessDate: displayAccessDate, hoverAccessDate: hoverAccessDate,
|
grant: this.model.toJSON(),
|
||||||
displayTimeoutDate: displayTimeoutDate, hoverTimeoutDate: hoverTimeoutDate};
|
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));
|
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.$('.dynamically-registered').tooltip({
|
||||||
this.$('.tokens').tooltip({title: $.t('grant.grant-table.active-tokens')});
|
title: $.t('grant.grant-table.dynamically-registered')
|
||||||
|
});
|
||||||
|
this.$('.tokens').tooltip({
|
||||||
|
title: $.t('grant.grant-table.active-tokens')
|
||||||
|
});
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -212,22 +248,23 @@ var ApprovedSiteView = Backbone.View.extend({
|
||||||
'click .toggleMoreInformation': 'toggleMoreInformation'
|
'click .toggleMoreInformation': 'toggleMoreInformation'
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteApprovedSite:function(e) {
|
deleteApprovedSite: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (confirm("Are you sure you want to revoke access to this site?")) {
|
if (confirm("Are you sure you want to revoke access to this site?")) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
self.$el.fadeTo("fast", 0.00, function () { //fade
|
success: function() {
|
||||||
$(this).slideUp("fast", function () { //slide up
|
self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||||
$(this).remove(); //then remove from the DOM
|
$(this).slideUp("fast", function() { // slide up
|
||||||
|
$(this).remove(); // then remove from the DOM
|
||||||
self.parentView.togglePlaceholder();
|
self.parentView.togglePlaceholder();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.parentView.delegateEvents();
|
this.parentView.delegateEvents();
|
||||||
|
@ -236,7 +273,7 @@ var ApprovedSiteView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMoreInformation:function(e) {
|
toggleMoreInformation: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($('.moreInformation', this.el).is(':visible')) {
|
if ($('.moreInformation', this.el).is(':visible')) {
|
||||||
// hide it
|
// hide it
|
||||||
|
@ -252,30 +289,38 @@ var ApprovedSiteView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
close:function() {
|
close: function() {
|
||||||
$(this.el).unbind();
|
$(this.el).unbind();
|
||||||
$(this.el).empty();
|
$(this.el).empty();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.routes.push({path: "user/approved", name: "approvedSites", callback:
|
ui.routes.push({
|
||||||
|
path: "user/approved",
|
||||||
|
name: "approvedSites",
|
||||||
|
callback:
|
||||||
|
|
||||||
function() {
|
function() {
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('grant.manage-approved-sites'), href:"manage/#user/approve"}
|
href: ""
|
||||||
]);
|
}, {
|
||||||
|
text: $.t('grant.manage-approved-sites'),
|
||||||
|
href: "manage/#user/approve"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('user/approved');
|
this.updateSidebar('user/approved');
|
||||||
|
|
||||||
var view = new ApprovedSiteListView({model:this.approvedSiteList, clientList: this.clientList, systemScopeList: this.systemScopeList});
|
var view = new ApprovedSiteListView({
|
||||||
view.load(
|
model: this.approvedSiteList,
|
||||||
function(collection, response, options) {
|
clientList: this.clientList,
|
||||||
|
systemScopeList: this.systemScopeList
|
||||||
|
});
|
||||||
|
view.load(function(collection, response, options) {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
setPageTitle($.t('grant.manage-approved-sites'));
|
setPageTitle($.t('grant.manage-approved-sites'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,18 +14,25 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
ui.routes.push({path: "user/profile", name: "profile", callback:
|
ui.routes.push({
|
||||||
function() {
|
path: "user/profile",
|
||||||
|
name: "profile",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.user-profile.show'), href:"manage/#user/profile"}
|
href: ""
|
||||||
]);
|
}, {
|
||||||
|
text: $.t('admin.user-profile.show'),
|
||||||
|
href: "manage/#user/profile"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('user/profile');
|
this.updateSidebar('user/profile');
|
||||||
|
|
||||||
var view = new UserProfileView({model: getUserInfo()});
|
var view = new UserProfileView({
|
||||||
|
model: getUserInfo()
|
||||||
|
});
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
|
|
||||||
setPageTitle($.t('admin.user-profile.show'));
|
setPageTitle($.t('admin.user-profile.show'));
|
||||||
|
|
|
@ -17,28 +17,28 @@
|
||||||
var ResRegClient = Backbone.Model.extend({
|
var ResRegClient = Backbone.Model.extend({
|
||||||
idAttribute: "client_id",
|
idAttribute: "client_id",
|
||||||
|
|
||||||
defaults:{
|
defaults: {
|
||||||
client_id:null,
|
client_id: null,
|
||||||
client_secret:null,
|
client_secret: null,
|
||||||
client_name:null,
|
client_name: null,
|
||||||
client_uri:null,
|
client_uri: null,
|
||||||
logo_uri:null,
|
logo_uri: null,
|
||||||
contacts:[],
|
contacts: [],
|
||||||
tos_uri:null,
|
tos_uri: null,
|
||||||
token_endpoint_auth_method:null,
|
token_endpoint_auth_method: null,
|
||||||
scope:null,
|
scope: null,
|
||||||
policy_uri:null,
|
policy_uri: null,
|
||||||
|
|
||||||
jwks_uri:null,
|
jwks_uri: null,
|
||||||
jwks:null,
|
jwks: null,
|
||||||
jwksType:'URI',
|
jwksType: 'URI',
|
||||||
|
|
||||||
application_type:null,
|
application_type: null,
|
||||||
registration_access_token:null,
|
registration_access_token: null,
|
||||||
registration_client_uri:null
|
registration_client_uri: null
|
||||||
},
|
},
|
||||||
|
|
||||||
sync: function(method, model, options){
|
sync: function(method, model, options) {
|
||||||
if (model.get('registration_access_token')) {
|
if (model.get('registration_access_token')) {
|
||||||
var headers = options.headers ? options.headers : {};
|
var headers = options.headers ? options.headers : {};
|
||||||
headers['Authorization'] = 'Bearer ' + model.get('registration_access_token');
|
headers['Authorization'] = 'Bearer ' + model.get('registration_access_token');
|
||||||
|
@ -48,7 +48,7 @@ var ResRegClient = Backbone.Model.extend({
|
||||||
return this.constructor.__super__.sync(method, model, options);
|
return this.constructor.__super__.sync(method, model, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
urlRoot:'resource'
|
urlRoot: 'resource'
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -56,17 +56,17 @@ var ResRegRootView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click #newreg":"newReg",
|
"click #newreg": "newReg",
|
||||||
"click #editreg":"editReg"
|
"click #editreg": "editReg"
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.options.systemScopeList.isFetched) {
|
if (this.options.systemScopeList.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -75,26 +75,32 @@ var ResRegRootView = Backbone.View.extend({
|
||||||
$('#loadingbox').sheet('show');
|
$('#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.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
render: function() {
|
||||||
$(this.el).html($('#tmpl-rsreg').html());
|
$(this.el).html($('#tmpl-rsreg').html());
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
newReg:function(e) {
|
newReg: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.remove();
|
this.remove();
|
||||||
app.navigate('dev/resource/new', {trigger: true});
|
app.navigate('dev/resource/new', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
editReg:function(e) {
|
editReg: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var clientId = $('#clientId').val();
|
var clientId = $('#clientId').val();
|
||||||
var token = $('#regtoken').val();
|
var token = $('#regtoken').val();
|
||||||
|
@ -112,24 +118,35 @@ var ResRegRootView = Backbone.View.extend({
|
||||||
if (client.get("jwks")) {
|
if (client.get("jwks")) {
|
||||||
client.set({
|
client.set({
|
||||||
jwksType: "VAL"
|
jwksType: "VAL"
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
client.set({
|
client.set({
|
||||||
jwksType: "URI"
|
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() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
view.delegateEvents();
|
view.delegateEvents();
|
||||||
setPageTitle($.t('rsreg.new'));
|
setPageTitle($.t('rsreg.new'));
|
||||||
app.navigate('dev/resource/edit', {trigger: true});
|
app.navigate('dev/resource/edit', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
self.remove();
|
self.remove();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError({message: $.t('dynreg.invalid-access-token')})
|
error: app.errorHandlerView.handleError({
|
||||||
|
message: $.t('dynreg.invalid-access-token')
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +156,7 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-rsreg-resource-form').html());
|
this.template = _.template($('#tmpl-rsreg-resource-form').html());
|
||||||
|
@ -154,7 +171,7 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
this.listWidgetViews = [];
|
this.listWidgetViews = [];
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.options.systemScopeList.isFetched) {
|
if (this.options.systemScopeList.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -163,40 +180,49 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
$('#loadingbox').sheet('show');
|
$('#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.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error:app.errorHandlerView.handleError()}))
|
$.when(this.options.systemScopeList.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .btn-save":"saveClient",
|
"click .btn-save": "saveClient",
|
||||||
"click .btn-cancel":"cancel",
|
"click .btn-cancel": "cancel",
|
||||||
"click .btn-delete":"deleteClient",
|
"click .btn-delete": "deleteClient",
|
||||||
"change #logoUri input":"previewLogo",
|
"change #logoUri input": "previewLogo",
|
||||||
"change #tokenEndpointAuthMethod input:radio":"toggleClientCredentials",
|
"change #tokenEndpointAuthMethod input:radio": "toggleClientCredentials",
|
||||||
"change #jwkSelector input:radio":"toggleJWKSetType"
|
"change #jwkSelector input:radio": "toggleJWKSetType"
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel:function(e) {
|
cancel: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
app.navigate('dev/resource', {trigger: true});
|
app.navigate('dev/resource', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteClient:function (e) {
|
deleteClient: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t('client.client-table.confirm'))) {
|
if (confirm($.t('client.client-table.confirm'))) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
|
success: function() {
|
||||||
self.remove();
|
self.remove();
|
||||||
app.navigate('dev/resource', {trigger: true});
|
app.navigate('dev/resource', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -204,27 +230,29 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
previewLogo:function() {
|
previewLogo: function() {
|
||||||
if ($('#logoUri input', this.el).val()) {
|
if ($('#logoUri input', this.el).val()) {
|
||||||
$('#logoPreview', this.el).empty();
|
$('#logoPreview', this.el).empty();
|
||||||
$('#logoPreview', this.el).attr('src', $('#logoUri input', this.el).val());
|
$('#logoPreview', this.el).attr('src', $('#logoUri input', this.el).val());
|
||||||
} else {
|
} else {
|
||||||
//$('#logoBlock', this.el).hide();
|
// $('#logoBlock', this.el).hide();
|
||||||
$('#logoPreview', this.el).attr('src', 'resources/images/logo_placeholder.gif');
|
$('#logoPreview', this.el).attr('src', 'resources/images/logo_placeholder.gif');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @param event
|
||||||
*/
|
*/
|
||||||
toggleClientCredentials:function() {
|
toggleClientCredentials: function() {
|
||||||
|
|
||||||
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
var tokenEndpointAuthMethod = $('#tokenEndpointAuthMethod input', this.el).filter(':checked').val();
|
||||||
|
|
||||||
// show or hide the signing algorithm method depending on what's selected
|
// show or hide the signing algorithm method depending on what's
|
||||||
if (tokenEndpointAuthMethod == 'private_key_jwt'
|
// selected
|
||||||
|| tokenEndpointAuthMethod == 'client_secret_jwt') {
|
if (tokenEndpointAuthMethod == 'private_key_jwt' || tokenEndpointAuthMethod == 'client_secret_jwt') {
|
||||||
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
$('#tokenEndpointAuthSigningAlg', this.el).show();
|
||||||
} else {
|
} else {
|
||||||
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
$('#tokenEndpointAuthSigningAlg', this.el).hide();
|
||||||
|
@ -234,7 +262,7 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
/**
|
/**
|
||||||
* Set up the form based on the JWK Set selector
|
* Set up the form based on the JWK Set selector
|
||||||
*/
|
*/
|
||||||
toggleJWKSetType:function() {
|
toggleJWKSetType: function() {
|
||||||
var jwkSelector = $('#jwkSelector input:radio', this.el).filter(':checked').val();
|
var jwkSelector = $('#jwkSelector input:radio', this.el).filter(':checked').val();
|
||||||
|
|
||||||
if (jwkSelector == 'URI') {
|
if (jwkSelector == 'URI') {
|
||||||
|
@ -250,13 +278,13 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
disableUnsupportedJOSEItems:function(serverSupported, query) {
|
disableUnsupportedJOSEItems: function(serverSupported, query) {
|
||||||
var supported = ['default'];
|
var supported = ['default'];
|
||||||
if (serverSupported) {
|
if (serverSupported) {
|
||||||
supported = _.union(supported, serverSupported);
|
supported = _.union(supported, serverSupported);
|
||||||
}
|
}
|
||||||
$(query, this.$el).each(function(idx) {
|
$(query, this.$el).each(function(idx) {
|
||||||
if(_.contains(supported, $(this).val())) {
|
if (_.contains(supported, $(this).val())) {
|
||||||
$(this).prop('disabled', false);
|
$(this).prop('disabled', false);
|
||||||
} else {
|
} else {
|
||||||
$(this).prop('disabled', true);
|
$(this).prop('disabled', true);
|
||||||
|
@ -265,8 +293,10 @@ 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,
|
||||||
defaultToNull:function(value) {
|
// otherwise returns input value. useful for parsing the JOSE
|
||||||
|
// algorithm dropdowns
|
||||||
|
defaultToNull: function(value) {
|
||||||
if (value == 'default') {
|
if (value == 'default') {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -274,7 +304,7 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
saveClient:function (e) {
|
saveClient: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$('.control-group').removeClass('error');
|
$('.control-group').removeClass('error');
|
||||||
|
@ -310,7 +340,7 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("An error occurred when parsing the JWK Set");
|
console.log("An error occurred when parsing the JWK Set");
|
||||||
|
|
||||||
//Display an alert with an error message
|
// Display an alert with an error message
|
||||||
app.errorHandlerView.showErrorMessage($.t("client.client-form.error.jwk-set"), $.t("client.client-form.error.jwk-set-parse"));
|
app.errorHandlerView.showErrorMessage($.t("client.client-form.error.jwk-set"), $.t("client.client-form.error.jwk-set-parse"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -320,8 +350,8 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var attrs = {
|
var attrs = {
|
||||||
client_name:$('#clientName input').val(),
|
client_name: $('#clientName input').val(),
|
||||||
logo_uri:$('#logoUri input').val(),
|
logo_uri: $('#logoUri input').val(),
|
||||||
scope: scopes,
|
scope: scopes,
|
||||||
client_secret: null, // never send a client secret
|
client_secret: null, // never send a client secret
|
||||||
tos_uri: $('#tosUri input').val(),
|
tos_uri: $('#tosUri input').val(),
|
||||||
|
@ -336,7 +366,7 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
};
|
};
|
||||||
|
|
||||||
// set all empty strings to nulls
|
// set all empty strings to nulls
|
||||||
for (var key in attrs) {
|
for ( var key in attrs) {
|
||||||
if (attrs[key] === "") {
|
if (attrs[key] === "") {
|
||||||
attrs[key] = null;
|
attrs[key] = null;
|
||||||
}
|
}
|
||||||
|
@ -344,22 +374,31 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.model.save(attrs, {
|
this.model.save(attrs, {
|
||||||
success:function () {
|
success: function() {
|
||||||
// switch to an "edit" view
|
// switch to an "edit" view
|
||||||
app.navigate('dev/resource/edit', {trigger: true});
|
app.navigate('dev/resource/edit', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
_self.remove();
|
_self.remove();
|
||||||
|
|
||||||
if (_self.model.get("jwks")) {
|
if (_self.model.get("jwks")) {
|
||||||
_self.model.set({
|
_self.model.set({
|
||||||
jwksType: "VAL"
|
jwksType: "VAL"
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
_self.model.set({
|
_self.model.set({
|
||||||
jwksType: "URI"
|
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() {
|
view.load(function() {
|
||||||
// reload
|
// reload
|
||||||
|
@ -367,14 +406,17 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
view.delegateEvents();
|
view.delegateEvents();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function() {
|
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 = [];
|
this.listWidgetViews = [];
|
||||||
|
|
||||||
|
@ -383,31 +425,36 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
// build and bind scopes
|
// build and bind scopes
|
||||||
var scopes = this.model.get("scope");
|
var scopes = this.model.get("scope");
|
||||||
var scopeSet = scopes ? scopes.split(" ") : [];
|
var scopeSet = scopes ? scopes.split(" ") : [];
|
||||||
_.each(scopeSet, function (scope) {
|
_.each(scopeSet, function(scope) {
|
||||||
_self.scopeCollection.add(new Backbone.Model({item:scope}));
|
_self.scopeCollection.add(new Backbone.Model({
|
||||||
|
item: scope
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
var scopeView = new ListWidgetView({
|
var scopeView = new ListWidgetView({
|
||||||
placeholder: $.t('client.client-form.scope-placeholder'),
|
placeholder: $.t('client.client-form.scope-placeholder'),
|
||||||
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.unrestrictedScopes().pluck("value"))),
|
autocomplete: _.uniq(_.flatten(this.options.systemScopeList.unrestrictedScopes().pluck("value"))),
|
||||||
helpBlockText: $.t('rsreg.client-form.scope-help'),
|
helpBlockText: $.t('rsreg.client-form.scope-help'),
|
||||||
collection: this.scopeCollection});
|
collection: this.scopeCollection
|
||||||
$("#scope .controls",this.el).html(scopeView.render().el);
|
});
|
||||||
|
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||||
this.listWidgetViews.push(scopeView);
|
this.listWidgetViews.push(scopeView);
|
||||||
|
|
||||||
// build and bind contacts
|
// build and bind contacts
|
||||||
_.each(this.model.get('contacts'), function (contact) {
|
_.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({
|
var contactView = new ListWidgetView({
|
||||||
placeholder: $.t('client.client-form.contacts-placeholder'),
|
placeholder: $.t('client.client-form.contacts-placeholder'),
|
||||||
helpBlockText: $.t('client.client-form.contacts-help'),
|
helpBlockText: $.t('client.client-form.contacts-help'),
|
||||||
collection: this.contactsCollection});
|
collection: this.contactsCollection
|
||||||
|
});
|
||||||
$("#contacts .controls", this.el).html(contactView.render().el);
|
$("#contacts .controls", this.el).html(contactView.render().el);
|
||||||
this.listWidgetViews.push(contactView);
|
this.listWidgetViews.push(contactView);
|
||||||
|
|
||||||
|
|
||||||
this.toggleClientCredentials();
|
this.toggleClientCredentials();
|
||||||
this.previewLogo();
|
this.previewLogo();
|
||||||
this.toggleJWKSetType();
|
this.toggleJWKSetType();
|
||||||
|
@ -421,25 +468,31 @@ var ResRegEditView = Backbone.View.extend({
|
||||||
content: $.t('common.not-yet-implemented-content')
|
content: $.t('common.not-yet-implemented-content')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.routes.push({path: "dev/resource", name: "resReg", callback:
|
ui.routes.push({
|
||||||
function() {
|
path: "dev/resource",
|
||||||
|
name: "resReg",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.self-service-resource'), href:"manage/#dev/resource"}
|
href: ""
|
||||||
]);
|
}, {
|
||||||
|
text: $.t('admin.self-service-resource'),
|
||||||
|
href: "manage/#dev/resource"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('dev/resource');
|
this.updateSidebar('dev/resource');
|
||||||
|
|
||||||
var view = new ResRegRootView({systemScopeList: this.systemScopeList});
|
var view = new ResRegRootView({
|
||||||
|
systemScopeList: this.systemScopeList
|
||||||
|
});
|
||||||
view.load(function() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#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:
|
ui.routes.push({
|
||||||
function() {
|
path: "dev/resource/new",
|
||||||
|
name: "newResReg",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.self-service-resource'), href:"manage/#dev/resource"},
|
href: ""
|
||||||
{text:$.t('rsreg.new'), href:"manage/#dev/resource/new"}
|
}, {
|
||||||
]);
|
text: $.t('admin.self-service-resource'),
|
||||||
|
href: "manage/#dev/resource"
|
||||||
|
}, {
|
||||||
|
text: $.t('rsreg.new'),
|
||||||
|
href: "manage/#dev/resource/new"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('dev/resource');
|
this.updateSidebar('dev/resource');
|
||||||
|
|
||||||
var client = new ResRegClient();
|
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() {
|
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(" "),
|
scope: _.uniq(_.flatten(app.systemScopeList.defaultUnrestrictedScopes().pluck("value"))).join(" "),
|
||||||
token_endpoint_auth_method: 'client_secret_basic',
|
token_endpoint_auth_method: 'client_secret_basic',
|
||||||
contacts: contacts
|
contacts: contacts
|
||||||
}, { silent: true });
|
}, {
|
||||||
|
silent: true
|
||||||
|
});
|
||||||
|
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
view.delegateEvents();
|
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:
|
ui.routes.push({
|
||||||
function() {
|
path: "dev/resource/edit",
|
||||||
|
name: "editResReg",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('admin.self-service-resource'), href:"manage/#dev/resource"},
|
href: ""
|
||||||
{text:$.t('rsreg.edit'), href:"manage/#dev/resource/edit"}
|
}, {
|
||||||
]);
|
text: $.t('admin.self-service-resource'),
|
||||||
|
href: "manage/#dev/resource"
|
||||||
|
}, {
|
||||||
|
text: $.t('rsreg.edit'),
|
||||||
|
href: "manage/#dev/resource/edit"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('dev/resource');
|
this.updateSidebar('dev/resource');
|
||||||
|
|
||||||
setPageTitle($.t('rsreg.edit'));
|
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...
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
var SystemScopeModel = Backbone.Model.extend({
|
var SystemScopeModel = Backbone.Model.extend({
|
||||||
idAttribute: 'id',
|
idAttribute: 'id',
|
||||||
|
|
||||||
defaults:{
|
defaults: {
|
||||||
id:null,
|
id: null,
|
||||||
description:null,
|
description: null,
|
||||||
icon:null,
|
icon: null,
|
||||||
value:null,
|
value: null,
|
||||||
defaultScope:false,
|
defaultScope: false,
|
||||||
restricted:false
|
restricted: false
|
||||||
},
|
},
|
||||||
|
|
||||||
urlRoot: 'api/scopes'
|
urlRoot: 'api/scopes'
|
||||||
|
@ -58,7 +58,9 @@ var SystemScopeCollection = Backbone.Collection.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getByValue: function(value) {
|
getByValue: function(value) {
|
||||||
var scopes = this.where({value: value});
|
var scopes = this.where({
|
||||||
|
value: value
|
||||||
|
});
|
||||||
if (scopes.length == 1) {
|
if (scopes.length == 1) {
|
||||||
return scopes[0];
|
return scopes[0];
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,7 +74,7 @@ var SystemScopeView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
|
@ -84,43 +86,50 @@ var SystemScopeView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .btn-edit':'editScope',
|
'click .btn-edit': 'editScope',
|
||||||
'click .btn-delete':'deleteScope'
|
'click .btn-delete': 'deleteScope'
|
||||||
},
|
},
|
||||||
|
|
||||||
editScope:function(e) {
|
editScope: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
app.navigate('admin/scope/' + this.model.id, {trigger: true});
|
app.navigate('admin/scope/' + this.model.id, {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
this.$el.html(this.template(this.model.toJSON()));
|
this.$el.html(this.template(this.model.toJSON()));
|
||||||
|
|
||||||
$('.restricted', this.el).tooltip({title: $.t('scope.system-scope-table.tooltip-restricted')});
|
$('.restricted', this.el).tooltip({
|
||||||
$('.default', this.el).tooltip({title: $.t('scope.system-scope-table.tooltip-default')});
|
title: $.t('scope.system-scope-table.tooltip-restricted')
|
||||||
|
});
|
||||||
|
$('.default', this.el).tooltip({
|
||||||
|
title: $.t('scope.system-scope-table.tooltip-default')
|
||||||
|
});
|
||||||
|
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteScope:function (e) {
|
deleteScope: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t("scope.system-scope-table.confirm"))) {
|
if (confirm($.t("scope.system-scope-table.confirm"))) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
|
success: function() {
|
||||||
|
|
||||||
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||||
$(this).slideUp("fast", function () { //slide up
|
$(this).slideUp("fast", function() { // slide up
|
||||||
$(this).remove(); //then remove from the DOM
|
$(this).remove(); // then remove from the DOM
|
||||||
_self.parentView.togglePlaceholder();
|
_self.parentView.togglePlaceholder();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
_self.parentView.delegateEvents();
|
_self.parentView.delegateEvents();
|
||||||
|
@ -129,7 +138,7 @@ var SystemScopeView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
close:function () {
|
close: function() {
|
||||||
$(this.el).unbind();
|
$(this.el).unbind();
|
||||||
$(this.el).empty();
|
$(this.el).empty();
|
||||||
}
|
}
|
||||||
|
@ -138,53 +147,59 @@ var SystemScopeView = Backbone.View.extend({
|
||||||
var SystemScopeListView = Backbone.View.extend({
|
var SystemScopeListView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.model.isFetched) {
|
if (this.model.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||||
'<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()}))
|
$.when(this.model.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .new-scope":"newScope",
|
"click .new-scope": "newScope",
|
||||||
"click .refresh-table":"refreshTable"
|
"click .refresh-table": "refreshTable"
|
||||||
},
|
},
|
||||||
|
|
||||||
newScope:function(e) {
|
newScope: function(e) {
|
||||||
this.remove();
|
this.remove();
|
||||||
app.navigate('admin/scope/new', {trigger: true});
|
app.navigate('admin/scope/new', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTable:function(e) {
|
refreshTable: function(e) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html('<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> ');
|
||||||
'<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()}))
|
$.when(this.model.fetch({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
_self.render();
|
_self.render();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePlaceholder:function() {
|
togglePlaceholder: function() {
|
||||||
if (this.model.length > 0) {
|
if (this.model.length > 0) {
|
||||||
$('#scope-table', this.el).show();
|
$('#scope-table', this.el).show();
|
||||||
$('#scope-table-empty', this.el).hide();
|
$('#scope-table-empty', this.el).hide();
|
||||||
|
@ -194,15 +209,17 @@ var SystemScopeListView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function (eventName) {
|
render: function(eventName) {
|
||||||
|
|
||||||
// append and render the table structure
|
// append and render the table structure
|
||||||
$(this.el).html($('#tmpl-system-scope-table').html());
|
$(this.el).html($('#tmpl-system-scope-table').html());
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
_.each(this.model.models, function (scope) {
|
_.each(this.model.models, function(scope) {
|
||||||
var view = new SystemScopeView({model: scope});
|
var view = new SystemScopeView({
|
||||||
|
model: scope
|
||||||
|
});
|
||||||
view.parentView = _self;
|
view.parentView = _self;
|
||||||
$("#scope-table", _self.el).append(view.render().el);
|
$("#scope-table", _self.el).append(view.render().el);
|
||||||
}, this);
|
}, this);
|
||||||
|
@ -213,10 +230,11 @@ var SystemScopeListView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var SystemScopeFormView = Backbone.View.extend({
|
var SystemScopeFormView = Backbone.View
|
||||||
|
.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-system-scope-form').html());
|
this.template = _.template($('#tmpl-system-scope-form').html());
|
||||||
|
@ -229,28 +247,11 @@ var SystemScopeFormView = Backbone.View.extend({
|
||||||
if (!this.bootstrapIcons) {
|
if (!this.bootstrapIcons) {
|
||||||
this.bootstrapIcons = [];
|
this.bootstrapIcons = [];
|
||||||
|
|
||||||
var iconList = ['glass', 'music', 'search', 'envelope', 'heart', 'star', 'star-empty',
|
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',
|
||||||
'user', 'film', 'th-large', 'th', 'th-list', 'ok', 'remove', 'zoom-in',
|
'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',
|
||||||
'zoom-out', 'off', 'signal', 'cog', 'trash', 'home', 'file', 'time', 'road',
|
'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',
|
||||||
'download-alt', 'download', 'upload', 'inbox', 'play-circle', 'repeat',
|
'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',
|
||||||
'refresh', 'list-alt', 'lock', 'flag', 'headphones', 'volume-off',
|
'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',
|
||||||
'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'];
|
'wrench', 'tasks', 'filter', 'briefcase', 'fullscreen'];
|
||||||
|
|
||||||
var size = 3;
|
var size = 3;
|
||||||
|
@ -261,32 +262,38 @@ var SystemScopeFormView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
'click .btn-save':'saveScope',
|
'click .btn-save': 'saveScope',
|
||||||
'click .btn-cancel': function() {app.navigate('admin/scope', {trigger: true}); },
|
'click .btn-cancel': function() {
|
||||||
'click .btn-icon':'selectIcon'
|
app.navigate('admin/scope', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'click .btn-icon': 'selectIcon'
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.model.isFetched) {
|
if (this.model.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html('<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> ');
|
||||||
'<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()}))
|
$.when(this.model.fetchIfNeeded({
|
||||||
.done(function() {
|
success: function(e) {
|
||||||
|
$('#loading-scopes').addClass('label-success');
|
||||||
|
},
|
||||||
|
error: app.errorHandlerView.handleError()
|
||||||
|
})).done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
saveScope:function(e) {
|
saveScope: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var value = $('#value input').val();
|
var value = $('#value input').val();
|
||||||
|
@ -297,29 +304,31 @@ var SystemScopeFormView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var valid = this.model.set({
|
var valid = this.model.set({
|
||||||
value:value,
|
value: value,
|
||||||
description:$('#description textarea').val(),
|
description: $('#description textarea').val(),
|
||||||
icon:$('#iconDisplay input').val(),
|
icon: $('#iconDisplay input').val(),
|
||||||
defaultScope:$('#defaultScope input').is(':checked'),
|
defaultScope: $('#defaultScope input').is(':checked'),
|
||||||
restricted:$('#restricted input').is(':checked')
|
restricted: $('#restricted input').is(':checked')
|
||||||
});
|
});
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.model.save({}, {
|
this.model.save({}, {
|
||||||
success:function() {
|
success: function() {
|
||||||
app.systemScopeList.add(_self.model);
|
app.systemScopeList.add(_self.model);
|
||||||
app.navigate('admin/scope', {trigger: true});
|
app.navigate('admin/scope', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectIcon:function(e) {
|
selectIcon: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var icon = e.target.value;
|
var icon = e.target.value;
|
||||||
|
@ -338,17 +347,21 @@ var SystemScopeFormView = Backbone.View.extend({
|
||||||
render: function(eventName) {
|
render: function(eventName) {
|
||||||
this.$el.html(this.template(this.model.toJSON()));
|
this.$el.html(this.template(this.model.toJSON()));
|
||||||
|
|
||||||
_.each(this.bootstrapIcons, function (items) {
|
_.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);
|
||||||
|
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.routes.push({path: "admin/scope", name: "siteScope", callback:
|
ui.routes.push({
|
||||||
function() {
|
path: "admin/scope",
|
||||||
|
name: "siteScope",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -356,14 +369,19 @@ ui.routes.push({path: "admin/scope", name: "siteScope", callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('scope.manage'), href:"manage/#admin/scope"}
|
href: ""
|
||||||
]);
|
}, {
|
||||||
|
text: $.t('scope.manage'),
|
||||||
|
href: "manage/#admin/scope"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('admin/scope');
|
this.updateSidebar('admin/scope');
|
||||||
|
|
||||||
var view = new SystemScopeListView({model:this.systemScopeList});
|
var view = new SystemScopeListView({
|
||||||
|
model: this.systemScopeList
|
||||||
|
});
|
||||||
|
|
||||||
view.load(function() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#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:
|
ui.routes.push({
|
||||||
function() {
|
path: "admin/scope/new",
|
||||||
|
name: "newScope",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -384,17 +403,24 @@ ui.routes.push({path: "admin/scope/new", name:"newScope", callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('scope.manage'), href:"manage/#admin/scope"},
|
href: ""
|
||||||
{text:$.t('scope.system-scope-form.new'), href:"manage/#admin/scope/new"}
|
}, {
|
||||||
]);
|
text: $.t('scope.manage'),
|
||||||
|
href: "manage/#admin/scope"
|
||||||
|
}, {
|
||||||
|
text: $.t('scope.system-scope-form.new'),
|
||||||
|
href: "manage/#admin/scope/new"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('admin/scope');
|
this.updateSidebar('admin/scope');
|
||||||
|
|
||||||
var scope = new SystemScopeModel();
|
var scope = new SystemScopeModel();
|
||||||
|
|
||||||
var view = new SystemScopeFormView({model:scope});
|
var view = new SystemScopeFormView({
|
||||||
|
model: scope
|
||||||
|
});
|
||||||
view.load(function() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
setPageTitle($.t('scope.system-scope-form.new'));
|
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:
|
ui.routes.push({
|
||||||
function(sid) {
|
path: "admin/scope/:id",
|
||||||
|
name: "editScope",
|
||||||
|
callback: function(sid) {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -412,20 +440,29 @@ ui.routes.push({path: "admin/scope/:id", name: "editScope", callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('scope.manage'), href:"manage/#admin/scope"},
|
href: ""
|
||||||
{text:$.t('scope.system-scope-form.edit'), href:"manage/#admin/scope/" + sid}
|
}, {
|
||||||
]);
|
text: $.t('scope.manage'),
|
||||||
|
href: "manage/#admin/scope"
|
||||||
|
}, {
|
||||||
|
text: $.t('scope.system-scope-form.edit'),
|
||||||
|
href: "manage/#admin/scope/" + sid
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('admin/scope');
|
this.updateSidebar('admin/scope');
|
||||||
|
|
||||||
var scope = this.systemScopeList.get(sid);
|
var scope = this.systemScopeList.get(sid);
|
||||||
if (!scope) {
|
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() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
setPageTitle($.t('scope.system-scope-form.new'));
|
setPageTitle($.t('scope.system-scope-form.new'));
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
var AccessTokenModel = Backbone.Model.extend({
|
var AccessTokenModel = Backbone.Model.extend({
|
||||||
idAttribute: 'id',
|
idAttribute: 'id',
|
||||||
|
|
||||||
defaults:{
|
defaults: {
|
||||||
id:null,
|
id: null,
|
||||||
value:null,
|
value: null,
|
||||||
refreshTokenId:null,
|
refreshTokenId: null,
|
||||||
scopes:[],
|
scopes: [],
|
||||||
clientId:null,
|
clientId: null,
|
||||||
userId:null,
|
userId: null,
|
||||||
expiration:null
|
expiration: null
|
||||||
},
|
},
|
||||||
|
|
||||||
urlRoot: 'api/tokens/access'
|
urlRoot: 'api/tokens/access'
|
||||||
|
@ -44,7 +44,7 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
|
@ -64,12 +64,12 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .btn-delete':'deleteToken',
|
'click .btn-delete': 'deleteToken',
|
||||||
'click .token-substring':'showTokenValue',
|
'click .token-substring': 'showTokenValue',
|
||||||
'click .toggleMoreInformation': 'toggleMoreInformation'
|
'click .toggleMoreInformation': 'toggleMoreInformation'
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
|
|
||||||
var expirationDate = this.model.get("expiration");
|
var expirationDate = this.model.get("expiration");
|
||||||
|
|
||||||
|
@ -81,7 +81,11 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
expirationDate = moment(expirationDate).calendar();
|
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));
|
this.$el.html(this.template(json));
|
||||||
|
|
||||||
|
@ -89,15 +93,20 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
$('.token-full', this.el).hide();
|
$('.token-full', this.el).hide();
|
||||||
|
|
||||||
// show scopes
|
// 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();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteToken:function (e) {
|
deleteToken: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t("token.token-table.confirm"))) {
|
if (confirm($.t("token.token-table.confirm"))) {
|
||||||
|
@ -105,18 +114,20 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
|
success: function() {
|
||||||
|
|
||||||
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||||
$(this).slideUp("fast", function () { //slide up
|
$(this).slideUp("fast", function() { // slide up
|
||||||
$(this).remove(); //then remove from the DOM
|
$(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();
|
_self.parentView.refreshTable();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.parentView.delegateEvents();
|
this.parentView.delegateEvents();
|
||||||
|
@ -125,7 +136,7 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMoreInformation:function(e) {
|
toggleMoreInformation: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($('.moreInformation', this.el).is(':visible')) {
|
if ($('.moreInformation', this.el).is(':visible')) {
|
||||||
// hide it
|
// hide it
|
||||||
|
@ -141,12 +152,12 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
close:function () {
|
close: function() {
|
||||||
$(this.el).unbind();
|
$(this.el).unbind();
|
||||||
$(this.el).empty();
|
$(this.el).empty();
|
||||||
},
|
},
|
||||||
|
|
||||||
showTokenValue:function (e) {
|
showTokenValue: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.token-substring', this.el).hide();
|
$('.token-substring', this.el).hide();
|
||||||
$('.token-full', this.el).show();
|
$('.token-full', this.el).show();
|
||||||
|
@ -156,13 +167,13 @@ var AccessTokenView = Backbone.View.extend({
|
||||||
var RefreshTokenModel = Backbone.Model.extend({
|
var RefreshTokenModel = Backbone.Model.extend({
|
||||||
idAttribute: 'id',
|
idAttribute: 'id',
|
||||||
|
|
||||||
defaults:{
|
defaults: {
|
||||||
id:null,
|
id: null,
|
||||||
value:null,
|
value: null,
|
||||||
scopes:[],
|
scopes: [],
|
||||||
clientId:null,
|
clientId: null,
|
||||||
userId:null,
|
userId: null,
|
||||||
expiration:null
|
expiration: null
|
||||||
},
|
},
|
||||||
|
|
||||||
urlRoot: 'api/tokens/refresh'
|
urlRoot: 'api/tokens/refresh'
|
||||||
|
@ -181,7 +192,7 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
|
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
|
@ -201,12 +212,12 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .btn-delete':'deleteToken',
|
'click .btn-delete': 'deleteToken',
|
||||||
'click .token-substring':'showTokenValue',
|
'click .token-substring': 'showTokenValue',
|
||||||
'click .toggleMoreInformation': 'toggleMoreInformation'
|
'click .toggleMoreInformation': 'toggleMoreInformation'
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
|
|
||||||
var expirationDate = this.model.get("expiration");
|
var expirationDate = this.model.get("expiration");
|
||||||
|
|
||||||
|
@ -218,7 +229,12 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
expirationDate = moment(expirationDate).calendar();
|
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));
|
this.$el.html(this.template(json));
|
||||||
|
|
||||||
|
@ -226,16 +242,21 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
$('.token-full', this.el).hide();
|
$('.token-full', this.el).hide();
|
||||||
|
|
||||||
// show scopes
|
// 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();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteToken:function (e) {
|
deleteToken: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t('token.token-table.confirm-refresh'))) {
|
if (confirm($.t('token.token-table.confirm-refresh'))) {
|
||||||
|
@ -243,18 +264,20 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
|
success: function() {
|
||||||
|
|
||||||
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||||
$(this).slideUp("fast", function () { //slide up
|
$(this).slideUp("fast", function() { // slide up
|
||||||
$(this).remove(); //then remove from the DOM
|
$(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();
|
_self.parentView.refreshTable();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
_self.parentView.delegateEvents();
|
_self.parentView.delegateEvents();
|
||||||
|
@ -263,7 +286,7 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMoreInformation:function(e) {
|
toggleMoreInformation: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($('.moreInformation', this.el).is(':visible')) {
|
if ($('.moreInformation', this.el).is(':visible')) {
|
||||||
// hide it
|
// hide it
|
||||||
|
@ -279,12 +302,12 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
close:function () {
|
close: function() {
|
||||||
$(this.el).unbind();
|
$(this.el).unbind();
|
||||||
$(this.el).empty();
|
$(this.el).empty();
|
||||||
},
|
},
|
||||||
|
|
||||||
showTokenValue:function (e) {
|
showTokenValue: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.token-substring', this.el).hide();
|
$('.token-substring', this.el).hide();
|
||||||
$('.token-full', this.el).show();
|
$('.token-full', this.el).show();
|
||||||
|
@ -294,46 +317,58 @@ var RefreshTokenView = Backbone.View.extend({
|
||||||
var TokenListView = Backbone.View.extend({
|
var TokenListView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .refresh-table":"refreshTable",
|
"click .refresh-table": "refreshTable",
|
||||||
'page .paginator-access':'changePageAccess',
|
'page .paginator-access': 'changePageAccess',
|
||||||
'page .paginator-refresh':'changePageRefresh'
|
'page .paginator-refresh': 'changePageRefresh'
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.model.access.isFetched &&
|
if (this.model.access.isFetched && this.model.refresh.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||||
this.model.refresh.isFetched &&
|
|
||||||
this.options.clientList.isFetched &&
|
|
||||||
this.options.systemScopeList.isFetched) {
|
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html(
|
||||||
'<span class="label" id="loading-access">' + $.t('token.token-table.access-tokens') + '</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">'
|
||||||
'<span class="label" id="loading-refresh">' + $.t('token.token-table.refresh-tokens') + '</span> ' +
|
+ $.t('common.scopes') + '</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()}),
|
$.when(this.model.access.fetchIfNeeded({
|
||||||
this.model.refresh.fetchIfNeeded({success:function(e) {$('#loading-refresh').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
$('#loading-access').addClass('label-success');
|
||||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
},
|
||||||
.done(function() {
|
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');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
changePageAccess:function(event, num) {
|
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) {
|
$('#access-token-table tbody tr', this.el).each(function(index, element) {
|
||||||
if (Math.ceil((index + 1) / 10) != num) {
|
if (Math.ceil((index + 1) / 10) != num) {
|
||||||
$(element).hide();
|
$(element).hide();
|
||||||
|
@ -343,8 +378,10 @@ var TokenListView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
changePageRefresh:function(event, num) {
|
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) {
|
$('#refresh-token-table tbody tr', this.el).each(function(index, element) {
|
||||||
if (Math.ceil((index + 1) / 10) != num) {
|
if (Math.ceil((index + 1) / 10) != num) {
|
||||||
$(element).hide();
|
$(element).hide();
|
||||||
|
@ -354,26 +391,39 @@ var TokenListView = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTable:function(e) {
|
refreshTable: function(e) {
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html(
|
||||||
'<span class="label" id="loading-access">' + $.t('token.token-table.access-tokens') + '</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">'
|
||||||
'<span class="label" id="loading-refresh">' + $.t('token.token-table.refresh-tokens') + '</span> ' +
|
+ $.t('common.scopes') + '</span> ');
|
||||||
'<span class="label" id="loading-clients">' + $.t('common.clients') + '</span> ' +
|
|
||||||
'<span class="label" id="loading-scopes">' + $.t('common.scopes') + '</span> '
|
|
||||||
);
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
$.when(this.model.access.fetch({success:function(e) {$('#loading-access').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
$.when(this.model.access.fetch({
|
||||||
this.model.refresh.fetch({success:function(e) {$('#loading-refresh').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
$('#loading-access').addClass('label-success');
|
||||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
},
|
||||||
.done(function(){
|
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();
|
_self.render();
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePlaceholder:function() {
|
togglePlaceholder: function() {
|
||||||
if (this.model.access.length > 0) {
|
if (this.model.access.length > 0) {
|
||||||
$('#access-token-table', this.el).show();
|
$('#access-token-table', this.el).show();
|
||||||
$('#access-token-table-empty', this.el).hide();
|
$('#access-token-table-empty', this.el).hide();
|
||||||
|
@ -393,7 +443,7 @@ var TokenListView = Backbone.View.extend({
|
||||||
$('#refresh-token-count', this.el).html(this.model.refresh.length);
|
$('#refresh-token-count', this.el).html(this.model.refresh.length);
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function (eventName) {
|
render: function(eventName) {
|
||||||
|
|
||||||
// append and render the table structure
|
// append and render the table structure
|
||||||
$(this.el).html($('#tmpl-token-table').html());
|
$(this.el).html($('#tmpl-token-table').html());
|
||||||
|
@ -415,10 +465,14 @@ var TokenListView = Backbone.View.extend({
|
||||||
// count up refresh tokens
|
// count up refresh tokens
|
||||||
var refreshCount = {};
|
var refreshCount = {};
|
||||||
|
|
||||||
_.each(this.model.access.models, function (token, index) {
|
_.each(this.model.access.models, function(token, index) {
|
||||||
// look up client
|
// look up client
|
||||||
var client = _self.options.clientList.getByClientId(token.get('clientId'));
|
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;
|
view.parentView = _self;
|
||||||
var element = view.render().el;
|
var element = view.render().el;
|
||||||
$('#access-token-table', _self.el).append(element);
|
$('#access-token-table', _self.el).append(element);
|
||||||
|
@ -426,7 +480,7 @@ var TokenListView = Backbone.View.extend({
|
||||||
$(element).hide();
|
$(element).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(token.get('refreshTokenId'));
|
// console.log(token.get('refreshTokenId'));
|
||||||
var refId = token.get('refreshTokenId');
|
var refId = token.get('refreshTokenId');
|
||||||
if (refId != null) {
|
if (refId != null) {
|
||||||
if (refreshCount[refId]) {
|
if (refreshCount[refId]) {
|
||||||
|
@ -439,7 +493,7 @@ var TokenListView = Backbone.View.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//console.log(refreshCount);
|
// console.log(refreshCount);
|
||||||
|
|
||||||
// set up pagination
|
// set up pagination
|
||||||
var numPagesRefresh = Math.ceil(this.model.refresh.length / 10);
|
var numPagesRefresh = Math.ceil(this.model.refresh.length / 10);
|
||||||
|
@ -453,10 +507,15 @@ var TokenListView = Backbone.View.extend({
|
||||||
$('.paginator-refresh', this.el).hide();
|
$('.paginator-refresh', this.el).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
_.each(this.model.refresh.models, function (token, index) {
|
_.each(this.model.refresh.models, function(token, index) {
|
||||||
// look up client
|
// look up client
|
||||||
var client = _self.options.clientList.getByClientId(token.get('clientId'));
|
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;
|
view.parentView = _self;
|
||||||
var element = view.render().el;
|
var element = view.render().el;
|
||||||
$('#refresh-token-table', _self.el).append(element);
|
$('#refresh-token-table', _self.el).append(element);
|
||||||
|
@ -466,11 +525,11 @@ var TokenListView = Backbone.View.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
_.each(this.model.models, function (scope) {
|
* _.each(this.model.models, function (scope) { $("#scope-table",
|
||||||
$("#scope-table", this.el).append(new SystemScopeView({model: scope}).render().el);
|
* this.el).append(new SystemScopeView({model: scope}).render().el); },
|
||||||
}, this);
|
* this);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.togglePlaceholder();
|
this.togglePlaceholder();
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
|
@ -478,25 +537,34 @@ var TokenListView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.routes.push({
|
||||||
ui.routes.push({path: "user/tokens", name: "tokens", callback:
|
path: "user/tokens",
|
||||||
function() {
|
name: "tokens",
|
||||||
|
callback: function() {
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('token.manage'), href:"manage/#user/tokens"}
|
href: ""
|
||||||
]);
|
}, {
|
||||||
|
text: $.t('token.manage'),
|
||||||
|
href: "manage/#user/tokens"
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('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(
|
view.load(function(collection, response, options) {
|
||||||
function(collection, response, options) {
|
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
setPageTitle($.t('token.manage'));
|
setPageTitle($.t('token.manage'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,8 @@ var WhiteListModel = Backbone.Model.extend({
|
||||||
|
|
||||||
idAttribute: "id",
|
idAttribute: "id",
|
||||||
|
|
||||||
initialize: function () { },
|
initialize: function() {
|
||||||
|
},
|
||||||
|
|
||||||
urlRoot: "api/whitelist"
|
urlRoot: "api/whitelist"
|
||||||
|
|
||||||
|
@ -26,11 +27,13 @@ var WhiteListModel = Backbone.Model.extend({
|
||||||
|
|
||||||
var WhiteListCollection = Backbone.Collection.extend({
|
var WhiteListCollection = Backbone.Collection.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
//this.fetch();
|
// this.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
getByClientId: function(clientId) {
|
getByClientId: function(clientId) {
|
||||||
var clients = this.where({clientId: clientId});
|
var clients = this.where({
|
||||||
|
clientId: clientId
|
||||||
|
});
|
||||||
if (clients.length == 1) {
|
if (clients.length == 1) {
|
||||||
return clients[0];
|
return clients[0];
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,51 +49,61 @@ var WhiteListCollection = Backbone.Collection.extend({
|
||||||
var WhiteListListView = Backbone.View.extend({
|
var WhiteListListView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
if (this.model.isFetched &&
|
if (this.model.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||||
this.options.clientList.isFetched &&
|
|
||||||
this.options.systemScopeList.isFetched) {
|
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#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> ');
|
||||||
'<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()}),
|
$.when(this.model.fetchIfNeeded({
|
||||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
$('#loading-whitelist').addClass('label-success');
|
||||||
.done(function() {
|
},
|
||||||
|
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');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
"click .refresh-table":"refreshTable"
|
"click .refresh-table": "refreshTable"
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
render: function(eventName) {
|
||||||
$(this.el).html($('#tmpl-whitelist-table').html());
|
$(this.el).html($('#tmpl-whitelist-table').html());
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
_.each(this.model.models, function (whiteList) {
|
_.each(this.model.models, function(whiteList) {
|
||||||
|
|
||||||
// look up client
|
// look up client
|
||||||
var client = _self.options.clientList.getByClientId(whiteList.get('clientId'));
|
var client = _self.options.clientList.getByClientId(whiteList.get('clientId'));
|
||||||
|
|
||||||
// if there's no client ID, this is an error!
|
// if there's no client ID, this is an error!
|
||||||
if (client != null) {
|
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;
|
view.parentView = _self;
|
||||||
$('#whitelist-table', _self.el).append(view.render().el);
|
$('#whitelist-table', _self.el).append(view.render().el);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +115,7 @@ var WhiteListListView = Backbone.View.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePlaceholder:function() {
|
togglePlaceholder: function() {
|
||||||
if (this.model.length > 0) {
|
if (this.model.length > 0) {
|
||||||
$('#whitelist-table', this.el).show();
|
$('#whitelist-table', this.el).show();
|
||||||
$('#whitelist-table-empty', this.el).hide();
|
$('#whitelist-table-empty', this.el).hide();
|
||||||
|
@ -112,20 +125,28 @@ var WhiteListListView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshTable:function(e) {
|
refreshTable: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var _self = this;
|
var _self = this;
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#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> ');
|
||||||
'<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()}),
|
$.when(this.model.fetch({
|
||||||
this.options.clientList.fetch({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.systemScopeList.fetch({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
$('#loading-whitelist').addClass('label-success');
|
||||||
.done(function() {
|
},
|
||||||
|
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');
|
$('#loadingbox').sheet('hide');
|
||||||
_self.render();
|
_self.render();
|
||||||
});
|
});
|
||||||
|
@ -135,7 +156,7 @@ var WhiteListListView = Backbone.View.extend({
|
||||||
var WhiteListView = Backbone.View.extend({
|
var WhiteListView = Backbone.View.extend({
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
|
|
||||||
initialize:function(options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-whitelist').html());
|
this.template = _.template($('#tmpl-whitelist').html());
|
||||||
|
@ -152,51 +173,64 @@ var WhiteListView = Backbone.View.extend({
|
||||||
this.model.bind('change', this.render, this);
|
this.model.bind('change', this.render, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function(eventName) {
|
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));
|
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();
|
$(this.el).i18n();
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events: {
|
||||||
'click .btn-edit': 'editWhitelist',
|
'click .btn-edit': 'editWhitelist',
|
||||||
'click .btn-delete': 'deleteWhitelist',
|
'click .btn-delete': 'deleteWhitelist',
|
||||||
'click .toggleMoreInformation': 'toggleMoreInformation'
|
'click .toggleMoreInformation': 'toggleMoreInformation'
|
||||||
},
|
},
|
||||||
|
|
||||||
editWhitelist:function(e) {
|
editWhitelist: function(e) {
|
||||||
e.preventDefault();
|
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) {
|
deleteWhitelist: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (confirm($.t('whitelist.confirm'))) {
|
if (confirm($.t('whitelist.confirm'))) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
|
|
||||||
this.model.destroy({
|
this.model.destroy({
|
||||||
dataType: false, processData: false,
|
dataType: false,
|
||||||
success:function () {
|
processData: false,
|
||||||
_self.$el.fadeTo("fast", 0.00, function () { //fade
|
success: function() {
|
||||||
$(this).slideUp("fast", function () { //slide up
|
_self.$el.fadeTo("fast", 0.00, function() { // fade
|
||||||
$(this).remove(); //then remove from the DOM
|
$(this).slideUp("fast", function() { // slide up
|
||||||
|
$(this).remove(); // then remove from the DOM
|
||||||
// check the placeholder in case it's empty now
|
// check the placeholder in case it's empty now
|
||||||
_self.parentView.togglePlaceholder();
|
_self.parentView.togglePlaceholder();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
|
|
||||||
_self.parentView.delegateEvents();
|
_self.parentView.delegateEvents();
|
||||||
|
@ -205,7 +239,7 @@ var WhiteListView = Backbone.View.extend({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleMoreInformation:function(e) {
|
toggleMoreInformation: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if ($('.moreInformation', this.el).is(':visible')) {
|
if ($('.moreInformation', this.el).is(':visible')) {
|
||||||
// hide it
|
// hide it
|
||||||
|
@ -221,7 +255,7 @@ var WhiteListView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
close:function() {
|
close: function() {
|
||||||
$(this.el).unbind();
|
$(this.el).unbind();
|
||||||
$(this.el).empty();
|
$(this.el).empty();
|
||||||
}
|
}
|
||||||
|
@ -230,7 +264,7 @@ var WhiteListView = Backbone.View.extend({
|
||||||
var WhiteListFormView = Backbone.View.extend({
|
var WhiteListFormView = Backbone.View.extend({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
|
||||||
initialize:function (options) {
|
initialize: function(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-whitelist-form').html());
|
this.template = _.template($('#tmpl-whitelist-form').html());
|
||||||
|
@ -242,27 +276,34 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
load:function(callback) {
|
load: function(callback) {
|
||||||
|
|
||||||
if (this.options.client) {
|
if (this.options.client) {
|
||||||
// we know what client we're dealing with already
|
// we know what client we're dealing with already
|
||||||
if (this.model.isFetched &&
|
if (this.model.isFetched && this.options.client.isFetched) {
|
||||||
this.options.client.isFetched) {
|
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#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> ');
|
||||||
'<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()}),
|
$.when(this.model.fetchIfNeeded({
|
||||||
this.options.client.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
$('#loading-whitelist').addClass('label-success');
|
||||||
.done(function() {
|
},
|
||||||
|
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');
|
$('#loadingbox').sheet('hide');
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
@ -270,9 +311,7 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
} else {
|
} else {
|
||||||
// we need to get the client information from the list
|
// we need to get the client information from the list
|
||||||
|
|
||||||
if (this.model.isFetched &&
|
if (this.model.isFetched && this.options.clientList.isFetched && this.options.systemScopeList.isFetched) {
|
||||||
this.options.clientList.isFetched &&
|
|
||||||
this.options.systemScopeList.isFetched) {
|
|
||||||
|
|
||||||
var client = this.options.clientList.getByClientId(this.model.get('clientId'));
|
var client = this.options.clientList.getByClientId(this.model.get('clientId'));
|
||||||
this.options.client = client;
|
this.options.client = client;
|
||||||
|
@ -282,18 +321,26 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#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> ');
|
||||||
'<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;
|
var _self = this;
|
||||||
|
|
||||||
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-whitelist').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
$.when(this.model.fetchIfNeeded({
|
||||||
this.options.clientList.fetchIfNeeded({success:function(e) {$('#loading-clients').addClass('label-success');}, error: app.errorHandlerView.handleError()}),
|
success: function(e) {
|
||||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}, error: app.errorHandlerView.handleError()}))
|
$('#loading-whitelist').addClass('label-success');
|
||||||
.done(function() {
|
},
|
||||||
|
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'));
|
var client = _self.options.clientList.getByClientId(_self.model.get('clientId'));
|
||||||
_self.options.client = client;
|
_self.options.client = client;
|
||||||
|
@ -304,18 +351,15 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click .btn-save': 'saveWhiteList',
|
||||||
|
'click .btn-cancel': 'cancelWhiteList',
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
saveWhiteList: function(e) {
|
||||||
'click .btn-save':'saveWhiteList',
|
|
||||||
'click .btn-cancel':'cancelWhiteList',
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
saveWhiteList:function (e) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.control-group').removeClass('error');
|
$('.control-group').removeClass('error');
|
||||||
|
|
||||||
|
@ -327,7 +371,11 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
// process allowed scopes
|
// process allowed scopes
|
||||||
var allowedScopes = this.scopeCollection.pluck("item");
|
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({
|
var valid = this.model.set({
|
||||||
allowedScopes: allowedScopes
|
allowedScopes: allowedScopes
|
||||||
|
@ -336,11 +384,13 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
if (valid) {
|
if (valid) {
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.model.save({}, {
|
this.model.save({}, {
|
||||||
success:function () {
|
success: function() {
|
||||||
app.whiteListList.add(_self.model);
|
app.whiteListList.add(_self.model);
|
||||||
app.navigate('admin/whitelists', {trigger:true});
|
app.navigate('admin/whitelists', {
|
||||||
|
trigger: true
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error:app.errorHandlerView.handleError()
|
error: app.errorHandlerView.handleError()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,21 +398,28 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
cancelWhiteList:function(e) {
|
cancelWhiteList: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// TODO: figure out where we came from and go back there instead
|
// TODO: figure out where we came from and go back there instead
|
||||||
if (this.model.get('id') == null) {
|
if (this.model.get('id') == null) {
|
||||||
// if it's a new whitelist entry, go back to the client listing page
|
// 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 {
|
} else {
|
||||||
// if we're editing a whitelist, go back to the whitelists page
|
// 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) {
|
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));
|
this.$el.html(this.template(json));
|
||||||
|
|
||||||
|
@ -370,16 +427,19 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
// build and bind scopes
|
// build and bind scopes
|
||||||
_.each(this.model.get("allowedScopes"), function (scope) {
|
_.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({
|
var scopeView = new ListWidgetView({
|
||||||
placeholder: $.t('whitelist.whitelist-form.scope-placeholder'),
|
placeholder: $.t('whitelist.whitelist-form.scope-placeholder'),
|
||||||
autocomplete: this.options.client.get("scope"),
|
autocomplete: this.options.client.get("scope"),
|
||||||
helpBlockText: $.t('whitelist.whitelist-form.scope-help'),
|
helpBlockText: $.t('whitelist.whitelist-form.scope-help'),
|
||||||
collection: this.scopeCollection});
|
collection: this.scopeCollection
|
||||||
$("#scope .controls",this.el).html(scopeView.render().el);
|
});
|
||||||
|
$("#scope .controls", this.el).html(scopeView.render().el);
|
||||||
this.listWidgetViews.push(scopeView);
|
this.listWidgetViews.push(scopeView);
|
||||||
|
|
||||||
$(this.el).i18n();
|
$(this.el).i18n();
|
||||||
|
@ -389,9 +449,10 @@ var WhiteListFormView = Backbone.View.extend({
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.routes.push({
|
||||||
ui.routes.push({path: "admin/whitelists", name: "whiteList", callback:
|
path: "admin/whitelists",
|
||||||
function () {
|
name: "whiteList",
|
||||||
|
callback: function() {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -401,28 +462,33 @@ ui.routes.push({path: "admin/whitelists", name: "whiteList", callback:
|
||||||
this.updateSidebar('admin/whitelists');
|
this.updateSidebar('admin/whitelists');
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"}
|
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(
|
view.load(function() {
|
||||||
function() {
|
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
view.delegateEvents();
|
view.delegateEvents();
|
||||||
setPageTitle($.t('whitelist.manage'));
|
setPageTitle($.t('whitelist.manage'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.routes.push({path: "admin/whitelist/new/:cid", name: "newWhitelist", callback:
|
ui.routes.push({
|
||||||
function(cid) {
|
path: "admin/whitelist/new/:cid",
|
||||||
|
name: "newWhitelist",
|
||||||
|
callback: function(cid) {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -430,11 +496,16 @@ ui.routes.push({path: "admin/whitelist/new/:cid", name: "newWhitelist", callback
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"},
|
href: ""
|
||||||
{text:$.t('whitelist.new'), href:"manage/#admin/whitelist/new/" + cid}
|
}, {
|
||||||
]);
|
text: $.t('whitelist.manage'),
|
||||||
|
href: "manage/#admin/whitelists"
|
||||||
|
}, {
|
||||||
|
text: $.t('whitelist.new'),
|
||||||
|
href: "manage/#admin/whitelist/new/" + cid
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('admin/whitelists');
|
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);
|
var client = this.clientList.get(cid);
|
||||||
if (!client) {
|
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(
|
view.load(function() {
|
||||||
function() {
|
|
||||||
|
|
||||||
// set the scopes on the model now that everything's loaded
|
// 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);
|
$('#content').html(view.render().el);
|
||||||
view.delegateEvents();
|
view.delegateEvents();
|
||||||
setPageTitle($.t('whitelist.manage'));
|
setPageTitle($.t('whitelist.manage'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.routes.push({
|
||||||
ui.routes.push({path: "admin/whitelist/:id", name: "editWhitelist", callback:
|
path: "admin/whitelist/:id",
|
||||||
function(id) {
|
name: "editWhitelist",
|
||||||
|
callback: function(id) {
|
||||||
|
|
||||||
if (!isAdmin()) {
|
if (!isAdmin()) {
|
||||||
this.root();
|
this.root();
|
||||||
|
@ -472,28 +552,37 @@ ui.routes.push({path: "admin/whitelist/:id", name: "editWhitelist", callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
this.breadCrumbView.collection.reset();
|
this.breadCrumbView.collection.reset();
|
||||||
this.breadCrumbView.collection.add([
|
this.breadCrumbView.collection.add([{
|
||||||
{text:$.t('admin.home'), href:""},
|
text: $.t('admin.home'),
|
||||||
{text:$.t('whitelist.manage'), href:"manage/#admin/whitelists"},
|
href: ""
|
||||||
{text:$.t('whitelist.edit'), href:"manage/#admin/whitelist/" + id}
|
}, {
|
||||||
]);
|
text: $.t('whitelist.manage'),
|
||||||
|
href: "manage/#admin/whitelists"
|
||||||
|
}, {
|
||||||
|
text: $.t('whitelist.edit'),
|
||||||
|
href: "manage/#admin/whitelist/" + id
|
||||||
|
}]);
|
||||||
|
|
||||||
this.updateSidebar('admin/whitelists');
|
this.updateSidebar('admin/whitelists');
|
||||||
|
|
||||||
var whiteList = this.whiteListList.get(id);
|
var whiteList = this.whiteListList.get(id);
|
||||||
if (!whiteList) {
|
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(
|
view.load(function() {
|
||||||
function() {
|
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
view.delegateEvents();
|
view.delegateEvents();
|
||||||
setPageTitle($.t('whitelist.manage'));
|
setPageTitle($.t('whitelist.manage'));
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue