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/common | |
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/common')
-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 |
3 files changed, 39 insertions, 7 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: { |