diff options
author | Yoshie Muranaka <yoshiemuranaka@gmail.com> | 2019-06-28 09:41:19 -0500 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2019-08-22 14:53:21 +0000 |
commit | dbafdc5f8f5cff2afeaece248a07a8ffc15ad8c8 (patch) | |
tree | d45413d4a235e1d8afd7931a86d4756ed07788ad /app | |
parent | 5e8785d3605b2f927d6024f3d72ebfcc98d0ae0e (diff) | |
download | phosphor-webui-dbafdc5f8f5cff2afeaece248a07a8ffc15ad8c8.tar.gz phosphor-webui-dbafdc5f8f5cff2afeaece248a07a8ffc15ad8c8.zip |
Enable CA certificate upload
This patchset enables CA certificate type to be uploaded
in the GUI.
Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I52953933f6fd3dbd363c42b887996942b99b358e
Diffstat (limited to 'app')
-rw-r--r-- | app/common/directives/certificate.html | 2 | ||||
-rw-r--r-- | app/common/directives/certificate.js | 33 | ||||
-rw-r--r-- | app/common/services/constants.js | 11 | ||||
-rw-r--r-- | app/configuration/controllers/certificate-controller.html | 12 | ||||
-rw-r--r-- | app/configuration/controllers/certificate-controller.js | 4 |
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)); }); |