-
Step 4: Publish to devices
+
Step 5: Publish to devices
@@ -110,7 +118,7 @@
-
Step 3: Assign to groups
+
Step 4: Assign to groups
@@ -201,7 +209,7 @@
@@ -209,7 +217,45 @@
-
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
index 94f0b1235b2..b3646d88849 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/create.js
@@ -118,5 +118,7 @@ function onRequest(context) {
var enrollmentApps = policyModule.getStoreAppsForPolicy();
types["storeApps"] = JSON.stringify(enrollmentApps["content"]);
+ types["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]);
+
return types;
}
\ 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.policy.create/public/js/policy-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js
index 703c808923c..16085c4b777 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.create/public/js/policy-create.js
@@ -39,6 +39,7 @@ var validateInline = {};
var clearInline = {};
var validateStep = {};
var hasPolicyProfileScript = false;
+var isCorrectiveActionProfileAdded = false;
var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField;
@@ -221,8 +222,36 @@ stepForwardFrom["policy-profile"] = function () {
*/
policy["profile"] = generatePolicyProfile();
}
+
+ // add policy correction action page
+ if (!isCorrectiveActionProfileAdded) {
+ var policyCorrectiveActionTemplateSrc =
+ "/public/cdmf.unit.policy.corrective-action/templates/policy-corrective-action.hbs";
+ var policyCorrectiveActionScriptSrc =
+ "/public/cdmf.unit.policy.corrective-action/js/policy-corrective-action.js";
+ var policyCorrectiveActionTemplateCacheKey = "policy-corrective-action";
+
+ $.template(policyCorrectiveActionTemplateCacheKey, context + policyCorrectiveActionTemplateSrc,
+ function (template) {
+ var content = template(
+ {
+ "deviceType": policy["platform"],
+ "correctivePolicies": $("#logged-in-user").data("corrective-policies")
+ }
+ );
+ $("#select-general-policy-type").html(content)
+ });
+
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = context + policyCorrectiveActionScriptSrc;
+ document.head.append(script);
+
+ isCorrectiveActionProfileAdded = true
+ }
+
// updating next-page wizard title with selected platform
- $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
+ $("#policy-type-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
};
/**
@@ -238,6 +267,28 @@ stepBackFrom["policy-profile"] = function () {
}
};
+
+/**
+ * Forward action of policy type page.
+ */
+stepForwardFrom["policy-type"] = function () {
+ policy["type"] = $("input[name=policy-type-radio-btn]:checked").val();
+ var correctiveActionList = [];
+ if (policy.type === "GENERAL") {
+ var selectedCorrectivePolicyId = $("#corrective-policy-input").val();
+ if (selectedCorrectivePolicyId !== "none") {
+ var correctiveAction = {
+ "actionType": "POLICY",
+ "policyId": selectedCorrectivePolicyId
+ };
+ correctiveActionList.push(correctiveAction);
+ }
+ }
+ policy["correctiveActionList"] = correctiveActionList;
+ //updating next-page wizard title with selected platform
+ $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY");
+};
+
/**
* Forward action of policy criteria page.
*/
@@ -438,6 +489,8 @@ var savePolicy = function (policy, isActive, serviceURL) {
"compliance": policy["selectedNonCompliantAction"],
"ownershipType": null,
"active": isActive,
+ "policyType": policy["type"],
+ "correctiveActions": policy["correctiveActionList"],
"profile": {
"profileName": policy["policyName"],
"deviceType": policy["platform"],
@@ -458,8 +511,6 @@ var savePolicy = function (policy, isActive, serviceURL) {
payload["deviceGroups"] = policy["selectedGroups"];
}
- payload["policyType"] = "GENERAL";
-
invokerUtil.post(
serviceURL,
payload,
@@ -594,6 +645,16 @@ $(document).ready(function () {
}
});
+ isCorrectiveActionProfileAdded = false;
+
+ $('input[type=radio][name=policy-type-radio-btn]').change(function() {
+ if ($(this).val() === "CORRECTIVE") {
+ $("#select-general-policy-type").addClass("hidden");
+ } else {
+ $("#select-general-policy-type").removeClass("hidden");
+ }
+ });
+
//Policy wizard stepper
$(".wizard-stepper").click(function () {
// button clicked here can be either a continue button or a back button.