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
78
|
import api from '@/store/api';
const PowerSupplyStore = {
namespaced: true,
state: {
powerSupplies: [],
},
getters: {
powerSupplies: (state) => state.powerSupplies,
},
mutations: {
setPowerSupply: (state, data) => {
state.powerSupplies = data.map((powerSupply) => {
const {
EfficiencyPercent,
FirmwareVersion,
LocationIndicatorActive,
MemberId,
Manufacturer,
Model,
Name,
PartNumber,
PowerInputWatts,
SerialNumber,
SparePartNumber,
Status = {},
} = powerSupply;
return {
id: MemberId,
health: Status.Health,
partNumber: PartNumber,
serialNumber: SerialNumber,
efficiencyPercent: EfficiencyPercent,
firmwareVersion: FirmwareVersion,
identifyLed: LocationIndicatorActive,
manufacturer: Manufacturer,
model: Model,
powerInputWatts: PowerInputWatts,
name: Name,
sparePartNumber: SparePartNumber,
statusState: Status.State,
};
});
},
},
actions: {
async getChassisCollection() {
return await api
.get('/redfish/v1/Chassis')
.then(({ data: { Members } }) =>
Members.map((member) => member['@odata.id'])
)
.catch((error) => console.log(error));
},
async getAllPowerSupplies({ dispatch, commit }) {
const collection = await dispatch('getChassisCollection');
if (!collection) return;
return await api
.all(collection.map((chassis) => dispatch('getChassisPower', chassis)))
.then((supplies) => {
let suppliesList = [];
supplies.forEach(
(supply) => (suppliesList = [...suppliesList, ...supply])
);
commit('setPowerSupply', suppliesList);
})
.catch((error) => console.log(error));
},
async getChassisPower(_, id) {
return await api
.get(`${id}/Power`)
.then(({ data: { PowerSupplies } }) => PowerSupplies || [])
.catch((error) => console.log(error));
},
},
};
export default PowerSupplyStore;
|