From 967eb3ce31712a60f0344e3b40f4746a881ae1b7 Mon Sep 17 00:00:00 2001 From: Madawa Soysa Date: Wed, 30 Jan 2019 22:48:13 +1100 Subject: [PATCH] Refactor global proxy implementation --- .../services/android/bean/GlobalProxy.java | 77 ++++++++++--------- .../mdm/services/android/bean/ProxyType.java | 5 ++ .../public/js/operation-mod.js | 4 - .../public/js/android-policy-edit.js | 15 ++-- .../public/templates/android-policy-edit.hbs | 28 +------ .../public/js/android-policy-view.js | 15 ++-- .../public/templates/android-policy-view.hbs | 28 +------ .../public/js/android-policy-operations.js | 15 ++-- .../templates/android-policy-operations.hbs | 28 +------ 9 files changed, 84 insertions(+), 131 deletions(-) create mode 100644 components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java index c2d279701..19145af9e 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/GlobalProxy.java @@ -23,7 +23,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; -import java.util.List; /** * This class represents the information of setting up global proxy @@ -35,71 +34,75 @@ import java.util.List; ) public class GlobalProxy extends AndroidOperation implements Serializable { - @ApiModelProperty(name = "host", value = "The hostname of the proxy server", required = true) - private String host; + @ApiModelProperty( + name = "proxyConfigType", + value = "Type of the proxy", + required = true + ) + private ProxyType proxyConfigType; @ApiModelProperty( - name = "port", - value = "The port which the proxy server is running", - required = true) - private int port; + name = "proxyHost", + value = "The hostname of the proxy server" + ) + private String proxyHost; @ApiModelProperty( - name = "excludedList", - value = "Hosts to exclude using the proxy on connections for. These hosts can use wildcards such as " + - "*.example.com" + name = "proxyPort", + value = "The port which the proxy server is running" ) - private List excludedList; + private int proxyPort; @ApiModelProperty( - name = "username", - value = "Username of the proxy server" + name = "proxyExclList", + value = "Hosts to exclude using the proxy on connections for. These hosts can use wildcards such as " + + "*.example.com" ) - private String username; + private String proxyExclList; @ApiModelProperty( - name = "password", - value = "Password of the proxy server" + name = "proxyPacUrl", + value = "PAC file URL to auto config proxy" ) - private String password; + private String proxyPacUrl; - public String getHost() { - return host; + public ProxyType getProxyConfigType() { + return proxyConfigType; } - public void setHost(String host) { - this.host = host; + public void setProxyConfigType(ProxyType proxyConfigType) { + this.proxyConfigType = proxyConfigType; } - public int getPort() { - return port; + public String getProxyHost() { + return proxyHost; } - public void setPort(int port) { - this.port = port; + public void setProxyHost(String proxyHost) { + this.proxyHost = proxyHost; } - public List getExcludedList() { - return excludedList; + public int getProxyPort() { + return proxyPort; } - public void setExcludedList(List excludedList) { - this.excludedList = excludedList; + public void setProxyPort(int proxyPort) { + this.proxyPort = proxyPort; } - public String getUsername() { - return username; + public String getProxyExclList() { + return proxyExclList; } - public void setUsername(String username) { - this.username = username; + public void setProxyExclList(String proxyExclList) { + this.proxyExclList = proxyExclList; } - public String getPassword() { - return password; + public String getProxyPacUrl() { + return proxyPacUrl; } - public void setPassword(String password) { - this.password = password; + public void setProxyPacUrl(String proxyPacUrl) { + this.proxyPacUrl = proxyPacUrl; } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java new file mode 100644 index 000000000..3fdc4e1ba --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/bean/ProxyType.java @@ -0,0 +1,5 @@ +package org.wso2.carbon.mdm.services.android.bean; + +public enum ProxyType { + MANUAL, AUTO +} 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 6821ab1ec..556dbb03d 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 @@ -161,8 +161,6 @@ var androidOperationModule = function () { "proxyHost": operationPayload["proxyHost"], "proxyPort": operationPayload["proxyPort"], "proxyExclList": operationPayload["proxyExclList"], - "proxyUsername": operationPayload["proxyUsername"], - "proxyPassword": operationPayload["proxyPassword"], "proxyPacUrl": operationPayload["proxyPacUrl"] }; break; @@ -331,8 +329,6 @@ var androidOperationModule = function () { "proxyHost": operationData["proxyHost"], "proxyPort": operationData["proxyPort"], "proxyExclList": operationData["proxyExclList"], - "proxyUsername": operationData["proxyUsername"], - "proxyPassword": operationData["proxyPassword"], "proxyPacUrl": operationData["proxyPacUrl"] } }; 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 d68fbb54c..b19525b04 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 @@ -855,17 +855,20 @@ var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneI var switchPaneAgainstValueSetForRadioButtons = function (selectElement, paneIdPrefix, valueSet) { var selectedValueOnChange = selectElement.value; var paneSelector = "#" + paneIdPrefix; + var pane; for (var i = 0; i < valueSet.length; ++i) { if (selectedValueOnChange !== valueSet[i]) { - if ($(paneSelector).hasClass("expanded")) { - $(paneSelector).removeClass("expanded"); + pane = paneSelector + valueSet[i].toLowerCase(); + if ($(pane).hasClass("expanded")) { + $(pane).removeClass("expanded"); } - $(paneSelector + valueSet[i]).slideUp(); + $(pane).slideUp(); } else { - if (!$(paneSelector).hasClass("expanded")) { - $(paneSelector).addClass("expanded"); + pane = paneSelector + selectedValueOnChange.toLowerCase(); + if (!$(pane).hasClass("expanded")) { + $(pane).addClass("expanded"); } - $(paneSelector + selectedValueOnChange).slideDown(); + $(pane).slideDown(); } } }; 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 510f0a3cb..df8ca218c 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 @@ -1014,9 +1014,9 @@