Merge pull request #343 from saadsahibjan/master

Added validations for COSU create and edit configurations - Android E…
revert-dabc3590
Chatura Dilan 8 years ago committed by GitHub
commit 6bd25a4aad

@ -49,7 +49,9 @@ var androidOperationConstants = {
"VPN_OPERATION": "vpn",
"VPN_OPERATION_CODE": "VPN",
"APPLICATION_OPERATION":"app-restriction",
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION"
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION",
"KIOSK_APPS_CODE":"KIOSK_APPS",
"KIOSK_APPS":"cosu-whitelisted-applications"
};
// Constants to define iOS Operation Constants
@ -520,6 +522,93 @@ validateStep["policy-profile"] = function () {
validationStatusArray.push(validationStatus);
}
if ($.inArray(androidOperationConstants["KIOSK_APPS_CODE"], configuredOperations) != -1) {
//If COSU whitelisting applications configured
operation = androidOperationConstants["KIOSK_APPS"];
// Initializing continueToCheckNextInputs to true
continueToCheckNextInputs = true;
var whitelistedApplicationsGridChildInputs = "div#cosu-whitelisted-applications .child-input";
if (continueToCheckNextInputs) {
if ($(whitelistedApplicationsGridChildInputs).length == 0) {
validationStatus = {
"error": true,
"subErrorMsg": "Applications are not provided in application whitelist list.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
else {
childInputCount = 0;
childInputArray = [];
emptyChildInputCount = 0;
duplicatesExist = false;
// Looping through each child input
$(whitelistedApplicationsGridChildInputs).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 (configuredOperations.length == 0) {

@ -77,14 +77,14 @@
<span id="cosu-system-update-policy-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-system-update-policy-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('cosu-whitelist-applications', this)">
<a href="javascript:void(0)" onclick="showAdvanceOperation('cosu-whitelisted-applications', this)">
<span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-register fw-stack-2x"></i>
</span>
Whitelist Apps (COSU)
<span id="cosu-whitelist-applications-configured" class="has-configured status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelist-applications-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelist-applications-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
<span id="cosu-whitelisted-applications-configured" class="has-configured status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelisted-applications-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelisted-applications-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
</div>
@ -1333,14 +1333,14 @@
</div>
<!-- cosu-whitelist-applications -->
<div class="wr-hidden-operation" data-operation="cosu-whitelist-applications">
<div class="panel panel-default operation-data" data-operation="cosu-whitelist-applications"
<div class="wr-hidden-operation" data-operation="cosu-whitelisted-applications">
<div class="panel panel-default operation-data" data-operation="cosu-whitelisted-applications"
data-operation-code="KIOSK_APPS">
<div id="cosu-whitelist-applications-heading" class="panel-heading" role="tab">
<div id="cosu-whitelisted-applications-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Whitelist Applications (COSU)
<label id="cosu-whitelist-applications-lbl" class="wr-input-control switch" data-toggle="collapse"
data-target="#cosu-whitelist-applications-body">
<label id="cosu-whitelisted-applications-lbl" class="wr-input-control switch" data-toggle="collapse"
data-target="#cosu-whitelisted-applications-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
@ -1355,10 +1355,10 @@
</h2>
</div>
<div id="cosu-whitelist-applications-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cosu-whitelist-applications-body">
<div id="cosu-whitelisted-applications-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cosu-whitelisted-applications-body">
<div id="cosu-whitelist-applications-feature-error-msg" class="alert alert-danger hidden" role="alert">
<div id="cosu-whitelisted-applications-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>

@ -114,7 +114,9 @@ var androidOperationConstants = {
"WIFI_OPERATION": "wifi",
"WIFI_OPERATION_CODE": "WIFI",
"APPLICATION_OPERATION":"app-restriction",
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION"
"APPLICATION_OPERATION_CODE":"APP-RESTRICTION",
"KIOSK_APPS_CODE":"KIOSK_APPS",
"KIOSK_APPS":"cosu-whitelisted-applications"
};
// Constants to define Android Operation Constants
@ -491,6 +493,93 @@ validateStep["policy-profile"] = function () {
validationStatusArray.push(validationStatus);
}
if ($.inArray(androidOperationConstants["KIOSK_APPS_CODE"], configuredOperations) != -1) {
//If COSU whitelisting applications configured
operation = androidOperationConstants["KIOSK_APPS"];
// Initializing continueToCheckNextInputs to true
continueToCheckNextInputs = true;
var whitelistedApplicationsGridChildInputs = "div#cosu-whitelisted-applications .child-input";
if (continueToCheckNextInputs) {
if ($(whitelistedApplicationsGridChildInputs).length == 0) {
validationStatus = {
"error": true,
"subErrorMsg": "Applications are not provided in application whitelist list.",
"erroneousFeature": operation
};
continueToCheckNextInputs = false;
}
else {
childInputCount = 0;
childInputArray = [];
emptyChildInputCount = 0;
duplicatesExist = false;
// Looping through each child input
$(whitelistedApplicationsGridChildInputs).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"]) {

@ -106,14 +106,14 @@
<span id="cosu-system-update-policy-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-system-update-policy-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('cosu-whitelist-applications', this)">
<a href="javascript:void(0)" onclick="showAdvanceOperation('cosu-whitelisted-applications', this)">
<span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-register fw-stack-2x"></i>
</span>
Whitelist Apps (COSU)
<span id="cosu-whitelist-applications-configured" class="has-configured status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelist-applications-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelist-applications-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
<span id="cosu-whitelisted-applications-configured" class="has-configured status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelisted-applications-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelisted-applications-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
</div>
@ -1469,14 +1469,14 @@
</div>
<!-- cosu-whitelist-applications -->
<div class="wr-hidden-operation" data-operation="cosu-whitelist-applications">
<div class="panel panel-default operation-data" data-operation="cosu-whitelist-applications"
<div class="wr-hidden-operation" data-operation="cosu-whitelisted-applications">
<div class="panel panel-default operation-data" data-operation="cosu-whitelisted-applications"
data-operation-code="KIOSK_APPS">
<div id="cosu-whitelist-applications-heading" class="panel-heading" role="tab">
<div id="cosu-whitelisted-applications-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Whitelist Applications (COSU)
<label id="cosu-whitelist-applications-lbl" class="wr-input-control switch" data-toggle="collapse"
data-target="#cosu-whitelist-applications-body">
<label id="cosu-whitelisted-applications-lbl" class="wr-input-control switch" data-toggle="collapse"
data-target="#cosu-whitelisted-applications-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
@ -1491,10 +1491,10 @@
</h2>
</div>
<div id="cosu-whitelist-applications-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cosu-whitelist-applications-body">
<div id="cosu-whitelisted-applications-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cosu-whitelisted-applications-body">
<div id="cosu-whitelist-applications-feature-error-msg" class="alert alert-danger hidden" role="alert">
<div id="cosu-whitelisted-applications-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>

@ -1951,6 +1951,24 @@ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) {
);
}
};
var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneID, valueSet) {
var selectedValueOnChange = selectElement.value;
var i, slideDownVotes = 0;
for (i = 0; i < valueSet.length; i++) {
if (selectedValueOnChange == valueSet[i]) {
slideDownVotes++;
}
}
var paneSelector = "#" + paneID;
if(slideDownVotes > 0) {
$(paneSelector).removeClass("hidden");
} else {
$(paneSelector).addClass("hidden");
}
};
// End of HTML embedded invoke methods

@ -73,14 +73,14 @@
<span id="cosu-system-update-policy-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-system-update-policy-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('cosu-whitelist-applications', this)">
<a href="javascript:void(0)" onclick="showAdvanceOperation('cosu-whitelisted-applications', this)">
<span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-register fw-stack-2x"></i>
</span>
Whitelist Apps (COSU)
<span id="cosu-whitelist-applications-configured" class="has-configured status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelist-applications-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelist-applications-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
<span id="cosu-whitelisted-applications-configured" class="has-configured status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelisted-applications-ok" class="has-success status-icon hidden"><i class="fw fw-ok"></i></span>
<span id="cosu-whitelisted-applications-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
</div>
@ -1395,14 +1395,14 @@
</div>
<!-- cosu-whitelist-applications -->
<div class="wr-hidden-operation" data-operation="cosu-whitelist-applications">
<div class="panel panel-default operation-data" data-operation="cosu-whitelist-applications"
<div class="wr-hidden-operation" data-operation="cosu-whitelisted-applications">
<div class="panel panel-default operation-data" data-operation="cosu-whitelisted-applications"
data-operation-code="KIOSK_APPS">
<div id="cosu-whitelist-applications-heading" class="panel-heading" role="tab">
<div id="cosu-whitelisted-applications-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Whitelist Applications (COSU)
<label id="cosu-whitelist-applications-lbl" class="wr-input-control switch hidden" data-toggle="collapse"
data-target="#cosu-whitelist-applications-body">
<label id="cosu-whitelisted-applications-lbl" class="wr-input-control switch hidden" data-toggle="collapse"
data-target="#cosu-whitelisted-applications-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
@ -1417,10 +1417,10 @@
</h2>
</div>
<div id="cosu-whitelist-applications-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cosu-whitelist-applications-body">
<div id="cosu-whitelisted-applications-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cosu-whitelisted-applications-body">
<div id="cosu-whitelist-applications-feature-error-msg" class="alert alert-danger hidden" role="alert">
<div id="cosu-whitelisted-applications-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
@ -1475,7 +1475,7 @@
maxlength="100" data-default="" placeholder="[ Package Name ]" disabled/>
</td>
<td>
<span class="list-group-item-actions">
<span class="list-group-item-actions hidden">
<a href="#cosu-whitelisted-applications-grid" class="grid-input-remove"
data-click-event="remove-form">
<span class="fw-stack helper" title="Remove Entry">

Loading…
Cancel
Save