1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
import api from '@/store/api';
const PciStore = {
namespaced: true,
state: {
pci: [],
},
getters: {
pciDevices: (state) => state.pci,
},
mutations: {
setPciDevises: (state, data) => {
state.pci = data.map((item) => {
const {
value: {
data: { Id, Name, Manufacturer, DeviceType, PCIeFunctions },
},
} = item;
return {
id: Id,
name: Name,
type: DeviceType,
manufacturer: Manufacturer,
PCIeFunction: PCIeFunctions,
};
});
},
setSecondPciDevises: (state, data) => {
state.pci = data.map((item, index) => {
const {
value: {
data: { ClassCode, DeviceClass, DeviceId, FunctionType },
},
} = item;
return {
...state.pci[index],
classCode: ClassCode,
deviceClass: DeviceClass,
deviceId: DeviceId,
functionType: FunctionType,
};
});
},
},
actions: {
async getDevices({ commit }) {
return await api
.get('/redfish/v1/Systems/system/PCIeDevices')
.then(({ data: { Members = [] } }) => {
const devices = Members.map((item) => api.get(item['@odata.id']));
return Promise.allSettled(devices);
})
.then((response) => {
commit('setPciDevises', response);
})
.catch((error) => console.log(error));
},
async getFunctionDevices({ commit, state }) {
const functions = 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);
})
.then((response) => {
commit('setSecondPciDevises', response);
})
.catch((error) => console.log(error));
},
},
};
export default PciStore;
|