summaryrefslogtreecommitdiff
path: root/src/store/modules/Health/PowerSupplyStore.js
blob: 565715fa08bc33c1b749bac5923155164280c76a (plain)
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
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,
          IndicatorLED,
          MemberId,
          Model,
          PartNumber,
          PowerInputWatts,
          SerialNumber,
          Status,
        } = powerSupply;
        return {
          id: MemberId,
          health: Status.Health,
          partNumber: PartNumber,
          serialNumber: SerialNumber,
          efficiencyPercent: EfficiencyPercent,
          firmwareVersion: FirmwareVersion,
          indicatorLed: IndicatorLED,
          model: Model,
          powerInputWatts: PowerInputWatts,
          statusState: Status.State,
        };
      });
    },
  },
  actions: {
    async getPowerSupply({ commit }) {
      return await api
        .get('/redfish/v1/Chassis/chassis/Power')
        .then(({ data: { PowerSupplies } }) =>
          commit('setPowerSupply', PowerSupplies)
        )
        .catch((error) => console.log(error));
    },
  },
};

export default PowerSupplyStore;