From 54807b99ee36080bea94a5503258f3dfa02906c0 Mon Sep 17 00:00:00 2001 From: dilanua Date: Thu, 1 Sep 2016 17:00:43 +0530 Subject: [PATCH] Updating role listing UI --- .../pages/cdmf.page.role.create/create.hbs | 4 +- .../pages/cdmf.page.role.create/create.json | 2 +- .../app/pages/cdmf.page.roles/roles.hbs | 6 +- .../public/js/role-listing.js | 167 ++++++++++-------- 4 files changed, 104 insertions(+), 75 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs index 4271391f97..7ca07cf8a9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs @@ -24,12 +24,14 @@
  • + Roles
  • - + + Add
  • diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json index e54dc5f2af..adab2be0f6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json @@ -1,5 +1,5 @@ { "version": "1.0.0", - "uri": "/roles/add-role", + "uri": "/role/add", "layout": "cdmf.layout.default" } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs index 07f4c0a143..81007c5718 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs @@ -15,8 +15,8 @@ specific language governing permissions and limitations 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"}} {{#zone "breadcrumbs"}} @@ -26,6 +26,7 @@
  • + Roles @@ -34,7 +35,8 @@ {{#zone "navbarActions"}}
  • - + + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js index afeb0a393e..c47045e309 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js @@ -1,20 +1,21 @@ /* - * 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, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + var loadRoleBasedActionURL = function (action, rolename) { var href = $("#ast-container").data("app-context") + "role/" + action + "/" + rolename; $(location).attr('href', href); @@ -36,47 +37,47 @@ function InitiateViewOption() { * listed on Role Management page in WSO2 Devicemgt Console. */ -var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGridTemplateSrc, serviceURL, callback) { - var templateSrc = $(objectGridTemplateSrc).attr("src"); - $.template(objectGridId, templateSrc, function (template) { - invokerUtil.get(serviceURL, - function (data) { - data = callback(data); - if (data.length > 0 && data != null) { - $('#ast-container').removeClass('hidden'); - $('#role-listing-status').hide(); - for (var i = 0; i < data.viewModel.roles.length; i++) { - data.viewModel.roles[i].adminRole = $("#role-table").data("role"); - } - var content = template(data.viewModel); - $(objectGridContainer).html(content); - if (isInit) { - $('#role-grid').datatables_extended_serverside_paging(); - isInit = false; - } - $("#dt-select-all").addClass("hidden"); - $(".icon .text").res_text(0.2); - } else { - $('#ast-container').addClass('hidden'); - $('#role-listing-status-msg').text('No roles are available to be displayed.'); - $('#role-listing-status').show(); - } - - //$(objectGridId).datatables_extended(); - }, function (message) { - $('#ast-container').addClass('hidden'); - $('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' + - 'query'); - $('#role-listing-status').show(); - }); - }); -}; - -function loadRoles(searchQuery) { +//var loadPaginatedObjects = function (objectGridId, objectGridContainer, objectGridTemplateSrc, serviceURL, callback) { +// var templateSrc = $(objectGridTemplateSrc).attr("src"); +// $.template(objectGridId, templateSrc, function (template) { +// invokerUtil.get(serviceURL, +// function (data) { +// data = callback(data); +// if (data.length > 0 && data != null) { +// $('#ast-container').removeClass('hidden'); +// $('#role-listing-status').hide(); +// for (var i = 0; i < data.viewModel.roles.length; i++) { +// data.viewModel.roles[i].adminRole = $("#role-table").data("role"); +// } +// var content = template(data.viewModel); +// $(objectGridContainer).html(content); +// if (isInit) { +// $('#role-grid').datatables_extended_serverside_paging(); +// isInit = false; +// } +// $("#dt-select-all").addClass("hidden"); +// $(".icon .text").res_text(0.2); +// } else { +// $('#ast-container').addClass('hidden'); +// $('#role-listing-status-msg').text('No roles are available to be displayed.'); +// $('#role-listing-status').show(); +// } +// +// //$(objectGridId).datatables_extended(); +// }, function (message) { +// $('#ast-container').addClass('hidden'); +// $('#role-listing-status-msg').text('Invalid search query. Try again with a valid search ' + +// 'query'); +// $('#role-listing-status').show(); +// }); +// }); +//}; + +function loadRoles() { var loadingContent = $("#loading-content"); loadingContent.show(); - var dataFilter = function(data){ + var dataFilter = function (data) { data = JSON.parse(data); var objects = []; @@ -85,19 +86,21 @@ function loadRoles(searchQuery) { objects.push({name: data.roles[index], DT_RowId : "role-" + data.roles[index]}) }); - json = { + var json = { "recordsTotal": data.count, "recordsFiltered": data.count, "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'); - } + }; + //noinspection JSUnusedLocalSymbols var columns = [ { 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", data: null, - render: function ( data, type, row, meta ) { - return '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + render: function (data, type, row, meta) { + return '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; } } ]; @@ -210,14 +235,14 @@ $("#role-grid").on("click", ".remove-role-link", function () { }); }); -$("#search-btn").click(function () { - var searchQuery = $("#search-by-name").val(); - if (searchQuery.trim() != "") { - loadRoles(searchQuery); - } else { - loadRoles(); - } -}); +//$("#search-btn").click(function () { +// var searchQuery = $("#search-by-name").val(); +// if (searchQuery.trim() != "") { +// loadRoles(searchQuery); +// } else { +// loadRoles(); +// } +//}); $(document).ready(function () { $('#role-listing-status').hide();