summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/common/directives/certificate.html2
-rw-r--r--app/common/directives/certificate.js33
-rw-r--r--app/common/services/constants.js11
-rw-r--r--app/configuration/controllers/certificate-controller.html12
-rw-r--r--app/configuration/controllers/certificate-controller.js4
5 files changed, 48 insertions, 14 deletions
diff --git a/app/common/directives/certificate.html b/app/common/directives/certificate.html
index 8579f7a..cb7281b 100644
--- a/app/common/directives/certificate.html
+++ b/app/common/directives/certificate.html
@@ -1,6 +1,6 @@
<div class="table__row-value row column">
<div class="certificate__type-cell bold">
- {{cert.Description}}
+ {{getCertificateName(cert.Description)}}
</div>
<div class="certificate__title-inline">
Issued by:
diff --git a/app/common/directives/certificate.js b/app/common/directives/certificate.js
index 63dc594..45b8c99 100644
--- a/app/common/directives/certificate.js
+++ b/app/common/directives/certificate.js
@@ -9,9 +9,32 @@ window.angular && (function(angular) {
'template': require('./certificate.html'),
'scope': {'cert': '=', 'reload': '&'},
'controller': [
- '$scope', 'APIUtils', 'toastService',
- function($scope, APIUtils, toastService) {
+ '$scope', 'APIUtils', 'toastService', 'Constants',
+ function($scope, APIUtils, toastService, Constants) {
var certificateType = 'PEM';
+ var availableCertificateTypes = Constants.CERTIFICATE_TYPES;
+
+ /**
+ * This function is needed to map the backend Description to what
+ * should appear in the GUI. This is needed specifically for CA
+ * certificate types. The backend description for the certificate
+ * type is 'TrustStore Certificate', this function will make sure we
+ * display 'CA Certificate' on the frontend
+ * @param {string} : certificate Description property
+ * @returns {string} : certificate name that should appear on GUI
+ */
+ $scope.getCertificateName = function(certificateDescription) {
+ var matched =
+ availableCertificateTypes.find(function(certificate) {
+ return certificate.Description === certificateDescription;
+ });
+ if (matched === undefined) {
+ return '';
+ } else {
+ return matched.name;
+ }
+ };
+
$scope.replaceCertificate = function(certificate) {
$scope.loading = true;
if (certificate.file.name.split('.').pop() !==
@@ -35,14 +58,16 @@ window.angular && (function(angular) {
function(data) {
$scope.loading = false;
toastService.success(
- certificate.Description + ' was replaced.');
+ $scope.getCertificateName(certificate.Description) +
+ ' was replaced.');
$scope.reload();
},
function(error) {
console.log(error);
$scope.loading = false;
toastService.error(
- 'Unable to replace ' + certificate.Description);
+ 'Unable to replace ' +
+ $scope.getCertificateName(certificate.Description));
});
};
reader.readAsBinaryString(file);
diff --git a/app/common/services/constants.js b/app/common/services/constants.js
index 9ac9b6c..cde6a87 100644
--- a/app/common/services/constants.js
+++ b/app/common/services/constants.js
@@ -24,11 +24,18 @@ window.angular && (function(angular) {
{
'Description': 'HTTPS Certificate',
'location':
- '/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/'
+ '/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/',
+ 'name': 'HTTPS Certificate'
},
{
'Description': 'LDAP Certificate',
- 'location': '/redfish/v1/AccountService/LDAP/Certificates/'
+ 'location': '/redfish/v1/AccountService/LDAP/Certificates/',
+ 'name': 'LDAP Certificate'
+ },
+ {
+ 'Description': 'TrustStore Certificate',
+ 'location': '/redfish/v1/Managers/bmc/Truststore/Certificates/',
+ 'name': 'CA Certificate'
}
],
HOST_STATE_TEXT: {
diff --git a/app/configuration/controllers/certificate-controller.html b/app/configuration/controllers/certificate-controller.html
index faedce2..c388670 100644
--- a/app/configuration/controllers/certificate-controller.html
+++ b/app/configuration/controllers/certificate-controller.html
@@ -5,13 +5,13 @@
</div>
<div ng-repeat="certificate in certificates | filter:{isExpiring:true}" class="row column">
<div class="small-12 alert alert-warning" role="alert">
- <icon aria-hidden="true" file="icon-warning.svg" /> The uploaded {{certificate.Description}} is expiring in {{getDays(certificate.ValidNotAfter) === 0 ? 'less than one
+ <icon aria-hidden="true" file="icon-warning.svg" /> The uploaded {{certificate.name}} is expiring in {{getDays(certificate.ValidNotAfter) === 0 ? 'less than one
day!' : getDays(certificate.ValidNotAfter) + ' days!'}}. Consider replacing it with a new certificate.
</div>
</div>
<div ng-repeat="certificate in certificates|filter:{isExpired:true}" class="row column">
<div class="small-12 alert alert-danger" role="alert">
- <div class="icon__critical inline"></div> The uploaded {{certificate.Description}} has expired! Consider replacing it with a new certificate.
+ <div class="icon__critical inline"></div> The uploaded {{certificate.name}} has expired! Consider replacing it with a new certificate.
</div>
</div>
<div class="row column">
@@ -66,7 +66,7 @@
<select id="cert__type" name="cert__type" ng-model="newCertificate.selectedType" required>
<option class="courier-bold" ng-value="">Select an option</option>
<option class="courier-bold" ng-value="type" ng-repeat="type in availableCertificateTypes">
- {{type.Description}}</option>
+ {{type.name}}</option>
</select>
<div ng-messages="add__cert__form.cert__type.$error" class="form-error" ng-class="{'visible' : add__cert__form.cert__type.$touched || submitted }">
<p ng-message="required">Field is required</p>
@@ -143,8 +143,10 @@
<label for="cert__type" class="add-csr__label">Certificate Type *</label>
<select class="add-csr__select" id="cert__type" name="cert__type" ng-model="newCSR.certificateCollection" required>
<option class="courier-bold" ng-value="default" ng-model="selectOption">Select an option</option>
- <option class="courier-bold" ng-value="type" ng-repeat="type in allCertificateTypes">
- {{type.Description}}</option>
+ <!-- Do not show CA certificate as an option. Only a certificate authority can generate a CA certificate (known as TrustStore Certificate in Redfish) -->
+ <option class="courier-bold" ng-value="type" ng-repeat="type in allCertificateTypes"
+ ng-if="type.Description !== 'TrustStore Certificate'">
+ {{type.name}}</option>
</select>
<div ng-messages="add__csr__form.cert__type.$error" class="form-error" ng-class="{'visible' : add__csr__form.cert__type.$touched}">
<p ng-message="required">Field is required</p>
diff --git a/app/configuration/controllers/certificate-controller.js b/app/configuration/controllers/certificate-controller.js
index 589035c..cb22ac7 100644
--- a/app/configuration/controllers/certificate-controller.js
+++ b/app/configuration/controllers/certificate-controller.js
@@ -73,14 +73,14 @@ window.angular && (function(angular) {
.then(
function(data) {
toastService.success(
- $scope.newCertificate.selectedType.Description +
+ $scope.newCertificate.selectedType.name +
' was uploaded.');
$scope.newCertificate = {};
$scope.loadCertificates();
},
function(error) {
toastService.error(
- $scope.newCertificate.selectedType.Description +
+ $scope.newCertificate.selectedType.name +
' failed upload.');
console.log(JSON.stringify(error));
});
OpenPOWER on IntegriCloud