blob: b4a4189a171dde8800a942beefa271fdf375613f [file] [log] [blame]
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07001import api from '@/store/api';
2
3const FanStore = {
4 namespaced: true,
5 state: {
Derick Montague602e98a2020-10-21 16:20:00 -05006 fans: [],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07007 },
8 getters: {
Derick Montague602e98a2020-10-21 16:20:00 -05009 fans: (state) => state.fans,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070010 },
11 mutations: {
12 setFanInfo: (state, data) => {
Derick Montague602e98a2020-10-21 16:20:00 -050013 state.fans = data.map((fan) => {
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070014 const { MemberId, Status = {}, PartNumber, SerialNumber } = fan;
15 return {
16 id: MemberId,
17 health: Status.Health,
18 partNumber: PartNumber,
19 serialNumber: SerialNumber,
Derick Montague602e98a2020-10-21 16:20:00 -050020 statusState: Status.State,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070021 };
22 });
Derick Montague602e98a2020-10-21 16:20:00 -050023 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070024 },
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 Montague602e98a2020-10-21 16:20:00 -050030 .catch((error) => console.log(error));
31 },
32 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070033};
34
35export default FanStore;