From db44610c112de9ffc7cb6fdc675022a10495ebe7 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Thu, 28 Mar 2019 05:06:13 +0000 Subject: [PATCH] Kiosk Policy UI --- .../public/js/operation-mod.js | 321 ++-- .../public/js/android-policy-edit.js | 119 +- .../public/templates/android-policy-edit.hbs | 1448 ++++++++-------- .../public/js/android-policy-view.js | 93 +- .../public/templates/android-policy-view.hbs | 1467 +++++++++-------- .../public/js/android-policy-operations.js | 116 +- .../templates/android-policy-operations.hbs | 1439 ++++++++-------- 7 files changed, 2850 insertions(+), 2153 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 56482acb64..515f7cb2ce 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 @@ -196,59 +196,93 @@ var androidOperationModule = function () { }; break; case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]: - 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"], - - "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"] - - }; + payload = {}; + payload["isDeviceRestrictOperationTimeEnabled"] = + operationPayload["isDeviceRestrictOperationTimeEnabled"]; + payload["isDeviceGlobalConfigEnabled"] = operationPayload["isDeviceGlobalConfigEnabled"]; + if (payload["isDeviceRestrictOperationTimeEnabled"] === true) { + payload["cosuProfileRestrictionStartTime"] = operationPayload["cosuProfileRestrictionStartTime"]; + payload["cosuProfileRestrictionEndTime"] = operationPayload["cosuProfileRestrictionEndTime"]; + } + if (payload["isDeviceGlobalConfigEnabled"] === true) { + var deviceGlobalConfigurations = operationPayload["deviceGlobalConfigurations"]; + payload["idleMediaURL"] = deviceGlobalConfigurations["idleMediaURL"]; + payload["kioskBackgroundImage"] = deviceGlobalConfigurations["kioskBackgroundImage"]; + payload["kioskLogoImage"] = deviceGlobalConfigurations["kioskLogoImage"]; + payload["kioskAppName"] = deviceGlobalConfigurations["kioskAppName"]; + payload["isIdleGraphicsEnabled"] = deviceGlobalConfigurations["isIdleGraphicsEnabled"]; + payload["idleTimeout"] = deviceGlobalConfigurations["idleTimeout"]; + payload["isMultiUserDevice"] = deviceGlobalConfigurations["isMultiUserDevice"]; + if (payload["isMultiUserDevice"] === true) { + payload["isLoginRequired"] = deviceGlobalConfigurations["isLoginRequired"]; + var userAppConfigurations = operationPayload["userAppConfigurations"]; + var index; + for (index = 0; index < userAppConfigurations.length; index++) { + userAppConfigurations[index]["visibleAppList"] = + userAppConfigurations[index]["visibleAppList"].map(function (item) { + var packageName = item.trim(); + if (packageName && packageName.charAt(0) !== "{") { + var indexValue = packageName.lastIndexOf(":"); + if (indexValue > -1) { + packageName = packageName.substring(0, indexValue); + } + } + return packageName; + }).filter(Boolean); + if (userAppConfigurations[index]["username"] === "primaryUser") { + payload["primaryUserApps"] = userAppConfigurations[index]["visibleAppList"]; + delete userAppConfigurations[index]; + } + } + payload["userAppConfigurations"] = userAppConfigurations.filter(Boolean); + } + payload["displayOrientation"] = deviceGlobalConfigurations["displayOrientation"]; + if ("browserProperties" in deviceGlobalConfigurations) { + var browserProperties = deviceGlobalConfigurations["browserProperties"]; + payload["isBrowserPropertyEnabled"] = browserProperties["isBrowserPropertyEnabled"]; + payload["primaryURL"] = browserProperties["primaryURL"]; + payload["isTopBarEnabled"] = browserProperties["isTopBarEnabled"]; + payload["isAddressBarEnabled"] = browserProperties["isAddressBarEnabled"]; + payload["showBackController"] = browserProperties["showBackController"]; + payload["isForwardControllerEnabled"] = browserProperties["isForwardControllerEnabled"]; + payload["isHomeButtonEnabled"] = browserProperties["isHomeButtonEnabled"]; + payload["isReloadEnabled"] = browserProperties["isReloadEnabled"]; + payload["lockToPrimaryURL"] = browserProperties["lockToPrimaryURL"]; + payload["isJavascriptEnabled"] = browserProperties["isJavascriptEnabled"]; + payload["isTextCopyEnabled"] = browserProperties["isTextCopyEnabled"]; + payload["isDownloadsEnabled"] = browserProperties["isDownloadsEnabled"]; + payload["isLockedToBrowser"] = browserProperties["isLockedToBrowser"]; + payload["isFormAutoFillEnabled"] = browserProperties["isFormAutoFillEnabled"]; + payload["isContentAccessEnabled"] = browserProperties["isContentAccessEnabled"]; + payload["isFileAccessAllowed"] = browserProperties["isFileAccessAllowed"]; + payload["isAllowedUniversalAccessFromFileURLs"] = + browserProperties["isAllowedUniversalAccessFromFileURLs"]; + payload["isAllowedFileAccessFromFileURLs"] = + browserProperties["isAllowedFileAccessFromFileURLs"]; + payload["isAppCacheEnabled"] = browserProperties["isAppCacheEnabled"]; + payload["appCachePath"] = browserProperties["appCachePath"]; + payload["cacheMode"] = browserProperties["cacheMode"]; + payload["isLoadsImagesAutomatically"] = browserProperties["isLoadsImagesAutomatically"]; + payload["isBlockNetworkImage"] = browserProperties["isBlockNetworkImage"]; + payload["isBlockNetworkLoads"] = browserProperties["isBlockNetworkLoads"]; + payload["isSupportZoomEnabled"] = browserProperties["isSupportZoomEnabled"]; + payload["isDisplayZoomControls"] = browserProperties["isDisplayZoomControls"]; + payload["textZoom"] = browserProperties["textZoom"]; + payload["defaultFontSize"] = browserProperties["defaultFontSize"]; + payload["defaultTextEncodingName"] = browserProperties["defaultTextEncodingName"]; + payload["isDatabaseEnabled"] = browserProperties["isDatabaseEnabled"]; + payload["isDomStorageEnabled"] = browserProperties["isDomStorageEnabled"]; + payload["geolocationEnabled"] = browserProperties["geolocationEnabled"]; + payload["isJavaScriptCanOpenWindowsAutomatically"] = + browserProperties["isJavaScriptCanOpenWindowsAutomatically"]; + payload["isMediaPlaybackRequiresUserGesture"] = + browserProperties["isMediaPlaybackRequiresUserGesture"]; + payload["isSafeBrowsingEnabled"] = browserProperties["isSafeBrowsingEnabled"]; + payload["isUseWideViewPort"] = browserProperties["isUseWideViewPort"]; + payload["userAgentString"] = browserProperties["userAgentString"]; + payload["mixedContentMode"] = browserProperties["mixedContentMode"]; + } + } break; case androidOperationConstants["KIOSK_APPS_CODE"]: payload = { @@ -445,86 +479,121 @@ var androidOperationModule = function () { case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]: operationType = operationTypeConstants["PROFILE"]; 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"]; + var operation = {}; + operation["isDeviceRestrictOperationTimeEnabled"] = + operationData["isDeviceRestrictOperationTimeEnabled"]; + operation["isDeviceGlobalConfigEnabled"] = operationData["isDeviceGlobalConfigEnabled"]; + if (operation["isDeviceRestrictOperationTimeEnabled"] === true) { + operation["cosuProfileRestrictionStartTime"] = operationData["cosuProfileRestrictionStartTime"]; + operation["cosuProfileRestrictionEndTime"] = operationData["cosuProfileRestrictionEndTime"]; } - 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"]; + if (operationData["isDeviceGlobalConfigEnabled"] === true) { + var deviceGlobalConfigurations = {}; + if (operationData["idleMediaURL"]) { + deviceGlobalConfigurations["idleMediaURL"] = operationData["idleMediaURL"]; } - 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["kioskBackgroundImage"]) { + deviceGlobalConfigurations["kioskBackgroundImage"] = operationData["kioskBackgroundImage"]; } - if (operationData["defaultFontSize"]) { - browserProperties["defaultFontSize"] = operationData["defaultFontSize"]; + if (operationData["kioskLogoImage"]) { + deviceGlobalConfigurations["kioskLogoImage"] = operationData["kioskLogoImage"]; } - if (operationData["defaultTextEncodingName"]) { - browserProperties["defaultTextEncodingName"] = operationData["defaultTextEncodingName"]; + if (operationData["kioskAppName"]) { + deviceGlobalConfigurations["kioskAppName"] = operationData["kioskAppName"]; } - 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"]; + deviceGlobalConfigurations["isIdleGraphicsEnabled"] = operationData["isIdleGraphicsEnabled"]; + if (operationData["idleTimeout"]) { + deviceGlobalConfigurations["idleTimeout"] = operationData["idleTimeout"]; } - browserProperties["mixedContentMode"] = operationData["mixedContentMode"]; - deviceGlobalConfigurations.browserProperties = browserProperties; + deviceGlobalConfigurations["isMultiUserDevice"] = operationData["isMultiUserDevice"]; + deviceGlobalConfigurations["displayOrientation"] = operationData["displayOrientation"]; + if (deviceGlobalConfigurations["isMultiUserDevice"] === true) { + deviceGlobalConfigurations["isLoginRequired"] = operationData["isLoginRequired"]; + var storeApps = $("#cosu-profile-app-configs-storeapps").data("storeapps"); + var primaryUserApps = { + "username" : "primaryUser", + "visibleAppList" : operationData["primaryUserApps"] + }; + var userAppConfigurations = operationData["userAppConfigurations"]; + userAppConfigurations.push(primaryUserApps); + var index; + for (index = 0; index < userAppConfigurations.length; index++) { + userAppConfigurations[index]["visibleAppList"] = + userAppConfigurations[index]["visibleAppList"].split(/,(?![^{]*})/) + .map(function (item) { + var packageName = item.trim(); + if (packageName) { + var i; + for (i=0; i 0) { + gridInputs.remove(); + } + var helpTexts = $(this).find("[data-help-text=add-form]"); + if (helpTexts.length > 0) { + helpTexts.show(); + } + } + ); + $("#" + divId + " .collapse-config").each( + function() { + this.style.display = "none"; + } + ); } }; @@ -1202,4 +1301,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 9dd9da8433..61ff2beb51 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 @@ -1511,737 +1511,847 @@ This policy can be used to configure the profile of COSU Devices. -

-