From 4a71be850c76a1baa83e6386cdab0f0446848e2a Mon Sep 17 00:00:00 2001 From: Megala Date: Mon, 17 Oct 2016 14:23:55 +0530 Subject: [PATCH] Refactoring code --- .../mgt/jaxrs/service/api/RoleManagementService.java | 10 +++++----- .../jaxrs/service/impl/UserManagementServiceImpl.java | 1 - .../app/pages/cdmf.page.role.create/create.hbs | 3 ++- .../pages/cdmf.page.role.create/public/js/bottomJs.js | 7 ++++--- .../pages/cdmf.page.roles/public/js/role-listing.js | 5 ++--- .../app/pages/cdmf.page.users/public/js/listing.js | 5 ++--- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java index 0476ba4cde..d53c367450 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java @@ -174,7 +174,7 @@ public interface RoleManagementService { @PathParam("roleName") String roleName, @ApiParam( name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", + value = "The name of the user store from which you wish to get the permission of role.", required = false) @QueryParam("user-store") String userStoreName, @ApiParam( @@ -244,7 +244,7 @@ public interface RoleManagementService { @PathParam("roleName") String roleName, @ApiParam( name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", + value = "The name of the user store which the particular of role resides in", required = false) @QueryParam("user-store") String userStoreName, @ApiParam( @@ -368,7 +368,7 @@ public interface RoleManagementService { required = true) RoleInfo role, @ApiParam( name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", + value = "The name of the user store which the particular role resides in.", required = false) @QueryParam("user-store") String userStoreName); @@ -407,7 +407,7 @@ public interface RoleManagementService { @PathParam("roleName") String roleName, @ApiParam( name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", + value = "The name of the user store which the particular role resides in.", required = false) @QueryParam("user-store") String userStoreName); @@ -471,7 +471,7 @@ public interface RoleManagementService { @PathParam("roleName") String roleName, @ApiParam( name = "user-store", - value = "The name of the UserStore you wish to get the list of roles.", + value = "The name of the user store which the particular role resides in.", required = false) @QueryParam("user-store") String userStoreName, @ApiParam( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index bb196bad3d..91538230a1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.opensaml.ws.wstrust.Primary; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo; 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 d3b2f15329..0bfdfe1d8f 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 @@ -94,7 +94,8 @@ data-error-msg="{{roleNameRegExViolationErrorMsg}}" class="form-control" /> {{#if canViewUsers}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js index 2b5a331398..d67c46ea8b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js @@ -83,7 +83,8 @@ clearInline["role-name"] = function () { */ validateInline["role-name"] = function () { var roleNameInput = $("input#roleName"); - if (inputIsValid( roleNameInput.data("regex"), roleNameInput.val())) { + if (inputIsValid( roleNameInput.data("regex"), roleNameInput.val()) && roleNameInput.indexOf("@") < 0 && + roleNameInput.indexOf("/") < 0) { disableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); } else { enableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); @@ -114,7 +115,6 @@ function formatRepoSelection (user) { $(document).ready(function () { var appContext = $("#app-context").data("app-context"); - $("#users").select2({ multiple:true, tags: false, @@ -204,7 +204,8 @@ $(document).ready(function () { $("input#roleName").val(""); $("#domain").val("PRIMARY"); $("#users").val(""); - window.location.href = appContext + "/role/edit-permission/?rolename=" + encodeURIComponent(addRoleFormData.roleName); + window.location.href = appContext + "/role/edit-permission/?rolename=" + + encodeURIComponent(addRoleFormData.roleName); } }, function (jqXHR) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index 0f5f905ec3..907d124f70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -218,10 +218,9 @@ $("#role-grid").on("click", ".remove-role-link", function () { removeRoleAPI, function () { if (userStore) { - $("#role-" + userStore + "\\/" + role).remove(); - } else { - $("#role-" + role).remove(); + role = userStore + '/' + role; } + $('[id=role-' + role + ']').remove(); $(modalPopupContent).html($('#remove-role-success-content').html()); $("a#remove-role-success-link").click(function () { hidePopup(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index d7e557a46c..b737f4472c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -218,10 +218,9 @@ function removeUser(username) { function (data, textStatus, jqXHR) { if (jqXHR.status == 200) { if (domain) { - $("#user-" + domain + "\\/" + username).remove(); - } else { - $("#user-" + username).remove(); + username = domain + '/' + username; } + $('[id=user-' + username + ']').remove(); // update modal-content with success message modalDialog.header("User Removed."); modalDialog.content("Done. User was successfully removed.");