summaryrefslogtreecommitdiff
path: root/src/store/modules/HardwareStatus/PciStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/modules/HardwareStatus/PciStore.js')
-rw-r--r--src/store/modules/HardwareStatus/PciStore.js76
1 files changed, 59 insertions, 17 deletions
diff --git a/src/store/modules/HardwareStatus/PciStore.js b/src/store/modules/HardwareStatus/PciStore.js
index baeaaadf..e49e452c 100644
--- a/src/store/modules/HardwareStatus/PciStore.js
+++ b/src/store/modules/HardwareStatus/PciStore.js
@@ -19,25 +19,64 @@ const PciStore = {
return {
id: Id,
name: Name,
- type: DeviceType,
+ DeviceType: DeviceType,
manufacturer: Manufacturer,
PCIeFunction: PCIeFunctions,
};
});
},
- setSecondPciDevises: (state, data) => {
+ setPciDevisesMembers: (state, data) => {
state.pci = data.map((item, index) => {
const {
value: {
- data: { ClassCode, DeviceClass, DeviceId, FunctionType },
+ data: { Members },
},
} = item;
return {
...state.pci[index],
- classCode: ClassCode,
- deviceClass: DeviceClass,
- deviceId: DeviceId,
- functionType: FunctionType,
+ Members: Members,
+ };
+ });
+ },
+ setFunctionDevices: (state, data) => {
+ let count = 0;
+ const newData = state.pci.map((item) => {
+ const result = data.slice(count, count + item.Members.length);
+ count += item.Members.length;
+ return result;
+ });
+ state.pci = newData.map((item, index) => {
+ const functions = item.map((item) => {
+ const {
+ value: {
+ data: {
+ ClassCode,
+ DeviceClass,
+ DeviceId,
+ FunctionType,
+ DeviceName,
+ },
+ },
+ } = item;
+ return {
+ classCode: ClassCode,
+ deviceClass: DeviceClass,
+ deviceId: DeviceId,
+ functionType: FunctionType,
+ DeviceName: DeviceName,
+ };
+ });
+
+ if (item.length > 1) {
+ return {
+ ...state.pci[index],
+ Functions: functions,
+ };
+ }
+
+ return {
+ ...state.pci[index],
+ ...functions[0],
};
});
},
@@ -55,22 +94,25 @@ const PciStore = {
})
.catch((error) => console.log(error));
},
- async getFunctionDevices({ commit, state }) {
- const functions = state.pci.map((item) =>
+ async getDevicesMembers({ commit, state }) {
+ const Members = state.pci.map((item) =>
api.get(item.PCIeFunction['@odata.id'])
);
- Promise.allSettled(functions)
- .then((response) => {
- const data = response.map((item) =>
- api.get(item.value.data.Members[0]['@odata.id'])
- );
- return Promise.allSettled(data);
- })
+ return Promise.allSettled(Members)
.then((response) => {
- commit('setSecondPciDevises', response);
+ commit('setPciDevisesMembers', response);
})
.catch((error) => console.log(error));
},
+ async getFunctionDevices({ commit, state }) {
+ const Functions = state.pci
+ .map((item) => item.Members)
+ .flat(Infinity)
+ .map((item) => api.get(item['@odata.id']));
+ return Promise.allSettled(Functions).then((response) =>
+ commit('setFunctionDevices', response)
+ );
+ },
},
};