From 019502c58460468ab403cbf7eb44f9883f353d43 Mon Sep 17 00:00:00 2001 From: Milan Perera Date: Fri, 17 May 2019 11:33:40 +0530 Subject: [PATCH] Add always on VPN policy --- .../public/js/operation-bar.js | 3 +- .../public/js/operation-mod.js | 8 ++- .../public/js/android-policy-edit.js | 38 +++++++++--- .../public/templates/android-policy-edit.hbs | 56 +++++++++++++++++ .../public/templates/android-policy-view.hbs | 58 ++++++++++++++++- .../public/js/android-policy-operations.js | 36 ++++++++--- .../templates/android-policy-operations.hbs | 62 ++++++++++++++++++- 7 files changed, 237 insertions(+), 24 deletions(-) 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.operation-bar/public/js/operation-bar.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.operation-bar/public/js/operation-bar.js index c6e811fae..56fc63621 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.operation-bar/public/js/operation-bar.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.operation-bar/public/js/operation-bar.js @@ -418,7 +418,8 @@ var generatePayload = function (operationCode, operationData, deviceList) { payload = { "operation": { "type": operationData["type"], - "openvpn_config": operationData["openvpn_config"] + "openvpn_config": operationData["openvpn_config"], + "packageName": operationData["packageName"] } }; break; 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.operation-mod/public/js/operation-mod.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.operation-mod/public/js/operation-mod.js index fe820ecc3..866e7efd1 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.operation-mod/public/js/operation-mod.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.operation-mod/public/js/operation-mod.js @@ -167,7 +167,8 @@ var androidOperationModule = function () { case androidOperationConstants["VPN_OPERATION_CODE"]: payload = { "type": operationPayload["type"], - "openvpn_config": operationPayload["openvpn_config"] + "openvpn_config": operationPayload["openvpn_config"], + "packageName": operationPayload["packageName"] }; break; case androidOperationConstants["APPLICATION_OPERATION_CODE"]: @@ -425,7 +426,8 @@ var androidOperationModule = function () { payload = { "operation": { "type": operationData["type"], - "openvpn_config": operationData["openvpn_config"] + "openvpn_config": operationData["openvpn_config"], + "packageName": operationData["packageName"] } }; break; @@ -1213,4 +1215,4 @@ var androidOperationModule = function () { }; return publicMethods; -}(); \ No newline at end of file +}(); 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 f00f61f30..f5b6fc4f4 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 @@ -590,14 +590,34 @@ var validatePolicyProfile = function () { // initializing continueToCheckNextInputs to true continueToCheckNextInputs = true; - var openvpnConfig = $("#openvpn-config").val(); - if (!openvpnConfig || openvpnConfig === '') { - validationStatus = { - "error": true, - "subErrorMsg": "ovpn config required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; + let openVpnConfigEnabled = document.getElementById('vpn-body').classList.contains('in'); + if (openVpnConfigEnabled) { + var openvpnConfig = $("textarea#openvpn-config").val(); + if (!openvpnConfig || openvpnConfig === '') { + validationStatus = { + "error": true, + "subErrorMsg": "ovpn config file is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (validationStatus) { + validationStatusArray.push(validationStatus); + } + + let alwaysOnVpnEnabled = document.getElementById('always-on-vpn-body').classList.contains('in'); + if (alwaysOnVpnEnabled) { + var alwaysOnConfig = $("input#vpn-client-app").val(); + if (!alwaysOnConfig || alwaysOnConfig === '') { + validationStatus = { + "error": true, + "subErrorMsg": "Add a valid package name for the VPN client", + "erroneousFeature": "always-on-vpn" + }; + continueToCheckNextInputs = false; + } } // at-last, if the value of continueToCheckNextInputs is still true @@ -1317,4 +1337,4 @@ $(document).ready(function () { $(this).removeClass("child-input"); }); }); -}); \ No newline at end of file +}); 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/templates/android-policy-edit.hbs 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/templates/android-policy-edit.hbs index c2e2cb227..d8b15d0d6 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/templates/android-policy-edit.hbs +++ 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/templates/android-policy-edit.hbs @@ -1246,6 +1246,62 @@ + + + + + +
+
+ + +
+ +
+ + +
+ + + + + + + + + + + + + +
+ + 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-view/public/templates/android-policy-view.hbs 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-view/public/templates/android-policy-view.hbs index 8d8f78d00..1649a0009 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-view/public/templates/android-policy-view.hbs +++ 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-view/public/templates/android-policy-view.hbs @@ -2142,6 +2142,62 @@ data-key="openvpn_config" style="height: 400px;" disabled> + + + + + +
+
+ + +
+ +
+ + +
+ + + + + + + + + + + + + +
+ + @@ -2810,4 +2866,4 @@ - \ No newline at end of file + 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 5554413f2..5ae4076b3 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 @@ -524,17 +524,35 @@ var validatePolicyProfile = function () { operation = androidOperationConstants["VPN_OPERATION"]; // initializing continueToCheckNextInputs to true continueToCheckNextInputs = true; + let openVpnConfigEnabled = document.getElementById('vpn-body').classList.contains('in'); + if (openVpnConfigEnabled) { + var openvpnConfig = $("input#openvpn-config").val(); + if (!openvpnConfig || openvpnConfig === '') { + validationStatus = { + "error": true, + "subErrorMsg": "ovpn config file is required. You cannot proceed.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } - var openvpnConfig = $("input#openvpn-config").val(); - if (!openvpnConfig || openvpnConfig === '') { - validationStatus = { - "error": true, - "subErrorMsg": "ovpn config file is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; + if (validationStatus) { + validationStatusArray.push(validationStatus); } + let alwaysOnVpnEnabled = document.getElementById('always-on-vpn-body').classList.contains('in'); + if (alwaysOnVpnEnabled) { + var alwaysOnConfig = $("input#vpn-client-app").val(); + if (!alwaysOnConfig || alwaysOnConfig === '') { + validationStatus = { + "error": true, + "subErrorMsg": "Add a valid package name for the VPN client", + "erroneousFeature": "always-on-vpn" + }; + continueToCheckNextInputs = false; + } + } // at-last, if the value of continueToCheckNextInputs is still true // this means that no error is found if (continueToCheckNextInputs) { @@ -1294,4 +1312,4 @@ $(document).ready(function () { $(this).removeClass("child-input"); }); }); -}); \ No newline at end of file +}); 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/templates/android-policy-operations.hbs 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/templates/android-policy-operations.hbs index 79bb6d402..36ed7b995 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/templates/android-policy-operations.hbs +++ 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/templates/android-policy-operations.hbs @@ -2160,7 +2160,67 @@ +
+ + + + + + + +
+
+ + +
+ +
+ + +
+ + + + + + + + + + + + +
+ + @@ -2763,4 +2823,4 @@ - \ No newline at end of file +