blob: 4e3d5fef8a937c32f7cb58642cd9f87c0fd2f11a [file] [log] [blame]
Yoshie Muranaka5918b482020-06-08 08:18:23 -07001import api from '@/store/api';
2
3const PowerSupplyStore = {
4 namespaced: true,
5 state: {
6 powerSupplies: []
7 },
8 getters: {
9 powerSupplies: state => state.powerSupplies
10 },
11 mutations: {
12 setPowerSupply: (state, data) => {
13 state.powerSupplies = data.map(powerSupply => {
14 const {
15 EfficiencyPercent,
16 FirmwareVersion,
17 IndicatorLED,
18 MemberId,
19 Model,
20 PartNumber,
21 PowerInputWatts,
22 SerialNumber,
23 Status
24 } = powerSupply;
25 return {
26 id: MemberId,
27 health: Status.Health,
28 partNumber: PartNumber,
29 serialNumber: SerialNumber,
30 efficiencyPercent: EfficiencyPercent,
31 firmwareVersion: FirmwareVersion,
32 indicatorLed: IndicatorLED,
33 model: Model,
34 powerInputWatts: PowerInputWatts,
35 statusState: Status.State
36 };
37 });
38 }
39 },
40 actions: {
41 async getPowerSupply({ commit }) {
42 return await api
43 .get('/redfish/v1/Chassis/chassis/Power')
44 .then(({ data: { PowerSupplies } }) =>
45 commit('setPowerSupply', PowerSupplies)
46 )
47 .catch(error => console.log(error));
48 }
49 }
50};
51
52export default PowerSupplyStore;