From 5b96e1b849e44a4712679385ca7e77ad9e930456 Mon Sep 17 00:00:00 2001 From: Megala Date: Wed, 12 Oct 2016 09:38:11 +0530 Subject: [PATCH 01/14] Fixing EMM-1333 --- .../service/impl/RoleManagementServiceImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 6cae3ad776..22499f79ce 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -135,7 +135,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore); final UIPermissionNode rolePermissions = userRealmProxy.getRolePermissions(roleName, MultitenantConstants.SUPER_TENANT_ID); - UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[2]; + UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[4]; for (UIPermissionNode permissionNode : rolePermissions.getNodeList()) { if (permissionNode.getResourcePath().equals("/permission/admin")) { @@ -144,6 +144,16 @@ public class RoleManagementServiceImpl implements RoleManagementService { deviceMgtPermissions[0] = node; } else if (node.getResourcePath().equals("/permission/admin/login")) { deviceMgtPermissions[1] = node; + } else if (node.getResourcePath().equals("/permission/admin/manage")) { + // Adding permissions related to app-store in emm-console + for (UIPermissionNode subNode : node.getNodeList()) { + if (subNode.getResourcePath().equals("/permission/admin/manage/mobileapp")) { + deviceMgtPermissions[2] = subNode; + } + if (subNode.getResourcePath().equals("/permission/admin/manage/webapp")) { + deviceMgtPermissions[3] = subNode; + } + } } } } From 4999b841691d1f6e0b5c47952c5859ac78eeea78 Mon Sep 17 00:00:00 2001 From: Megala Date: Wed, 12 Oct 2016 09:41:43 +0530 Subject: [PATCH 02/14] Reformatting code --- .../mgt/jaxrs/service/impl/RoleManagementServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 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/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 22499f79ce..bfc767b8cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -149,8 +149,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { for (UIPermissionNode subNode : node.getNodeList()) { if (subNode.getResourcePath().equals("/permission/admin/manage/mobileapp")) { deviceMgtPermissions[2] = subNode; - } - if (subNode.getResourcePath().equals("/permission/admin/manage/webapp")) { + } else if (subNode.getResourcePath().equals("/permission/admin/manage/webapp")) { deviceMgtPermissions[3] = subNode; } } From 0498c68ca56e948ca03ebff2fa613409018fc62e Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 12 Oct 2016 12:55:59 +0530 Subject: [PATCH 03/14] Add validation to maximum limit value (cherry picked from commit 4ed757f) --- .../mgt/jaxrs/service/impl/util/RequestValidationUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 603cbe2005..00c7a503e2 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 @@ -337,10 +337,10 @@ public class RequestValidationUtil { new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter limit is a " + "negative value.").build()); } - if (limit - offset > 100) { + if (limit > 100) { throw new InputValidationException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request results list should" + - " be less than or equal 100 values.").build()); + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter limit should" + + " be less than or equal to 100.").build()); } } From 43b1a9f2787a240dd51001b33b413df259270d12 Mon Sep 17 00:00:00 2001 From: kamidu Date: Wed, 12 Oct 2016 16:09:28 +0530 Subject: [PATCH 04/14] Fix for EMM-1651 --- .../cdmf.page.users/public/js/listing.js | 34 +++++++------------ .../app/pages/cdmf.page.users/users.hbs | 2 +- .../app/pages/cdmf.page.users/users.js | 3 +- 3 files changed, 15 insertions(+), 24 deletions(-) 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 43d6de1a83..1074b271cf 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 @@ -313,7 +313,7 @@ function loadUsers() { if (!data.firstname && !data.lastname) { return ""; } else if (data.firstname && data.lastname) { - return "

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

"; + return "

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

"; } } }, @@ -321,7 +321,7 @@ function loadUsers() { class: "fade-edge remove-padding-top", data: 'filter', render: function (filter, type, row, meta) { - return '    ' + filter; + return '' + filter; } }, { @@ -331,7 +331,7 @@ function loadUsers() { if (!data.emailAddress) { return ""; } else { - return "    " + data.emailAddress + ""; + return "" + data.emailAddress + ""; } } }, @@ -339,17 +339,13 @@ function loadUsers() { class: "text-right content-fill text-left-on-grid-view no-wrap", data: null, render: function (data, type, row, meta) { - var editbtn = '  ' + ' ' + '' + '' + - '' + - '' + - ''; + ''; var resetPasswordbtn = '' + '' + '' + - '' + - '' + - ''; + ''; var removebtn = '' + '' + '' + - '' + - '' + - ''; + ''; var returnbtnSet = ''; - if ($("#can-edit").length > 0) { + var adminUser = $("#user-table").data("user"); + var currentUser = $("#user-table").data("logged-user"); + if ($("#can-edit").length > 0 && adminUser !== data.filter) { returnbtnSet = returnbtnSet + editbtn; } - if ($("#can-reset-password").length > 0) { + if ($("#can-reset-password").length > 0 && adminUser !== data.filter) { returnbtnSet = returnbtnSet + resetPasswordbtn; } - if ($("#can-remove").length > 0) { + if ($("#can-remove").length > 0 && adminUser !== data.filter && currentUser !== data.filter) { returnbtnSet = returnbtnSet + removebtn; } 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 fe56dedb3c..ea30ecbfc9 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 @@ -65,7 +65,7 @@
-
+
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 e4ef55ed1f..e777b314ac 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 @@ -31,7 +31,8 @@ function onRequest(context) { var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - page["adminUser"] = deviceMgtProps["adminUser"]; + page["currentUser"] = userModule.getCarbonUser().username; + page["adminUser"] = deviceMgtProps["adminUser"].split("@")[0]; if (userModule.isAuthorized("/permission/admin/device-mgt/users/manage")) { page.canManage = true; From c4a0ac4bf37ca9b35e85c3b4dfec73bc4bb69ebb Mon Sep 17 00:00:00 2001 From: kamidu Date: Wed, 12 Oct 2016 17:39:31 +0530 Subject: [PATCH 05/14] Enable centralized modal handling unit for cdmf --- .../app/units/cdmf.unit.ui.modal/modal.hbs | 51 +++++++++++++ .../app/units/cdmf.unit.ui.modal/modal.json | 4 ++ .../units/cdmf.unit.ui.modal/public/modal.js | 72 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs new file mode 100644 index 0000000000..aa18aaf814 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs @@ -0,0 +1,51 @@ +{{! + 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. +}} + +{{#zone "content"}} + + + + +{{/zone}} + +{{#zone "topJs"}} + {{js "js/modal.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.modal/modal.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json new file mode 100644 index 0000000000..50380954de --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "isAnonymous": true, +} \ 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.modal/public/modal.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js new file mode 100644 index 0000000000..0e97b964b7 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js @@ -0,0 +1,72 @@ +/** + * 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. + */ + + +var modalDialog = (function () { + var publicMethoads = {}; + publicMethoads.header = function (headerText) { + $("#modal-title-text").html(headerText); + + }; + publicMethoads.content = function (contentText) { + $("#modal-content-text").html(contentText); + + }; + publicMethoads.footer = function (footerContent) { + $("#modal-footer-content").html(footerContent); + + }; + publicMethoads.footerButtons = function (buttonList) { + var footerContent = ""; + for (var btn in buttonList) { + footerContent = footerContent + ''; + } + $("#modal-footer-content").html(footerContent); + }; + publicMethoads.show = function () { + + $(".error-msg-icon").addClass("hidden"); + $(".warning-msg-icon").addClass("hidden"); + $("#basic-modal-view").removeClass('hidden'); + $("#basic-modal-view").modal('show'); + + }; + publicMethoads.showAsError = function () { + $(".error-msg-icon").removeClass("hidden"); + $("#basic-modal-view").removeClass('hidden'); + $("#basic-modal-view").modal('show'); + + }; + publicMethoads.showAsAWarning = function () { + $(".warning-msg-icon").removeClass("hidden"); + $("#basic-modal-view").removeClass('hidden'); + $("#basic-modal-view").modal('show'); + + }; + publicMethoads.hide = function () { + $("#basic-modal-view").addClass('hidden'); + $("#basic-modal-view").modal('hide'); + $("#modal-title-text").html(""); + $("#modal-content-text").html(""); + $("#modal-footer-content").html(""); + $('body').removeClass('modal-open').css('padding-right', '0px'); + $('.modal-backdrop').remove(); + }; + return publicMethoads; +}(modalDialog)); \ No newline at end of file From 135b6e888121c185d74d208fa56fee328ca02715 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 13 Oct 2016 08:15:43 +0530 Subject: [PATCH 06/14] Fixing device view page --- .../app/units/cdmf.unit.device.view/view.hbs | 624 +++++------------- .../app/units/cdmf.unit.device.view/view.js | 277 +++++--- 2 files changed, 351 insertions(+), 550 deletions(-) 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 586cad7073..5a9a302a77 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 @@ -1,481 +1,193 @@ -{{unit "cdmf.unit.lib.qrcode"}} +{{! + 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. +}} {{#zone "content"}} {{#if deviceFound}} {{#if isAuthorized}} -

- Device {{deviceView.name}} - {{#if deviceView.model}} +

+ Device {{device.name}} + {{#if device.viewModel.model}} - ( {{deviceView.vendor}} {{deviceView.model}} ) - + ( {{device.viewModel.vendor}} {{device.viewModel.model}} ) + {{/if}}

-
-
-
-
-
Device - Overview -
- {{#defineZone "device-detail-properties"}} -
- - {{#if deviceView.deviceIdentifier}} - - - - - {{/if}} - {{#if deviceView.name}} - - - - - {{/if}} - {{#if deviceView.vendor}} - {{#if deviceView.model}} - - - - - {{/if}} - {{/if}} - {{#if deviceView.status}} - - - - - {{/if}} - {{#if deviceView.owner}} - - - - - {{/if}} - {{#if deviceView.ownership}} - - - - - {{/if}} - {{#if deviceView.imei}} - - - - - {{/if}} - {{#if deviceView.udid}} - - - - - {{/if}} - {{#if deviceView.osBuildDate}} - - - - - {{/if}} - {{#if deviceView.phoneNumber}} - - - - - {{/if}} - {{#if deviceView.lastUpdatedTime}} - - - - - {{/if}} - -
Device ID{{deviceView.deviceIdentifier}}
Name{{deviceView.name}}
Model{{deviceView.vendor}} {{deviceView.model}}
Status - {{#equal deviceView.status "ACTIVE"}}Active{{/equal}} - {{#equal deviceView.status "INACTIVE"}}Inactive{{/equal}} - {{#equal deviceView.status "BLOCKED"}}Blocked{{/equal}} - {{#equal deviceView.status "REMOVED"}}Removed{{/equal}} -
Owner{{deviceView.owner}}
Ownership{{deviceView.ownership}}
IMEI{{deviceView.imei}}
UDID{{deviceView.udid}}
Firmware Build - Date - {{deviceView.osBuildDate}}
Phone Number{{deviceView.phoneNumber}}
Last Update{{deviceView.lastUpdatedTime}}
- {{/defineZone}} -
- Operations +
+
+
+ {{#defineZone "device-thumbnail"}} + + {{/defineZone}} +
-
- {{unit "mdm.unit.device.operation-bar" deviceType=deviceView.deviceType ownership=deviceView.ownership}} +
+
+ Device Overview - {{label}}
+ {{unit "cdmf.unit.device.overview-section" device=device}} + {{#defineZone "operation-status"}}{{/defineZone}} + {{#defineZone "device-opetations"}} +
+ Operations +
+
+ {{unit "cdmf.unit.device.operation-bar" device=device}} +
+ {{/defineZone}}
-
- - {{#defineZone "device-detail-properties"}} -
-
- - - {{#if deviceView.isNotWindows}} -
-