Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 1 | import api from '@/store/api'; |
| 2 | |
| 3 | const PowerSupplyStore = { |
| 4 | namespaced: true, |
| 5 | state: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 6 | powerSupplies: [], |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 7 | }, |
| 8 | getters: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 9 | powerSupplies: (state) => state.powerSupplies, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 10 | }, |
| 11 | mutations: { |
| 12 | setPowerSupply: (state, data) => { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 13 | state.powerSupplies = data.map((powerSupply) => { |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 14 | const { |
| 15 | EfficiencyPercent, |
| 16 | FirmwareVersion, |
| 17 | IndicatorLED, |
| 18 | MemberId, |
| 19 | Model, |
| 20 | PartNumber, |
| 21 | PowerInputWatts, |
| 22 | SerialNumber, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 23 | Status, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 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, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 35 | statusState: Status.State, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 36 | }; |
| 37 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 38 | }, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 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 | ) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 47 | .catch((error) => console.log(error)); |
| 48 | }, |
| 49 | }, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | export default PowerSupplyStore; |