diff --git a/src/store/modules/SecurityAndAccess/CertificatesStore.js b/src/store/modules/SecurityAndAccess/CertificatesStore.js index bff479e9fb..d40457ed70 100644 --- a/src/store/modules/SecurityAndAccess/CertificatesStore.js +++ b/src/store/modules/SecurityAndAccess/CertificatesStore.js @@ -42,21 +42,53 @@ const CertificatesStore = { namespaced: true, state: { allCertificates: [], + acfCertificate: [], availableUploadTypes: [], }, getters: { allCertificates: (state) => state.allCertificates, + acfCertificate: (state) => state.acfCertificate, availableUploadTypes: (state) => state.availableUploadTypes, }, mutations: { setCertificates(state, certificates) { state.allCertificates = certificates; }, + setAcfCertificate(state, certificate) { + state.acfCertificate = certificate; + }, setAvailableUploadTypes(state, availableUploadTypes) { state.availableUploadTypes = availableUploadTypes; }, }, actions: { + async getAcfCertificate({ commit }) { + return await api + .get('/redfish/v1/AccountService/Accounts/service') + .then( + ({ + data: { + Oem: { + IBM: { ACF }, + }, + }, + }) => { + if (ACF.ExpirationDate) { + var acfCertificate = { + type: '', + location: '', + certificate: 'ServiceLogin Certificate', + issuedBy: '', + issuedTo: '', + validFrom: '', + validUntil: new Date(ACF.ExpirationDate), + }; + commit('setAcfCertificate', [acfCertificate]); + } + } + ) + .catch((error) => console.log(error)); + }, async getCertificates({ commit }) { return await api .get('/redfish/v1/CertificateService/CertificateLocations') @@ -147,7 +179,11 @@ const CertificatesStore = { ) { const data = {}; data.CertificateString = certificateString; - data.CertificateType = 'PEM'; + if (certificateString === 'ServiceLogin Certificate') { + data.CertificateType = 'ACF'; + } else { + data.CertificateType = 'PEM'; + } data.CertificateUri = { '@odata.id': location }; return await api .post( diff --git a/src/views/SecurityAndAccess/Certificates/Certificates.vue b/src/views/SecurityAndAccess/Certificates/Certificates.vue index f92c58d2dd..b6acbdddec 100644 --- a/src/views/SecurityAndAccess/Certificates/Certificates.vue +++ b/src/views/SecurityAndAccess/Certificates/Certificates.vue @@ -160,7 +160,10 @@ export default { }, computed: { certificates() { - return this.$store.getters['certificates/allCertificates']; + let acfCertificate = this.$store.getters['certificates/acfCertificate']; + let certificates = this.$store.getters['certificates/allCertificates']; + let allCertificates = [...acfCertificate, ...certificates]; + return allCertificates; }, tableItems() { return this.certificates.map((certificate) => { @@ -206,13 +209,13 @@ export default { }, []); }, }, - async created() { + created() { this.startLoader(); - await this.$store.dispatch('global/getBmcTime'); - this.$store.dispatch('certificates/getCertificates').finally(() => { - this.endLoader(); - this.isBusy = false; - }); + Promise.all([ + this.$store.dispatch('global/getBmcTime'), + this.$store.dispatch('certificates/getAcfCertificate'), + this.$store.dispatch('certificates/getCertificates'), + ]).finally(() => this.endLoader()); }, methods: { onTableRowAction(event, rowItem) { diff --git a/src/views/SecurityAndAccess/Certificates/ModalUploadCertificate.vue b/src/views/SecurityAndAccess/Certificates/ModalUploadCertificate.vue index f4db7a26f4..d99f0e72dd 100644 --- a/src/views/SecurityAndAccess/Certificates/ModalUploadCertificate.vue +++ b/src/views/SecurityAndAccess/Certificates/ModalUploadCertificate.vue @@ -40,18 +40,34 @@ - - - + +