From 37f0bc396da87cce746093f178c89368f2d8de84 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Fri, 2 Dec 2016 17:03:19 +0530 Subject: [PATCH] IOTS-296: Moving policy profile generation to android plugin Policy profile generation part is removed from the CDMF core and moved to plugins as policy profile is dependent on the device type. In this commit, policy profile generation for android device type is implemnted in android plugin. --- .../public/js/android-policy-edit.js | 38 +++++++++++++++++++ .../public/js/android-policy-operations.js | 31 +++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js index eb36242fea..d673b6d6a9 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-edit/public/js/android-policy-edit.js @@ -55,6 +55,13 @@ var updateGroupedInputVisibility = function (domElement) { } }; +/** + * Populates policy configuration to the ui elements. + * + * This method will be invoked from the relevant cdmf unit when the edit page gets loaded. + * + * @param configuredOperations selected configurations. + */ var polulateProfileOperations = function (configuredOperations) { $(".wr-advance-operations li.grouped-input").each(function () { updateGroupedInputVisibility(this); @@ -80,6 +87,13 @@ var inputIsValidAgainstRange = function (numberInput, min, max) { return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); }; +/** + * Validates policy profile operations for the windows platform. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {boolean} whether validation is successful. + */ var validatePolicyProfile = function () { var validationStatusArray = []; var validationStatus; @@ -528,6 +542,30 @@ var validatePolicyProfile = function () { return wizardIsToBeContinued; }; +/** + * Generates policy profile object which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {Array} profile payloads + */ +var generatePolicyProfile = function () { + var profilePayloads = []; + // traverses key by key in policy["profile"] + var key; + for (key in policy["profile"]) { + if (policy["profile"].hasOwnProperty(key)) { + profilePayloads.push({ + "featureCode": key, + "deviceType": policy["platform"], + "content": policy["profile"][key] + }); + } + } + + return profilePayloads; +}; + // Start of HTML embedded invoke methods var showAdvanceOperation = function (operation, button) { $(button).addClass('selected'); diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js index 0853791071..22bf73250f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard/public/js/android-policy-operations.js @@ -67,6 +67,13 @@ var inputIsValidAgainstRange = function (numberInput, min, max) { return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); }; +/** + * Validates policy profile operations for the windows platform. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {boolean} whether validation is successful. + */ var validatePolicyProfile = function () { var validationStatusArray = []; var validationStatus; @@ -515,6 +522,30 @@ var validatePolicyProfile = function () { return wizardIsToBeContinued; }; +/** + * Generates policy profile object which will be saved with the profile. + * + * This function will be invoked from the relevant cdmf unit at the time of policy creation. + * + * @returns {Array} profile payloads + */ +var generatePolicyProfile = function () { + var profilePayloads = []; + // traverses key by key in policy["profile"] + var key; + for (key in policy["profile"]) { + if (policy["profile"].hasOwnProperty(key)) { + profilePayloads.push({ + "featureCode": key, + "deviceType": policy["platform"], + "content": policy["profile"][key] + }); + } + } + + return profilePayloads; +}; + // Start of HTML embedded invoke methods var showAdvanceOperation = function (operation, button) { $(button).addClass('selected');