problems loading the resource set
parent
a9f531bffe
commit
53922374df
|
@ -1111,14 +1111,14 @@ var AppRouter = Backbone.Router.extend({
|
||||||
var rs = this.resourceSetList.get(rsid);
|
var rs = this.resourceSetList.get(rsid);
|
||||||
if (rs == null) {
|
if (rs == null) {
|
||||||
// need to load it directly
|
// need to load it directly
|
||||||
var policy = new PolicyCollection([], {rsid: rsid});
|
var policies = new PolicyCollection([], {rsid: rsid});
|
||||||
} else {
|
} else {
|
||||||
// the resource set is loaded, preload the claims
|
// the resource set is loaded, preload the claims
|
||||||
var policy = new PolicyCollection(rs.get('policies'), {rsid: rsid});
|
var policies = new PolicyCollection(rs.get('policies'), {rsid: rsid});
|
||||||
policy.isFetched = true;
|
policy.isFetched = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var view = new PolicyListView({model: policy, rs: rs, systemScopeList: this.systemScopeList});
|
var view = new PolicyListView({model: policies, rs: rs, systemScopeList: this.systemScopeList});
|
||||||
|
|
||||||
view.load(function() {
|
view.load(function() {
|
||||||
$('#content').html(view.render().el);
|
$('#content').html(view.render().el);
|
||||||
|
@ -1127,6 +1127,51 @@ var AppRouter = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
newPolicy:function(rsid) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
editPolicy:function(rsid, pid) {
|
||||||
|
this.breadCrumbView.collection.reset();
|
||||||
|
this.breadCrumbView.collection.add([
|
||||||
|
{text:$.t('admin.home'), href:""},
|
||||||
|
{text:$.t('policy.resource-sets'), href:"manage/#user/policy"},
|
||||||
|
{text:$.t('policy.edit-policies'), href:"manage/#user/policy/" + rsid},
|
||||||
|
{text:$.t('policy.edit-policy'), href:"manage/#user/policy/" + rsid + "/" + pid}
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.updateSidebar('user/policy');
|
||||||
|
|
||||||
|
var rs = this.resourceSetList.get(rsid);
|
||||||
|
var policy = null;
|
||||||
|
if (rs == null) {
|
||||||
|
// need to load it directly
|
||||||
|
rs = new ResourceSetModel({id: rsid});
|
||||||
|
policy = new PolicyModel({id: pid}, {rsid: rsid});
|
||||||
|
} else {
|
||||||
|
// the resource set is loaded, preload the claims
|
||||||
|
_.each(rs.get('policies'), function(p) {
|
||||||
|
if (p.id == pid) {
|
||||||
|
policy = new PolicyModel(p, {rsid: rsid});
|
||||||
|
policy.isFetched = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (policy == null) {
|
||||||
|
// need to load it directly
|
||||||
|
policy = new PolicyModel({id: pid}, {rsid: rsid});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var view = new PolicyFormView({model: policy, rs: rs, systemScopeList: this.systemScopeList});
|
||||||
|
|
||||||
|
view.load(function() {
|
||||||
|
$('#content').html(view.render().el);
|
||||||
|
setPageTitle($.t('policy.edit-policy'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
updateSidebar:function(item) {
|
updateSidebar:function(item) {
|
||||||
$('.sidebar-nav li.active').removeClass('active');
|
$('.sidebar-nav li.active').removeClass('active');
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,12 @@ var ResourceSetCollection = Backbone.Collection.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
var PolicyModel = Backbone.Model.extend({
|
var PolicyModel = Backbone.Model.extend({
|
||||||
|
urlRoot: function() {
|
||||||
|
return 'api/policy/' + this.options.rsid + '/';
|
||||||
|
},
|
||||||
|
initialize: function(model, options) {
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var PolicyCollection = Backbone.Collection.extend({
|
var PolicyCollection = Backbone.Collection.extend({
|
||||||
|
@ -242,6 +247,7 @@ var PolicyListView = Backbone.View.extend({
|
||||||
|
|
||||||
load:function(callback) {
|
load:function(callback) {
|
||||||
if (this.model.isFetched &&
|
if (this.model.isFetched &&
|
||||||
|
this.options.rs.isFetched &&
|
||||||
this.options.systemScopeList.isFetched) {
|
this.options.systemScopeList.isFetched) {
|
||||||
callback();
|
callback();
|
||||||
return;
|
return;
|
||||||
|
@ -250,10 +256,12 @@ var PolicyListView = Backbone.View.extend({
|
||||||
$('#loadingbox').sheet('show');
|
$('#loadingbox').sheet('show');
|
||||||
$('#loading').html(
|
$('#loading').html(
|
||||||
'<span class="label" id="loading-policies">' + $.t('policy.loading-policies') + '</span> ' +
|
'<span class="label" id="loading-policies">' + $.t('policy.loading-policies') + '</span> ' +
|
||||||
|
'<span class="label" id="loading-rs">' + $.t('policy.loading-rs') + '</span> ' +
|
||||||
'<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-policies').addClass('label-success');}}),
|
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-policies').addClass('label-success');}}),
|
||||||
|
this.options.rs.fetchIfNeeded({success:function(e) {$('#loading-rs').addClass('label-success');}}),
|
||||||
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||||
.done(function() {
|
.done(function() {
|
||||||
$('#loadingbox').sheet('hide');
|
$('#loadingbox').sheet('hide');
|
||||||
|
@ -344,10 +352,6 @@ var PolicyView = Backbone.View.extend({
|
||||||
this.template = _.template($('#tmpl-policy').html());
|
this.template = _.template($('#tmpl-policy').html());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.scopeTemplate) {
|
|
||||||
this.scopeTemplate = _.template($('#tmpl-scope-list').html());
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events:{
|
||||||
|
@ -414,11 +418,38 @@ var PolicyFormView = Backbone.View.extend({
|
||||||
if (!this.template) {
|
if (!this.template) {
|
||||||
this.template = _.template($('#tmpl-policy-form').html());
|
this.template = _.template($('#tmpl-policy-form').html());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.scopeCollection = new Backbone.Collection();
|
||||||
},
|
},
|
||||||
|
|
||||||
render:function (eventName) {
|
load:function(callback) {
|
||||||
|
if (this.model.isFetched &&
|
||||||
|
this.options.rs.isFetched &&
|
||||||
|
this.options.systemScopeList.isFetched) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#loadingbox').sheet('show');
|
||||||
|
$('#loading').html(
|
||||||
|
'<span class="label" id="loading-policies">' + $.t('policy.loading-policies') + '</span> ' +
|
||||||
|
'<span class="label" id="loading-rs">' + $.t('policy.loading-rs') + '</span> ' +
|
||||||
|
'<span class="label" id="loading-scopes">' + $.t("common.scopes") + '</span> '
|
||||||
|
);
|
||||||
|
|
||||||
|
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-policies').addClass('label-success');}}),
|
||||||
|
this.options.rs.fetchIfNeeded({success:function(e) {$('#loading-rs').addClass('label-success');}}),
|
||||||
|
this.options.systemScopeList.fetchIfNeeded({success:function(e) {$('#loading-scopes').addClass('label-success');}}))
|
||||||
|
.done(function() {
|
||||||
|
$('#loadingbox').sheet('hide');
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render:function (eventName) {
|
||||||
|
var json = this.model.toJSON();
|
||||||
|
|
||||||
|
this.$el.html(this.template({policy: json, rs: this.options.rs}));
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,15 +72,6 @@
|
||||||
<button class="btn btn-small btn-cancel"><i class="icon-ban-circle"></i> <span data-i18n="common.cancel">Cancel</span></button>
|
<button class="btn btn-small btn-cancel"><i class="icon-ban-circle"></i> <span data-i18n="common.cancel">Cancel</span></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="add-required-claim">
|
|
||||||
<form class="form-horizontal">
|
|
||||||
<fieldset>
|
|
||||||
<input type="text" id="email" placeholder="email address" data-i18n="[placeholder]policy.policy-table.email-address" />
|
|
||||||
<button id="add-email" class="btn btn-info"><i class="icon-share icon-white"></i> <span data-i18n="policy.policy-table.share-email">Share with email address</span></button>
|
|
||||||
</fieldset>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="alert alert-info" data-i18n="policy.policy-table.required-claims">
|
<div class="alert alert-info" data-i18n="policy.policy-table.required-claims">
|
||||||
Users that you share this resource will with need to be able to present the following claims in order to access the resource.
|
Users that you share this resource will with need to be able to present the following claims in order to access the resource.
|
||||||
</div>
|
</div>
|
||||||
|
@ -144,4 +135,73 @@
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="tmpl-policy-form">
|
||||||
|
|
||||||
|
<% if (policy.id == null) { %>
|
||||||
|
<h1 data-i18n="policy.policy-form.new">New Policy</h1>
|
||||||
|
<% } else { %>
|
||||||
|
<h1 data-i18n="policy.policy-form.edit">Edit Policy</h1>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
<div class="well well-small">
|
||||||
|
<button class="btn btn-small btn-save btn-success"><i class="icon-ok-circle icon-white"></i> <span data-i18n="common.save">Save</span></button>
|
||||||
|
<button class="btn btn-small btn-cancel"><i class="icon-ban-circle"></i> <span data-i18n="common.cancel">Cancel</span></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="add-required-claim">
|
||||||
|
<form class="form-horizontal">
|
||||||
|
<fieldset>
|
||||||
|
<input type="text" id="email" placeholder="email address" data-i18n="[placeholder]policy.policy-table.email-address" />
|
||||||
|
<button id="add-email" class="btn btn-info"><i class="icon-share icon-white"></i> <span data-i18n="policy.policy-table.share-email">Share with email address</span></button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form class="form-horizontal">
|
||||||
|
<fieldset>
|
||||||
|
|
||||||
|
<div class="control-group" id="scopes">
|
||||||
|
<label class="control-label" data-i18n="common.scope">Scopes</label>
|
||||||
|
<div class="controls">
|
||||||
|
<% _.each(rs.scopes, function(scope) { %>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox"
|
||||||
|
<%-($.inArray(scope, policy.scopes) > -1 ? 'checked' : '')%>>
|
||||||
|
<label class="checkbox"><%- scope %></label>
|
||||||
|
</div>
|
||||||
|
<% }); %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<tbody>
|
||||||
|
<% _.each(policy.claimsRequired, function(claim) { %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<% _.each(claim.issuer, function(issuer) { %>
|
||||||
|
<span class="label label-info"><%- issuer %></span>
|
||||||
|
<% }); %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%- claim.friendlyName ? claim.friendlyName : claim.name %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%- JSON.stringify(claim.value) %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% }); %>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="well well-small">
|
||||||
|
<button class="btn btn-small btn-save btn-success"><i class="icon-ok-circle icon-white"></i> <span data-i18n="common.save">Save</span></button>
|
||||||
|
<button class="btn btn-small btn-cancel"><i class="icon-ban-circle"></i> <span data-i18n="common.cancel">Cancel</span></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue