*/
$(function() {
- role = function(name,description){
+ role = function(name,description,permissions){
this.name = name;
this.description = description;
+ this.permissions=permissions;
+ }
+
+ permission = function(){
+
}
displayRolesGrid = function(){
$.ajax("restServices/redbackServices/roleManagementService/allRoles",
{
type: "GET",
- async: false,
dataType: 'json',
success: function(data) {
var roles = $.map(data.role, function(item) {
$("#main-content").html($("#rolesTabs").tmpl());
$("#main-content #roles-view-tabs-content #roles-view").html($("#rolesGrid").tmpl(data));
+ $("#roles-view-tabs").tabs();
activateRolesGridTab();
}
}
);
}
+ editRole = function(roleName){
+ $.log("edit role:"+roleName);
+ $.ajax("restServices/redbackServices/roleManagementService/getRole/"+roleName,
+ {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var role = mapRole(data.role);
+ $("#main-content #roles-view-tabs-content #role-edit").html($("#editRoleTab").tmpl(data.role));
+ activateRoleEditTab();
+ }
+ }
+ );
+ }
+
/**
* @param data Role response from redback rest api
*/
<tr>
<th>${$.i18n.prop('roles.name')}</th>
<th>${$.i18n.prop('roles.description')}</th>
+ <th>${$.i18n.prop('edit')}</th>
</tr>
</thead>
<tbody>
<tr>
<td>${$value.name}</td>
<td>${$value.description}</td>
+ <td>
+ <a href="#" onclick="javascript:editRole(encodeURI('${$value.name}'));">${$.i18n.prop('edit')}</a>
+ </td>
</tr>
{{/each}}
</tbody>
<div id="role-edit"></div>
</div>
-</script>
\ No newline at end of file
+</script>
+
+<script id="editRoleTab" type="text/x-jquery-tmpl">
+ <div class="page-header">
+ <h3>${$.i18n.prop('role.edit')}</h3>
+ </div>
+ <table class="bordered-table" id="editRoleTable">
+ <tbody>
+ <tr>
+ <td>${$.i18n.prop('role.edit.name')}:</td>
+ <td>${name}</td>
+ </tr>
+ <tr>
+ <td>${$.i18n.prop('role.edit.description')}:</td>
+ <td>${description}</td>
+ </tr>
+ </tbody>
+ </table>
+
+ <div class="page-header">
+ <h3>${$.i18n.prop('role.parents')}</h3>
+ </div>
+ <ul>
+ {{each parentRoleNames}}
+ <li>${$value}</li>
+ {{/each}}
+ </ul>
+
+ <div class="page-header">
+ <h3>${$.i18n.prop('role.childs')}</h3>
+ </div>
+ <ul>
+ {{each childRoleNames}}
+ <li>${$value}</li>
+ {{/each}}
+ </ul>
+
+ {{if permissions}}
+ <div class="page-header">
+ <h3>${$.i18n.prop('role.permissions')}</h3>
+ </div>
+ <table class="bordered-table zebra-striped" id="rolePermissionsTable">
+ <thead>
+ <tr>
+ <th>${$.i18n.prop('role.permission.name')}</th>
+ <th>${$.i18n.prop('role.permission.operation.name')}</th>
+ <th>${$.i18n.prop('role.permission.resource.')}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{each permissions}}
+ <tr>
+ <td>${$value.name}</td>
+ <td>${$value.operation.name}</td>
+ <td>${$value.resource.identifier}</td>
+ </tr>
+ {{/each}}
+ </tbody>
+ </table>
+ {{/if}}
+
+</script>