Merge branch 'cert-ui' into 'master'

Add android certificate policy add UI

See merge request entgra/carbon-device-mgt-plugins!44
revert-dabc3590
Ruwan Yatawara 6 years ago
commit b12958bc69

@ -108,7 +108,8 @@ var androidOperationModule = function () {
"DISALLOW_BLUETOOTH": "DISALLOW_BLUETOOTH", "DISALLOW_BLUETOOTH": "DISALLOW_BLUETOOTH",
"DISALLOW_BLUETOOTH_SHARING": "DISALLOW_BLUETOOTH_SHARING", "DISALLOW_BLUETOOTH_SHARING": "DISALLOW_BLUETOOTH_SHARING",
"DISALLOW_REMOVE_USER": "DISALLOW_REMOVE_USER", "DISALLOW_REMOVE_USER": "DISALLOW_REMOVE_USER",
"DISALLOW_DATA_ROAMING": "DISALLOW_DATA_ROAMING" "DISALLOW_DATA_ROAMING": "DISALLOW_DATA_ROAMING",
"CERT_ADD_OPERATION_CODE": "INSTALL_CERT"
}; };
/** /**
@ -308,6 +309,17 @@ var androidOperationModule = function () {
"enrollmentAppInstall": operationPayload["enrollmentAppInstall"] "enrollmentAppInstall": operationPayload["enrollmentAppInstall"]
}; };
break; break;
case androidOperationConstants["CERT_ADD_OPERATION_CODE"]:
var certList = operationPayload["CERT_LIST"];
var listNew = [];
certList.forEach(function (element) {
element["CERT_CONTENT_VIEW"] = element["CERT_NAME"] + " File";
listNew.push(element);
});
payload = {
"CERT_LIST": listNew
};
break;
} }
return payload; return payload;
}; };
@ -668,6 +680,14 @@ var androidOperationModule = function () {
} }
}; };
break; break;
case androidOperationConstants["CERT_ADD_OPERATION_CODE"]:
operationType = operationTypeConstants["PROFILE"];
payload = {
"operation": {
"CERT_LIST": operationData["CERT_LIST"]
}
};
break;
default: default:
// If the operation is neither of above, it is a command operation // If the operation is neither of above, it is a command operation
operationType = operationTypeConstants["COMMAND"]; operationType = operationTypeConstants["COMMAND"];

@ -58,7 +58,8 @@ var androidOperationConstants = {
"COSU_PROFILE_CONFIGURATION_OPERATION": "cosu-profile-configuration", "COSU_PROFILE_CONFIGURATION_OPERATION": "cosu-profile-configuration",
"COSU_PROFILE_CONFIGURATION_OPERATION_CODE": "COSU_PROFILE", "COSU_PROFILE_CONFIGURATION_OPERATION_CODE": "COSU_PROFILE",
"ENROLLMENT_APP_INSTALL": "enrollment-app-install", "ENROLLMENT_APP_INSTALL": "enrollment-app-install",
"ENROLLMENT_APP_INSTALL_CODE": "ENROLLMENT_APP_INSTALL" "ENROLLMENT_APP_INSTALL_CODE": "ENROLLMENT_APP_INSTALL",
"CERT_ADD_OPERATION_CODE": "INSTALL_CERT"
}; };
/** /**
@ -172,6 +173,29 @@ var ovpnConfigUploaded = function () {
} }
}; };
var certConfigUploaded = function (val) {
var certFileInput = document.getElementById("cert-file-field");
if ('files' in certFileInput) {
if (certFileInput.files.length === 1) {
var reader = new FileReader();
reader.onload = function (progressEvent) {
var txt = "";
var lines = this.result.split('\n');
for (var line = 0; line < lines.length; line++) {
console.log(lines[line]);
if (lines[line].charAt(0) !== '#') {
txt += lines[line] + '\n';
}
}
//document.getElementById ("cert-config").value = txt;
//console.log(document.getElementById ("cert-config").value);
$(val).next().val(txt);
};
reader.readAsText(certFileInput.files[0]);
}
}
};
/** /**
* Validates policy profile operations for the windows platform. * Validates policy profile operations for the windows platform.
* *
@ -828,6 +852,32 @@ var validatePolicyProfile = function () {
} }
validationStatusArray.push(validationStatus); validationStatusArray.push(validationStatus);
} }
if ($.inArray(androidOperationConstants["CERT_ADD_OPERATION_CODE"], configuredOperations) != -1) {
//If enrollment app install configured
let isErrorsFound = false;
operation = androidOperationConstants["CERT_ADD_OPERATION_CODE"];
var certList = $("#cert-list").find(".child-input");
for (let j = 0; j < certList.length; j++) {
if ($(certList[j]).val().trim() === "") {
isErrorsFound = true;
break;
}
}
if (isErrorsFound) {
validationStatus = {
"error": true,
"subErrorMsg": "Certificates are not selected to be installed.",
"erroneousFeature": operation
};
validationStatusArray.push(validationStatus);
} else {
validationStatus = {
"error": false,
"okFeature": operation
};
validationStatusArray.push(validationStatus);
}
}
} }
// ending validation process // ending validation process
@ -1141,6 +1191,16 @@ var applyDataTable = function() {
lengthMenu: [5, 10, 25, 50, 100] lengthMenu: [5, 10, 25, 50, 100]
}); });
}; };
var myFrom;
function appendCertInputField(inputElement) {
let element = "<input id=\"cert-file-field\" type=\"file\" class=\"form-control grid-input-text\"\n" +
" data-child-key=\"CERT_CONTENT_VIEW\" maxlength=\"100\" data-default=\"\"\n" +
" placeholder=\"Select certificate file\" onchange=\"certConfigUploaded(this)\"/>\n" +
"<input id=\"cert-config\" class=\"form-control operationDataKeys\" type=\"hidden\"\n" +
" data-child-key=\"CERT_CONTENT\"/>";
inputElement.append(element);
}
$(document).ready(function () { $(document).ready(function () {
// Maintains an array of configured features of the profile // Maintains an array of configured features of the profile
@ -1297,15 +1357,23 @@ $(document).ready(function () {
updateGroupedInputVisibility(this); updateGroupedInputVisibility(this);
}); });
// add form entry click function for grid inputs // add form entry click function for grid inputs
$(advanceOperations).on("click", "[data-click-event=add-form]", function () { $(advanceOperations).on("click", "[data-click-event=add-form]", function (event) {
var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]");
var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone().find("[data-add-form-element=clone]") var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone().find("[data-add-form-element=clone]")
.attr("data-add-form-clone", $(this).attr("href")); .attr("data-add-form-clone", $(this).attr("href"));
// adding class .child-input to capture text-input-array-values // adding class .child-input to capture text-input-array-values
$("input, select", clonedForm).addClass("child-input"); $("input, select", clonedForm).addClass("child-input");
if ($(this).attr("href") === "#cert-grid") {
if (event.originalEvent !== undefined) {
let inputElement = $(clonedForm).children('td.cert-file-tr');
inputElement.find("input[type=text]").remove();
inputElement.find("input[type=hidden]").remove();
appendCertInputField(inputElement);
$("input, select", clonedForm).addClass("child-input");
}
}
$(addFormContainer).append(clonedForm); $(addFormContainer).append(clonedForm);
setId(addFormContainer); setId(addFormContainer);
showHideHelpText(addFormContainer); showHideHelpText(addFormContainer);

@ -76,6 +76,15 @@
<span id="vpn-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span> <span id="vpn-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span>
<span id="vpn-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span> <span id="vpn-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a> </a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('cert', this)">
<span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-security-policy fw-stack-2x"></i>
</span>
Secure Certificates
<span id="cert-configured" class="has-configured status-icon hidden"><i class="fw fw-success"></i></span>
<span id="cert-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span>
<span id="cert-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
{{#unless iscloud}} {{#unless iscloud}}
<a href="javascript:void(0)" onclick="showAdvanceOperation('work-profile', this)"> <a href="javascript:void(0)" onclick="showAdvanceOperation('work-profile', this)">
<span class="wr-hidden-operations-icon fw-stack"> <span class="wr-hidden-operations-icon fw-stack">
@ -1417,6 +1426,107 @@
</div> </div>
<!-- /VPN --> <!-- /VPN -->
<!--cert-->
<div class="wr-hidden-operation" data-operation="cert">
<div class="panel panel-default operation-data" data-operation="cert"
data-operation-code="INSTALL_CERT">
<div id="cert-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Secure Certificate Settings
<label class="wr-input-control switch" data-toggle="collapse"
data-target="#cert-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
Configure the Secure Certificate settings on Android devices.
</div>
</div>
<div id="cert-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cert-body">
<hr/>
<div id="INSTALL_CERT-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div class="wr-input-control">
<label class="wr-input-label" for="cert-list">
<br><br>Added Certificate List
<span class="helper" title="Add a certificate.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<br/>
<a href="#cert-grid" class="btn btn-secondary grid-input-add "
data-click-event="add-form">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Add Certificate
</a>
<div id="cert-list"
class="operationDataKeys grouped-array-input multi-column-key-value-pair-array"
data-key="CERT_LIST" data-column-count="3">
<table class="table table-responsive table-striped">
<thead>
<tr>
<th>No:</th>
<th>Certificate Name</th>
<th>Certificate File</th>
<th></th>
</tr>
</thead>
<tbody data-add-form-container="#cert-grid" id="cert-table">
<tr data-help-text="add-form">
<td colspan="4">
No entries added yet .
</td>
</tr>
</tbody>
</table>
<table class="template hidden">
<tbody data-add-form="#cert-grid">
<tr data-add-form-element="clone">
<td data-title="No:">
<span class="index"></span>
</td>
<td data-title="Cert Name">
<input type="text" class="form-control grid-input-text operationDataKeys"
data-child-key="CERT_NAME"
maxlength="100" placeholder="Cert Name"/>
</td>
<td data-title="Cert File" class="cert-file-tr">
<input type="text" class="form-control grid-input-text"
data-child-key="CERT_CONTENT_VIEW" maxlength="100" data-default=""
placeholder="Select certificate file" disabled/>
<input id="cert-config" class="form-control operationDataKeys" type="hidden"
data-child-key="CERT_CONTENT"/>
</td>
<td>
<span class="list-group-item-actions">
<a href="#cert-grid" class="grid-input-remove"
data-click-event="remove-form">
<span class="fw-stack helper" title="Remove Entry">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
</a>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--/cert-->
<!--Work-profile--> <!--Work-profile-->
<div class="wr-hidden-operation" data-operation="work-profile"> <div class="wr-hidden-operation" data-operation="work-profile">
<div class="panel panel-default operation-data" data-operation="work-profile" <div class="panel panel-default operation-data" data-operation="work-profile"

@ -59,6 +59,15 @@
<span id="wifi-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span> <span id="wifi-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span>
<span id="wifi-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span> <span id="wifi-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a> </a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('cert', this)">
<span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-security-policy fw-stack-2x"></i>
</span>
Secure Certificate
<span id="cert-configured" class="has-configured status-icon hidden"><i class="fw fw-success"></i></span>
<span id="cert-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span>
<span id="cert-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
{{#unless iscloud}} {{#unless iscloud}}
<a href="javascript:void(0)" onclick="showAdvanceOperation('work-profile', this)"> <a href="javascript:void(0)" onclick="showAdvanceOperation('work-profile', this)">
<span class="wr-hidden-operations-icon fw-stack"> <span class="wr-hidden-operations-icon fw-stack">
@ -2306,6 +2315,104 @@
</div> </div>
<!-- /VPN --> <!-- /VPN -->
<!-- Cert -->
<div class="wr-hidden-operation" data-operation="cert">
<div class="panel panel-default operation-data" data-operation="cert"
data-operation-code="INSTALL_CERT">
<div id="cert-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Secure Certificate Settings
<label class="wr-input-control switch hidden" data-toggle="collapse"
data-target="#cert-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
Configure the Secure Certificate settings on Android devices.
</div>
</div>
<div id="cert-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cert-body">
<hr/>
<div id="cert-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div class="wr-input-control">
<label class="wr-input-label" for="cert-list">
<br><br>Added Certificate List
<span class="helper" title="Add a certificate.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<br/>
<a href="#cert-grid" class="btn btn-secondary grid-input-add hidden"
data-click-event="add-form">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Add Certificate
</a>
<div id="cert-list"
class="operationDataKeys grouped-array-input multi-column-key-value-pair-array"
data-key="CERT_LIST" data-column-count="3">
<table class="table table-responsive table-striped">
<thead>
<tr>
<th>No:</th>
<th>Certificate Name</th>
<th>Certificate File</th>
<th></th>
</tr>
</thead>
<tbody data-add-form-container="#cert-grid">
<tr data-help-text="add-form">
<td colspan="4">
No entries added yet .
</td>
</tr>
</tbody>
</table>
<table class="template hidden">
<tbody data-add-form="#cert-grid">
<tr data-add-form-element="clone">
<td data-title="No:">
<span class="index"></span>
</td>
<td data-title="Cert Name">
<input type="text" class="form-control grid-input-text operationDataKeys" data-child-key="CERT_NAME"
maxlength="100" placeholder="Cert Name" disabled/>
</td>
<td data-title="Cert File">
<input type="text" class="form-control grid-input-text"
data-child-key="CERT_CONTENT_VIEW" maxlength="100" data-default=""
placeholder="Select certificate file" disabled/>
</td>
<td>
<span class="list-group-item-actions hidden">
<a href="#cert-grid" class="grid-input-remove"
data-click-event="remove-form">
<span class="fw-stack helper" title="Remove Entry">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
</a>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- /Cert -->
<!-- install-applications --> <!-- install-applications -->
<!--<div class="wr-hidden-operation" data-operation="install-apps">--> <!--<div class="wr-hidden-operation" data-operation="install-apps">-->
<!--<div class="panel panel-default operation-data" data-operation="INSTALL_APPLICATION">--> <!--<div class="panel panel-default operation-data" data-operation="INSTALL_APPLICATION">-->

@ -55,7 +55,8 @@ var androidOperationConstants = {
"COSU_PROFILE_CONFIGURATION_OPERATION": "cosu-profile-configuration", "COSU_PROFILE_CONFIGURATION_OPERATION": "cosu-profile-configuration",
"COSU_PROFILE_CONFIGURATION_OPERATION_CODE": "COSU_PROFILE", "COSU_PROFILE_CONFIGURATION_OPERATION_CODE": "COSU_PROFILE",
"ENROLLMENT_APP_INSTALL": "enrollment-app-install", "ENROLLMENT_APP_INSTALL": "enrollment-app-install",
"ENROLLMENT_APP_INSTALL_CODE": "ENROLLMENT_APP_INSTALL" "ENROLLMENT_APP_INSTALL_CODE": "ENROLLMENT_APP_INSTALL",
"CERTIFICATE_INSTALL": "INSTALL_CERT"
}; };
/** /**
@ -114,6 +115,30 @@ var ovpnConfigUploaded = function () {
} }
}; };
var certConfigUploaded = function (val) {
var certFileInput = document.getElementById("cert-file-field");
if ('files' in certFileInput) {
if (certFileInput.files.length === 1) {
var reader = new FileReader();
reader.onload = function(progressEvent){
var txt = "";
var lines = this.result.split('\n');
for(var line = 0; line < lines.length; line++){
console.log(lines[line]);
if (lines[line].charAt(0) !== '#') {
txt += lines[line] + '\n';
}
}
//document.getElementById ("cert-config").value = txt;
//console.log(document.getElementById ("cert-config").value);
$(val).next().val(txt);
};
reader.readAsText(certFileInput.files[0]);
}
}
};
/** /**
* Validates policy profile operations for the windows platform. * Validates policy profile operations for the windows platform.
* *
@ -761,6 +786,32 @@ var validatePolicyProfile = function () {
} }
validationStatusArray.push(validationStatus); validationStatusArray.push(validationStatus);
} }
if ($.inArray(androidOperationConstants["CERTIFICATE_INSTALL"], configuredOperations) != -1) {
//If enrollment app install configured
let isErrorsFound = false;
operation = androidOperationConstants["CERTIFICATE_INSTALL"];
var certList = $("#cert-list").find(".child-input");
for (let j = 0; j < certList.length; j++) {
if ($(certList[j]).val().trim() === "") {
isErrorsFound = true;
break;
}
}
if (isErrorsFound) {
validationStatus = {
"error": true,
"subErrorMsg": "Certificates are not selected to be installed.",
"erroneousFeature": operation
};
validationStatusArray.push(validationStatus);
} else {
validationStatus = {
"error": false,
"okFeature": operation
};
validationStatusArray.push(validationStatus);
}
}
} }
// ending validation process // ending validation process

@ -76,6 +76,15 @@
<span id="vpn-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span> <span id="vpn-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span>
<span id="vpn-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span> <span id="vpn-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a> </a>
<a href="javascript:void(0)" onclick="showAdvanceOperation('cert', this)">
<span class="wr-hidden-operations-icon fw-stack">
<i class="fw fw-security-policy fw-stack-2x"></i>
</span>
Secure Certificate
<span id="cert-configured" class="has-configured status-icon hidden"><i class="fw fw-success"></i></span>
<span id="cert-ok" class="has-success status-icon hidden"><i class="fw fw-success"></i></span>
<span id="cert-error" class="has-error status-icon hidden"><i class="fw fw-error"></i></span>
</a>
{{#unless iscloud}} {{#unless iscloud}}
<a href="javascript:void(0)" class="worker-profile" onclick="showAdvanceOperation('work-profile', this)"> <a href="javascript:void(0)" class="worker-profile" onclick="showAdvanceOperation('work-profile', this)">
<span class="wr-hidden-operations-icon fw-stack"> <span class="wr-hidden-operations-icon fw-stack">
@ -2330,6 +2339,109 @@
</div> </div>
<!-- /VPN --> <!-- /VPN -->
<!--cert-->
<div class="wr-hidden-operation" data-operation="cert">
<div class="panel panel-default operation-data" data-operation="cert"
data-operation-code="INSTALL_CERT">
<div id="cert-heading" class="panel-heading" role="tab">
<h2 class="sub-title panel-title">
Secure Certificate Settings
<label class="wr-input-control switch" data-toggle="collapse"
data-target="#cert-body">
<input type="checkbox"/>
<span class="helper"></span>
<span class="text"></span>
</label>
</h2>
<div class="panel-title-description">
Configure the Secure Certificate settings on Android devices.
</div>
</div>
<div id="cert-body" class="panel-collapse panel-body collapse" role="tabpanel"
aria-labelledby="cert-body">
<hr/>
<div id="INSTALL_CERT-feature-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<div class="wr-input-control">
<label class="wr-input-label" for="cert-list">
<br><br>Added Certificate List
<span class="helper" title="Add a certificate.">
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</span>
</label>
<br/>
<a href="#cert-grid" class="btn btn-secondary grid-input-add "
data-click-event="add-form">
<span class="icon fw-stack">
<i class="fw fw-add fw-stack-1x"></i>
<i class="fw fw-circle-outline fw-stack-2x"></i>
</span>
Add Certificate
</a>
<div id="cert-list"
class="operationDataKeys grouped-array-input multi-column-key-value-pair-array"
data-key="CERT_LIST" data-column-count="3">
<table class="table table-responsive table-striped">
<thead>
<tr>
<th>No:</th>
<th>Certificate Name</th>
<th>Certificate File</th>
<th></th>
</tr>
</thead>
<tbody data-add-form-container="#cert-grid">
<tr data-help-text="add-form">
<td colspan="4">
No entries added yet .
</td>
</tr>
</tbody>
</table>
<table class="template hidden">
<tbody data-add-form="#cert-grid">
<tr data-add-form-element="clone">
<td data-title="No:">
<span class="index"></span>
</td>
<td data-title="Cert Name">
<input id="cert-name-field" type="text" class="form-control grid-input-text operationDataKeys" data-child-key="CERT_NAME"
maxlength="100" placeholder="Cert Name"/>
<!--<input id="cert-name" class="form-control operationDataKeys" type="hidden"
data-key="CERT_NAME"/>-->
</td>
<td data-title="Cert File">
<input id="cert-file-field" type="file" class="form-control grid-input-text"
data-child-key="CERT_CONTENT" maxlength="100" data-default=""
placeholder="Select certificate file" onchange="certConfigUploaded(this)"/>
<input id="cert-config" class="form-control operationDataKeys" type="hidden"
data-child-key="CERT_CONTENT"/>
</td>
<td>
<span class="list-group-item-actions">
<a href="#cert-grid" class="grid-input-remove"
data-click-event="remove-form">
<span class="fw-stack helper" title="Remove Entry">
<i class="fw fw-circle-outline fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
</a>
</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!--/cert-->
<!--Work-profile--> <!--Work-profile-->
<div class="wr-hidden-operation" data-operation="work-profile"> <div class="wr-hidden-operation" data-operation="work-profile">
<div class="panel panel-default operation-data" data-operation="work-profile" <div class="panel panel-default operation-data" data-operation="work-profile"

Loading…
Cancel
Save