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 427a654e544..9d70f40848a 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 09453f80419..7c55d710fb9 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 6ba6306444f..26ba4b6482d 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,118 @@ {{/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 18b5968f702..c06ce52deee 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 489eee0bc24..3963ffeba18 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 795a6ab9c17..1c7c7840b5c 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 8b8353bdeb6..ae091ec38c5 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 a8a2641eb8e..7c59cd24945 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 49e7c10ef52..da8d44ac3a1 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 ca16f9f3158..8b41bc8a366 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 90368be5b39..6c29b73a401 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 12eb4f81837..ebbf6596f98 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 ce78e837cc8..74f3d583fc2 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 f84f1b959cf..00000000000 --- 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 9eecd8f5bf8..00000000000 --- 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 da29c85144e..00000000000 --- 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 4c4e59d3ecd..00000000000 --- 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 688e939808b..00000000000 --- 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 8e923f8aca8..00000000000 --- 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 feeda066cbb..00000000000 --- 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 b88788f78bc..00000000000 --- 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 9ed2c501fd8..00000000000 --- 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 a4f690df46a..00000000000 --- 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 688e939808b..00000000000 --- 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