From 0ccaa9fe8192f10c2d918992bb435f1dab86c2cd Mon Sep 17 00:00:00 2001 From: charitha Date: Tue, 17 May 2016 13:57:47 +0530 Subject: [PATCH 1/2] Fix for https://wso2.org/jira/browse/IOTS-50 & https://wso2.org/jira/browse/IOTS-112 --- .../device/mgt/jaxrs/api/impl/UserImpl.java | 51 ++- .../cdmf.page.device.analytics/analytics.hbs | 0 .../cdmf.page.device.analytics/analytics.js | 0 .../public/css/analytics.css | 0 .../cdmf.page.devices/public/js/listing.js | 2 +- .../cdmf.page.group.analytics/analytics.hbs | 0 .../cdmf.page.group.analytics/analytics.js | 0 .../cdmf.page.group.analytics/analytics.json | 0 .../public/css/analytics.css | 0 .../cdmf.page.groups/public/js/listing.js | 0 .../pages/cdmf.page.user.create/create.hbs | 116 ++++++- .../cdmf.page.user.create}/create.js | 21 +- .../public/js/bottomJs.js | 158 ++++----- .../app/pages/cdmf.page.user.edit/edit.hbs | 104 +++++- .../app/pages/cdmf.page.user.edit/edit.js | 34 +- .../public/js/bottomJs.js | 6 +- .../app/pages/cdmf.page.user.view/view.hbs | 135 +++++++- .../app/pages/cdmf.page.user.view/view.js | 25 +- .../cdmf.page.users}/public/js/listing.js | 125 ++++---- .../public/templates/listing.hbs | 0 .../app/pages/cdmf.page.users/users.hbs | 302 +++++++++++++++++- .../app/pages/cdmf.page.users/users.js | 27 ++ .../units/cdmf.unit.user.create/create.hbs | 113 ------- .../units/cdmf.unit.user.create/create.json | 3 - .../app/units/cdmf.unit.user.edit/edit.hbs | 91 ------ .../app/units/cdmf.unit.user.edit/edit.js | 58 ---- .../app/units/cdmf.unit.user.edit/edit.json | 3 - .../units/cdmf.unit.user.listing/listing.hbs | 299 ----------------- .../units/cdmf.unit.user.listing/listing.js | 46 --- .../units/cdmf.unit.user.listing/listing.json | 3 - .../app/units/cdmf.unit.user.view/view.hbs | 129 -------- .../app/units/cdmf.unit.user.view/view.js | 48 --- .../app/units/cdmf.unit.user.view/view.json | 3 - 33 files changed, 913 insertions(+), 989 deletions(-) mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.js mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/public/css/analytics.css mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/public/css/analytics.css mode change 100755 => 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/{units/cdmf.unit.user.create => pages/cdmf.page.user.create}/create.js (59%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/{units/cdmf.unit.user.create => pages/cdmf.page.user.create}/public/js/bottomJs.js (62%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/{units/cdmf.unit.user.edit => pages/cdmf.page.user.edit}/public/js/bottomJs.js (98%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/{units/cdmf.unit.user.listing => pages/cdmf.page.users}/public/js/listing.js (71%) rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/{units/cdmf.unit.user.listing => pages/cdmf.page.users}/public/templates/listing.hbs (100%) delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.hbs delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.json delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.hbs delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.js delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.json delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.hbs delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.js delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.json delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js delete mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.json diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/UserImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/UserImpl.java index 427a654e54..9d70f40848 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/UserImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/api/impl/UserImpl.java @@ -24,17 +24,17 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; -import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; -import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper; -import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper; -import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo; +import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.util.CredentialManagementResponseBuilder; import org.wso2.carbon.device.mgt.jaxrs.api.util.DeviceMgtAPIUtils; import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload; +import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper; +import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper; +import org.wso2.carbon.device.mgt.jaxrs.util.Constants; import org.wso2.carbon.device.mgt.jaxrs.util.SetReferenceTransformer; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; @@ -60,7 +60,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Random; -import java.util.TreeSet; /** * This class represents the JAX-RS services of User related functionality. @@ -195,31 +194,23 @@ public class UserImpl implements org.wso2.carbon.device.mgt.jaxrs.api.User { new String(decodedBytes, "UTF-8")); log.debug("User credential of username: " + userWrapper.getUsername() + " has been changed"); } - List listofFilteredRoles = getFilteredRoles(userStoreManager, userWrapper.getUsername()); - final String[] existingRoles = listofFilteredRoles.toArray(new String[listofFilteredRoles.size()]); - - /* - Use the Set theory to find the roles to delete and roles to add - The difference of roles in existingRolesSet and newRolesSet needed to be deleted - new roles to add = newRolesSet - The intersection of roles in existingRolesSet and newRolesSet - */ - final TreeSet existingRolesSet = new TreeSet<>(); - Collections.addAll(existingRolesSet, existingRoles); - final TreeSet newRolesSet = new TreeSet<>(); - Collections.addAll(newRolesSet, userWrapper.getRoles()); - existingRolesSet.removeAll(newRolesSet); - // Now we have the roles to delete - String[] rolesToDelete = existingRolesSet.toArray(new String[existingRolesSet.size()]); - List roles = new ArrayList<>(Arrays.asList(rolesToDelete)); - roles.remove(ROLE_EVERYONE); - rolesToDelete = new String[0]; - // Clearing and re-initializing the set - existingRolesSet.clear(); - Collections.addAll(existingRolesSet, existingRoles); - newRolesSet.removeAll(existingRolesSet); - // Now we have the roles to add - String[] rolesToAdd = newRolesSet.toArray(new String[newRolesSet.size()]); - userStoreManager.updateRoleListOfUser(userWrapper.getUsername(), rolesToDelete, rolesToAdd); + List currentRoles = getFilteredRoles(userStoreManager, userWrapper.getUsername()); + List newRoles = Arrays.asList(userWrapper.getRoles()); + + List rolesToAdd = new ArrayList<>(newRoles); + List rolesToDelete = new ArrayList<>(); + + for (String role : currentRoles) { + if (newRoles.contains(role)) { + rolesToAdd.remove(role); + } else { + rolesToDelete.add(role); + } + } + rolesToDelete.remove(ROLE_EVERYONE); + userStoreManager.updateRoleListOfUser(userWrapper.getUsername(), + rolesToDelete.toArray(new String[rolesToDelete.size()]), + rolesToAdd.toArray(new String[rolesToAdd.size()])); userStoreManager.setUserClaimValues(userWrapper.getUsername(), defaultUserClaims, null); // Outputting debug message upon successful addition of user if (log.isDebugEnabled()) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.hbs old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/analytics.js old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/public/css/analytics.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.device.analytics/public/css/analytics.css old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js index 09453f8041..7c55d710fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devices/public/js/listing.js @@ -252,7 +252,7 @@ function loadDevices(searchType, searchParam){ { targets: 1, data: 'name', className: 'fade-edge' , render: function ( name, type, row, meta ) { var model = getPropertyValue(row.properties, 'DEVICE_MODEL'); var vendor = getPropertyValue(row.properties, 'VENDOR'); - var html = '

Device ' + name + '

'; + var html = '

' + name + '

'; if (model) { html += '
(' + vendor + '-' + model + ')
'; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.hbs old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.js old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/analytics.json old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/public/css/analytics.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.group.analytics/public/css/analytics.css old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.groups/public/js/listing.js old mode 100755 new mode 100644 diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs index 6ba6306444..efab4e02f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs @@ -19,5 +19,119 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.user.create"}} + +
+
+ +
+
+

Add User

+

Please note that * sign represents required fields of data.

+
+
+
+ + +
+ +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + + +
+ +
+ +
+
+
+
+ +
+
+ + +
+
+{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/bottomJs.js"}} {{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js similarity index 59% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js index 18b5968f70..c06ce52dee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js @@ -26,16 +26,17 @@ function onRequest(context) { var userModule = require("/app/modules/user.js")["userModule"]; var response = userModule.getRolesByUserStore("PRIMARY"); var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); - context["charLimit"] = devicemgtProps.usernameLength; + var page = {}; + page["charLimit"] = devicemgtProps.usernameLength; if (response["status"] == "success") { - context["roles"] = response["content"]; + page["roles"] = response["content"]; } - context["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; - context["usernameHelpText"] = devicemgtProps.userValidationConfig.usernameHelpMsg; - context["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg; - context["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx; - context["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg; - context["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx; - context["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg; - return context; + page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; + page["usernameHelpMsg"] = devicemgtProps.userValidationConfig.usernameHelpMsg; + page["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg; + page["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx; + page["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg; + page["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx; + page["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg; + return page; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js similarity index 62% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js index 489eee0bc2..3963ffeba1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/public/js/bottomJs.js @@ -72,8 +72,8 @@ var disableInlineError = function (inputField, errorMsg, errorSign) { */ validateInline["user-name"] = function () { var usernameinput = $("input#username"); - if (inputIsValid( usernameinput.data("regex"), usernameinput.val())) { - disableInlineError("usernameInputField", "usernameEmpty", "usernameError"); + if (inputIsValid(usernameinput.data("regex"), usernameinput.val())) { + disableInlineError("usernameInputField", "usernameEmpty", "usernameError"); } else { enableInlineError("usernameInputField", "usernameEmpty", "usernameError"); } @@ -85,7 +85,7 @@ validateInline["user-name"] = function () { validateInline["first-name"] = function () { var firstnameinput = $("input#firstname"); if (firstnameinput.val()) { - disableInlineError("firstNameField", "fnError"); + disableInlineError("firstNameField", "fnError"); } else { enableInlineError("firstNameField", "fnError"); } @@ -97,7 +97,7 @@ validateInline["first-name"] = function () { validateInline["last-name"] = function () { var lastnameinput = $("input#lastname"); if (lastnameinput.val()) { - disableInlineError("lastNameField", "lnError"); + disableInlineError("lastNameField", "lnError"); } else { enableInlineError("lastNameField", "lnError"); } @@ -110,12 +110,12 @@ validateInline["last-name"] = function () { validateInline["emailAddress"] = function () { var email = $("#emailAddress").val(); if (!email) { - enableInlineError("emailField", "email-required" , "emailError"); + enableInlineError("emailField", "email-required", "emailError"); } else if (emailIsValid(email)) { - disableInlineError("emailField", "email-required" , "emailError"); - disableInlineError("emailField", "email-invalid" , "emailError"); + disableInlineError("emailField", "email-required", "emailError"); + disableInlineError("emailField", "email-invalid", "emailError"); } else { - enableInlineError("emailField", "email-invalid" , "emailError"); + enableInlineError("emailField", "email-invalid", "emailError"); } }; @@ -123,21 +123,21 @@ validateInline["emailAddress"] = function () { * clear Validation messages when gain focus to the field. */ clearInline["user-name"] = function () { - disableInlineError("usernameInputField", "usernameEmpty", "usernameError"); + disableInlineError("usernameInputField", "usernameEmpty", "usernameError"); }; /** * clear Validation messages when gain focus to the field. */ clearInline["first-name"] = function () { - disableInlineError("firstNameField", "fnError"); + disableInlineError("firstNameField", "fnError"); }; /** * clear Validation messages when gain focus to the field. */ clearInline["last-name"] = function () { - disableInlineError("lastNameField", "lnError"); + disableInlineError("lastNameField", "lnError"); }; @@ -145,8 +145,8 @@ clearInline["last-name"] = function () { * clear Validation messages when gain focus to the field. */ clearInline["emailAddress"] = function () { - disableInlineError("emailField", "email-required" , "emailError"); - disableInlineError("emailField", "email-invalid" , "emailError"); + disableInlineError("emailField", "email-required", "emailError"); + disableInlineError("emailField", "email-invalid", "emailError"); }; /** @@ -160,37 +160,37 @@ function emailIsValid(email) { return regExp.test(email); } -$( "#userStore" ) - .change(function () { - var str = ""; - $( "select option:selected" ).each(function() { - str += $( this ).text() + " "; - }); - var addUserAPI = "/devicemgt_admin/roles/"+ str; - - invokerUtil.get( - addUserAPI, - function (data) { - data = JSON.parse(data); - if (data.errorMessage) { - $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); - $(errorMsgWrapper).removeClass("hidden"); - } else if (data["status"] == 200) { - $("#roles").empty(); - for (var i = 0; i < data.responseContent.length; i++) { - var newOption = $(''); - $('#roles').append(newOption); +$("#userStore") + .change(function () { + var str = ""; + $("select option:selected").each(function () { + str += $(this).text() + " "; + }); + var addUserAPI = "/devicemgt_admin/roles/" + str; + + invokerUtil.get( + addUserAPI, + function (data) { + data = JSON.parse(data); + if (data.errorMessage) { + $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); + $(errorMsgWrapper).removeClass("hidden"); + } else if (data["statusCode"] == 200) { + $("#roles").empty(); + for (var i = 0; i < data.responseContent.length; i++) { + var newOption = $(''); + $('#roles').append(newOption); + } + } } - } - } - ); - }).change(); + ); + }).change(); $(document).ready(function () { $("#emailValidationText").hide(); $("select.select2[multiple=multiple]").select2({ - tags: false - }); + tags: false + }); /** * Following click function would execute @@ -247,74 +247,74 @@ $(document).ready(function () { var addUserAPI = "/devicemgt_admin/users"; invokerUtil.post( - addUserAPI, - addUserFormData, - function (data) { - data = JSON.parse(data); - if (data.errorMessage) { - $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); - $(errorMsgWrapper).removeClass("hidden"); - } else if (data["statusCode"] == 201) { - // Clearing user input fields. - $("input#username").val(""); - $("input#firstname").val(""); - $("input#lastname").val(""); - $("input#email").val(""); - $("select#roles").select2("val", ""); - // Refreshing with success message - $("#user-create-form").addClass("hidden"); - $("#user-created-msg").removeClass("hidden"); - generateQRCode("#user-created-msg .qr-code"); - } else if (data["statusCode"] == 409) { - $(errorMsg).text(data["messageFromServer"]); - $(errorMsgWrapper).removeClass("hidden"); - } else if (data["statusCode"] == 500) { - $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); - $(errorMsgWrapper).removeClass("hidden"); - } - }, function (data) { + addUserAPI, + addUserFormData, + function (data) { + data = JSON.parse(data); + if (data.errorMessage) { + $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); + $(errorMsgWrapper).removeClass("hidden"); + } else if (data["statusCode"] == 201) { + // Clearing user input fields. + $("input#username").val(""); + $("input#firstname").val(""); + $("input#lastname").val(""); + $("input#email").val(""); + $("select#roles").select2("val", ""); + // Refreshing with success message + $("#user-create-form").addClass("hidden"); + $("#user-created-msg").removeClass("hidden"); + generateQRCode("#user-created-msg .qr-code"); + } else if (data["statusCode"] == 409) { + $(errorMsg).text(data["messageFromServer"]); + $(errorMsgWrapper).removeClass("hidden"); + } else if (data["statusCode"] == 500) { + $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); + $(errorMsgWrapper).removeClass("hidden"); + } + }, function (data) { if (data["statusCode"] == 409) { - $(errorMsg).text("User : " + username + " already exists. Pick another username."); + $(errorMsg).text("User : " + username + " already exists. Pick another username."); } else if (data["statusCode"] == 500) { - $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); - } else { - $(errorMsg).text(data.errorMessage); + $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); + } else { + $(errorMsg).text(data.errorMessage); + } + $(errorMsgWrapper).removeClass("hidden"); } - $(errorMsgWrapper).removeClass("hidden"); - } ); } }); - $("#username").focus(function() { + $("#username").focus(function () { clearInline["user-name"](); }); - $("#username").blur(function() { + $("#username").blur(function () { validateInline["user-name"](); }); - $("#emailAddress").focus(function() { + $("#emailAddress").focus(function () { clearInline["emailAddress"](); }); - $("#emailAddress").blur(function() { + $("#emailAddress").blur(function () { validateInline["emailAddress"](); }); - $("#lastname").focus(function() { + $("#lastname").focus(function () { clearInline["last-name"](); }); - $("#lastname").blur(function() { + $("#lastname").blur(function () { validateInline["last-name"](); }); - $("#firstname").focus(function() { + $("#firstname").focus(function () { clearInline["first-name"](); }); - $("#firstname").blur(function() { + $("#firstname").blur(function () { validateInline["first-name"](); }); }); \ 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.user.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.hbs index 795a6ab9c1..1c7c7840b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.hbs @@ -19,5 +19,105 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.user.edit"}} -{{/zone}} \ No newline at end of file + + +
+
+ +
+
+

Edit User

+

Please note that * sign represents required fields of data.

+
+
+
+ + +
+ +
+ + + +
+ + + +
+ +
+ + + +
+ +
+ + + + +
+ +
+ +
+
+
+
+ +
+
+ + +
+
+ +{{/zone}} + +{{#zone "bottomJs"}} + {{js "js/bottomJs.js"}} +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js index 8b8353bdeb..ae091ec38c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.js @@ -18,8 +18,9 @@ function onRequest(context) { var userModule = require("/app/modules/user.js").userModule; - var username = request.getParameter("username"); - var user = userModule.getUser(username)["content"]; + var userName = request.getParameter("username"); + var user = userModule.getUser(userName)["content"]; + var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); if (user) { var title; if (user.firstname || user.lastname) { @@ -27,6 +28,33 @@ function onRequest(context) { } else { title = user.username; } - return {"user": user, "title": title}; + var page = {"user": user, "title": title}; + + var userStore = "PRIMARY"; + if (userName.indexOf("/") > -1) { + userStore = userName.substr(0, userName.indexOf('/')); + } + var response = userModule.getUser(userName); + + if (response["status"] == "success") { + page["editUser"] = response["content"]; + } + + response = userModule.getRolesByUsername(userName); + if (response["status"] == "success") { + page["usersRoles"] = response["content"]; + } + response = userModule.getRolesByUserStore(userStore); + if (response["status"] == "success") { + page["userRoles"] = response["content"]; + } + } + page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; + page["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg; + page["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx; + page["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg; + page["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx; + page["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg; + return page; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js similarity index 98% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js index a8a2641eb8..7c59cd2494 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js @@ -232,7 +232,7 @@ $(document).ready(function () { addUserFormData, function (data) { data = JSON.parse(data); - if (data["status"] == 201) { + if (data["statusCode"] == 201) { // Clearing user input fields. $("input#username").val(""); $("input#firstname").val(""); @@ -244,9 +244,9 @@ $(document).ready(function () { $("#user-created-msg").removeClass("hidden"); } }, function (data) { - if (data["status"] == 409) { + if (data["statusCode"] == 409) { $(errorMsg).text("User : " + username + " doesn't exists. You cannot proceed."); - } else if (data["status"] == 500) { + } else if (data["statusCode"] == 500) { $(errorMsg).text("An unexpected error occurred @ backend server. Please try again later."); } else { $(errorMsg).text(data.errorMessage); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs index 49e7c10ef5..da8d44ac3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.hbs @@ -13,11 +13,140 @@
  • - {{username}} + {{user.username}}
  • {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.user.view"}} -{{/zone}} \ No newline at end of file + {{#zone "contentTitle"}} +
    +
    + +
    +
    + {{/zone}} + +
    +
    +
    +
    +
    +
    + {{#if editPermitted}} + + {{/if}} +
    +
    +
    +
    Profile Overview
    + {{#defineZone "user-detail-properties"}} + + + + + + + + + + + + + + + + + + + + + + + +
    Username{{user.username}}
    First Name{{user.firstname}}
    Last Name{{user.lastname}}
    Email{{user.emailAddress}}
    Roles + {{#each userRoles}} + + {{/each}} +
    + {{/defineZone}} +
    +
    +
    +
    + +
    + {{#defineZone "user-enrolled-devices"}} +
    +
    +
    +
    Enrolled Devices by + {{#if user.firstname}} + {{user.firstname}} {{user.lastname}} + {{else}} + {{user.username}} + {{/if}} +
    +
    +
    +
    + {{#each devices}} +
    + +
    +
    + +
    + +
    +
    + +

    {{name}}

    +
    +
    +
    +
    + +
    +
    +
    + {{/each}} +
    +
    +
    +
    +
    +
    +
    + {{/defineZone}} +
    +
    +{{/zone}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js index ca16f9f315..8b41bc8a36 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.view/view.js @@ -20,7 +20,26 @@ function onRequest(context) { var userModule = require("/app/modules/user.js").userModule; var username = request.getParameter("username"); var user = userModule.getUser(username)["content"]; - if (user) { - return {"username": user.username}; + var userModule = require("/app/modules/user.js")["userModule"]; + + var userName = request.getParameter("username"); + + var user, userRoles, devices; + + if (userName) { + var response = userModule.getUser(userName); + + if (response["status"] == "success") { + user = response["content"]; + user.domain = response["userDomain"]; + } + + response = userModule.getRolesByUsername(userName); + if (response["status"] == "success") { + userRoles = response["content"]; + } + var deviceModule = require("/app/modules/device.js").deviceModule; + devices = deviceModule.getDevices(userName); } -} \ No newline at end of file + return {"user": user, "userRoles": userRoles, "devices": devices}; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/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 similarity index 71% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/js/listing.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index 90368be5b3..6c29b73a40 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/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 @@ -16,6 +16,18 @@ * under the License. */ +/** + * Checks if provided input is valid against RegEx input. + * + * @param regExp Regular expression + * @param inputString Input string to check + * @returns {boolean} Returns true if input matches RegEx + */ +function inputIsValid(regExp, inputString) { + regExp = new RegExp(regExp); + return regExp.test(inputString); +} + /** * Sorting function of users * listed on User Management page in WSO2 Devicemgt Console. @@ -23,10 +35,10 @@ $(function () { var sortableElem = '.wr-sortable'; $(sortableElem).sortable({ - beforeStop: function () { - var sortedIDs = $(this).sortable('toArray'); - } - }); + beforeStop: function () { + var sortedIDs = $(this).sortable('toArray'); + } + }); $(sortableElem).disableSelection(); }); @@ -96,20 +108,20 @@ $("a.invite-user-link").click(function () { $("a#invite-user-yes-link").click(function () { invokerUtil.post( - inviteUserAPI, - usernameList, - function () { - $(modalPopupContent).html($('#invite-user-success-content').html()); - $("a#invite-user-success-link").click(function () { - hidePopup(); - }); - }, - function () { - $(modalPopupContent).html($('#invite-user-error-content').html()); - $("a#invite-user-error-link").click(function () { - hidePopup(); - }); - } + inviteUserAPI, + usernameList, + function () { + $(modalPopupContent).html($('#invite-user-success-content').html()); + $("a#invite-user-success-link").click(function () { + hidePopup(); + }); + }, + function () { + $(modalPopupContent).html($('#invite-user-error-content').html()); + $("a#invite-user-error-link").click(function () { + hidePopup(); + }); + } ); }); @@ -132,25 +144,25 @@ function removeUser(uname, uid) { $("a#remove-user-yes-link").click(function () { invokerUtil.delete( - removeUserAPI, - function () { - $("#" + userid).remove(); - // get new user-list-count - var newUserListCount = $(".user-list > span").length; - // update user-listing-status-msg with new user-count - $("#user-listing-status-msg").text("Total number of Users found : " + newUserListCount); - // update modal-content with success message - $(modalPopupContent).html($('#remove-user-success-content').html()); - $("a#remove-user-success-link").click(function () { - hidePopup(); - }); - }, - function () { - $(modalPopupContent).html($('#remove-user-error-content').html()); - $("a#remove-user-error-link").click(function () { - hidePopup(); - }); - } + removeUserAPI, + function () { + $("#" + userid).remove(); + // get new user-list-count + var newUserListCount = $(".user-list > span").length; + // update user-listing-status-msg with new user-count + $("#user-listing-status-msg").text("Total number of Users found : " + newUserListCount); + // update modal-content with success message + $(modalPopupContent).html($('#remove-user-success-content').html()); + $("a#remove-user-success-link").click(function () { + hidePopup(); + }); + }, + function () { + $(modalPopupContent).html($('#remove-user-error-content').html()); + $("a#remove-user-error-link").click(function () { + hidePopup(); + }); + } ); }); @@ -194,25 +206,25 @@ function resetPassword(uname) { resetPasswordFormData.newPassword = window.btoa(unescape(encodeURIComponent(confirmedPassword))); invokerUtil.post( - resetPasswordServiceURL, - resetPasswordFormData, - function (data) { // The success callback - data = JSON.parse(data); - if (data.status == 201) { - $(modalPopupContent).html($('#reset-password-success-content').html()); - $("a#reset-password-success-link").click(function () { - hidePopup(); - }); - } - }, function (data) { // The error callback - if (data.status == 400) { - $(errorMsg).text("Old password does not match with the provided value."); - $(errorMsgWrapper).removeClass("hidden"); - } else { - $(errorMsg).text("An unexpected error occurred. Please try again later."); - $(errorMsgWrapper).removeClass("hidden"); + resetPasswordServiceURL, + resetPasswordFormData, + function (data) { // The success callback + data = JSON.parse(data); + if (data.statusCode == 201) { + $(modalPopupContent).html($('#reset-password-success-content').html()); + $("a#reset-password-success-link").click(function () { + hidePopup(); + }); + } + }, function (data) { // The error callback + if (data.statusCode == 400) { + $(errorMsg).text("Old password does not match with the provided value."); + $(errorMsgWrapper).removeClass("hidden"); + } else { + $(errorMsg).text("An unexpected error occurred. Please try again later."); + $(errorMsgWrapper).removeClass("hidden"); + } } - } ); } }); @@ -302,8 +314,7 @@ function loadUsers(searchParam) { successCallback, function (message) { $('#ast-container').addClass('hidden'); - $('#user-listing-status-msg'). - text('Invalid search query. Try again with a valid search query'); + $('#user-listing-status-msg').text('Invalid search query. Try again with a valid search query'); } ); }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/templates/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/templates/listing.hbs similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/public/templates/listing.hbs rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/templates/listing.hbs diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs index 12eb4f8183..ebbf6596f9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs @@ -28,5 +28,305 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.user.listing"}} + + +
    + {{#if removePermitted}} + + {{/if}} + {{#if editPermitted}} + + {{/if}} + {{#if viewPermitted}} + + {{/if}} + {{#if invitePermitted}} + + {{/if}} + {{#if resetPasswordPermitted}} + + {{/if}} + + + Loading users . . . +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    + +
    By Username
    + + + + +
    + +
    +
    +
    + + +
    +
    +
    +
    +

    + An invitation mail will be sent to the selected user(s) to initiate an enrolment process. + Do you wish to continue ? +

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    User invitation email for enrollment was successfully sent.

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Try again later.

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Do you really want to remove this user ?

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Done. User was successfully removed.

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    + +
    +
    +
    +
    +

    + + + + + Operation cannot be performed ! +

    +

    + Please select a user or a list of users to send invitation emails. +

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    + + + + + Unauthorized action! +

    +
    +
    +
    +
    + +
    + +
    +
    +
    +

    + + + + + Reset Password +
    +

    + +

    + Enter new password +

    +
    + +
    +
    + Retype new password +

    +
    + +
    +
    +

    + +
    +
    +
    +
    + +
    +
    +
    +
    +

    Password reset is successful.

    + +
    +
    +
    +
    +{{/zone}} +{{#zone "common-navigation"}} + {{/zone}} +{{#zone "bottomJs"}} + + {{js "js/listing.js"}} +{{/zone}} \ 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.users/users.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.js index ce78e837cc..74f3d583fc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.js @@ -26,4 +26,31 @@ function onRequest(context) { return options.fn(this); } }); + var page = {}; + var userModule = require("/app/modules/user.js")["userModule"]; + var deviceMgtProps = require("/app/conf/devicemgt-props.js").config(); + page["permissions"] = userModule.getUIPermissions(); + if (userModule.isAuthorized("/permission/admin/device-mgt/users/delete")) { + page["removePermitted"] = true; + } + + if (userModule.isAuthorized("/permission/admin/device-mgt/users/remove")) { + page["removePermitted"] = true; + } + + if (userModule.isAuthorized("/permission/admin/device-mgt/users/update")) { + page["editPermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/users/view")) { + page["viewPermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/users/invite")) { + page["invitePermitted"] = true; + } + if (userModule.isAuthorized("/permission/admin/device-mgt/users/reset-password")) { + page["resetPasswordPermitted"] = true; + } + + page["adminUser"] = deviceMgtProps.adminUser; + return page; } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.hbs deleted file mode 100644 index f84f1b959c..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.hbs +++ /dev/null @@ -1,113 +0,0 @@ - - -
    -
    - -
    -
    -

    Add User

    -

    Please note that * sign represents required fields of data.

    -
    -
    -
    - - -
    - -
    - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - - -
    - -
    - -
    -
    -
    -
    - -
    -
    - - -
    -
    - - - -{{#zone "bottomJs"}} - {{js "js/bottomJs.js"}} -{{/zone}} - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.json deleted file mode 100644 index 9eecd8f5bf..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.create/create.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.hbs deleted file mode 100644 index da29c85144..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.hbs +++ /dev/null @@ -1,91 +0,0 @@ - - -
    -
    - -
    -
    -

    Edit User

    -

    Please note that * sign represents required fields of data.

    -
    -
    -
    - - -
    - -
    - - - -
    - - - -
    - -
    - - - -
    - -
    - - - - -
    - -
    - -
    -
    -
    -
    - -
    -
    - - -
    -
    - -{{#zone "bottomJs"}} - {{js "js/bottomJs.js"}} -{{/zone}} - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.js deleted file mode 100644 index 4c4e59d3ec..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * - * 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 - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Returns a context with the user object to be populated by the edit-user page. - * - * @param context Object that gets updated with the dynamic state of this page to be presented - * @returns {*} A context object that returns the dynamic state of this page to be presented - */ -function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; - var devicemgtProps = require('/app/conf/devicemgt-props.js').config(); - var userName = request.getParameter("username"); - - if (userName) { - var userStore = "PRIMARY"; - if (userName.indexOf("/") > -1) { - userStore = userName.substr(0, userName.indexOf('/')); - } - var response = userModule.getUser(userName); - - if (response["status"] == "success") { - context["editUser"] = response["content"]; - } - - response = userModule.getRolesByUsername(userName); - if (response["status"] == "success") { - context["usersRoles"] = response["content"]; - } - response = userModule.getRolesByUserStore(userStore); - if (response["status"] == "success") { - context["userRoles"] = response["content"]; - } - - } - context["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; - context["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg; - context["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx; - context["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg; - context["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx; - context["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg; - return context; -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.edit/edit.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.hbs deleted file mode 100644 index 8e923f8aca..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.hbs +++ /dev/null @@ -1,299 +0,0 @@ - - -
    - {{#if removePermitted}} - - {{/if}} - {{#if editPermitted}} - - {{/if}} - {{#if viewPermitted}} - - {{/if}} - {{#if invitePermitted}} - - {{/if}} - {{#if resetPasswordPermitted}} - - {{/if}} - - - Loading users . . . -
    -
    - - - -
    - - - - - - - - - - - - - - - - - - - -
    - -
    By Username
    - - - - -
    - -
    -
    -
    - - -
    -
    -
    -
    -

    - An invitation mail will be sent to the selected user(s) to initiate an enrolment process. - Do you wish to continue ? -

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    User invitation email for enrollment was successfully sent.

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Try again later.

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Do you really want to remove this user ?

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Done. User was successfully removed.

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    An unexpected error occurred. Please try again later.

    - - -
    -
    -
    -
    - -
    -
    -
    -
    -

    - - - - - Operation cannot be performed ! -

    -

    - Please select a user or a list of users to send invitation emails. -

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    - - - - - Unauthorized action! -

    -
    -
    -
    -
    - -
    - -
    -
    -
    -

    - - - - - Reset Password -
    -

    - -

    - Enter new password -

    -
    - -
    -
    - Retype new password -

    -
    - -
    -
    -

    - -
    -
    -
    -
    - -
    -
    -
    -
    -

    Password reset is successful.

    - -
    -
    -
    -
    - -{{#zone "common-navigation"}} - -{{/zone}} -{{#zone "bottomJs"}} - - {{js "js/listing.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.js deleted file mode 100644 index feeda066cb..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * - * 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 - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; - var deviceMgtProps = require("/app/conf/devicemgt-props.js").config(); - context["permissions"] = userModule.getUIPermissions(); - if (userModule.isAuthorized("/permission/admin/device-mgt/users/delete")) { - context["removePermitted"] = true; - } - - if (userModule.isAuthorized("/permission/admin/device-mgt/users/remove")) { - context["removePermitted"] = true; - } - - if (userModule.isAuthorized("/permission/admin/device-mgt/users/update")) { - context["editPermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/users/view")) { - context["viewPermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/users/invite")) { - context["invitePermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/users/reset-password")) { - context["resetPasswordPermitted"] = true; - } - - context["adminUser"] = deviceMgtProps.adminUser; - return context; -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.json deleted file mode 100644 index b88788f78b..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.listing/listing.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version" : "1.0.0" -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs deleted file mode 100644 index 9ed2c501fd..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.hbs +++ /dev/null @@ -1,129 +0,0 @@ -{{#zone "contentTitle"}} -
    -
    - -
    -
    -{{/zone}} - -
    -
    -
    -
    -
    - {{#if editPermitted}} - - {{/if}} -
    -
    -
    -
    Profile Overview
    - {{#defineZone "user-detail-properties"}} - - - - - - - - - - - - - - - - - - - - - - - -
    Username{{user.username}}
    First Name{{user.firstname}}
    Last Name{{user.lastname}}
    Email{{user.emailAddress}}
    Roles - {{#each userRoles}} - - {{/each}} -
    - {{/defineZone}} -
    -
    -
    -
    - -
    - {{#defineZone "user-enrolled-devices"}} -
    -
    -
    -
    Enrolled Devices by - {{#if user.firstname}} - {{user.firstname}} {{user.lastname}} - {{else}} - {{user.username}} - {{/if}} -
    -
    -
    -
    - {{#each devices}} -
    - -
    -
    - -
    - -
    -
    - -

    {{name}}

    -
    -
    -
    -
    - -
    -
    -
    - {{/each}} -
    -
    -
    -
    -
    -
    -
    - {{/defineZone}} -
    -
    - diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js deleted file mode 100644 index a4f690df46..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.js +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * - * 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 - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Returns a context with the user object to be populated by the edit-user page. - * - * @param context Object that gets updated with the dynamic state of this page to be presented - * @returns {*} A context object that returns the dynamic state of this page to be presented - */ -function onRequest(context) { - var userModule = require("/app/modules/user.js")["userModule"]; - - var userName = request.getParameter("username"); - - var user, userRoles, devices; - - if (userName) { - var response = userModule.getUser(userName); - - if (response["status"] == "success") { - user = response["content"]; - user.domain = response["userDomain"]; - } - - response = userModule.getRolesByUsername(userName); - if (response["status"] == "success") { - userRoles = response["content"]; - } - var deviceModule = require("/app/modules/device.js").deviceModule; - devices = deviceModule.getDevices(userName); - } - return {"user": user, "userRoles": userRoles, "devices": devices}; -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.json deleted file mode 100644 index 688e939808..0000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.user.view/view.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file From ddc47cd86217685634dcbcf4211ead0e874fbb47 Mon Sep 17 00:00:00 2001 From: charitha Date: Tue, 17 May 2016 14:25:28 +0530 Subject: [PATCH 2/2] Fix for https://wso2.org/jira/browse/IOTS-161 --- .../devicemgt/app/pages/cdmf.page.user.create/create.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs index efab4e02f3..26ba4b6482 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs @@ -106,7 +106,6 @@

    User was added successfully.


    An invitation mail will be sent to this user to initiate device enrollment. - Below QR code can also be used to enroll a device.