From bb681c43d00c47b982f1614a765308b1439db8ff Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 21 Oct 2019 13:50:21 +0530 Subject: [PATCH] Message to display in view when a selected corrective policy is changed to general or deleted --- .../units/cdmf.unit.policy.view/public/js/view.js | 12 +++++++++++- .../app/units/cdmf.unit.policy.view/view.hbs | 13 ++++++++++++- .../app/units/cdmf.unit.policy.view/view.js | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js index 5e3b17092d..a7fd6e461a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js @@ -73,7 +73,17 @@ var displayPolicy = function (policyPayloadObj) { policyPayloadObj.correctiveActions && policyPayloadObj.correctiveActions.length > 0) { policyPayloadObj.correctiveActions.forEach(function (correctiveAction) { if ("POLICY" === correctiveAction.actionType) { - $("#corrective-action-type-policy-id").html(correctiveAction.policyId); + $("#corrective-action-type-policy-id").html(correctiveAction.policyId); + var correctivePolicies = $("#logged-in-user").data("corrective-policies"); + if (correctivePolicies) { + var i; + for (i = 0; i < correctivePolicies.length; i++) { + if (correctiveAction.policyId === correctivePolicies[i].id) { + $("#corrective-action-policy-id-missing-msg").addClass("hidden"); + break; + } + } + } return true; } }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs index 8ac41acee8..c65faea981 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs @@ -1,7 +1,8 @@ {{#zone "content"}} {{#if isAuthorized}} + data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" + data-corrective-policies="{{correctivePolicies}}"> {{#defineZone "policy-profile-top"}}
@@ -67,6 +68,16 @@ Policy ID + + + + + Corrective policy having the above Policy ID has been updated to + a GENERAL policy or it has been deleted. Hence this policy will + not be applied till modified correctly. + + +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js index 8dcefb24bc..417910dc78 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js @@ -18,6 +18,8 @@ function onRequest(context) { var utility = require("/app/modules/utility.js").utility; + var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; + var page = {}; var deviceType = request.getParameter("deviceType"); var policyViewSrc = "/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-view"); @@ -42,6 +44,8 @@ function onRequest(context) { var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; page["isCloud"] = devicemgtProps.isCloud; + + page["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]); return page; } \ No newline at end of file