diff options
author | Vitalii Lysak <v.lysak@dunice.net> | 2022-07-01 15:43:26 +0300 |
---|---|---|
committer | Vitalii Lysak <v.lysak@dunice.net> | 2022-07-01 15:43:26 +0300 |
commit | ce69dc38e39aaeb0b531842970da9784093861f8 (patch) | |
tree | 4ee64c88d39a6487d58a755f887e7fd9a30ccc5b | |
parent | 1a88912340f70d1a25d965dc6c60ee0ffc516df8 (diff) | |
download | webui-vue-ce69dc38e39aaeb0b531842970da9784093861f8.tar.xz |
show only fans items
-rw-r--r-- | src/store/modules/HardwareStatus/SensorsStore.js | 42 | ||||
-rw-r--r-- | src/views/Fans/StaticInformation/FansStaticPage.vue | 2 |
2 files changed, 43 insertions, 1 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`) diff --git a/src/views/Fans/StaticInformation/FansStaticPage.vue b/src/views/Fans/StaticInformation/FansStaticPage.vue index 6b071e87..ba312384 100644 --- a/src/views/Fans/StaticInformation/FansStaticPage.vue +++ b/src/views/Fans/StaticInformation/FansStaticPage.vue @@ -124,7 +124,7 @@ export default { }, created() { - this.$store.dispatch('sensors/getAllSensors').finally(() => { + this.$store.dispatch('sensors/getFanSensors').finally(() => { this.isBusy = false; }); }, |