blob: 251279e68ad6f5d021baada4ce42ae3c56b80466 [file] [log] [blame]
import api from '@/store/api';
const ChassisStore = {
namespaced: true,
state: {
chassis: [],
},
getters: {
chassis: (state) => state.chassis,
},
mutations: {
setChassisInfo: (state, data) => {
state.chassis = data.map((chassis) => {
const {
Id,
Status = {},
PartNumber,
SerialNumber,
ChassisType,
Manufacturer,
PowerState,
} = chassis;
return {
id: Id,
health: Status.Health,
partNumber: PartNumber,
serialNumber: SerialNumber,
chassisType: ChassisType,
manufacturer: Manufacturer,
powerState: PowerState,
statusState: Status.State,
healthRollup: Status.HealthRollup,
};
});
},
},
actions: {
async getChassisInfo({ commit }) {
return await api
.get('/redfish/v1/Chassis')
.then(({ data: { Members = [] } }) =>
Members.map((member) => api.get(member['@odata.id']))
)
.then((promises) => api.all(promises))
.then((response) => {
const data = response.map(({ data }) => data);
commit('setChassisInfo', data);
})
.catch((error) => console.log(error));
},
},
};
export default ChassisStore;