From 8b2a5f51578409363b8ea79bf8b41b74aecf4a87 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Wed, 23 Jan 2019 14:43:27 +1100 Subject: [PATCH] Improve global proxy policy config UI Improve the policy config ui to support auto config proxy using a pac file url --- .../public/js/operation-mod.js | 14 +- .../public/js/android-policy-edit.js | 101 +++++++---- .../public/templates/android-policy-edit.hbs | 164 ++++++++++++------ .../public/js/android-policy-view.js | 27 +++ .../public/templates/android-policy-view.hbs | 162 +++++++++++------ .../public/js/android-policy-operations.js | 101 +++++++---- .../templates/android-policy-operations.hbs | 164 ++++++++++++------ 7 files changed, 498 insertions(+), 235 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-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 261202565..de615926d 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 @@ -157,11 +157,13 @@ var androidOperationModule = function () { break; case androidOperationConstants["GLOBAL_PROXY_OPERATION_CODE"]: payload = { + "proxyConfigType": operationPayload["proxyConfigType"], "proxyHost": operationPayload["proxyHost"], "proxyPort": operationPayload["proxyPort"], "proxyExclList": operationPayload["proxyExclList"], "proxyUsername": operationPayload["proxyUsername"], - "proxyPassword": operationPayload["proxyPassword"] + "proxyPassword": operationPayload["proxyPassword"], + "proxyPacUrl": operationPayload["proxyPacUrl"] }; break; case androidOperationConstants["VPN_OPERATION_CODE"]: @@ -323,17 +325,15 @@ var androidOperationModule = function () { break; case androidOperationConstants["GLOBAL_PROXY_OPERATION_CODE"]: operationType = operationTypeConstants["PROFILE"]; - var proxyExclList = []; - if (operationData["proxyExclList"]) { - proxyExclList = operationData["proxyExclList"].trim().split(/\s*,\s*/); - } payload = { "operation": { + "proxyConfigType": operationData["proxyConfigType"], "proxyHost": operationData["proxyHost"], "proxyPort": operationData["proxyPort"], - "proxyExclList": proxyExclList, + "proxyExclList": operationData["proxyExclList"], "proxyUsername": operationData["proxyUsername"], - "proxyPassword": operationData["proxyPassword"] + "proxyPassword": operationData["proxyPassword"], + "proxyPacUrl": operationData["proxyPacUrl"] } }; 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.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 63f26628b..d68fbb54c 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 @@ -332,38 +332,50 @@ var validatePolicyProfile = function () { // initializing continueToCheckNextInputs to true continueToCheckNextInputs = true; - var proxyHost = $("input#proxy-host").val(); - var proxyPort = $("input#proxy-port").val(); - if (!proxyHost) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server host name is required.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } + if ($("input#manual-proxy-configuration-radio-button").is(":checked")) { + var proxyHost = $("input#proxy-host").val(); + var proxyPort = $("input#proxy-port").val(); + if (!proxyHost) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server host name is required.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } - if (!proxyPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server port is required.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(proxyPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(proxyPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server port is not within the range of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; + if (!proxyPort) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server port is required.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!$.isNumeric(proxyPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(proxyPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server port is not within the range of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } else if ($("input#auto-proxy-configuration-radio-button").is(":checked")) { + var pacFileUrl = $("input#proxy-pac-url").val(); + if (!pacFileUrl) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy pac file URL is required for proxy auto config.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } } // at-last, if the value of continueToCheckNextInputs is still true @@ -830,6 +842,33 @@ var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneI $(paneSelector).addClass("hidden"); } }; + +/** + * Method to switch panes based on the selected radio button. + * + * The method will un hide the element with the id (paneIdPrefix + selectElement.value) + * + * @param selectElement selected HTML element + * @param paneIdPrefix prefix of the id of the pane to un hide. + * @param valueSet applicable value set + */ +var switchPaneAgainstValueSetForRadioButtons = function (selectElement, paneIdPrefix, valueSet) { + var selectedValueOnChange = selectElement.value; + var paneSelector = "#" + paneIdPrefix; + for (var i = 0; i < valueSet.length; ++i) { + if (selectedValueOnChange !== valueSet[i]) { + if ($(paneSelector).hasClass("expanded")) { + $(paneSelector).removeClass("expanded"); + } + $(paneSelector + valueSet[i]).slideUp(); + } else { + if (!$(paneSelector).hasClass("expanded")) { + $(paneSelector).addClass("expanded"); + } + $(paneSelector + selectedValueOnChange).slideDown(); + } + } +}; // End of HTML embedded invoke methods 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 e6771b207..4a692358c 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 @@ -979,79 +979,133 @@ device. Once this configuration profile is installed on a device, all the network traffic will be routed through the proxy server.

-

- This method requires the caller to be the device owner. -

-

- This proxy is only a recommendation and it is possible that some apps will ignore it. -


+ +
+ +
Please note that * sign represents required fields of data.

-
- - -
-
- -
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/js/android-policy-view.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-view/public/js/android-policy-view.js index 0dba7a2ed..7afcd4b66 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/js/android-policy-view.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-view/public/js/android-policy-view.js @@ -166,6 +166,33 @@ var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneI $(paneSelector).addClass("hidden"); } }; + +/** + * Method to switch panes based on the selected radio button. + * + * The method will un hide the element with the id (paneIdPrefix + selectElement.value) + * + * @param selectElement selected HTML element + * @param paneIdPrefix prefix of the id of the pane to un hide. + * @param valueSet applicable value set + */ +var switchPaneAgainstValueSetForRadioButtons = function (selectElement, paneIdPrefix, valueSet) { + var selectedValueOnChange = selectElement.value; + var paneSelector = "#" + paneIdPrefix; + for (var i = 0; i < valueSet.length; ++i) { + if (selectedValueOnChange !== valueSet[i]) { + if ($(paneSelector).hasClass("expanded")) { + $(paneSelector).removeClass("expanded"); + } + $(paneSelector + valueSet[i]).slideUp(); + } else { + if (!$(paneSelector).hasClass("expanded")) { + $(paneSelector).addClass("expanded"); + } + $(paneSelector + selectedValueOnChange).slideDown(); + } + } +}; // End of HTML embedded invoke methods /** 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 eb7033388..1cce8875b 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 @@ -968,7 +968,8 @@
-
+

+ +
+ +
Please note that * sign represents required fields of data.

-
- - -
-
- -
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 09f1838c2..19d522c3d 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 @@ -251,38 +251,50 @@ var validatePolicyProfile = function () { // initializing continueToCheckNextInputs to true continueToCheckNextInputs = true; - var proxyHost = $("input#proxy-host").val(); - var proxyPort = $("input#proxy-port").val(); - if (!proxyHost) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server host name is required.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } + if ($("input#manual-proxy-configuration-radio-button").is(":checked")) { + var proxyHost = $("input#proxy-host").val(); + var proxyPort = $("input#proxy-port").val(); + if (!proxyHost) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server host name is required.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } - if (!proxyPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server port is required.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - }else if (!$.isNumeric(proxyPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(proxyPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Proxy server port is not within the range of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; + if (!proxyPort) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server port is required.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!$.isNumeric(proxyPort)) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server port requires a number input.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (!inputIsValidAgainstRange(proxyPort, 0, 65535)) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy server port is not within the range of valid port numbers.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } else if ($("input#auto-proxy-configuration-radio-button").is(":checked")) { + var pacFileUrl = $("input#proxy-pac-url").val(); + if (!pacFileUrl) { + validationStatus = { + "error": true, + "subErrorMsg": "Proxy pac file URL is required for proxy auto config.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } } // at-last, if the value of continueToCheckNextInputs is still true @@ -795,6 +807,33 @@ var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneI } }; +/** + * Method to switch panes based on the selected radio button. + * + * The method will un hide the element with the id (paneIdPrefix + selectElement.value) + * + * @param selectElement selected HTML element + * @param paneIdPrefix prefix of the id of the pane to un hide. + * @param valueSet applicable value set + */ +var switchPaneAgainstValueSetForRadioButtons = function (selectElement, paneIdPrefix, valueSet) { + var selectedValueOnChange = selectElement.value; + var paneSelector = "#" + paneIdPrefix; + for (var i = 0; i < valueSet.length; ++i) { + if (selectedValueOnChange !== valueSet[i]) { + if ($(paneSelector).hasClass("expanded")) { + $(paneSelector).removeClass("expanded"); + } + $(paneSelector + valueSet[i]).slideUp(); + } else { + if (!$(paneSelector).hasClass("expanded")) { + $(paneSelector).addClass("expanded"); + } + $(paneSelector + selectedValueOnChange).slideDown(); + } + } +}; + // End of HTML embedded invoke methods 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 5c51b323b..376405224 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 @@ -1003,79 +1003,133 @@ device. Once this configuration profile is installed on a device, all the network traffic will be routed through the proxy server.

-

- This method requires the caller to be the device owner. -

-

- This proxy is only a recommendation and it is possible that some apps will ignore it. -


+ +
+ +
Please note that * sign represents required fields of data.

-
- - -
-
- -