blob: 2de388bf6ff211fe75dbdc381bb4bfc479653b53 [file] [log] [blame]
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07001import api from '@/store/api';
2
3const FanStore = {
4 namespaced: true,
5 state: {
6 fans: []
7 },
8 getters: {
9 fans: state => state.fans
10 },
11 mutations: {
12 setFanInfo: (state, data) => {
13 state.fans = data.map(fan => {
14 const { MemberId, Status = {}, PartNumber, SerialNumber } = fan;
15 return {
16 id: MemberId,
17 health: Status.Health,
18 partNumber: PartNumber,
19 serialNumber: SerialNumber,
20 statusState: Status.State
21 };
22 });
23 }
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))
30 .catch(error => console.log(error));
31 }
32 }
33};
34
35export default FanStore;