From b79c36cf0c271313e4ae5f2d223fc25505f202c7 Mon Sep 17 00:00:00 2001 From: Maksim Zakharov Date: Wed, 31 Aug 2022 16:39:51 +0300 Subject: add comments for pci --- src/store/modules/HardwareStatus/PciStore.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/store/modules/HardwareStatus/PciStore.js b/src/store/modules/HardwareStatus/PciStore.js index 97817d55..dcc7c175 100644 --- a/src/store/modules/HardwareStatus/PciStore.js +++ b/src/store/modules/HardwareStatus/PciStore.js @@ -85,18 +85,22 @@ const PciStore = { async getDevices({ commit }) { return await api .get('/redfish/v1/Systems/system/PCIeDevices') + // get all pci devices .then(({ data: { Members = [] } }) => { const devices = Members.map((item) => async () => api.get(item['@odata.id']) ); + // create an array of async functions to get all devices return devices; }) .then(async (response) => { + // calling functions one by one to avoid errors const results = []; for (let request of response) { const reponse = await request(); results.push(reponse); } + // return successful requests return Promise.allSettled(results); }) .then((response) => { @@ -105,6 +109,7 @@ const PciStore = { .catch((error) => console.log(error)); }, async getDevicesMembers({ commit, state }) { + // the same logic as in getDevices const Members = state.pci.map((item) => async () => api.get(item.PCIeFunction['@odata.id']) ); @@ -117,6 +122,7 @@ const PciStore = { .then((response) => { commit('setPciDevisesMembers', response); const Functions = response + // can return an array of routes .map((item) => item.value.data.Members) .flat(Infinity) .map((item) => async () => api.get(item['@odata.id'])); -- cgit v1.2.3