From c4d433a1a0e53549240c100823478f209af30475 Mon Sep 17 00:00:00 2001 From: madhawap Date: Mon, 29 May 2017 20:13:51 +0530 Subject: [PATCH] Fix for disabling reboot and upgrade-firmware operations on UI and Code formatting In order to execute these two operations the enrolled device needs to have the system app installed. Therefore, in order to stop users from trying these two operations on cloud, the icons related to these two operations, on operation bar are disabled. In addition change a c-style for loop to a foreach loop in PolicyManagementServiceImpl.java --- .../jaxrs/service/impl/PolicyManagementServiceImpl.java | 8 ++++---- .../app/modules/business-controllers/operation.js | 8 ++++++++ .../units/cdmf.unit.ui.theme/public/css/custom-common.css | 7 ++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java index 7c1fe8e407..f51ebfd928 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -345,11 +345,11 @@ public class PolicyManagementServiceImpl implements PolicyManagementService { public Response updatePolicyPriorities(List priorityUpdatedPolicies) { PolicyManagerService policyManagementService = DeviceMgtAPIUtils.getPolicyManagementService(); List policiesToUpdate = new ArrayList<>(priorityUpdatedPolicies.size()); - int i; - for (i = 0; i < priorityUpdatedPolicies.size(); i++) { + + for (PriorityUpdatedPolicyWrapper priorityUpdatedPolicy : priorityUpdatedPolicies) { Policy policyObj = new Policy(); - policyObj.setId(priorityUpdatedPolicies.get(i).getId()); - policyObj.setPriorityId(priorityUpdatedPolicies.get(i).getPriority()); + policyObj.setId(priorityUpdatedPolicy.getId()); + policyObj.setPriorityId(priorityUpdatedPolicy.getPriority()); policiesToUpdate.add(policyObj); } boolean policiesUpdated; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index 666b1b571d..3451c66cb3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -86,6 +86,14 @@ var operationModule = function () { var iconIdentifier = operations[op].operation; if (features && features[iconIdentifier]) { var icon = features[iconIdentifier].icon; + var isCloud = devicemgtProps["isCloud"]; + //TODO: remove isCloud check once able to verify features from the device agent + var isDisabled = features[iconIdentifier].isDisabled; + if (isDisabled && isCloud) { + operations[op]["isDisabled"] = isDisabled; + } else { + operations[op]["isDisabled"] = false; + } if (icon) { operations[op]["iconFont"] = icon; } else if (iconPath) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css index 1fa92bf549..82a5f91859 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css @@ -265,4 +265,9 @@ header .username { .add-padding-top-3x { padding-top: 15px !important; -} \ No newline at end of file +} + +.op-disabled, .op-disabled i, .op-disabled span { + cursor: not-allowed; ++ color: #d2d2d2; +}