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) => { |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 14 | const { MemberId, Status = {}, PartNumber, SerialNumber } = fan; |
| 15 | return { |
| 16 | id: MemberId, |
| 17 | health: Status.Health, |
| 18 | partNumber: PartNumber, |
| 19 | serialNumber: SerialNumber, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 20 | statusState: Status.State, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 21 | }; |
| 22 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 23 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 24 | }, |
| 25 | actions: { |
| 26 | async getFanInfo({ commit }) { |
| 27 | return await api |
| 28 | .get('/redfish/v1/Chassis/chassis/Thermal') |
| 29 | .then(({ data: { Fans = [] } }) => commit('setFanInfo', Fans)) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 30 | .catch((error) => console.log(error)); |
| 31 | }, |
| 32 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | export default FanStore; |