|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* 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,
|
|
|
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
|
|
|
* Version 2.0 (the "License"); you may not use this file except
|
|
|
|
* Version 2.0 (the "License"); you may not use this file except
|
|
|
@ -10,8 +10,8 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -24,6 +24,71 @@ var policy = {};
|
|
|
|
var configuredOperations = [];
|
|
|
|
var configuredOperations = [];
|
|
|
|
var currentlyEffected = {};
|
|
|
|
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
|
|
|
|
// Constants to define platform types available
|
|
|
|
var platformTypeConstants = {
|
|
|
|
var platformTypeConstants = {
|
|
|
|
"ANDROID": "android",
|
|
|
|
"ANDROID": "android",
|
|
|
@ -47,7 +112,9 @@ var androidOperationConstants = {
|
|
|
|
"ENCRYPT_STORAGE_OPERATION": "encrypt-storage",
|
|
|
|
"ENCRYPT_STORAGE_OPERATION": "encrypt-storage",
|
|
|
|
"ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE",
|
|
|
|
"ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE",
|
|
|
|
"WIFI_OPERATION": "wifi",
|
|
|
|
"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
|
|
|
|
// Constants to define Android Operation Constants
|
|
|
@ -110,24 +177,30 @@ var updateGroupedInputVisibility = function (domElement) {
|
|
|
|
|
|
|
|
|
|
|
|
skipStep["policy-platform"] = function (policyPayloadObj) {
|
|
|
|
skipStep["policy-platform"] = function (policyPayloadObj) {
|
|
|
|
policy["name"] = policyPayloadObj["policyName"];
|
|
|
|
policy["name"] = policyPayloadObj["policyName"];
|
|
|
|
policy["platform"] = policyPayloadObj["profile"]["deviceType"]["name"];
|
|
|
|
policy["platform"] = policyPayloadObj["profile"]["deviceType"];
|
|
|
|
policy["platformId"] = policyPayloadObj["profile"]["deviceType"]["id"];
|
|
|
|
|
|
|
|
var userRoleInput = $("#user-roles-input");
|
|
|
|
var userRoleInput = $("#user-roles-input");
|
|
|
|
var ownershipInput = $("#ownership-input");
|
|
|
|
var ownershipInput = $("#ownership-input");
|
|
|
|
var userInput = $("#users-input");
|
|
|
|
var userInput = $("#users-input");
|
|
|
|
var actionInput = $("#action-input");
|
|
|
|
var actionInput = $("#action-input");
|
|
|
|
var policyNameInput = $("#policy-name-input");
|
|
|
|
var policyNameInput = $("#policy-name-input");
|
|
|
|
var policyDescriptionInput = $("#policy-description-input");
|
|
|
|
var policyDescriptionInput = $("#policy-description-input");
|
|
|
|
|
|
|
|
|
|
|
|
currentlyEffected["roles"] = policyPayloadObj.roles;
|
|
|
|
currentlyEffected["roles"] = policyPayloadObj.roles;
|
|
|
|
currentlyEffected["users"] = policyPayloadObj.users;
|
|
|
|
currentlyEffected["users"] = policyPayloadObj.users;
|
|
|
|
userRoleInput.val(currentlyEffected["roles"]).trigger("change");
|
|
|
|
|
|
|
|
userInput.val(currentlyEffected["users"]).trigger("change");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentlyEffected["users"].length > 0) {
|
|
|
|
if (currentlyEffected["roles"].length > 0) {
|
|
|
|
$("#users-radio-btn").prop("checked", true)
|
|
|
|
$("#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();
|
|
|
|
$("#users-select-field").show();
|
|
|
|
$("#user-roles-select-field").hide();
|
|
|
|
$("#user-roles-select-field").hide();
|
|
|
|
|
|
|
|
userInput.val(currentlyEffected["users"]).trigger("change");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ownershipInput.val(policyPayloadObj.ownershipType);
|
|
|
|
ownershipInput.val(policyPayloadObj.ownershipType);
|
|
|
|
actionInput.val(policyPayloadObj.compliance);
|
|
|
|
actionInput.val(policyPayloadObj.compliance);
|
|
|
|
policyNameInput.val(policyPayloadObj["policyName"]);
|
|
|
|
policyNameInput.val(policyPayloadObj["policyName"]);
|
|
|
@ -157,9 +230,8 @@ skipStep["policy-platform"] = function (policyPayloadObj) {
|
|
|
|
for (var i = 0; i < configuredOperations.length; ++i) {
|
|
|
|
for (var i = 0; i < configuredOperations.length; ++i) {
|
|
|
|
var configuredOperation = configuredOperations[i];
|
|
|
|
var configuredOperation = configuredOperations[i];
|
|
|
|
$(".operation-data").filterByData("operation-code", configuredOperation).
|
|
|
|
$(".operation-data").filterByData("operation-code", configuredOperation).
|
|
|
|
find(".panel-title .wr-input-control.switch input[type=checkbox]").each(function () {
|
|
|
|
find(".panel-title .wr-input-control.switch input[type=checkbox]").
|
|
|
|
$(this).click();
|
|
|
|
each(function () {$(this).click();});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -321,9 +393,107 @@ validateStep["policy-profile"] = function () {
|
|
|
|
// updating validationStatusArray with validationStatus
|
|
|
|
// updating validationStatusArray with validationStatus
|
|
|
|
validationStatusArray.push(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;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (policy["platform"] == platformTypeConstants["WINDOWS"]) {
|
|
|
|
// 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 (configuredOperations.length == 0) {
|
|
|
|
if (configuredOperations.length == 0) {
|
|
|
|
// updating validationStatus
|
|
|
|
// updating validationStatus
|
|
|
|
validationStatus = {
|
|
|
|
validationStatus = {
|
|
|
@ -1663,7 +1833,9 @@ stepForwardFrom["policy-criteria"] = function () {
|
|
|
|
if ($(this).is(":checked")) {
|
|
|
|
if ($(this).is(":checked")) {
|
|
|
|
if ($(this).attr("id") == "users-radio-btn") {
|
|
|
|
if ($(this).attr("id") == "users-radio-btn") {
|
|
|
|
policy["selectedUsers"] = $("#users-input").val();
|
|
|
|
policy["selectedUsers"] = $("#users-input").val();
|
|
|
|
|
|
|
|
policy["selectedUserRoles"] = null;
|
|
|
|
} else if ($(this).attr("id") == "user-roles-radio-btn") {
|
|
|
|
} else if ($(this).attr("id") == "user-roles-radio-btn") {
|
|
|
|
|
|
|
|
policy["selectedUsers"] = null;
|
|
|
|
policy["selectedUserRoles"] = $("#user-roles-input").val();
|
|
|
|
policy["selectedUserRoles"] = $("#user-roles-input").val();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1810,14 +1982,15 @@ var updatePolicy = function (policy, state) {
|
|
|
|
// traverses key by key in policy["profile"]
|
|
|
|
// traverses key by key in policy["profile"]
|
|
|
|
var key;
|
|
|
|
var key;
|
|
|
|
for (key in policy["profile"]) {
|
|
|
|
for (key in policy["profile"]) {
|
|
|
|
if (policy["platformId"] == platformTypeIds["WINDOWS"] && key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) {
|
|
|
|
if (policy["platform"] == platformTypeConstants["WINDOWS"] &&
|
|
|
|
policy["profile"][key].enablePassword = true;
|
|
|
|
key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) {
|
|
|
|
|
|
|
|
policy["profile"][windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]].enablePassword = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (policy["profile"].hasOwnProperty(key)) {
|
|
|
|
if (policy["profile"].hasOwnProperty(key)) {
|
|
|
|
profilePayloads.push({
|
|
|
|
profilePayloads.push({
|
|
|
|
"featureCode": key,
|
|
|
|
"featureCode": key,
|
|
|
|
"deviceTypeId": policy["platformId"],
|
|
|
|
"deviceType": policy["platform"],
|
|
|
|
"content": policy["profile"][key]
|
|
|
|
"content": policy["profile"][key]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1825,7 +1998,7 @@ var updatePolicy = function (policy, state) {
|
|
|
|
|
|
|
|
|
|
|
|
$.each(profilePayloads, function (i, item) {
|
|
|
|
$.each(profilePayloads, function (i, item) {
|
|
|
|
$.each(item.content, function (key, value) {
|
|
|
|
$.each(item.content, function (key, value) {
|
|
|
|
if (value === "" || value === undefined) {
|
|
|
|
if (value === null || value === undefined || value === "") {
|
|
|
|
item.content[key] = null;
|
|
|
|
item.content[key] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -1838,68 +2011,72 @@ var updatePolicy = function (policy, state) {
|
|
|
|
"ownershipType": policy["selectedOwnership"],
|
|
|
|
"ownershipType": policy["selectedOwnership"],
|
|
|
|
"profile": {
|
|
|
|
"profile": {
|
|
|
|
"profileName": policy["policyName"],
|
|
|
|
"profileName": policy["policyName"],
|
|
|
|
"deviceType": {
|
|
|
|
"deviceType": policy["platform"],
|
|
|
|
"id": policy["platformId"]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"profileFeaturesList": profilePayloads
|
|
|
|
"profileFeaturesList": profilePayloads
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (policy["selectedUsers"]) {
|
|
|
|
if (policy["selectedUsers"]) {
|
|
|
|
payload["users"] = policy["selectedUsers"];
|
|
|
|
payload["users"] = policy["selectedUsers"];
|
|
|
|
|
|
|
|
payload["roles"] = [];
|
|
|
|
} else if (policy["selectedUserRoles"]) {
|
|
|
|
} else if (policy["selectedUserRoles"]) {
|
|
|
|
|
|
|
|
payload["users"] = [];
|
|
|
|
payload["roles"] = policy["selectedUserRoles"];
|
|
|
|
payload["roles"] = policy["selectedUserRoles"];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
payload["users"] = [];
|
|
|
|
payload["users"] = [];
|
|
|
|
payload["roles"] = [];
|
|
|
|
payload["roles"] = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var serviceURL = "/devicemgt_admin/policies/" + getParameterByName("id");
|
|
|
|
var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id");
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
serviceURL,
|
|
|
|
serviceURL,
|
|
|
|
payload,
|
|
|
|
payload,
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function () {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
if (state == "save") {
|
|
|
|
if (jqXHR.status == 200) {
|
|
|
|
var policyList = [];
|
|
|
|
var policyList = [];
|
|
|
|
policyList.push(getParameterByName("id"));
|
|
|
|
policyList.push(getParameterByName("id"));
|
|
|
|
serviceURL = "/devicemgt_admin/policies/inactivate";
|
|
|
|
if (state == "save") {
|
|
|
|
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy";
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
serviceURL,
|
|
|
|
serviceURL,
|
|
|
|
policyList,
|
|
|
|
policyList,
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function () {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
|
|
|
|
if (jqXHR.status == 200) {
|
|
|
|
$(".add-policy").addClass("hidden");
|
|
|
|
$(".add-policy").addClass("hidden");
|
|
|
|
$(".policy-message").removeClass("hidden");
|
|
|
|
$(".policy-message").removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// on error
|
|
|
|
function (daa) {
|
|
|
|
function (jqXHR) {
|
|
|
|
console.log(data);
|
|
|
|
console.log("error in saving policy. Received error code : " + jqXHR.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else if (state == "publish") {
|
|
|
|
} else if (state == "publish") {
|
|
|
|
var policyList = [];
|
|
|
|
serviceURL = "/api/device-mgt/v1.0/policies/activate-policy";
|
|
|
|
policyList.push(getParameterByName("id"));
|
|
|
|
|
|
|
|
serviceURL = "/devicemgt_admin/policies/activate";
|
|
|
|
|
|
|
|
invokerUtil.put(
|
|
|
|
invokerUtil.put(
|
|
|
|
serviceURL,
|
|
|
|
serviceURL,
|
|
|
|
policyList,
|
|
|
|
policyList,
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function () {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
|
|
|
|
if (jqXHR.status == 200) {
|
|
|
|
$(".add-policy").addClass("hidden");
|
|
|
|
$(".add-policy").addClass("hidden");
|
|
|
|
$(".policy-naming").addClass("hidden");
|
|
|
|
$(".policy-naming").addClass("hidden");
|
|
|
|
$(".policy-message").removeClass("hidden");
|
|
|
|
$(".policy-message").removeClass("hidden");
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// on error
|
|
|
|
function (data) {
|
|
|
|
function (jqXHR) {
|
|
|
|
console.log(data);
|
|
|
|
console.log("error in publishing policy. Received error code : " + jqXHR.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// 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();
|
|
|
|
$(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.
|
|
|
|
* 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 slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) {
|
|
|
|
var selectedValueOnChange = $(selectElement).find("option:selected").val();
|
|
|
|
var selectedValueOnChange = $(selectElement).find("option:selected").val();
|
|
|
|
|
|
|
|
if ($(selectElement).is("input:checkbox")) {
|
|
|
|
|
|
|
|
selectedValueOnChange = $(selectElement).is(":checked").toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
var i, slideDownVotes = 0;
|
|
|
|
var i, slideDownVotes = 0;
|
|
|
|
for (i = 0; i < valueSet.length; i++) {
|
|
|
|
for (i = 0; i < valueSet.length; i++) {
|
|
|
|
if (selectedValueOnChange == valueSet[i]) {
|
|
|
|
if (selectedValueOnChange == valueSet[i]) {
|
|
|
@ -2033,54 +2264,49 @@ var getParameterByName = function (name) {
|
|
|
|
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
|
|
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function formatRepo(user) {
|
|
|
|
//function formatRepo(user) {
|
|
|
|
if (user.loading) {
|
|
|
|
// if (user.loading) {
|
|
|
|
return user.text
|
|
|
|
// return user.text
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
if (!user.username) {
|
|
|
|
// if (!user.username) {
|
|
|
|
return;
|
|
|
|
// return;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
var markup = '<div class="clearfix">' +
|
|
|
|
// var markup = '<div class="clearfix">' +
|
|
|
|
'<div clas="col-sm-8">' +
|
|
|
|
// '<div clas="col-sm-8">' +
|
|
|
|
'<div class="clearfix">' +
|
|
|
|
// '<div class="clearfix">' +
|
|
|
|
'<div class="col-sm-3">' + user.username + '</div>';
|
|
|
|
// '<div class="col-sm-3">' + user.username + '</div>';
|
|
|
|
if (user.firstname) {
|
|
|
|
// if (user.firstname) {
|
|
|
|
markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + user.firstname + '</div>';
|
|
|
|
// markup += '<div class="col-sm-3"><i class="fa fa-code-fork"></i> ' + user.firstname + '</div>';
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
if (user.emailAddress) {
|
|
|
|
// if (user.emailAddress) {
|
|
|
|
markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + user.emailAddress + '</div></div>';
|
|
|
|
// markup += '<div class="col-sm-2"><i class="fa fa-star"></i> ' + user.emailAddress + '</div></div>';
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
markup += '</div></div>';
|
|
|
|
// markup += '</div></div>';
|
|
|
|
return markup;
|
|
|
|
// return markup;
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
//
|
|
|
|
function formatRepoSelection(user) {
|
|
|
|
//function formatRepoSelection(user) {
|
|
|
|
return user.username || user.text;
|
|
|
|
// return user.username || user.text;
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
|
// Adding initial state of wizard-steps.
|
|
|
|
// Adding initial state of wizard-steps.
|
|
|
|
|
|
|
|
|
|
|
|
var policyPayloadObj;
|
|
|
|
|
|
|
|
invokerUtil.get(
|
|
|
|
invokerUtil.get(
|
|
|
|
"/devicemgt_admin/policies/" + getParameterByName("id"),
|
|
|
|
"/api/device-mgt/v1.0/policies/" + getParameterByName("id"),
|
|
|
|
// on success
|
|
|
|
// on success
|
|
|
|
function (data) {
|
|
|
|
function (data, textStatus, jqXHR) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
if (jqXHR.status == 200 && data) {
|
|
|
|
policyPayloadObj = data["responseContent"];
|
|
|
|
var policy = JSON.parse(data);
|
|
|
|
skipStep["policy-platform"](policyPayloadObj);
|
|
|
|
skipStep["policy-platform"](policy);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
// on error
|
|
|
|
// on error
|
|
|
|
function (data) {
|
|
|
|
function (jqXHR) {
|
|
|
|
console.log(data);
|
|
|
|
console.log(jqXHR);
|
|
|
|
// should be redirected to an error page
|
|
|
|
// should be redirected to an error page
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$("#users-select-field").hide();
|
|
|
|
|
|
|
|
$("#user-roles-select-field").show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("input[type='radio'].select-users-radio").change(function () {
|
|
|
|
$("input[type='radio'].select-users-radio").change(function () {
|
|
|
|
if ($("#users-radio-btn").is(":checked")) {
|
|
|
|
if ($("#users-radio-btn").is(":checked")) {
|
|
|
|
$("#user-roles-select-field").hide();
|
|
|
|
$("#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
|
|
|
|
// 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
|
|
|
|
"tags": false
|
|
|
|
}).on("select2:select", function (e) {
|
|
|
|
}).on("select2:select", function (e) {
|
|
|
|
if (e.params.data.id == "ANY") {
|
|
|
|
if (e.params.data.id == "ANY") {
|
|
|
@ -2102,12 +2328,19 @@ $(document).ready(function () {
|
|
|
|
$("option[value=ANY]", this).prop("selected", false).parent().trigger("change");
|
|
|
|
$("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
|
|
|
|
"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
|
|
|
|
// Maintains an array of configured features of the profile
|
|
|
|
var advanceOperations = ".wr-advance-operations";
|
|
|
|
var advanceOperations = ".wr-advance-operations";
|
|
|
|
$(advanceOperations).on("click", ".wr-input-control.switch", function (event) {
|
|
|
|
$(advanceOperations).on("click", ".wr-input-control.switch", function (event) {
|