diff options
author | Maksim Zakharov <m.zakharov@IBS.RU> | 2022-08-18 17:33:32 +0300 |
---|---|---|
committer | Maksim Zakharov <m.zakharov@IBS.RU> | 2022-08-18 17:33:32 +0300 |
commit | 51afd867f9ae51c6c11c48bdfec91d4988f35397 (patch) | |
tree | 5606931783d8724a01bd2418f9986ffc26451334 /src/store | |
parent | efbb9eab830830923ef1afea8fc8b70974772373 (diff) | |
download | webui-vue-51afd867f9ae51c6c11c48bdfec91d4988f35397.tar.xz |
add status for pci devises
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/modules/HardwareStatus/PciStore.js | 76 |
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) + ); + }, }, }; |