claim forms displayed
parent
3e931c68b4
commit
332cb22a99
|
@ -504,6 +504,7 @@ var AppRouter = Backbone.Router.extend({
|
||||||
"user/tokens":"tokens",
|
"user/tokens":"tokens",
|
||||||
"user/profile":"profile",
|
"user/profile":"profile",
|
||||||
"user/policy":"policy",
|
"user/policy":"policy",
|
||||||
|
"user/policy/:rsid":"editPolicy",
|
||||||
|
|
||||||
"dev/dynreg":"dynReg",
|
"dev/dynreg":"dynReg",
|
||||||
"dev/dynreg/new":"newDynReg",
|
"dev/dynreg/new":"newDynReg",
|
||||||
|
@ -1081,7 +1082,7 @@ var AppRouter = Backbone.Router.extend({
|
||||||
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:""},
|
||||||
{text:$.t('policy.resource-sets'), href:"manage/#user/profile"}
|
{text:$.t('policy.resource-sets'), href:"manage/#user/policy"}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
this.updateSidebar('user/policy');
|
this.updateSidebar('user/policy');
|
||||||
|
@ -1095,6 +1096,37 @@ var AppRouter = Backbone.Router.extend({
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editPolicy:function(rsid) {
|
||||||
|
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-policy'), href:"manage/#user/policy/" + rsid}
|
||||||
|
]);
|
||||||
|
|
||||||
|
this.updateSidebar('user/policy');
|
||||||
|
|
||||||
|
var rs = this.resourceSetList.get(rsid);
|
||||||
|
if (rs == null) {
|
||||||
|
// need to load it directly
|
||||||
|
var claims = new ClaimCollection();
|
||||||
|
} else {
|
||||||
|
// the resource set is loaded, preload the claims
|
||||||
|
var claims = new ClaimCollection(rs.get('claimsRequired'));
|
||||||
|
claims.isFetched = true;
|
||||||
|
}
|
||||||
|
// set the URL for the collection
|
||||||
|
claims.url = 'api/claims/' + rsid;
|
||||||
|
|
||||||
|
var view = new ClaimListView({model: claims});
|
||||||
|
|
||||||
|
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');
|
||||||
|
|
||||||
|
|
|
@ -340,10 +340,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"policy" : {
|
"policy" : {
|
||||||
"resource-sets": "Resource sets",
|
"resource-sets": "Resource Sets",
|
||||||
|
"edit-policy": "Edit Policy",
|
||||||
|
"required-claims": "Required Claims",
|
||||||
"policy-table": {
|
"policy-table": {
|
||||||
"edit": "Edit Policies",
|
"edit": "Edit Policies",
|
||||||
"no-resource-sets": "There are no resource sets registered. Introduce a protected to this authorization server to let it register some."
|
"no-resource-sets": "There are no resource sets registered. Introduce a protected to this authorization server to let it register some.",
|
||||||
|
"no-required-claims": "There are no required claims for this resource set."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"copyright": "Powered by <a href=\"https://github.com/mitreid-connect/\">MITREid Connect <span class=\"label\">{0}</span></a> <span class=\"pull-right\">© 2015 The MITRE Corporation and MIT KIT.</span>.",
|
"copyright": "Powered by <a href=\"https://github.com/mitreid-connect/\">MITREid Connect <span class=\"label\">{0}</span></a> <span class=\"pull-right\">© 2015 The MITRE Corporation and MIT KIT.</span>.",
|
||||||
|
|
|
@ -184,5 +184,82 @@ var ResourceSetView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
var ClaimListView = Backbone.View.extend({
|
||||||
|
tagName: 'span',
|
||||||
|
|
||||||
|
initialize:function(options) {
|
||||||
|
this.options = options;
|
||||||
|
},
|
||||||
|
|
||||||
|
load:function(callback) {
|
||||||
|
if (this.model.isFetched) {
|
||||||
|
callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#loadingbox').sheet('show');
|
||||||
|
$('#loading').html(
|
||||||
|
'<span class="label" id="loading-claims">' + $.t('policy.required-claims') + '</span> '
|
||||||
|
);
|
||||||
|
|
||||||
|
$.when(this.model.fetchIfNeeded({success:function(e) {$('#loading-claims').addClass('label-success');}}))
|
||||||
|
.done(function() {
|
||||||
|
$('#loadingbox').sheet('hide');
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
togglePlaceholder:function() {
|
||||||
|
if (this.model.length > 0) {
|
||||||
|
$('#required-claim-table', this.el).show();
|
||||||
|
$('#required-claim-table-empty', this.el).hide();
|
||||||
|
} else {
|
||||||
|
$('#required-claim-table', this.el).hide();
|
||||||
|
$('#required-claim-table-empty', this.el).show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render:function (eventName) {
|
||||||
|
$(this.el).html($('#tmpl-required-claim-table').html());
|
||||||
|
|
||||||
|
var _self = this;
|
||||||
|
|
||||||
|
_.each(this.model.models, function (claim) {
|
||||||
|
|
||||||
|
var view = new ClaimView({model: claim});
|
||||||
|
view.parentView = _self;
|
||||||
|
$('#required-claim-table', this.el).append(view.render().el);
|
||||||
|
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.togglePlaceholder();
|
||||||
|
$(this.el).i18n();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var ClaimView = Backbone.View.extend({
|
||||||
|
tagName: 'tr',
|
||||||
|
|
||||||
|
initialize:function(options) {
|
||||||
|
this.options = options;
|
||||||
|
|
||||||
|
if (!this.template) {
|
||||||
|
this.template = _.template($('#tmpl-required-claim').html());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render:function (eventName) {
|
||||||
|
var json = this.model.toJSON();
|
||||||
|
|
||||||
|
this.$el.html(this.template(json));
|
||||||
|
|
||||||
|
$(this.el).i18n();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
|
@ -57,3 +57,64 @@
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="tmpl-required-claim-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>
|
||||||
|
|
||||||
|
<div id="required-claim-table-empty" class="alert alert-info" data-i18n="policy.policy-table.no-required-claims">
|
||||||
|
There are no required claims for this resource set.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="add-required-claim">
|
||||||
|
<form>
|
||||||
|
<fieldset>
|
||||||
|
<input type="text" />
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table id="required-claim-table" class="table table-hover table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Issuers</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Value</th>
|
||||||
|
<th></th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<script type="text/html" id="tmpl-required-claim">
|
||||||
|
<td>
|
||||||
|
<% _.each(issuer, function(issuer) { %>
|
||||||
|
<span class="label"><%- issuer %></span>
|
||||||
|
<% }); %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<%- name %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<%- value %>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
<div class="btn-group pull-right">
|
||||||
|
<button class="btn btn-edit"><i class="icon-edit"></i> <span data-i18n="policy.policy-table.edit">Edit Policies</span></button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue