Updating role listing UI

revert-70aa11f8
dilanua 8 years ago
parent a580dc7a55
commit 54807b99ee

@ -24,12 +24,14 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles"> <a href="{{@app.context}}/roles">
Roles Roles
</a> </a>
</li> </li>
<li> <li>
<a href="{{@app.context}}/roles/add-role"> <!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/role/add">
Add Add
</a> </a>
</li> </li>

@ -1,5 +1,5 @@
{ {
"version": "1.0.0", "version": "1.0.0",
"uri": "/roles/add-role", "uri": "/role/add",
"layout": "cdmf.layout.default" "layout": "cdmf.layout.default"
} }

@ -15,8 +15,8 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}}
{{unit "cdmf.unit.data-tables-extended"}} {{unit "cdmf.unit.data-tables-extended"}}
{{#zone "breadcrumbs"}} {{#zone "breadcrumbs"}}
@ -26,6 +26,7 @@
</a> </a>
</li> </li>
<li> <li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles"> <a href="{{@app.context}}/roles">
Roles Roles
</a> </a>
@ -34,7 +35,8 @@
{{#zone "navbarActions"}} {{#zone "navbarActions"}}
<li> <li>
<a href="{{@app.context}}/roles/add-role" class="cu-btn"> <!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/role/add" class="cu-btn">
<span class="icon fw-stack"> <span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i> <i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-ring fw-stack-2x"></i> <i class="fw fw-ring fw-stack-2x"></i>

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except * Version 2.0 (the "License"); you may not use this file except
@ -10,11 +10,12 @@
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* KIND, either express or implied. See the License for the * either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
var loadRoleBasedActionURL = function (action, rolename) { var loadRoleBasedActionURL = function (action, rolename) {
var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename; var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename;
$(location).attr('href', href); $(location).attr('href', href);
@ -36,47 +37,47 @@ function InitiateViewOption() {
* listed on Role Management page in WSO2 Devicemgt Console. * listed on Role Management page in WSO2 Devicemgt Console.
*/ */
var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGridTemplateSrc, serviceURL, callback) { //var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGridTemplateSrc, serviceURL, callback) {
var templateSrc = $(objectGridTemplateSrc).attr("src"); // var templateSrc = $(objectGridTemplateSrc).attr("src");
$.template(objectGridId, templateSrc, function (template) { // $.template(objectGridId, templateSrc, function (template) {
invokerUtil.get(serviceURL, // invokerUtil.get(serviceURL,
function (data) { // function (data) {
data = callback(data); // data = callback(data);
if (data.length > 0 && data != null) { // if (data.length > 0 && data != null) {
$('#ast-container').removeClass('hidden'); // $('#ast-container').removeClass('hidden');
$('#role-listing-status').hide(); // $('#role-listing-status').hide();
for (var i = 0; i < data.viewModel.roles.length; i++) { // for (var i = 0; i < data.viewModel.roles.length; i++) {
data.viewModel.roles[i].adminRole = $("#role-table").data("role"); // data.viewModel.roles[i].adminRole = $("#role-table").data("role");
} // }
var content = template(data.viewModel); // var content = template(data.viewModel);
$(objectGridContainer).html(content); // $(objectGridContainer).html(content);
if (isInit) { // if (isInit) {
$('#role-grid').datatables_extended_serverside_paging(); // $('#role-grid').datatables_extended_serverside_paging();
isInit = false; // isInit = false;
} // }
$("#dt-select-all").addClass("hidden"); // $("#dt-select-all").addClass("hidden");
$(".icon .text").res_text(0.2); // $(".icon .text").res_text(0.2);
} else { // } else {
$('#ast-container').addClass('hidden'); // $('#ast-container').addClass('hidden');
$('#role-listing-status-msg').text('No roles are available to be displayed.'); // $('#role-listing-status-msg').text('No roles are available to be displayed.');
$('#role-listing-status').show(); // $('#role-listing-status').show();
} // }
//
//$(objectGridId).datatables_extended(); // //$(objectGridId).datatables_extended();
}, function (message) { // }, function (message) {
$('#ast-container').addClass('hidden'); // $('#ast-container').addClass('hidden');
$('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' + // $('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' +
'query'); // 'query');
$('#role-listing-status').show(); // $('#role-listing-status').show();
}); // });
}); // });
}; //};
function loadRoles(searchQuery) { function loadRoles() {
var loadingContent = $("#loading-content"); var loadingContent = $("#loading-content");
loadingContent.show(); loadingContent.show();
var dataFilter = function(data){ var dataFilter = function (data) {
data = JSON.parse(data); data = JSON.parse(data);
var objects = []; var objects = [];
@ -85,19 +86,21 @@ function loadRoles(searchQuery) {
objects.push({name: data.roles[index], DT_RowId : "role-" + data.roles[index]}) objects.push({name: data.roles[index], DT_RowId : "role-" + data.roles[index]})
}); });
json = { var json = {
"recordsTotal": data.count, "recordsTotal": data.count,
"recordsFiltered": data.count, "recordsFiltered": data.count,
"data": objects "data": objects
}; };
return JSON.stringify( json ); return JSON.stringify(json);
} };
var fnCreatedRow = function( nRow, aData, iDataIndex ) { //noinspection JSUnusedLocalSymbols
var fnCreatedRow = function (nRow, aData, iDataIndex) {
$(nRow).attr('data-type', 'selectable'); $(nRow).attr('data-type', 'selectable');
} };
//noinspection JSUnusedLocalSymbols
var columns = [ var columns = [
{ {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
@ -112,22 +115,44 @@ function loadRoles(searchQuery) {
{ {
class: "text-right content-fill text-left-on-grid-view no-wrap", class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null, data: null,
render: function ( data, type, row, meta ) { render: function (data, type, row, meta) {
return '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" data-role="' + data.name + return '<a onclick="javascript:loadRoleBasedActionURL(\'edit\', \'' + data.name + '\')" ' +
'" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-role-link"><span class="fw-stack fw-lg">' + 'data-role="' + data.name + '" ' +
'<i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-user fw-stack-1x"></i>' + 'data-click-event="edit-form" ' +
'<span class="fw-stack fw-move-right fw-move-bottom"><i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' + 'class="btn padding-reduce-on-grid-view edit-role-link">' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i></span></span>' + '<span class="fw-stack fw-lg">' +
'<span class="hidden-xs hidden-on-grid-view">Edit</span></a>' + '<i class="fw fw-ring fw-stack-2x"></i>' +
'<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '<i class="fw fw-user fw-stack-1x"></i>' +
'\')" data-role="' + data.name + '" data-click-event="edit-form" class="btn padding-reduce-on-grid-view edit-permission-link">' + '<span class="fw-stack fw-move-right fw-move-bottom">' +
'<span class="fw-stack fw-lg"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-security-policy fw-stack-1x"></i>' + '<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom"><i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' + '<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i></span></span>' + '</span>' +
'<span class="hidden-xs hidden-on-grid-view">Edit Permission</span></a>' + '</span>' +
'<a data-role="' + data.name + '" data-click-event="remove-form" class="btn padding-reduce-on-grid-view remove-role-link">' + '<span class="hidden-xs hidden-on-grid-view">&nbsp;&nbsp;Edit</span>' +
'<span class="fw-stack"><i class="fw fw-ring fw-stack-2x"></i><i class="fw fw-delete fw-stack-1x"></i></span>' + '</a>' +
'<span class="hidden-xs hidden-on-grid-view">Remove</span></a>' '<a onclick="javascript:loadRoleBasedActionURL(\'edit-permission\', \'' + data.name + '\')" ' +
'data-role="' + data.name + '" ' +
'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-permission-link">' +
'<span class="fw-stack fw-lg">' +
'<i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-security-policy fw-stack-1x"></i>' +
'<span class="fw-stack fw-move-right fw-move-bottom">' +
'<i class="fw fw-circle fw-stack-2x fw-stroke fw-inverse"></i>' +
'<i class="fw fw-circle fw-stack-2x"></i><i class="fw fw-edit fw-stack-1x fw-inverse"></i>' +
'</span>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">&nbsp;&nbsp;Edit Permission</span>' +
'</a>' +
'<a data-role="' + data.name + '" ' +
'data-click-event="remove-form" ' +
'class="btn padding-reduce-on-grid-view remove-role-link">' +
'<span class="fw-stack">' +
'<i class="fw fw-ring fw-stack-2x"></i>' +
'<i class="fw fw-delete fw-stack-1x"></i>' +
'</span>' +
'<span class="hidden-xs hidden-on-grid-view">&nbsp;&nbsp;Remove</span>' +
'</a>';
} }
} }
]; ];
@ -210,14 +235,14 @@ $("#role-grid").on("click", ".remove-role-link", function () {
}); });
}); });
$("#search-btn").click(function () { //$("#search-btn").click(function () {
var searchQuery = $("#search-by-name").val(); // var searchQuery = $("#search-by-name").val();
if (searchQuery.trim() != "") { // if (searchQuery.trim() != "") {
loadRoles(searchQuery); // loadRoles(searchQuery);
} else { // } else {
loadRoles(); // loadRoles();
} // }
}); //});
$(document).ready(function () { $(document).ready(function () {
$('#role-listing-status').hide(); $('#role-listing-status').hide();

Loading…
Cancel
Save