diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index bf09bd367cc..bd2b6d6f526 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -415,31 +415,24 @@ public class OperationManagerImpl implements OperationManager { try { OperationManagementDAOFactory.openConnection(); - org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO. - getNextOperation( - enrolmentId); + org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation = operationDAO.getNextOperation( + enrolmentId); if (dtoOperation != null) { - if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND. - equals(dtoOperation - .getType())) { + if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND.equals(dtoOperation.getType() + )) { org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation; commandOperation = (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO. - getOperation( - dtoOperation - .getId()); + getOperation(dtoOperation.getId()); dtoOperation.setEnabled(commandOperation.isEnabled()); - } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG. - equals(dtoOperation - .getType())) { + } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG.equals(dtoOperation. + getType())) { dtoOperation = configOperationDAO.getOperation(dtoOperation.getId()); - } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE. - equals(dtoOperation - .getType())) { + } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.PROFILE.equals(dtoOperation. + getType())) { dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId()); - } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY. - equals(dtoOperation - .getType())) { + } else if (org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.POLICY.equals(dtoOperation. + getType())) { dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId()); } operation = OperationDAOUtil.convertOperation(dtoOperation); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java index 2dd8956a533..22b7530cafd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java @@ -181,7 +181,7 @@ public interface DeviceManagementProviderService { * @return true if the user owns the device else will return false. * @throws DeviceManagementException If some unusual behaviour is observed while fetching the device. */ - public boolean isEnrolled(DeviceIdentifier deviceId, String user) throws DeviceManagementException; + boolean isEnrolled(DeviceIdentifier deviceId, String user) throws DeviceManagementException; License getLicense(String deviceType, String languageCode) throws DeviceManagementException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/assembly/src.xml b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/assembly/src.xml index c9805f89463..5aeaa05a35a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/assembly/src.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/assembly/src.xml @@ -28,13 +28,15 @@ ${basedir}/src + ${basedir}/src/main/resources/jaggeryapps/devicemgt /jaggeryapps/devicemgt-cdmf/ true + ${basedir}/src/main/resources/jaggeryapps/uuf-template-app - /jaggeryapps/devicemgt-cdmf/ + /jaggeryapps/uuf-template-app/ true 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 05906058918..dde8854bbbd 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 @@ -308,7 +308,9 @@ var userModule = function () { var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/roles/" + encodeURIComponent(roleName); var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - response.content = parse(response.content); + if (response.status == "success") { + response.content = parse(response.content); + } return response; } catch (e) { throw e; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs index 4271391f974..5efc9b61e52 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.hbs @@ -24,17 +24,117 @@
  • + Roles
  • - + + Add
  • {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.role.create"}} + +
    +
    + +
    +
    +

    Add Role

    +
    +
    +
    +
    +
    +
    +
    1
    + +
    +
    +
    +
    +
    2
    + +
    +
    +
    +
    +

    +
    + + +
    + + +
    + + +
    + + +
    + + + + +
    + + +
    + + +
    +
    +
    +
    + +
    +
    + + + +
    +
    + +{{/zone}} +{{#zone "bottomJs"}} + {{js "js/bottomJs.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.role.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js similarity index 68% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js index a65fa31e257..909a3ee3038 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.js @@ -25,14 +25,11 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var response = userModule.getRoles(); - if (response["status"] == "success") { - context["roles"] = response["content"]; - } - var userStores = userModule.getSecondaryUserStores(); - context["userStores"] = userStores; - context["roleNameJSRegEx"] = deviceMgtProps.roleValidationConfig.rolenameJSRegEx; - context["roleNameHelpText"] = deviceMgtProps.roleValidationConfig.rolenameHelpMsg; - context["roleNameRegExViolationErrorMsg"] = deviceMgtProps.roleValidationConfig.rolenameRegExViolationErrorMsg; + + context["userStores"] = userModule.getSecondaryUserStores(); + context["roleNameJSRegEx"] = deviceMgtProps["roleValidationConfig"]["roleNameJSRegEx"]; + context["roleNameHelpText"] = deviceMgtProps["roleValidationConfig"]["roleNameHelpMsg"]; + context["roleNameRegExViolationErrorMsg"] = deviceMgtProps["roleValidationConfig"]["roleNameRegExViolationErrorMsg"]; + 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/pages/cdmf.page.role.create/create.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json index e54dc5f2af2..adab2be0f6f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/create.json @@ -1,5 +1,5 @@ { "version": "1.0.0", - "uri": "/roles/add-role", + "uri": "/role/add", "layout": "cdmf.layout.default" } \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js similarity index 69% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.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.role.create/public/js/bottomJs.js index 5a7d7eb304a..013402bf841 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.create/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.create/public/js/bottomJs.js @@ -73,19 +73,19 @@ var disableInlineError = function (inputField, errorMsg, errorSign) { *clear inline validation messages. */ clearInline["role-name"] = function () { - disableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); + disableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); }; /** - * Validate if provided rolename is valid against RegEx configures. + * Validate if provided role-name is valid against RegEx configures. */ validateInline["role-name"] = function () { - var rolenameinput = $("input#rolename"); - if (inputIsValid( rolenameinput.data("regex"), rolenameinput.val())) { - disableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); + var roleNameInput = $("input#roleName"); + if (inputIsValid( roleNameInput.data("regex"), roleNameInput.val())) { + disableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); } else { - enableInlineError("roleNameField", "rolenameEmpty", "rolenameError"); + enableInlineError("roleNameField", "roleNameEmpty", "roleNameError"); } }; @@ -97,16 +97,16 @@ function formatRepo (user) { return; } var markup = '
    ' + - '
    ' + + '
    ' + '
    ' + - '
    ' + user.username + '
    '; - if (user.firstname) { - markup += '
    ' + user.firstname + '
    '; + '
    User : ' + user.username + '
    '; + if (user.name) { + markup += '
    ' + user.name + '
    '; } if (user.emailAddress) { - markup += '
    ' + user.emailAddress + '
    '; + markup += '
    ' + user.emailAddress + '
    '; } - markup += '
    '; + markup += '
    '; return markup; } @@ -129,17 +129,19 @@ $(document).ready(function () { }, data: function (params) { var postData = {}; - postData.actionMethod = "GET"; - postData.actionUrl = apiBasePath + "/users/search/usernames?filter=" + params.term; - postData.actionPayload = null; + postData.requestMethod = "GET"; + postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term; + postData.requestPayload = null; return JSON.stringify(postData); }, - processResults: function (data, page) { + processResults: function (data) { var newData = []; $.each(data, function (index, value) { var user = {}; - user.username = value.username; user.id = value.username; + user.username = value.username; + user.name = value.firstname + " " + value.lastname; + user.emailAddress = value.emailAddress; newData.push(user); }); return { @@ -159,10 +161,10 @@ $(document).ready(function () { * when a user clicks on "Add Role" button * on Add Role page in WSO2 MDM Console. */ - $("button#add-role-btn").click(function() { - var rolenameInput = $("input#rolename"); - var roleName = rolenameInput.val(); + $("button#add-role-btn").click(function () { var domain = $("#domain").val(); + var roleNameInput = $("input#roleName"); + var roleName = roleNameInput.val(); var users = $("#users").val(); var errorMsgWrapper = "#role-create-error-msg"; @@ -170,8 +172,8 @@ $(document).ready(function () { if (!roleName) { $(errorMsg).text("Role name is a required field. It cannot be empty."); $(errorMsgWrapper).removeClass("hidden"); - } else if (!inputIsValid(rolenameInput.data("regex"), roleName)) { - $(errorMsg).text(rolenameInput.data("errormsg")); + } else if (!inputIsValid(roleNameInput.data("regex"), roleName)) { + $(errorMsg).text(roleNameInput.data("error-msg")); $(errorMsgWrapper).removeClass("hidden"); } else if (!domain) { $(errorMsg).text("Domain is a required field. It cannot be empty."); @@ -181,13 +183,11 @@ $(document).ready(function () { $(errorMsgWrapper).removeClass("hidden"); } else { var addRoleFormData = {}; - addRoleFormData.roleName = roleName; - if (domain != "PRIMARY"){ addRoleFormData.roleName = domain + "/" + roleName; } - if (users == null){ + if (users == null) { users = []; } addRoleFormData.users = users; @@ -197,37 +197,31 @@ $(document).ready(function () { invokerUtil.post( addRoleAPI, addRoleFormData, - function (data) { - data = JSON.parse(data); - if (data.errorMessage) { - $(errorMsg).text("Selected user store prompted an error : " + data.errorMessage); - $(errorMsgWrapper).removeClass("hidden"); - } else { + function (data, textStatus, jqXHR) { + if (jqXHR.status == 201) { // Clearing user input fields. - //$("input#rolename").val(""); - //$("#domain").val(""); - //// Refreshing with success message - //$("#role-create-form").addClass("hidden"); - //$("#role-created-msg").removeClass("hidden"); - window.location.href = appContext + '/role/edit-permission/' + roleName; + $("input#roleName").val(""); + $("#domain").val("PRIMARY"); + $("#users").val(""); + window.location.href = appContext + "/role/edit-permission/" + roleName; } - }, function (data) { - if (JSON.parse(data).errorMessage.indexOf("RoleExisting") > -1) { - $(errorMsg).text("Role name : " + roleName + " already exists. Pick another role name."); - } else { - $(errorMsg).text(JSON.parse(data.responseText).errorMessage); + }, + function (jqXHR) { + if (jqXHR.status == 500) { + $(errorMsg).text("Either role already exists or unexpected error."); + $(errorMsgWrapper).removeClass("hidden"); } - $(errorMsgWrapper).removeClass("hidden"); } ); } }); - $("#rolename").focus(function() { + var roleNameInputElement = "#roleName"; + $(roleNameInputElement).focus(function() { clearInline["role-name"](); }); - $("#rolename").blur(function() { + $(roleNameInputElement).blur(function() { validateInline["role-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.role.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.hbs index cdf32d98844..d1c488dbef6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.role.edit/edit.hbs @@ -26,6 +26,7 @@
  • + Roles diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js similarity index 97% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index bfec8b339f2..47a6dc90e08 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -145,7 +145,7 @@ function loadRoles(searchQuery) { var modalPopup = ".modal"; var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-body"; +var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; var isInit = true; @@ -162,8 +162,8 @@ function setPopupMaxHeight() { * show popup function. */ function showPopup() { - $(modalPopup).show(); - setPopupMaxHeight(); + $(modalPopup).modal('show'); + //setPopupMaxHeight(); } /* @@ -172,6 +172,8 @@ function showPopup() { function hidePopup() { $(modalPopupContent).html(''); $(modalPopup).modal('hide'); + $('body').removeClass('modal-open').css('padding-right','0px'); + $('.modal-backdrop').remove(); } /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/public/templates/role-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/templates/role-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.role.listing/public/templates/role-listing.hbs rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/templates/role-listing.hbs diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs index 07f4c0a143f..b9c4083c4e4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.hbs @@ -15,8 +15,8 @@ specific language governing permissions and limitations under the License. }} -{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}} +{{unit "cdmf.unit.ui.title" pageTitle="Role Management"}} {{unit "cdmf.unit.data-tables-extended"}} {{#zone "breadcrumbs"}} @@ -26,6 +26,7 @@
  • + Roles @@ -34,7 +35,8 @@ {{#zone "navbarActions"}}
  • - + + @@ -45,5 +47,114 @@ {{/zone}} {{#zone "content"}} - {{unit "cdmf.unit.role.listing"}} +{{! +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. +}} + +
    + {{#if removePermitted}} + + {{/if}} + {{#if editPermitted}} + + {{/if}} + + Loading roles . . . +
    +
    + +
    + + + + + + + + + + +
    By Role Name
    +
    + + + + +
    + +
    +
    +
    +
    +

    Done. Role was successfully removed.

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

    An unexpected error occurred. Please try again later.

    + + +
    +
    +
    +
    +{{/zone}} + +{{#zone "bottomJs"}} + + + {{js "js/role-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.role.listing/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.js similarity index 88% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.js index d908da5d2d3..341720e9a8e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.role.listing/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/roles.js @@ -18,8 +18,8 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var response = userModule.getUsers(); - var users = {}; + var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + context["permissions"] = userModule.getUIPermissions(); if (userModule.isAuthorized("/permission/admin/device-mgt/roles/delete")) { context["removePermitted"] = true; @@ -30,8 +30,9 @@ function onRequest(context) { if (userModule.isAuthorized("/permission/admin/device-mgt/roles/remove")) { context["removePermitted"] = true; } - var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - context["appContext"] = deviceMgtProps.appContext; - context["adminRole"] = deviceMgtProps.adminRole; + + context["appContext"] = deviceMgtProps["appContext"]; + context["adminRole"] = deviceMgtProps["adminRole"]; + 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/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 e2017b97bc2..5aa17f26fe9 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 @@ -32,7 +32,7 @@ $(function () { var sortableElem = '.wr-sortable'; $(sortableElem).sortable({ beforeStop: function () { - var sortedIDs = $(this).sortable('toArray'); + $(this).sortable('toArray'); } }); $(sortableElem).disableSelection(); @@ -43,7 +43,6 @@ var modalPopup = ".modal"; var modalPopupContainer = modalPopup + " .modal-content"; var modalPopupContent = modalPopup + " .modal-body"; var body = "body"; -var isInit = true; $(".icon .text").res_text(0.2); /* @@ -70,24 +69,12 @@ function hidePopup() { $(modalPopup).modal('hide'); } -/* - * Function to get selected usernames. - */ -function getSelectedUsernames() { - var usernameList = []; - var userList = $("#user-grid").find('tr.DTTT_selected'); - userList.each(function () { - usernameList.push($(this).data('username')); - }); - return usernameList; -} - /** * Following click function would execute * when a user clicks on "Invite" link * on User Management page in WSO2 MDM Console. */ -$("a.invite-user-link").click(function () { +$("a#invite-user-link").click(function () { var usernameList = getSelectedUsernames(); var inviteUserAPI = apiBasePath + "/users/send-invitation"; @@ -123,44 +110,16 @@ $("a.invite-user-link").click(function () { }); }); -/** - * Following click function would execute - * when a user clicks on "Remove" link - * on User Listing page in WSO2 MDM Console. +/* + * Function to get selected usernames. */ -function removeUser(uname) { - var username = uname; - var removeUserAPI = apiBasePath + "/users/" + username; - $(modalPopupContent).html($('#remove-user-modal-content').html()); - showPopup(); - - $("a#remove-user-yes-link").click(function () { - invokerUtil.delete( - removeUserAPI, - function () { - $("#role-" + username).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(); - }); - } - ); - }); - - $("a#remove-user-cancel-link").click(function () { - hidePopup(); +function getSelectedUsernames() { + var usernameList = []; + var userList = $("#user-grid").find("tr.DTTT_selected"); + userList.each(function () { + usernameList.push($(this).data('username')); }); + return usernameList; } /** @@ -168,15 +127,13 @@ function removeUser(uname) { * when a user clicks on "Reset Password" link * on User Listing page in WSO2 MDM Console. */ -function resetPassword(uname) { - +function resetPassword(username) { $(modalPopupContent).html($('#reset-password-window').html()); showPopup(); $("a#reset-password-yes-link").click(function () { var newPassword = $("#new-password").val(); var confirmedPassword = $("#confirmed-password").val(); - var user = uname; var errorMsgWrapper = "#notification-error-msg"; var errorMsg = "#notification-error-msg span"; @@ -194,22 +151,24 @@ function resetPassword(uname) { $(errorMsgWrapper).removeClass("hidden"); } else { var resetPasswordFormData = {}; - //resetPasswordFormData.username = user; resetPasswordFormData.newPassword = unescape(confirmedPassword); - var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ user +"/credentials"; + var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials"; invokerUtil.post( resetPasswordServiceURL, resetPasswordFormData, - function (data, textStatus, jqXHR) { // The success callback + // The success callback + function (data, textStatus, jqXHR) { if (jqXHR.status == 200) { $(modalPopupContent).html($('#reset-password-success-content').html()); $("a#reset-password-success-link").click(function () { hidePopup(); }); } - }, function (jqXHR) { // The error callback + }, + // The error callback + function (jqXHR) { var payload = JSON.parse(jqXHR.responseText); $(errorMsg).text(payload.message); $(errorMsgWrapper).removeClass("hidden"); @@ -224,15 +183,41 @@ function resetPassword(uname) { } /** - * Following on click function would execute - * when a user type on the search field on User Listing page in - * WSO2 MDM Console then click on the search button. + * Following click function would execute + * when a user clicks on "Remove" link + * on User Listing page in WSO2 MDM Console. */ -$("#search-btn").click(function () { - var searchQuery = $("#search-by-username").val(); - $("#ast-container").empty(); - loadUsers(searchQuery); -}); +function removeUser(username) { + var removeUserAPI = apiBasePath + "/users/" + username; + $(modalPopupContent).html($('#remove-user-modal-content').html()); + showPopup(); + + $("a#remove-user-yes-link").click(function () { + invokerUtil.delete( + removeUserAPI, + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + $("#user-" + username).remove(); + // 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(); + }); + } + ); + }); + + $("a#remove-user-cancel-link").click(function () { + hidePopup(); + }); +} /** * Following function would execute @@ -248,169 +233,132 @@ function InitiateViewOption() { } } -function loadUsers(searchParam) { - - - $("#loading-content").show(); +function loadUsers() { + var loadingContentView = "#loading-content"; + $(loadingContentView).show(); - - var dataFilter = function(data){ + var dataFilter = function (data) { data = JSON.parse(data); var objects = []; - $(data.users).each(function( index ) { + $(data.users).each( function (index) { objects.push({ filter: data.users[index].username, - firstname: data.users[index].firstname ? data.users[index].firstname: '' , - lastname: data.users[index].lastname ? data.users[index].lastname : '', - emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress: '', - DT_RowId : "role-" + data.users[index].username}) + firstname: data.users[index].firstname ? data.users[index].firstname : "" , + lastname: data.users[index].lastname ? data.users[index].lastname : "", + emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress : "", + DT_RowId : "user-" + data.users[index].username}) }); - json = { + var json = { "recordsTotal": data.count, "recordsFiltered": data.count, "data": objects }; - return JSON.stringify( json ); - } + return JSON.stringify(json); + }; - var fnCreatedRow = function( nRow, aData, iDataIndex ) { + //noinspection JSUnusedLocalSymbols + var fnCreatedRow = function (nRow, aData, iDataIndex) { $(nRow).attr('data-type', 'selectable'); $(nRow).attr('data-username', aData["filter"]); - } + }; + //noinspection JSUnusedLocalSymbols var columns = [ { class: "remove-padding icon-only content-fill", data: null, - defaultContent: '
    ' + defaultContent: '
    ' + + '' + + '
    ' }, { class: "fade-edge", data: null, - render: function ( data, type, row, meta ) { - return '

    ' + data.firstname + ' ' + data.lastname + '

    '; + render: function (data, type, row, meta) { + if (!data.firstname && !data.lastname) { + return ""; + } else if (data.firstname && data.lastname) { + return "

      " + data.firstname + " " + data.lastname + "

    "; + } } }, { class: "fade-edge remove-padding-top", data: 'filter', - render: function ( filter, type, row, meta ) { - return ' ' + filter; + render: function (filter, type, row, meta) { + return '    ' + filter; } }, { class: "fade-edge remove-padding-top", data: null, - render: function ( data, type, row, meta ) { - return ' ' + data.emailAddress + ' '; + render: function (data, type, row, meta) { + if (!data.emailAddress) { + return ""; + } else { + return "    " + data.emailAddress + ""; + } } }, { class: "text-right content-fill text-left-on-grid-view no-wrap", data: null, - render: function ( data, type, row, meta ) { - return ' ' + - ' ' + - ' ' + - - ' ' + + ' ' + + '' + + '' + + '' + + '' + + '' + + '' + - ' ' + - ' ' + - - ' ' + - ' <' + - '/i> ' + - ' ' + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; } } ]; - var options = { "placeholder": "Search By Username", "searchKey" : "filter" }; - $('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options); - - $("#loading-content").hide(); - - - - // $("#loading-content").show(); - // var userListing = $("#user-listing"); - // var userListingSrc = userListing.attr("src"); - // $.template("user-listing", userListingSrc, function (template) { - // var serviceURL = apiBasePath + "/users"; - // if (searchParam) { - // serviceURL = serviceURL + "?filter=" + searchParam; - // } - // var successCallback = function (data) { - // if (!data) { - // $('#ast-container').addClass('hidden'); - // $('#user-listing-status-msg').text('No users are available to be displayed.'); - // return; - // } - // var canRemove = $("#can-remove").val(); - // var canEdit = $("#can-edit").val(); - // var canResetPassword = $("#can-reset-password").val(); - // data = JSON.parse(data); - // var viewModel = {}; - // viewModel.users = data.users; - // for (var i = 0; i < viewModel.users.length; i++) { - // viewModel.users[i].userid = viewModel.users[i].username.replace(/[^\w\s]/gi, ''); - // if (canRemove) { - // viewModel.users[i].canRemove = true; - // } - // if (canEdit) { - // viewModel.users[i].canEdit = true; - // } - // if (canResetPassword) { - // viewModel.users[i].canResetPassword = true; - // } - // viewModel.users[i].adminUser = $("#user-table").data("user"); - // } - // if (data.count > 0) { - // $('#ast-container').removeClass('hidden'); - // $('#user-listing-status-msg').text(""); - // var content = template(viewModel); - // $("#ast-container").html(content); - // } else { - // $('#ast-container').addClass('hidden'); - // $('#user-listing-status-msg').text('No users are available to be displayed.'); - // } - // $("#loading-content").hide(); - // if (isInit) { - // $('#user-grid').datatables_extended(); - // isInit = false; - // } - // $(".icon .text").res_text(0.2); - // }; - // invokerUtil.get(serviceURL, - // successCallback, - // function (message) { - // $('#ast-container').addClass('hidden'); - // $('#user-listing-status-msg'). - // text('Invalid search query. Try again with a valid search query'); - // } - // ); - // }); + $(loadingContentView).hide(); } $(document).ready(function () { loadUsers(); - $(".viewEnabledIcon").click(function () { InitiateViewOption(); }); 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 ae90987ece3..c74c4870ef9 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 @@ -15,8 +15,8 @@ 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"}} {{unit "cdmf.unit.data-tables-extended"}} {{#zone "breadcrumbs"}} @@ -26,6 +26,7 @@
  • + USERS @@ -34,6 +35,7 @@ {{#zone "navbarActions"}}
  • + @@ -64,84 +66,25 @@ {{/if}} - Loading users . . .
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - +
    By Username
    +
    -
    +