From bd5ef4158b0c696ea06764d4c7db05f5fda94c5a Mon Sep 17 00:00:00 2001 From: dilanua Date: Wed, 10 Aug 2016 18:52:39 +0530 Subject: [PATCH] Adding emm policy edit UI --- .../app/units/mdm.unit.policy.edit/edit.hbs | 448 +- .../app/units/mdm.unit.policy.edit/edit.js | 22 +- .../app/units/mdm.unit.policy.edit/edit.json | 3 +- .../public/js/{policy-create.js => edit.js} | 473 +- .../templates/hidden-operations-android.hbs | 1534 +++-- .../templates/hidden-operations-ios.hbs | 6114 +++++++++++------ .../templates/hidden-operations-windows.hbs | 898 +-- 7 files changed, 6181 insertions(+), 3311 deletions(-) rename components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/{policy-create.js => edit.js} (87%) diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs index 9c913a932..4f499fddd 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs @@ -1,239 +1,233 @@ -{{! - Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - - WSO2 Inc. licenses this file to you under the Apache License, - Version 2.0 (the "License"); you may not use this file except - in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. -}} +{{#zone "content"}}
-
+
- + - + + + + + +
+
+

EDIT POLICY

+
+
+
+
+
+

Step 1: Edit current profile

+
+ +
+
+
+    + +  Loading platform features . . . +
+
+
+
+ +
+
+
+
+ + + +
+
+{{/zone}} {{#zone "bottomJs"}} - - - - {{js "js/policy-create.js"}} + + + + + + + {{js "js/edit.js"}} {{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js index 836302069..dfb1cbe95 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,8 +19,18 @@ function onRequest(context) { var log = new Log("policy-view-edit-unit backend js"); log.debug("calling policy-view-edit-unit"); + var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - context.roles = userModule.getRoles().content; - context.users = userModule.getUsersByUsername().content; + + var rolesResult = userModule.getRoles(); + if (rolesResult.status == "success") { + context.roles = rolesResult.content; + } + + var usersResult = userModule.getUsers(); + if (usersResult.status == "success") { + context.users = usersResult.content; + } + return context; } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json index fd2590129..395c829c5 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json @@ -1,3 +1,4 @@ { - "version" : "1.0.0" + "version" : "1.0.0", + "extends" : "cdmf.unit.policy.edit" } \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/policy-create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js similarity index 87% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/policy-create.js rename to components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js index fafc43318..89252aaf1 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/policy-create.js +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js @@ -1,17 +1,17 @@ /* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -24,6 +24,71 @@ var policy = {}; var configuredOperations = []; var currentlyEffected = {}; +var validateInline = {}; +var clearInline = {}; + +var enableInlineError = function (inputField, errorMsg, errorSign) { + var fieldIdentifier = "#" + inputField; + var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; + var errorSignIdentifier = "#" + inputField + " ." + errorSign; + + if (inputField) { + $(fieldIdentifier).addClass(" has-error has-feedback"); + } + + if (errorMsg) { + $(errorMsgIdentifier).removeClass(" hidden"); + } + + if (errorSign) { + $(errorSignIdentifier).removeClass(" hidden"); + } +}; + +var disableInlineError = function (inputField, errorMsg, errorSign) { + var fieldIdentifier = "#" + inputField; + var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; + var errorSignIdentifier = "#" + inputField + " ." + errorSign; + + if (inputField) { + $(fieldIdentifier).removeClass(" has-error has-feedback"); + } + + if (errorMsg) { + $(errorMsgIdentifier).addClass(" hidden"); + } + + if (errorSign) { + $(errorSignIdentifier).addClass(" hidden"); + } +}; + +/** + *clear inline validation messages. + */ +clearInline["policy-name"] = function () { + disableInlineError("policy-name-field", "nameEmpty", "nameError"); +}; + + +/** + * Validate if provided policy name is valid against RegEx configures. + */ +validateInline["policy-name"] = function () { + var policyName = $("input#policy-name-input").val(); + if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) { + disableInlineError("policy-name-field", "nameEmpty", "nameError"); + } else { + enableInlineError("policy-name-field", "nameEmpty", "nameError"); + } +}; + +$("#policy-name-input").focus(function(){ + clearInline["policy-name"](); +}).blur(function(){ + validateInline["policy-name"](); +}); + // Constants to define platform types available var platformTypeConstants = { "ANDROID": "android", @@ -47,7 +112,9 @@ var androidOperationConstants = { "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI" + "WIFI_OPERATION_CODE": "WIFI", + "APPLICATION_OPERATION":"app-restriction", + "APPLICATION_OPERATION_CODE":"APP-RESTRICTION" }; // Constants to define Android Operation Constants @@ -110,24 +177,30 @@ var updateGroupedInputVisibility = function (domElement) { skipStep["policy-platform"] = function (policyPayloadObj) { policy["name"] = policyPayloadObj["policyName"]; - policy["platform"] = policyPayloadObj["profile"]["deviceType"]["name"]; - policy["platformId"] = policyPayloadObj["profile"]["deviceType"]["id"]; + policy["platform"] = policyPayloadObj["profile"]["deviceType"]; + var userRoleInput = $("#user-roles-input"); var ownershipInput = $("#ownership-input"); var userInput = $("#users-input"); var actionInput = $("#action-input"); var policyNameInput = $("#policy-name-input"); var policyDescriptionInput = $("#policy-description-input"); + currentlyEffected["roles"] = policyPayloadObj.roles; currentlyEffected["users"] = policyPayloadObj.users; - userRoleInput.val(currentlyEffected["roles"]).trigger("change"); - userInput.val(currentlyEffected["users"]).trigger("change"); - if (currentlyEffected["users"].length > 0) { - $("#users-radio-btn").prop("checked", true) + if (currentlyEffected["roles"].length > 0) { + $("#user-roles-radio-btn").prop("checked", true); + $("#user-roles-select-field").show(); + $("#users-select-field").hide(); + userRoleInput.val(currentlyEffected["roles"]).trigger("change"); + } else if (currentlyEffected["users"].length > 0) { + $("#users-radio-btn").prop("checked", true); $("#users-select-field").show(); $("#user-roles-select-field").hide(); + userInput.val(currentlyEffected["users"]).trigger("change"); } + ownershipInput.val(policyPayloadObj.ownershipType); actionInput.val(policyPayloadObj.compliance); policyNameInput.val(policyPayloadObj["policyName"]); @@ -157,9 +230,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) { for (var i = 0; i < configuredOperations.length; ++i) { var configuredOperation = configuredOperations[i]; $(".operation-data").filterByData("operation-code", configuredOperation). - find(".panel-title .wr-input-control.switch input[type=checkbox]").each(function () { - $(this).click(); - }); + find(".panel-title .wr-input-control.switch input[type=checkbox]"). + each(function () {$(this).click();}); } }); }, @@ -321,9 +393,107 @@ validateStep["policy-profile"] = function () { // updating validationStatusArray with validationStatus validationStatusArray.push(validationStatus); } + if ($.inArray(androidOperationConstants["APPLICATION_OPERATION_CODE"], configuredOperations) != -1) { + //If application restriction configured + operation = androidOperationConstants["APPLICATION_OPERATION"]; + // Initializing continueToCheckNextInputs to true + continueToCheckNextInputs = true; + + var appRestrictionType = $("#app-restriction-type").val(); + + var restrictedApplicationsGridChildInputs = "div#restricted-applications .child-input"; + + if (!appRestrictionType) { + validationStatus = { + "error": true, + "subErrorMsg": "Applications restriction type is not provided.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + if (continueToCheckNextInputs) { + if ($(restrictedApplicationsGridChildInputs).length == 0) { + validationStatus = { + "error": true, + "subErrorMsg": "Applications are not provided in application restriction list.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + else { + childInputCount = 0; + childInputArray = []; + emptyChildInputCount = 0; + duplicatesExist = false; + // Looping through each child input + $(restrictedApplicationsGridChildInputs).each(function () { + childInputCount++; + if (childInputCount % 2 == 0) { + // If child input is of second column + childInput = $(this).val(); + childInputArray.push(childInput); + // Updating emptyChildInputCount + if (!childInput) { + // If child input field is empty + emptyChildInputCount++; + } + } + }); + // Checking for duplicates + initialChildInputArrayLength = childInputArray.length; + if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { + for (m = 0; m < (initialChildInputArrayLength - 1); m++) { + poppedChildInput = childInputArray.pop(); + for (n = 0; n < childInputArray.length; n++) { + if (poppedChildInput == childInputArray[n]) { + duplicatesExist = true; + break; + } + } + if (duplicatesExist) { + break; + } + } + } + // Updating validationStatus + if (emptyChildInputCount > 0) { + // If empty child inputs are present + validationStatus = { + "error": true, + "subErrorMsg": "One or more package names of " + + "applications are empty.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } else if (duplicatesExist) { + // If duplicate input is present + validationStatus = { + "error": true, + "subErrorMsg": "Duplicate values exist with " + + "for package names.", + "erroneousFeature": operation + }; + continueToCheckNextInputs = false; + } + + } + } + + if (continueToCheckNextInputs) { + validationStatus = { + "error": false, + "okFeature": operation + }; + } + + // Updating validationStatusArray with validationStatus + validationStatusArray.push(validationStatus); + + + } } - } - if (policy["platform"] == platformTypeConstants["WINDOWS"]) { + } if (policy["platform"] == platformTypeConstants["WINDOWS"]) { if (configuredOperations.length == 0) { // updating validationStatus validationStatus = { @@ -541,7 +711,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more permitted App ID entries in " + - "Autonomous Single App Mode are empty.", + "Autonomous Single App Mode are empty.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -549,7 +719,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist with permitted App ID entries in " + - "Autonomous Single App Mode.", + "Autonomous Single App Mode.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -622,7 +792,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Wi-Fi Proxy Port is not within the range " + - "of valid port numbers.", + "of valid port numbers.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -672,7 +842,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more Payload Certificate " + - "Anchor UUIDs are empty.", + "Anchor UUIDs are empty.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -680,7 +850,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist " + - "with Payload Certificate Anchor UUIDs.", + "with Payload Certificate Anchor UUIDs.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -732,7 +902,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist " + - "with TLS Trusted Server Names.", + "with TLS Trusted Server Names.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -793,7 +963,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more Roaming Consortium OIs " + - "are out of allowed length.", + "are out of allowed length.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -802,7 +972,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more Roaming Consortium OIs " + - "contain non-hexadecimal characters.", + "contain non-hexadecimal characters.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -941,7 +1111,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more MCC/MNC pairs " + - "do not fulfill the accepted length of 6 digits.", + "do not fulfill the accepted length of 6 digits.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1011,7 +1181,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Incoming Mail Server Port is not within the range " + - "of valid port numbers.", + "of valid port numbers.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1045,7 +1215,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Outgoing Mail Server Port is not within the range " + - "of valid port numbers.", + "of valid port numbers.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1126,7 +1296,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more Device Names of " + - "AirPlay Credentials are empty.", + "AirPlay Credentials are empty.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1135,7 +1305,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist with " + - "Device Names of AirPlay Credentials.", + "Device Names of AirPlay Credentials.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1158,7 +1328,7 @@ validateStep["policy-profile"] = function () { // if child input field is empty emptyChildInputCount++; } else if (!inputIsValidAgainstRegExp( - /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { + /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { // if child input field is invalid against RegEx invalidAgainstRegExCount++ } @@ -1193,7 +1363,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "One or more AirPlay Destination fields " + - "do not fulfill expected format.", + "do not fulfill expected format.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1295,7 +1465,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist with " + - "Search Setting Search Base and Scope pairs.", + "Search Setting Search Base and Scope pairs.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1352,7 +1522,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Account Port is not within the range " + - "of valid port numbers.", + "of valid port numbers.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1465,7 +1635,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist with " + - "APN fields of Configurations.", + "APN fields of Configurations.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1553,7 +1723,7 @@ validateStep["policy-profile"] = function () { validationStatus = { "error": true, "subErrorMsg": "Duplicate values exist with " + - "APN fields of APN Configurations.", + "APN fields of APN Configurations.", "erroneousFeature": operation }; continueToCheckNextInputs = false; @@ -1663,7 +1833,9 @@ stepForwardFrom["policy-criteria"] = function () { if ($(this).is(":checked")) { if ($(this).attr("id") == "users-radio-btn") { policy["selectedUsers"] = $("#users-input").val(); + policy["selectedUserRoles"] = null; } else if ($(this).attr("id") == "user-roles-radio-btn") { + policy["selectedUsers"] = null; policy["selectedUserRoles"] = $("#user-roles-input").val(); } } @@ -1810,14 +1982,15 @@ var updatePolicy = function (policy, state) { // traverses key by key in policy["profile"] var key; for (key in policy["profile"]) { - if (policy["platformId"] == platformTypeIds["WINDOWS"] && key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { - policy["profile"][key].enablePassword = true; + if (policy["platform"] == platformTypeConstants["WINDOWS"] && + key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { + policy["profile"][windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]].enablePassword = true; } if (policy["profile"].hasOwnProperty(key)) { profilePayloads.push({ "featureCode": key, - "deviceTypeId": policy["platformId"], + "deviceType": policy["platform"], "content": policy["profile"][key] }); } @@ -1825,7 +1998,7 @@ var updatePolicy = function (policy, state) { $.each(profilePayloads, function (i, item) { $.each(item.content, function (key, value) { - if (value === "" || value === undefined) { + if (value === null || value === undefined || value === "") { item.content[key] = null; } }); @@ -1838,68 +2011,72 @@ var updatePolicy = function (policy, state) { "ownershipType": policy["selectedOwnership"], "profile": { "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"] - }, + "deviceType": policy["platform"], "profileFeaturesList": profilePayloads } }; if (policy["selectedUsers"]) { payload["users"] = policy["selectedUsers"]; + payload["roles"] = []; } else if (policy["selectedUserRoles"]) { + payload["users"] = []; payload["roles"] = policy["selectedUserRoles"]; } else { payload["users"] = []; payload["roles"] = []; } - var serviceURL = "/devicemgt_admin/policies/" + getParameterByName("id"); + var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id"); invokerUtil.put( serviceURL, payload, // on success - function () { - if (state == "save") { + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { var policyList = []; policyList.push(getParameterByName("id")); - serviceURL = "/devicemgt_admin/policies/inactivate"; - invokerUtil.put( - serviceURL, - policyList, - // on success - function () { - $(".add-policy").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - // on error - function (daa) { - console.log(data); - } - ); - } else if (state == "publish") { - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = "/devicemgt_admin/policies/activate"; - invokerUtil.put( - serviceURL, - policyList, - // on success - function () { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - // on error - function (data) { - console.log(data); - } - ); + if (state == "save") { + serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy"; + invokerUtil.put( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + $(".add-policy").addClass("hidden"); + $(".policy-message").removeClass("hidden"); + } + }, + // on error + function (jqXHR) { + console.log("error in saving policy. Received error code : " + jqXHR.status); + } + ); + } else if (state == "publish") { + serviceURL = "/api/device-mgt/v1.0/policies/activate-policy"; + invokerUtil.put( + serviceURL, + policyList, + // on success + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200) { + $(".add-policy").addClass("hidden"); + $(".policy-naming").addClass("hidden"); + $(".policy-message").removeClass("hidden"); + } + }, + // on error + function (jqXHR) { + console.log("error in publishing policy. Received error code : " + jqXHR.status); + } + ); + } } }, // on error - function () { - + function (jqXHR) { + console.log("error in updating policy. Received error code : " + jqXHR.status); } ); }; @@ -1913,6 +2090,57 @@ var showAdvanceOperation = function (operation, button) { $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); }; +/** + * This method will display appropriate fields based on wifi type + * @param {object} wifi type select object + */ +var changeAndroidWifiPolicy = function (select) { + slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); +} + +/** + * This method will display appropriate fields based on wifi EAP type + * @param {object} wifi eap select object + * @param {object} wifi type select object + */ +var changeAndroidWifiPolicyEAP = function (select, superSelect) { + slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd' ,'fast', 'leap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); + slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); + slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); + slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); + slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); + if(superSelect.value != '802eap'){ + changeAndroidWifiPolicy(superSelect); + } +} + +/** + * This method will encode the fileinput and enter the values to given input files + * @param {object} fileInput + * @param {object} fileHiddenInput + * @param {object} fileNameHiddenInput + */ +var base64EncodeFile = function (fileInput, fileHiddenInput, fileNameHiddenInput) { + var file = fileInput.files[0]; + if (file) { + var reader = new FileReader(); + reader.onload = function(readerEvt) { + var binaryString = readerEvt.target.result; + fileHiddenInput.value = (btoa(binaryString)); + fileNameHiddenInput.value = file.name.substr(0,file.name.lastIndexOf(".")); + }; + reader.readAsBinaryString(file); + } +} + + + /** * Method to slide down a provided pane upon provided value set. * @@ -1922,6 +2150,9 @@ var showAdvanceOperation = function (operation, button) { */ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { var selectedValueOnChange = $(selectElement).find("option:selected").val(); + if ($(selectElement).is("input:checkbox")) { + selectedValueOnChange = $(selectElement).is(":checked").toString(); + } var i, slideDownVotes = 0; for (i = 0; i < valueSet.length; i++) { if (selectedValueOnChange == valueSet[i]) { @@ -2033,54 +2264,49 @@ var getParameterByName = function (name) { return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); }; -function formatRepo(user) { - if (user.loading) { - return user.text - } - if (!user.username) { - return; - } - var markup = '
' + - '
' + - '
' + - '
' + user.username + '
'; - if (user.firstname) { - markup += '
' + user.firstname + '
'; - } - if (user.emailAddress) { - markup += '
' + user.emailAddress + '
'; - } - markup += '
'; - return markup; -} - -function formatRepoSelection(user) { - return user.username || user.text; -} +//function formatRepo(user) { +// if (user.loading) { +// return user.text +// } +// if (!user.username) { +// return; +// } +// var markup = '
' + +// '
' + +// '
' + +// '
' + user.username + '
'; +// if (user.firstname) { +// markup += '
' + user.firstname + '
'; +// } +// if (user.emailAddress) { +// markup += '
' + user.emailAddress + '
'; +// } +// markup += '
'; +// return markup; +//} +// +//function formatRepoSelection(user) { +// return user.username || user.text; +//} $(document).ready(function () { - // Adding initial state of wizard-steps. - - var policyPayloadObj; invokerUtil.get( - "/devicemgt_admin/policies/" + getParameterByName("id"), + "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), // on success - function (data) { - data = JSON.parse(data); - policyPayloadObj = data["responseContent"]; - skipStep["policy-platform"](policyPayloadObj); + function (data, textStatus, jqXHR) { + if (jqXHR.status == 200 && data) { + var policy = JSON.parse(data); + skipStep["policy-platform"](policy); + } }, // on error - function (data) { - console.log(data); + function (jqXHR) { + console.log(jqXHR); // should be redirected to an error page } ); - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - $("input[type='radio'].select-users-radio").change(function () { if ($("#users-radio-btn").is(":checked")) { $("#user-roles-select-field").hide(); @@ -2093,7 +2319,7 @@ $(document).ready(function () { }); // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input,#user-input").select2({ + $("#user-roles-input").select2({ "tags": false }).on("select2:select", function (e) { if (e.params.data.id == "ANY") { @@ -2102,12 +2328,19 @@ $(document).ready(function () { $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); } }); - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - $("select.select2[multiple=multiple]").select2({ + $("#users-input").select2({ "tags": false + }).on("select2:select", function (e) { + if (e.params.data.id == "ANY") { + $(this).val("ANY").trigger("change"); + } else { + $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); + } }); + $("#policy-profile-wizard-steps").html($(".wr-steps").html()); + // Maintains an array of configured features of the profile var advanceOperations = ".wr-advance-operations"; $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { @@ -2318,4 +2551,4 @@ $(document).ready(function () { } }); -}); \ No newline at end of file +}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs index d82da3c0f..4736d8ec3 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android.hbs @@ -1,457 +1,1225 @@
-
- + + Wi-Fi Settings + + + + + + + + + Virtual Private Network + + + + + + + + + Work-Profile Configurations + + + + -
- -
-
- + +
+ +
+
+ +
- + -
- +
-
- +
-
- + +
-
- + +
-
- + +
-
- + +
-
-
+ +
- +
+
+ - -
-
- -
- - Un-check following checkbox in case you need to disable camera. -
-
-
- +
+
+ Below restrictions will be applied on devices with Android version 5.0 Lollipop onwards only + +

+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
- -
-
- +
+
+ + + +
+
+ +
+ + Un-check following checkbox in case you do not need the device to be encrypted. +
+
+
+ -
-
-
+
+
- +
+
+ - -
-
- + + +
+
+ +
+ + + + + +
+ +
+ + + + + + + + + + + + + + +
No:Application Name/DescriptionPackage Name
+ No entries added yet . +
+ + + + + + + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ + + +
+
+ +
+ Please note that * sign represents required fields of data. +
+
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+ + + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
\ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs index aec18bda8..612b913d6 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs +++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios.hbs @@ -1,2923 +1,4679 @@
-
- + + +
+ +
+
+ +
+ + -
- -
-
- -
- - - -
- +
-
- +
-
- +
-
- + +
-
- + +
-
- + +
-
- + +
-
- + +
-
- + +
-
-
+ + +
+
+
+
+ + + +
+
+ +
+Please note that * sign represents required fields of data. +
+
+ + +
+ + +
+
+ +
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + +
No:KeyValue
+ No entries added yet . +
+ + + + + + + + + + +
+
+
+ + +
+ + + + +
+
+
+ + + +
+
+ +
+ Please note that * sign represents required fields of data. +
+
+ + +
+ + +
+
+ +
+
+ +
+ + + + + + + + + + + + + +
No:Safari Domain
+ No entries added yet . +
+ + + + + + + + + +
- +
+
+
+ +
+ Please note that * sign represents required fields of data. +
+
- -
-
- -
- - -
- +
+ + + + + + + + + + + + + + +
No:App IdentifierVPN UUID
+ No entries added yet . +
+ + + + + + + + + + +
+
+
+
+
+ -
-