From 6c5418f599c6cd87941331a970c03f68eec66c39 Mon Sep 17 00:00:00 2001 From: MichalX Szopinski Date: Fri, 25 Feb 2022 13:13:27 +0100 Subject: Remove hardcoded chassis from Fan store This change removes the hardcoded chassis URL from FanStore. Now the URL is taken from the odata.id. Signed-off-by: MichalX Szopinski Change-Id: I59e4d46a8aaa453f6662f4f396f32d7fad18fb91 --- src/store/modules/HardwareStatus/FanStore.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index fca1f326..3f172d2d 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -38,10 +38,30 @@ const FanStore = { }, }, actions: { - async getFanInfo({ commit }) { + async getChassisCollection() { return await api - .get('/redfish/v1/Chassis/chassis/Thermal') - .then(({ data: { Fans = [] } }) => commit('setFanInfo', Fans)) + .get('/redfish/v1/Chassis') + .then(({ data: { Members } }) => + api.all( + Members.map((member) => + api.get(member['@odata.id']).then((response) => response.data) + ) + ) + ) + .catch((error) => console.log(error)); + }, + async getFanInfo({ dispatch, commit }) { + const collection = await dispatch('getChassisCollection'); + if (!collection || collection.length === 0) return; + return await api + .all(collection.map((chassis) => dispatch('getChassisFans', chassis))) + .then((fansFromChassis) => commit('setFanInfo', fansFromChassis.flat())) + .catch((error) => console.log(error)); + }, + async getChassisFans(_, chassis) { + return await api + .get(chassis.Thermal['@odata.id']) + .then(({ data: { Fans } }) => Fans || []) .catch((error) => console.log(error)); }, }, -- cgit v1.2.3