Merge branch 'kiosk-policy-ui' into 'master'

Kiosk Policy UI

Closes product-iots#52 and product-iots#23

See merge request entgra/carbon-device-mgt-plugins!24
revert-dabc3590
Inosh Perara 6 years ago
commit 2ec653d2bf

@ -196,59 +196,93 @@ var androidOperationModule = function () {
}; };
break; break;
case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]: case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]:
payload = { payload = {};
"cosuProfileRestrictionStartTime": operationPayload["cosuProfileOperationRestrictionEndTime"], payload["isDeviceRestrictOperationTimeEnabled"] =
"cosuProfileRestrictionEndTime": operationPayload["cosuProfileOperationRestrictionEndTime"], operationPayload["isDeviceRestrictOperationTimeEnabled"];
"idleMediaURL" : operationPayload["deviceGlobalConfigurations"]["idleMediaURL"], payload["isDeviceGlobalConfigEnabled"] = operationPayload["isDeviceGlobalConfigEnabled"];
"kioskBackgroundImage": operationPayload["deviceGlobalConfigurations"]["kioskBackgroundImage"], if (payload["isDeviceRestrictOperationTimeEnabled"] === true) {
"kioskLogoImage" : operationPayload["deviceGlobalConfigurations"]["kioskLogoImage"], payload["cosuProfileRestrictionStartTime"] = operationPayload["cosuProfileRestrictionStartTime"];
"kioskAppName" : operationPayload["deviceGlobalConfigurations"]["kioskAppName"], payload["cosuProfileRestrictionEndTime"] = operationPayload["cosuProfileRestrictionEndTime"];
"isIdleGraphicsEnabled" : operationPayload["deviceGlobalConfigurations"]["isIdleGraphicsEnabled"], }
"idleTimeout" : operationPayload["deviceGlobalConfigurations"]["idleTimeout"], if (payload["isDeviceGlobalConfigEnabled"] === true) {
"isMultiUserDevice" : operationPayload["deviceGlobalConfigurations"]["isMultiUserDevice"], var deviceGlobalConfigurations = operationPayload["deviceGlobalConfigurations"];
"isLoginRequired" : operationPayload["deviceGlobalConfigurations"]["isLoginRequired"], payload["idleMediaURL"] = deviceGlobalConfigurations["idleMediaURL"];
"displayOrientation" : operationPayload["deviceGlobalConfigurations"]["displayOrientation"], payload["kioskBackgroundImage"] = deviceGlobalConfigurations["kioskBackgroundImage"];
"primaryURL": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["primaryURL"], payload["kioskLogoImage"] = deviceGlobalConfigurations["kioskLogoImage"];
"isTopBarEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isTopBarEnabled"], payload["kioskAppName"] = deviceGlobalConfigurations["kioskAppName"];
"isAddressBarEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"] payload["isIdleGraphicsEnabled"] = deviceGlobalConfigurations["isIdleGraphicsEnabled"];
["isAddressBarEnabled"], payload["idleTimeout"] = deviceGlobalConfigurations["idleTimeout"];
payload["isMultiUserDevice"] = deviceGlobalConfigurations["isMultiUserDevice"];
"showBackController": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["showBackController"], if (payload["isMultiUserDevice"] === true) {
"isForwardControllerEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isForwardControllerEnabled"], payload["isLoginRequired"] = deviceGlobalConfigurations["isLoginRequired"];
"isHomeButtonEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isHomeButtonEnabled"], var userAppConfigurations = operationPayload["userAppConfigurations"];
"isReloadEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isReloadEnabled"], var index;
"lockToPrimaryURL": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["lockToPrimaryURL"], for (index = 0; index < userAppConfigurations.length; index++) {
"isJavascriptEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isJavascriptEnabled"], userAppConfigurations[index]["visibleAppList"] =
"isTextCopyEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isTextCopyEnabled"], userAppConfigurations[index]["visibleAppList"].map(function (item) {
"isDownloadsEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDownloadsEnabled"], var packageName = item.trim();
"isLockedToBrowser": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isLockedToBrowser"], if (packageName && packageName.charAt(0) !== "{") {
"isFormAutoFillEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isFormAutoFillEnabled"], var indexValue = packageName.lastIndexOf(":");
"isContentAccessEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isContentAccessEnabled"], if (indexValue > -1) {
"isFileAccessAllowed": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isFileAccessAllowed"], packageName = packageName.substring(0, indexValue);
"isAllowedUniversalAccessFromFileURLs": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isAllowedUniversalAccessFromFileURLs"], }
"isAllowedFileAccessFromFileURLs": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isAllowedFileAccessFromFileURLs"], }
"isAppCacheEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isAppCacheEnabled"], return packageName;
"appCachePath": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["appCachePath"], }).filter(Boolean);
"cacheMode": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["cacheMode"], if (userAppConfigurations[index]["username"] === "primaryUser") {
"isLoadsImagesAutomatically": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isLoadsImagesAutomatically"], payload["primaryUserApps"] = userAppConfigurations[index]["visibleAppList"];
"isBlockNetworkImage": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isBlockNetworkImage"], delete userAppConfigurations[index];
"isBlockNetworkLoads": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isBlockNetworkLoads"], }
"isSupportZoomEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isSupportZoomEnabled"], }
"isDisplayZoomControls": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDisplayZoomControls"], payload["userAppConfigurations"] = userAppConfigurations.filter(Boolean);
"textZoom": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["textZoom"], }
"defaultFontSize": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["defaultFontSize"], payload["displayOrientation"] = deviceGlobalConfigurations["displayOrientation"];
"defaultTextEncodingName": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["defaultTextEncodingName"], if ("browserProperties" in deviceGlobalConfigurations) {
"isDatabaseEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDatabaseEnabled"], var browserProperties = deviceGlobalConfigurations["browserProperties"];
"isDomStorageEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isDomStorageEnabled"], payload["isBrowserPropertyEnabled"] = browserProperties["isBrowserPropertyEnabled"];
"geolocationEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["geolocationEnabled"], payload["primaryURL"] = browserProperties["primaryURL"];
"isJavaScriptCanOpenWindowsAutomatically": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isJavaScriptCanOpenWindowsAutomatically"], payload["isTopBarEnabled"] = browserProperties["isTopBarEnabled"];
"isMediaPlaybackRequiresUserGesture": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isMediaPlaybackRequiresUserGesture"], payload["isAddressBarEnabled"] = browserProperties["isAddressBarEnabled"];
"isSafeBrowsingEnabled": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isSafeBrowsingEnabled"], payload["showBackController"] = browserProperties["showBackController"];
"isUseWideViewPort": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["isUseWideViewPort"], payload["isForwardControllerEnabled"] = browserProperties["isForwardControllerEnabled"];
"userAgentString": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["userAgentString"], payload["isHomeButtonEnabled"] = browserProperties["isHomeButtonEnabled"];
"mixedContentMode": operationPayload["deviceGlobalConfigurations"]["browserProperties"]["mixedContentMode"] 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; break;
case androidOperationConstants["KIOSK_APPS_CODE"]: case androidOperationConstants["KIOSK_APPS_CODE"]:
payload = { payload = {
@ -445,86 +479,121 @@ var androidOperationModule = function () {
case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]: case androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
payload = {}; payload = {};
operation = {}; var operation = {};
operation["cosuProfileRestrictionStartTime"] = operation["isDeviceRestrictOperationTimeEnabled"] =
operationData["cosuProfileOperationRestrictionStartTime"]; operationData["isDeviceRestrictOperationTimeEnabled"];
operation["cosuProfileRestrictionEndTime"] = operationData["cosuProfileOperationRestrictionEndTime"]; operation["isDeviceGlobalConfigEnabled"] = operationData["isDeviceGlobalConfigEnabled"];
if (operation["isDeviceRestrictOperationTimeEnabled"] === true) {
deviceGlobalConfigurations = {}; operation["cosuProfileRestrictionStartTime"] = operationData["cosuProfileRestrictionStartTime"];
if (operationData["idleMediaURL"]) { operation["cosuProfileRestrictionEndTime"] = operationData["cosuProfileRestrictionEndTime"];
deviceGlobalConfigurations["idleMediaURL"] = operationData["idleMediaURL"];
}
if (operationData["kioskBackgroundImage"]) {
deviceGlobalConfigurations["kioskBackgroundImage"] = operationData["kioskBackgroundImage"];
}
if (operationData["kioskLogoImage"]) {
deviceGlobalConfigurations["kioskLogoImage"] = operationData["kioskLogoImage"];
} }
if (operationData["kioskAppName"]) { if (operationData["isDeviceGlobalConfigEnabled"] === true) {
deviceGlobalConfigurations["kioskAppName"] = operationData["kioskAppName"]; var deviceGlobalConfigurations = {};
} if (operationData["idleMediaURL"]) {
deviceGlobalConfigurations["isIdleGraphicsEnabled"] = operationData["isIdleGraphicsEnabled"]; deviceGlobalConfigurations["idleMediaURL"] = operationData["idleMediaURL"];
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"]; if (operationData["kioskBackgroundImage"]) {
browserProperties["isLoadsImagesAutomatically"] = operationData["isLoadsImagesAutomatically"]; deviceGlobalConfigurations["kioskBackgroundImage"] = operationData["kioskBackgroundImage"];
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"]) { if (operationData["kioskLogoImage"]) {
browserProperties["defaultFontSize"] = operationData["defaultFontSize"]; deviceGlobalConfigurations["kioskLogoImage"] = operationData["kioskLogoImage"];
} }
if (operationData["defaultTextEncodingName"]) { if (operationData["kioskAppName"]) {
browserProperties["defaultTextEncodingName"] = operationData["defaultTextEncodingName"]; deviceGlobalConfigurations["kioskAppName"] = operationData["kioskAppName"];
} }
browserProperties["isDatabaseEnabled"] = operationData["isDatabaseEnabled"]; deviceGlobalConfigurations["isIdleGraphicsEnabled"] = operationData["isIdleGraphicsEnabled"];
browserProperties["isDomStorageEnabled"] = operationData["isDomStorageEnabled"]; if (operationData["idleTimeout"]) {
browserProperties["geolocationEnabled"] = operationData["geolocationEnabled"]; deviceGlobalConfigurations["idleTimeout"] = operationData["idleTimeout"];
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["isMultiUserDevice"] = operationData["isMultiUserDevice"];
deviceGlobalConfigurations.browserProperties = browserProperties; 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<storeApps.length; i++) {
if (packageName === storeApps[i]["packageName"]) {
packageName += ":" + storeApps[i]["webUrl"];
}
}
}
return packageName;
}).filter(Boolean);
}
operation["userAppConfigurations"] = operationData["userAppConfigurations"];
}
if (operationData["isBrowserPropertyEnabled"] === true) {
var browserProperties = {};
browserProperties["isBrowserPropertyEnabled"] = true;
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;
} }
operation.deviceGlobalConfigurations = deviceGlobalConfigurations;
payload.operation = operation; payload.operation = operation;
break; break;
case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]: case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]:
operationType = operationTypeConstants["PROFILE"]; operationType = operationTypeConstants["PROFILE"];
@ -793,6 +862,7 @@ var androidOperationModule = function () {
operationDataObj.val(value); operationDataObj.val(value);
} else if (operationDataObj.is(":checkbox")) { } else if (operationDataObj.is(":checkbox")) {
operationDataObj.prop("checked", value); operationDataObj.prop("checked", value);
operationDataObj.trigger("change");
} else if (operationDataObj.is(":radio")) { } else if (operationDataObj.is(":radio")) {
if (operationDataObj.val() == uiPayload[key]) { if (operationDataObj.val() == uiPayload[key]) {
operationDataObj.attr("checked", true); operationDataObj.attr("checked", true);
@ -917,6 +987,7 @@ var androidOperationModule = function () {
var multiColumnKeyValuePair = value[multiColumnKeyValuePairArrayIndex]; var multiColumnKeyValuePair = value[multiColumnKeyValuePairArrayIndex];
var childInputKey = childInput.data("child-key"); var childInputKey = childInput.data("child-key");
var childInputValue = multiColumnKeyValuePair[childInputKey]; var childInputValue = multiColumnKeyValuePair[childInputKey];
// populating extracted value in the UI according to the input type // populating extracted value in the UI according to the input type
if (childInput.is(":text") || if (childInput.is(":text") ||
childInput.is("textarea") || childInput.is("textarea") ||

@ -274,6 +274,18 @@ var validatePolicyProfile = function () {
operation = androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION"]; operation = androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION"];
var continueToCheckNextInputs = true; var continueToCheckNextInputs = true;
var isDeviceGlobalConfigChecked = $("input#cosu-profile-device-global-config").is(":checked");
var isDeviceRestrictOperationChecked = $("input#cosu-profile-device-restrict-operation-time").is(":checked");
if (isDeviceGlobalConfigChecked === false && isDeviceRestrictOperationChecked === false) {
validationStatus = {
"error": true,
"subErrorMsg": "COSU Profile Configuration is empty.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
if (continueToCheckNextInputs) { if (continueToCheckNextInputs) {
var backgroundImage = $("input#cosu-global-config-kiosk-background-image").val(); var backgroundImage = $("input#cosu-global-config-kiosk-background-image").val();
if (backgroundImage && !(backgroundImage.endsWith("jpg") || backgroundImage.endsWith("jpeg") if (backgroundImage && !(backgroundImage.endsWith("jpg") || backgroundImage.endsWith("jpeg")
@ -353,6 +365,69 @@ var validatePolicyProfile = function () {
} }
} }
if (continueToCheckNextInputs) {
var isMultiUser = $("input#cosu-global-config-is-multi-user-device").is(":checked");
if (isMultiUser === true) {
var primaryUserApps = $("input#cosu-user-app-config-primary-user").val();
if (!primaryUserApps) {
validationStatus = {
"error": true,
"subErrorMsg": "Primary user apps are not configured.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
if (continueToCheckNextInputs) {
var isEmptyInputValue = false;
var cosuUserAppConfig = $("#cosu-user-app-config .child-input");
if ($(cosuUserAppConfig).length === 0) {
validationStatus = {
"error": true,
"subErrorMsg": "Users and apps are not configured for multi users.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
} else {
var childInputCount = 0;
var userInputArray = [];
var appInputArray = [];
$(cosuUserAppConfig).each(function () {
childInputCount++;
var childInputValue = $(this).val();
if (!childInputValue) {
isEmptyInputValue = true;
return false;
}
if (childInputCount % 2 === 0) {
appInputArray.push(childInputValue);
} else {
userInputArray.push(childInputValue);
}
});
var uniqueUserInputArray = userInputArray.filter(function (value, index, self) {
return self.indexOf(value) === index;
});
if (userInputArray.length !== uniqueUserInputArray.length) {
validationStatus = {
"error": true,
"subErrorMsg": "Duplicate values exist for username in multi user app configuration.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
}
if (isEmptyInputValue === true) {
validationStatus = {
"error": true,
"subErrorMsg": "One or more multi user app configurations are empty.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
}
}
}
if (continueToCheckNextInputs) { if (continueToCheckNextInputs) {
validationStatus = { validationStatus = {
"error": false, "error": false,
@ -830,17 +905,41 @@ var changeAndroidWifiPolicyEAP = function (select, superSelect) {
*/ */
var changeDivVisibility = function (divId, checkbox) { var changeDivVisibility = function (divId, checkbox) {
if (checkbox.checked) { if (checkbox.checked) {
document.getElementById(divId).style.display= "block" document.getElementById(divId).style.display= "block";
} else { } else {
document.getElementById(divId).style.display= "none"
inputs = document.getElementById(divId).getElementsByTagName('input'); document.getElementById(divId).style.display= "none";
for (index = 0; index < inputs.length; ++index) { $("#" + divId + " input").each(
if (inputs[index].type == "text") { function () {
inputs[index].value = inputs[index].defaultValue; if ($(this).is("input:text")) {
} else if (inputs[index].type == "checkbox") { $(this).val(this.defaultValue);
inputs[index].checked = inputs[index].defaultChecked; } else if ($(this).is("input:checkbox")) {
$(this).prop("checked", this.defaultChecked);
}
} }
} );
$("#" + divId + " select").each(
function () {
$(this).val($(this).data("default"));
}
);
$("#" + divId + " .grouped-array-input").each(
function () {
var gridInputs = $(this).find("[data-add-form-clone]");
if (gridInputs.length > 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"); $(this).removeClass("child-input");
}); });
}); });
}); });

@ -198,6 +198,48 @@ var switchPaneAgainstValueSetForRadioButtons = function (selectElement, paneIdPr
}; };
// End of HTML embedded invoke methods // End of HTML embedded invoke methods
/**
* 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";
$("#" + divId + " input").each(
function () {
if ($(this).is("input:text")) {
$(this).val(this.defaultValue);
} else if ($(this).is("input:checkbox")) {
$(this).prop("checked", this.defaultChecked);
}
}
);
$("#" + divId + " select").each(
function () {
$(this).val($(this).data("default"));
}
);
$("#" + divId + " .grouped-array-input").each(
function () {
var gridInputs = $(this).find("[data-add-form-clone]");
if (gridInputs.length > 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";
}
);
}
};
/** /**
* This method will display appropriate fields based on wifi type * This method will display appropriate fields based on wifi type
* @param {object} wifi type select object * @param {object} wifi type select object
@ -254,4 +296,53 @@ $(document).ready(function () {
} }
} }
}); });
});
// add form entry click function for grid inputs
$(advanceOperations).on("click", "[data-click-event=add-form]", function () {
var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]");
var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone().find("[data-add-form-element=clone]")
.attr("data-add-form-clone", $(this).attr("href"));
// adding class .child-input to capture text-input-array-values
$("input, select", clonedForm).addClass("child-input");
$(addFormContainer).append(clonedForm);
setId(addFormContainer);
showHideHelpText(addFormContainer);
});
// remove form entry click function for grid inputs
$(advanceOperations).on("click", "[data-click-event=remove-form]", function () {
var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]");
$(this).closest("[data-add-form-element=clone]").remove();
setId(addFormContainer);
showHideHelpText(addFormContainer);
});
});
/**
* Method to set count id to cloned elements.
* @param {object} addFormContainer
*/
var setId = function (addFormContainer) {
$(addFormContainer).find("[data-add-form-clone]").each(function (i) {
$(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1));
if ($(this).find(".index").length > 0) {
$(this).find(".index").html(i + 1);
}
});
};
/**
* Method to set count id to cloned elements.
* @param {object} addFormContainer
*/
var showHideHelpText = function (addFormContainer) {
var helpText = "[data-help-text=add-form]";
if ($(addFormContainer).find("[data-add-form-clone]").length > 0) {
$(addFormContainer).find(helpText).hide();
} else {
$(addFormContainer).find(helpText).show();
}
};

@ -217,6 +217,18 @@ var validatePolicyProfile = function () {
operation = androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION"]; operation = androidOperationConstants["COSU_PROFILE_CONFIGURATION_OPERATION"];
var continueToCheckNextInputs = true; var continueToCheckNextInputs = true;
var isDeviceGlobalConfigChecked = $("input#cosu-profile-device-global-config").is(":checked");
var isDeviceRestrictOperationChecked = $("input#cosu-profile-device-restrict-operation-time").is(":checked");
if (isDeviceGlobalConfigChecked === false && isDeviceRestrictOperationChecked === false) {
validationStatus = {
"error": true,
"subErrorMsg": "COSU Profile Configuration is empty.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
if (continueToCheckNextInputs) { if (continueToCheckNextInputs) {
var backgroundImage = $("input#cosu-global-config-kiosk-background-image").val(); var backgroundImage = $("input#cosu-global-config-kiosk-background-image").val();
if (backgroundImage && !(backgroundImage.endsWith("jpg") || backgroundImage.endsWith("jpeg") if (backgroundImage && !(backgroundImage.endsWith("jpg") || backgroundImage.endsWith("jpeg")
@ -296,6 +308,69 @@ var validatePolicyProfile = function () {
} }
} }
if (continueToCheckNextInputs) {
var isMultiUser = $("input#cosu-global-config-is-multi-user-device").is(":checked");
if (isMultiUser === true) {
var primaryUserApps = $("input#cosu-user-app-config-primary-user").val();
if (!primaryUserApps) {
validationStatus = {
"error": true,
"subErrorMsg": "Primary user apps are not configured.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
if (continueToCheckNextInputs) {
var isEmptyInputValue = false;
var cosuUserAppConfig = $("#cosu-user-app-config .child-input");
if ($(cosuUserAppConfig).length === 0) {
validationStatus = {
"error": true,
"subErrorMsg": "Users and apps are not configured for multi users.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
} else {
var childInputCount = 0;
var userInputArray = [];
var appInputArray = [];
$(cosuUserAppConfig).each(function () {
childInputCount++;
var childInputValue = $(this).val();
if (!childInputValue) {
isEmptyInputValue = true;
return false;
}
if (childInputCount % 2 === 0) {
appInputArray.push(childInputValue);
} else {
userInputArray.push(childInputValue);
}
});
var uniqueUserInputArray = userInputArray.filter(function (value, index, self) {
return self.indexOf(value) === index;
});
if (userInputArray.length !== uniqueUserInputArray.length) {
validationStatus = {
"error": true,
"subErrorMsg": "Duplicate values exist for username in multi user app configuration.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
}
if (isEmptyInputValue === true) {
validationStatus = {
"error": true,
"subErrorMsg": "One or more multi user app configurations are empty.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
}
}
}
if (continueToCheckNextInputs) { if (continueToCheckNextInputs) {
validationStatus = { validationStatus = {
"error": false, "error": false,
@ -807,17 +882,40 @@ var changeAndroidWifiPolicyEAP = function (select, superSelect) {
*/ */
var changeDivVisibility = function (divId, checkbox) { var changeDivVisibility = function (divId, checkbox) {
if (checkbox.checked) { if (checkbox.checked) {
document.getElementById(divId).style.display= "block" document.getElementById(divId).style.display= "block";
} else { } else {
document.getElementById(divId).style.display= "none" document.getElementById(divId).style.display= "none";
inputs = document.getElementById(divId).getElementsByTagName('input'); $("#" + divId + " input").each(
for (index = 0; index < inputs.length; ++index) { function () {
if (inputs[index].type == "text") { if ($(this).is("input:text")) {
inputs[index].value = inputs[index].defaultValue; $(this).val(this.defaultValue);
} else if (inputs[index].type == "checkbox") { } else if ($(this).is("input:checkbox")) {
inputs[index].checked = inputs[index].defaultChecked; $(this).prop("checked", this.defaultChecked);
}
} }
} );
$("#" + divId + " select").each(
function () {
$(this).val($(this).data("default"));
}
);
$("#" + divId + " .grouped-array-input").each(
function () {
var gridInputs = $(this).find("[data-add-form-clone]");
if (gridInputs.length > 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";
}
);
} }
}; };

Loading…
Cancel
Save