diff options
Diffstat (limited to 'src/store/modules/HardwareStatus/SensorsStore.js')
-rw-r--r-- | src/store/modules/HardwareStatus/SensorsStore.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/store/modules/HardwareStatus/SensorsStore.js b/src/store/modules/HardwareStatus/SensorsStore.js index 287796d9..f28c50ea 100644 --- a/src/store/modules/HardwareStatus/SensorsStore.js +++ b/src/store/modules/HardwareStatus/SensorsStore.js @@ -26,6 +26,15 @@ const SensorsStore = { }, []); return await api.all(promises); }, + async getFanSensors({ dispatch }) { + const collection = await dispatch('getChassisCollection'); + if (!collection) return; + const promises = collection.reduce((acc, id) => { + acc.push(dispatch('getOnlyFanSensors', id)); + return acc; + }, []); + return await api.all(promises); + }, async getChassisCollection() { return await api .get('/redfish/v1/Chassis') @@ -64,6 +73,39 @@ const SensorsStore = { }) ); }, + async getOnlyFanSensors({ commit }, id) { + const sensors = await api + .get(`${id}/Sensors`) + .then((response) => response.data.Members) + .catch((error) => console.log(error)); + const fanSensors = sensors.filter((sensor) => { + return sensor['@odata.id'].toLowerCase().includes('fan'); + }); + if (!fanSensors) return; + const promises = fanSensors.map((sensor) => { + return api.get(sensor['@odata.id']).catch((error) => { + console.log(error); + return error; + }); + }); + return await api.all(promises).then( + api.spread((...responses) => { + const sensorData = responses.map(({ data }) => { + return { + name: data.Name, + status: data.Status.Health, + currentValue: data.Reading, + lowerCaution: data.Thresholds?.LowerCaution?.Reading, + upperCaution: data.Thresholds?.UpperCaution?.Reading, + lowerCritical: data.Thresholds?.LowerCritical?.Reading, + upperCritical: data.Thresholds?.UpperCritical?.Reading, + units: data.ReadingUnits, + }; + }); + commit('setSensors', sensorData); + }) + ); + }, async getThermalSensors({ commit }, id) { return await api .get(`${id}/Thermal`) |