1import api from '@/store/api'; 2 3const MemoryStore = { 4 namespaced: true, 5 state: { 6 dimms: [], 7 }, 8 getters: { 9 dimms: (state) => state.dimms, 10 }, 11 mutations: { 12 setMemoryInfo: (state, data) => { 13 state.dimms = data.map(({ data }) => { 14 const { Id, Status = {}, PartNumber, SerialNumber } = data; 15 return { 16 id: Id, 17 health: Status.Health, 18 partNumber: PartNumber, 19 serialNumber: SerialNumber, 20 statusState: Status.State, 21 }; 22 }); 23 }, 24 }, 25 actions: { 26 async getDimms({ commit }) { 27 return await api 28 .get('/redfish/v1/Systems/system/Memory') 29 .then(({ data: { Members } }) => { 30 const promises = Members.map((item) => api.get(item['@odata.id'])); 31 return api.all(promises); 32 }) 33 .then((response) => commit('setMemoryInfo', response)) 34 .catch((error) => console.log(error)); 35 }, 36 }, 37}; 38 39export default MemoryStore; 40