From c6cc5e8df3677d04084fb720a7b5a30d6978ce8c Mon Sep 17 00:00:00 2001 From: madhawap Date: Fri, 12 Aug 2016 12:45:58 +0530 Subject: [PATCH 01/12] fixes to role updating endpoint --- .../jaxrs/service/impl/util/RequestValidationUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index 6fbc75264c0..603cbe20053 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -309,8 +309,12 @@ public class RequestValidationUtil { public static void validateRoleDetails(RoleInfo roleInfo) { if (roleInfo == null) { throw new InputValidationException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is incorrect or" + - " empty").build()); + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is " + + "empty").build()); + } else if (roleInfo.getRoleName() == null) { + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request body is " + + "incorrect").build()); } } From aa01c7a52e95259609e5bf6a78ae34ae60dfecaa Mon Sep 17 00:00:00 2001 From: Ace Date: Fri, 12 Aug 2016 13:40:49 +0530 Subject: [PATCH 02/12] Adding query improvements to activities retrieval query --- .../mgt/dao/impl/GenericOperationDAOImpl.java | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 1e9c3d68fd6..8fa69c67ffb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -381,11 +381,31 @@ public class GenericOperationDAOImpl implements OperationDAO { "WHERE UPDATED_TIMESTAMP > ? LIMIT ? OFFSET ?) eom ON eom.ENROLMENT_ID=oor.ENROLMENT_ID AND " + "oor.OPERATION_ID=eom.OPERATION_ID ORDER BY oor.OPERATION_ID"; + String sql = "SELECT feom.ENROLMENT_ID, feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE AS OPERATION_TYPE, " + + "o.OPERATION_CODE, orsp.OPERATION_RESPONSE, orsp.LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, " + + "orsp.ID AS OP_RES_ID, feom.STATUS, feom.UPDATED_TIMESTAMP, feom.DEVICE_IDENTIFICATION, " + + "feom.DEVICE_TYPE FROM (SELECT eom.ENROLMENT_ID, eom.OPERATION_ID, eom.STATUS, eom.CREATED_TIMESTAMP, " + + "eom.UPDATED_TIMESTAMP, fe.DEVICE_IDENTIFICATION, fe.DEVICE_TYPE FROM " + + "(SELECT ENROLMENT_ID, OPERATION_ID, STATUS, CREATED_TIMESTAMP, UPDATED_TIMESTAMP " + + "FROM DM_ENROLMENT_OP_MAPPING WHERE UPDATED_TIMESTAMP > ? ORDER BY OPERATION_ID LIMIT ? OFFSET ?) eom " + + "LEFT OUTER JOIN (SELECT e.ID AS ENROLMENT_ID, d.ID AS DEVICE_ID, d.DEVICE_IDENTIFICATION, " + + "t.NAME AS DEVICE_TYPE FROM DM_ENROLMENT e LEFT OUTER JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + + "LEFT OUTER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID WHERE d.TENANT_ID = ? AND " + + "e.TENANT_ID = ?) fe ON fe.ENROLMENT_ID = eom.ENROLMENT_ID) feom LEFT OUTER JOIN DM_OPERATION o " + + "ON feom.OPERATION_ID = o.ID LEFT OUTER JOIN (SELECT ID, ENROLMENT_ID, OPERATION_ID, " + + "OPERATION_RESPONSE, MAX(RECEIVED_TIMESTAMP) LATEST_RECEIVED_TIMESTAMP " + + "FROM DM_DEVICE_OPERATION_RESPONSE GROUP BY ENROLMENT_ID , OPERATION_ID) orsp " + + "ON o.ID = orsp.OPERATION_ID AND feom.ENROLMENT_ID = orsp.ENROLMENT_ID GROUP BY feom.ENROLMENT_ID"; + stmt = conn.prepareStatement(sql); - stmt.setInt(1, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - stmt.setLong(2, timestamp); - stmt.setInt(3, limit); - stmt.setInt(4, offset); + + stmt.setLong(1, timestamp); + stmt.setInt(2, limit); + stmt.setInt(3, offset); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + stmt.setInt(4, tenantId); + stmt.setInt(5, tenantId); + rs = stmt.executeQuery(); int operationId = 0; From d8c6720857f5734795317e164b937bcf1f69f35c Mon Sep 17 00:00:00 2001 From: Ace Date: Fri, 12 Aug 2016 13:44:26 +0530 Subject: [PATCH 03/12] Removing previous query --- .../mgt/dao/impl/GenericOperationDAOImpl.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index 8fa69c67ffb..d52922db627 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -368,19 +368,6 @@ public class GenericOperationDAOImpl implements OperationDAO { // sql = sql + " OFFSET ?"; // } - String sql = "SELECT dte.ENROLMENT_ID, oor.OPERATION_ID, oor.OP_RES_ID, oor.OPERATION_TYPE, " + - "oor.OPERATION_CODE, oor.OPERATION_RESPONSE, dte.DEVICE_TYPE, dte.DEVICE_IDENTIFICATION, " + - "oor.RECEIVED_TIMESTAMP, eom.UPDATED_TIMESTAMP, eom.STATUS FROM (SELECT d.DEVICE_IDENTIFICATION, " + - "t.NAME AS DEVICE_TYPE, e.ID AS ENROLMENT_ID FROM DM_DEVICE d INNER JOIN DM_DEVICE_TYPE t " + - "ON d.DEVICE_TYPE_ID = t.ID INNER JOIN DM_ENROLMENT e ON d.ID = e.DEVICE_ID WHERE " + - "e.TENANT_ID = ?) dte INNER JOIN (SELECT o.ID AS OPERATION_ID, o.TYPE AS OPERATION_TYPE, " + - "o.OPERATION_CODE, r.ID AS OP_RES_ID, r.OPERATION_RESPONSE, r.RECEIVED_TIMESTAMP, " + - "r.ENROLMENT_ID FROM DM_OPERATION o INNER JOIN DM_DEVICE_OPERATION_RESPONSE r ON " + - "o.ID = r.OPERATION_ID) oor ON oor.ENROLMENT_ID=dte.ENROLMENT_ID LEFT OUTER JOIN " + - "(SELECT ENROLMENT_ID, OPERATION_ID, STATUS, UPDATED_TIMESTAMP FROM DM_ENROLMENT_OP_MAPPING " + - "WHERE UPDATED_TIMESTAMP > ? LIMIT ? OFFSET ?) eom ON eom.ENROLMENT_ID=oor.ENROLMENT_ID AND " + - "oor.OPERATION_ID=eom.OPERATION_ID ORDER BY oor.OPERATION_ID"; - String sql = "SELECT feom.ENROLMENT_ID, feom.OPERATION_ID, feom.CREATED_TIMESTAMP, o.TYPE AS OPERATION_TYPE, " + "o.OPERATION_CODE, orsp.OPERATION_RESPONSE, orsp.LATEST_RECEIVED_TIMESTAMP AS RECEIVED_TIMESTAMP, " + "orsp.ID AS OP_RES_ID, feom.STATUS, feom.UPDATED_TIMESTAMP, feom.DEVICE_IDENTIFICATION, " + From 280c5e496d1d9795bd3d4d39762d24701cdda567 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 12 Aug 2016 13:49:38 +0530 Subject: [PATCH 04/12] Adding user edit UI and fixes --- .../app/modules/business-controllers/user.js | 10 +++-- .../pages/cdmf.page.user.create/create.hbs | 4 +- .../public/js/bottomJs.js | 2 +- .../app/pages/cdmf.page.user.edit/edit.hbs | 22 ++++++---- .../app/pages/cdmf.page.user.edit/edit.js | 41 ++++++++++--------- .../app/pages/cdmf.page.user.edit/edit.json | 2 +- .../cdmf.page.user.edit/public/js/bottomJs.js | 23 ++++++----- .../cdmf.page.users/public/js/listing.js | 16 ++++---- 8 files changed, 67 insertions(+), 53 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index b3b8ff7e8ef..bc5c727bcb5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -42,7 +42,7 @@ var userModule = function () { privateMethods.getCarbonUser = function () { var carbon = require("carbon"); var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/modules/utility.js")["utility"]; + var utility = require("/app/modules/utility.js")["utility"]; if (!carbonUser) { log.error("User object was not found in the session"); throw constants["ERRORS"]["USER_NOT_FOUND"]; @@ -174,7 +174,11 @@ var userModule = function () { utility.startTenantFlow(carbonUser); var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" + encodeURIComponent(username) + "/roles"; - return privateMethods.callBackend(url, constants["HTTP_GET"]); + var response = privateMethods.callBackend(url, constants["HTTP_GET"]); + if (response.status == "success") { + response.content = parse(response.content).roles; + } + return response; } catch (e) { throw e; } finally { @@ -265,7 +269,7 @@ var userModule = function () { /** * Get Platforms. */ - //TODO Move this piece of logic out of user.js to somewhere else appropriate. + //TODO Move this piece of logic out of user.js to somewhere else appropriate. publicMethods.getPlatforms = function () { var carbonUser = session.get(constants["USER_SESSION_KEY"]); var utility = require("/app/modules/utility.js")["utility"]; 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 9fc20f80494..af9184b5f6a 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 @@ -56,9 +56,9 @@
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.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 index c254b82cc9d..44eb92993d8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.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 @@ -86,7 +86,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"); } 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 4597dae477a..c041cf7aa72 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 @@ -15,7 +15,7 @@ specific language governing permissions and limitations under the License. }} -{{unit "cdmf.unit.ui.title" pageTitle="User Management"}} +{{unit "cdmf.unit.ui.title" pageTitle="User Management | Edit User"}} {{#zone "breadcrumbs"}}
  • @@ -51,6 +51,15 @@ + +
    + +
    @@ -59,8 +68,6 @@ data-errormsg="{{usernameRegExViolationErrorMsg}}" class="form-control" value="{{editUser.username}}" disabled/> - -
    - + {{#each rolesByUserStore}} {{/each}} 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 a8eab037315..bcedb8361c5 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 @@ -16,14 +16,16 @@ * under the License. */ -function onRequest(context) { +function onRequest() { + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; + var userName = request.getParameter("username"); var user = userModule.getUser(userName)["content"]; - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + if (user) { var title; - if (user.firstname || user.lastname) { + if (user.firstname && user.lastname) { title = user.firstname + " " + user.lastname; } else { title = user.username; @@ -34,6 +36,8 @@ function onRequest(context) { if (userName.indexOf("/") > -1) { userStore = userName.substr(0, userName.indexOf('/')); } + page["userStore"] = userStore; + var response = userModule.getUser(userName); if (response["status"] == "success") { @@ -41,28 +45,27 @@ function onRequest(context) { } response = userModule.getRolesByUsername(userName); + var rolesByUsername; if (response["status"] == "success") { - page["usersRoles"] = response["content"]; + rolesByUsername = response["content"]; } + response = userModule.getRolesByUserStore(userStore); + var rolesByUserStore; if (response["status"] == "success") { - var roleVals = response["content"]; - var filteredRoles = []; - var prefix = "Application"; - for (i = 0; i < roleVals.length; i++) { - if(roleVals[i].indexOf(prefix) < 0){ - filteredRoles.push(roleVals[i]); - } - } - page["userRoles"] = filteredRoles; + rolesByUserStore = response["content"]; } + page["rolesByUsername"] = rolesByUsername; + page["rolesByUserStore"] = rolesByUserStore; } - 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; + + 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/pages/cdmf.page.user.edit/edit.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.json index fe718dc4fda..cfa389ca807 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/edit.json @@ -1,5 +1,5 @@ { "version": "1.0.0", - "uri": "/user/edit", + "uri": "/user/edit", "layout": "cdmf.layout.default" } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.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 index 7c59cd24945..0f89ee66b0c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.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 @@ -32,6 +32,8 @@ function inputIsValid(regExp, inputString) { var validateInline = {}; var clearInline = {}; +var deviceMgtBasePath = "/api/device-mgt/v1.0"; + var enableInlineError = function (inputField, errorMsg, errorSign) { var fieldIdentifier = "#" + inputField; var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; @@ -181,6 +183,7 @@ $(document).ready(function () { var firstnameInput = $("input#firstname"); var lastnameInput = $("input#lastname"); var charLimit = parseInt($("input#username").attr("limit")); + var domain = $("#userStore").val(); var username = usernameInput.val().trim(); var firstname = firstnameInput.val(); var lastname = lastnameInput.val(); @@ -215,7 +218,7 @@ $(document).ready(function () { } else { var addUserFormData = {}; - addUserFormData.username = username; + addUserFormData.username = domain + "/" + username; addUserFormData.firstname = firstname; addUserFormData.lastname = lastname; addUserFormData.emailAddress = emailAddress; @@ -225,14 +228,13 @@ $(document).ready(function () { } addUserFormData.roles = roles; - var addUserAPI = "/devicemgt_admin/users?username=" + username; + var addUserAPI = deviceMgtBasePath + "/users/" + username; invokerUtil.put( addUserAPI, addUserFormData, - function (data) { - data = JSON.parse(data); - if (data["statusCode"] == 201) { + function (data, textStatus, jqXHR) { + if (jqXHR.status == 201) { // Clearing user input fields. $("input#username").val(""); $("input#firstname").val(""); @@ -243,13 +245,14 @@ $(document).ready(function () { $("#user-create-form").addClass("hidden"); $("#user-created-msg").removeClass("hidden"); } - }, function (data) { - if (data["statusCode"] == 409) { + }, function (jqXHR) { + var payload = JSON.parse(jqXHR.responseText); + if (jqXHR.status == 409) { $(errorMsg).text("User : " + username + " doesn't exists. You cannot proceed."); - } else if (data["statusCode"] == 500) { - $(errorMsg).text("An unexpected error occurred @ backend server. Please try again later."); + } else if (jqXHR.status == 500) { + $(errorMsg).text("An unexpected error occurred at backend server. Please try again later."); } else { - $(errorMsg).text(data.errorMessage); + $(errorMsg).text(payload.message); } $(errorMsgWrapper).removeClass("hidden"); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index 3d48c71ae80..4b618f2973e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -264,12 +264,12 @@ function loadUsers(searchParam) { }; return JSON.stringify( json ); - }; + } var fnCreatedRow = function( nRow, aData, iDataIndex ) { $(nRow).attr('data-type', 'selectable'); $(nRow).attr('data-username', aData["filter"]); - }; + } var columns = [ { @@ -302,19 +302,19 @@ function loadUsers(searchParam) { class: "text-right content-fill text-left-on-grid-view no-wrap", data: null, render: function ( data, type, row, meta ) { - return ' ' + ' ' + ' ' + - '' + + '' + ' ' + ' ' + - ' ' + ' <' + '/i> ' + From 3219ac21018d3178140a15ebcf0f0304a5dfbb87 Mon Sep 17 00:00:00 2001 From: kamidu Date: Fri, 12 Aug 2016 14:04:16 +0530 Subject: [PATCH 05/12] Fixing the notification listing ui --- .../listing.hbs | 53 ++++++++++--------- .../cdmf.unit.notification.listing/listing.js | 11 ++-- .../public/js/notification-listing.js | 4 +- .../public/templates/notification-listing.hbs | 8 +-- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs index 073d9cb3b28..694154c3838 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs @@ -15,47 +15,48 @@ specific language governing permissions and limitations under the License. }} - -
    -
    - -
    -
    - Device Notifications -
    -
    -
    -
    -
    - +{{#zone "content"}} + +
    +
    + +
    +
    + Device Notifications +
    +
    +
    + -
    -
    - No unread messages +
    +
    + No unread messages +
    +
    -
    -
    +{{/zone}} {{#zone "bottomJs"}} {{js "js/notification-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.notification.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js index 0086ba8e3e6..3512296bdac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.js @@ -16,15 +16,16 @@ * under the License. */ -function onRequest(context){ +function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var constants = require("/app/modules/constants.js"); + var viewModel = {}; var permissions = []; - if(userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/list")){ + if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/list")) { permissions.push("LIST_NOTIFICATIONS"); } var currentUser = session.get(constants.USER_SESSION_KEY); - context.permissions = stringify(permissions); - context.currentUser = currentUser; - return context; + viewModel.permissions = stringify(permissions); + viewModel.currentUser = currentUser; + return viewModel; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js index 52fd96af333..f7f7db822f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js @@ -91,8 +91,8 @@ function loadNotifications(){ var successCallback = function (data) { var viewModel = {}; data = JSON.parse(data); - viewModel.notifications = data; - if(data.length > 0){ + viewModel.notifications = data.notifications; + if(data.count > 0){ var content = template(viewModel); $("#ast-container").html(content); $('#unread-notifications').datatables_extended(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs index d59fc831db2..418bef892bb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs @@ -16,10 +16,10 @@ {{#each notifications}} {{#equal "NEW" status }} - + {{description}} - + @@ -54,10 +54,10 @@ {{#each notifications}} - + {{description}} - + From 4acfde1511da94f763efbaadaff630143badb43e Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 12 Aug 2016 14:08:46 +0530 Subject: [PATCH 06/12] Adding user edit UI and fixes --- .../devicemgt/app/pages/cdmf.page.user.edit/edit.hbs | 2 +- .../app/pages/cdmf.page.user.edit/public/js/bottomJs.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 c041cf7aa72..8db65617b96 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 @@ -57,7 +57,7 @@
    ' + '' + + ' data-click-event="remove-form" onclick="javascript:removeUser(\'' + data.filter + '\')" ' + + 'class="btn padding-reduce-on-grid-view remove-user-link">' + ' ' + ' ' + From 0836b2c99ecbc0fc61b5dfc464c281ab456eb59f Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 12 Aug 2016 14:46:17 +0530 Subject: [PATCH 08/12] Fixing user create page QR-generation issues --- .../app/pages/cdmf.page.user.create/create.hbs | 10 ++++++---- .../app/pages/cdmf.page.user.create/create.js | 1 + .../cdmf.page.user.create/public/js/bottomJs.js | 14 +++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) 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 af9184b5f6a..8716965fd20 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 @@ -113,15 +113,17 @@
  • @@ -40,6 +39,7 @@ {{/zone}} {{#zone "content"}} + {{unit deviceViewUnitName}} {{unit "cdmf.unit.lib.data-table"}} {{unit "cdmf.unit.device.operation-mod"}} {{unit "cdmf.unit.device.view"}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs index 3663b0c6e91..83b6f723338 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.view/view.hbs @@ -15,6 +15,7 @@ specific language governing permissions and limitations under the License. }} + {{#zone "contentTitle"}}
    @@ -32,6 +33,7 @@
    {{/zone}} +{{#zone "content"}}
    @@ -193,7 +195,7 @@
    {{/defineZone}}
    - +{{/zone}} {{#zone "bottomJs"}} {{js "js/device-view.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.ui.header.user-menu/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.js new file mode 100644 index 00000000000..e0ebe26b0a4 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.js @@ -0,0 +1,4 @@ +function onRequest() { + var constants = require("/app/modules/constants.js"); + return session.get(constants["USER_SESSION_KEY"]); +} From fcff1f085422ae6761d7d74c799500d6c1fd6102 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 12 Aug 2016 20:00:46 +0530 Subject: [PATCH 12/12] Fixing user menu reg exp issue --- .../units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js index fe168cc0e04..9547a1e50d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js @@ -6,6 +6,7 @@ * @returns {boolean} Returns true if input matches RegEx */ function inputIsValid(regExp, inputString) { + regExp = new RegExp(regExp); return regExp.test(inputString); }