Skip to content

Commit

Permalink
Acf_Certificate (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandeepa Singh authored and GitHub Enterprise committed Feb 17, 2022
1 parent 8448577 commit 5b9031f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 20 deletions.
38 changes: 37 additions & 1 deletion src/store/modules/SecurityAndAccess/CertificatesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 10 additions & 7 deletions src/views/SecurityAndAccess/Certificates/Certificates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) {
Expand Down
40 changes: 28 additions & 12 deletions src/views/SecurityAndAccess/Certificates/ModalUploadCertificate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,34 @@
</template>

<b-form-group :label="$t('pageCertificates.modal.certificateFile')">
<form-file
id="certificate-file"
v-model="form.file"
accept=".pem"
:state="getValidationState($v.form.file)"
>
<template #invalid>
<b-form-invalid-feedback role="alert">
{{ $t('global.form.required') }}
</b-form-invalid-feedback>
</template>
</form-file>
<template v-if="form.certificateType === 'ServiceLogin Certificate'">
<form-file
id="certificate-file"
v-model="form.file"
accept=".acf"
:state="getValidationState($v.form.file)"
>
<template #invalid>
<b-form-invalid-feedback role="alert">
{{ $t('global.form.required') }}
</b-form-invalid-feedback>
</template>
</form-file>
</template>
<template v-else>
<form-file
id="certificate-file"
v-model="form.file"
accept=".pem"
:state="getValidationState($v.form.file)"
>
<template #invalid>
<b-form-invalid-feedback role="alert">
{{ $t('global.form.required') }}
</b-form-invalid-feedback>
</template>
</form-file>
</template>
</b-form-group>
</b-form>
<template #modal-ok>
Expand Down

0 comments on commit 5b9031f

Please sign in to comment.