Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 1 | import api from '@/store/api'; |
| 2 | |
| 3 | const FanStore = { |
| 4 | namespaced: true, |
| 5 | state: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 6 | fans: [], |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 7 | }, |
| 8 | getters: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 9 | fans: (state) => state.fans, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 10 | }, |
| 11 | mutations: { |
| 12 | setFanInfo: (state, data) => { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 13 | state.fans = data.map((fan) => { |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 14 | const { |
| 15 | IndicatorLED, |
| 16 | Location, |
| 17 | MemberId, |
| 18 | Name, |
| 19 | Reading, |
| 20 | ReadingUnits, |
| 21 | Status = {}, |
| 22 | PartNumber, |
| 23 | SerialNumber, |
| 24 | } = fan; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 25 | return { |
| 26 | id: MemberId, |
| 27 | health: Status.Health, |
| 28 | partNumber: PartNumber, |
| 29 | serialNumber: SerialNumber, |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 30 | healthRollup: Status.HealthRollup, |
| 31 | identifyLed: IndicatorLED, |
| 32 | locationNumber: Location, |
| 33 | name: Name, |
| 34 | speed: Reading + ' ' + ReadingUnits, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 35 | statusState: Status.State, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 36 | }; |
| 37 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 38 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 39 | }, |
| 40 | actions: { |
| 41 | async getFanInfo({ commit }) { |
| 42 | return await api |
| 43 | .get('/redfish/v1/Chassis/chassis/Thermal') |
| 44 | .then(({ data: { Fans = [] } }) => commit('setFanInfo', Fans)) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 45 | .catch((error) => console.log(error)); |
| 46 | }, |
| 47 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | export default FanStore; |