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 dd11dcaeb..56482acb6 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 @@ -199,9 +199,55 @@ var androidOperationModule = function () { payload = { "cosuProfileRestrictionStartTime": operationPayload["cosuProfileOperationRestrictionEndTime"], "cosuProfileRestrictionEndTime": operationPayload["cosuProfileOperationRestrictionEndTime"], + "idleMediaURL" : operationPayload["deviceGlobalConfigurations"]["idleMediaURL"], + "kioskBackgroundImage": operationPayload["deviceGlobalConfigurations"]["kioskBackgroundImage"], + "kioskLogoImage" : operationPayload["deviceGlobalConfigurations"]["kioskLogoImage"], + "kioskAppName" : operationPayload["deviceGlobalConfigurations"]["kioskAppName"], + "isIdleGraphicsEnabled" : operationPayload["deviceGlobalConfigurations"]["isIdleGraphicsEnabled"], + "idleTimeout" : operationPayload["deviceGlobalConfigurations"]["idleTimeout"], + "isMultiUserDevice" : operationPayload["deviceGlobalConfigurations"]["isMultiUserDevice"], + "isLoginRequired" : operationPayload["deviceGlobalConfigurations"]["isLoginRequired"], + "displayOrientation" : operationPayload["deviceGlobalConfigurations"]["displayOrientation"], "primaryURL": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["primaryURL"], + "isTopBarEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isTopBarEnabled"], "isAddressBarEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"] - ["isAddressBarEnabled"] + ["isAddressBarEnabled"], + + "showBackController": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["showBackController"], + "isForwardControllerEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isForwardControllerEnabled"], + "isHomeButtonEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isHomeButtonEnabled"], + "isReloadEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isReloadEnabled"], + "lockToPrimaryURL": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["lockToPrimaryURL"], + "isJavascriptEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isJavascriptEnabled"], + "isTextCopyEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isTextCopyEnabled"], + "isDownloadsEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDownloadsEnabled"], + "isLockedToBrowser": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isLockedToBrowser"], + "isFormAutoFillEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isFormAutoFillEnabled"], + "isContentAccessEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isContentAccessEnabled"], + "isFileAccessAllowed": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isFileAccessAllowed"], + "isAllowedUniversalAccessFromFileURLs": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isAllowedUniversalAccessFromFileURLs"], + "isAllowedFileAccessFromFileURLs": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isAllowedFileAccessFromFileURLs"], + "isAppCacheEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isAppCacheEnabled"], + "appCachePath": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["appCachePath"], + "cacheMode": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["cacheMode"], + "isLoadsImagesAutomatically": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isLoadsImagesAutomatically"], + "isBlockNetworkImage": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isBlockNetworkImage"], + "isBlockNetworkLoads": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isBlockNetworkLoads"], + "isSupportZoomEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isSupportZoomEnabled"], + "isDisplayZoomControls": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDisplayZoomControls"], + "textZoom": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["textZoom"], + "defaultFontSize": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["defaultFontSize"], + "defaultTextEncodingName": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["defaultTextEncodingName"], + "isDatabaseEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDatabaseEnabled"], + "isDomStorageEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDomStorageEnabled"], + "geolocationEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["geolocationEnabled"], + "isJavaScriptCanOpenWindowsAutomatically": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isJavaScriptCanOpenWindowsAutomatically"], + "isMediaPlaybackRequiresUserGesture": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isMediaPlaybackRequiresUserGesture"], + "isSafeBrowsingEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isSafeBrowsingEnabled"], + "isUseWideViewPort": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isUseWideViewPort"], + "userAgentString": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["userAgentString"], + "mixedContentMode": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["mixedContentMode"] + }; break; case androidOperationConstants["KIOSK_APPS_CODE"]: @@ -398,18 +444,87 @@ var androidOperationModule = function () { break; case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]: operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "cosuProfileRestrictionStartTime": operationData["cosuProfileOperationRestrictionStartTime"], - "cosuProfileRestrictionEndTime": operationData["cosuProfileOperationRestrictionEndTime"], - "deviceGlobalConfigurations" : { - "browserProperties": { - "primaryURL": operationData["primaryURL"], - "isAddressBarEnabled": operationData["isAddressBarEnabled"] - } - } - } - }; + payload = {}; + operation = {}; + operation["cosuProfileRestrictionStartTime"] = + operationData["cosuProfileOperationRestrictionStartTime"]; + operation["cosuProfileRestrictionEndTime"] = operationData["cosuProfileOperationRestrictionEndTime"]; + + deviceGlobalConfigurations = {}; + if (operationData["idleMediaURL"]) { + deviceGlobalConfigurations["idleMediaURL"] = operationData["idleMediaURL"]; + } + if (operationData["kioskBackgroundImage"]) { + deviceGlobalConfigurations["kioskBackgroundImage"] = operationData["kioskBackgroundImage"]; + } + if (operationData["kioskLogoImage"]) { + deviceGlobalConfigurations["kioskLogoImage"] = operationData["kioskLogoImage"]; + } + if (operationData["kioskAppName"]) { + deviceGlobalConfigurations["kioskAppName"] = operationData["kioskAppName"]; + } + deviceGlobalConfigurations["isIdleGraphicsEnabled"] = operationData["isIdleGraphicsEnabled"]; + if (operationData["idleTimeout"]) { + deviceGlobalConfigurations["idleTimeout"] = operationData["idleTimeout"]; + } + deviceGlobalConfigurations["isMultiUserDevice"] = operationData["isMultiUserDevice"]; + deviceGlobalConfigurations["isLoginRequired"] = operationData["isLoginRequired"]; + deviceGlobalConfigurations["displayOrientation"] = operationData["displayOrientation"]; + + browserProperties = {}; + if (operationData["primaryURL"]) { + browserProperties["primaryURL"] = operationData["primaryURL"]; + browserProperties["isTopBarEnabled"] = operationData["isTopBarEnabled"]; + browserProperties["isAddressBarEnabled"] = operationData["isAddressBarEnabled"]; + browserProperties["showBackController"] = operationData["showBackController"]; + browserProperties["isForwardControllerEnabled"] = operationData["isForwardControllerEnabled"]; + browserProperties["isHomeButtonEnabled"] = operationData["isHomeButtonEnabled"]; + browserProperties["isReloadEnabled"] = operationData["isReloadEnabled"]; + browserProperties["lockToPrimaryURL"] = operationData["lockToPrimaryURL"]; + browserProperties["isJavascriptEnabled"] = operationData["isJavascriptEnabled"]; + browserProperties["isTextCopyEnabled"] = operationData["isTextCopyEnabled"]; + browserProperties["isDownloadsEnabled"] = operationData["isDownloadsEnabled"]; + browserProperties["isLockedToBrowser"] = operationData["isLockedToBrowser"]; + browserProperties["isFormAutoFillEnabled"] = operationData["isFormAutoFillEnabled"]; + browserProperties["isContentAccessEnabled"] = operationData["isContentAccessEnabled"]; + browserProperties["isFileAccessAllowed"] = operationData["isFileAccessAllowed"]; + browserProperties["isAllowedUniversalAccessFromFileURLs"] = operationData["isAllowedUniversalAccessFromFileURLs"]; + browserProperties["isAllowedFileAccessFromFileURLs"] = operationData["isAllowedFileAccessFromFileURLs"]; + browserProperties["isAppCacheEnabled"] = operationData["isAppCacheEnabled"]; + if (operationData["isAppCacheEnabled"] && operationData["appCachePath"]) { + browserProperties["appCachePath"] = operationData["appCachePath"]; + } + browserProperties["cacheMode"] = operationData["cacheMode"]; + browserProperties["isLoadsImagesAutomatically"] = operationData["isLoadsImagesAutomatically"]; + browserProperties["isBlockNetworkImage"] = operationData["isBlockNetworkImage"]; + browserProperties["isBlockNetworkLoads"] = operationData["isBlockNetworkLoads"]; + browserProperties["isSupportZoomEnabled"] = operationData["isSupportZoomEnabled"]; + browserProperties["isDisplayZoomControls"] = operationData["isDisplayZoomControls"]; + if (operationData["textZoom"]) { + browserProperties["textZoom"] = operationData["textZoom"]; + } + if (operationData["defaultFontSize"]) { + browserProperties["defaultFontSize"] = operationData["defaultFontSize"]; + } + if (operationData["defaultTextEncodingName"]) { + browserProperties["defaultTextEncodingName"] = operationData["defaultTextEncodingName"]; + } + browserProperties["isDatabaseEnabled"] = operationData["isDatabaseEnabled"]; + browserProperties["isDomStorageEnabled"] = operationData["isDomStorageEnabled"]; + browserProperties["geolocationEnabled"] = operationData["geolocationEnabled"]; + browserProperties["isJavaScriptCanOpenWindowsAutomatically"] = operationData["isJavaScriptCanOpenWindowsAutomatically"]; + browserProperties["isMediaPlaybackRequiresUserGesture"] = operationData["isMediaPlaybackRequiresUserGesture"]; + browserProperties["isSafeBrowsingEnabled"] = operationData["isSafeBrowsingEnabled"]; + browserProperties["isUseWideViewPort"] = operationData["isUseWideViewPort"]; + if (operationData["userAgentString"]) { + browserProperties["userAgentString"] = operationData["userAgentString"]; + } + browserProperties["mixedContentMode"] = operationData["mixedContentMode"]; + deviceGlobalConfigurations.browserProperties = browserProperties; + } + operation.deviceGlobalConfigurations = deviceGlobalConfigurations; + payload.operation = operation; + break; case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]: operationType = operationTypeConstants["PROFILE"]; 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 17d70b0c8..1f7ed3518 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 @@ -270,11 +270,95 @@ var validatePolicyProfile = function () { } // Validating COSU PROFILE CONFIGURATION if ($.inArray(androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"], configuredOperations) != -1) { - operation = androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION"]; - validationStatus = { - "error": false, - "okFeature": operation - }; + + operation = androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION"]; + var continueToCheckNextInputs = true; + + if (continueToCheckNextInputs) { + var backgroundImage = $("input#cosu-global-config-kiosk-background-image").val(); + if (backgroundImage && !(backgroundImage.endsWith("jpg") || backgroundImage.endsWith("jpeg") + || backgroundImage.endsWith("png"))) { + validationStatus = { + "error": true, + "subErrorMsg": "Launcher background image file types are jpg, jpeg and png", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var kioskLogo = $("input#cosu-global-config-kiosk-logo-image").val(); + if (kioskLogo && !(kioskLogo.endsWith("jpg") || kioskLogo.endsWith("jpeg") + || kioskLogo.endsWith("png"))) { + validationStatus = { + "error": true, + "subErrorMsg": "Company log to display file types are jpg, jpeg and png", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var idleMediaUrl = $("input#cosu-global-config-idle-media-url").val(); + if (idleMediaUrl && !(idleMediaUrl.endsWith("jpg") || idleMediaUrl.endsWith("jpeg") + || idleMediaUrl.endsWith("png") || idleMediaUrl.endsWith("mp4") + || idleMediaUrl.endsWith("3gp") || idleMediaUrl.endsWith("wmv") + || idleMediaUrl.endsWith("mkv"))) { + validationStatus = { + "error": true, + "subErrorMsg": "Idle media url file types are .jpg, .png, .jpeg, .mp4, .3gp, .wmv, .mkv", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var idleTimeout = $("input#cosu-browser-property-idle-timeout").val(); + if (idleTimeout && (!$.isNumeric(idleTimeout) || idleTimeout < 0)) { + validationStatus = { + "error": true, + "subErrorMsg": "Idle timeout must be a positive whole number", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var textZoom = $("input#cosu-browser-property-text-zoom").val(); + if (textZoom && (!$.isNumeric(textZoom) || textZoom < 0)) { + validationStatus = { + "error": true, + "subErrorMsg": "Text zoom must be a positive whole number", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + + if (continueToCheckNextInputs) { + var defaultFontSize = $("input#cosu-browser-property-default-font-size").val(); + if (defaultFontSize) { + if (!$.isNumeric(defaultFontSize) || !inputIsValidAgainstRange(defaultFontSize, 0, 72)) { + validationStatus = { + "error": true, + "subErrorMsg": "Default font size is a number between 0 and 72", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + } + } + + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } validationStatusArray.push(validationStatus); } // Validating ENCRYPT_STORAGE @@ -741,6 +825,25 @@ var changeAndroidWifiPolicyEAP = function (select, superSelect) { } }; +/** + * Pass a div Id and a check box to view or hide div content based on checkbox value + */ +var changeDivVisibility = function (divId, checkbox) { + if (checkbox.checked) { + document.getElementById(divId).style.display= "block" + } else { + document.getElementById(divId).style.display= "none" + inputs = document.getElementById(divId).getElementsByTagName('input'); + for (index = 0; index < inputs.length; ++index) { + if (inputs[index].type == "text") { + inputs[index].value = inputs[index].defaultValue; + } else if (inputs[index].type == "checkbox") { + inputs[index].checked = inputs[index].defaultChecked; + } + } + } +}; + /** * Method to slide down a provided pane upon provided value set. * 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 b1016204d..78723cbdc 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 @@ -1677,6 +1677,117 @@