blob: fca1f32680e91d811a22f686b1453a9b85533fa0 [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) => {
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050014 const {
15 IndicatorLED,
16 Location,
17 MemberId,
18 Name,
19 Reading,
20 ReadingUnits,
21 Status = {},
22 PartNumber,
23 SerialNumber,
24 } = fan;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070025 return {
26 id: MemberId,
27 health: Status.Health,
28 partNumber: PartNumber,
29 serialNumber: SerialNumber,
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050030 healthRollup: Status.HealthRollup,
31 identifyLed: IndicatorLED,
32 locationNumber: Location,
33 name: Name,
34 speed: Reading + ' ' + ReadingUnits,
Derick Montague602e98a2020-10-21 16:20:00 -050035 statusState: Status.State,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070036 };
37 });
Derick Montague602e98a2020-10-21 16:20:00 -050038 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070039 },
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 Montague602e98a2020-10-21 16:20:00 -050045 .catch((error) => console.log(error));
46 },
47 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070048};
49
50export default FanStore;