diff options
author | Vitalii Lysak <v.lysak@dunice.net> | 2022-07-04 12:02:52 +0300 |
---|---|---|
committer | Vitalii Lysak <v.lysak@dunice.net> | 2022-07-04 12:02:52 +0300 |
commit | 03080e30d351494fbedef1b1c616bddb6bfe13cc (patch) | |
tree | 352f769075b6f4668d4106d0f6acc7c05a773ae5 /src/store/modules | |
parent | 17c1d8bdaf236f1209b7283bbf75a4c062c7a6ad (diff) | |
parent | c8d25fd2b9ecb1395fa086a727d238489d568908 (diff) | |
download | webui-vue-03080e30d351494fbedef1b1c616bddb6bfe13cc.tar.xz |
Merge branch 'template-bugs' into sila-dev
Diffstat (limited to 'src/store/modules')
-rw-r--r-- | src/store/modules/HardwareStatus/SensorsStore.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/store/modules/HardwareStatus/SensorsStore.js b/src/store/modules/HardwareStatus/SensorsStore.js index 287796d9..896297e3 100644 --- a/src/store/modules/HardwareStatus/SensorsStore.js +++ b/src/store/modules/HardwareStatus/SensorsStore.js @@ -5,14 +5,19 @@ const SensorsStore = { namespaced: true, state: { sensors: [], + fanSensors: [], }, getters: { sensors: (state) => state.sensors, + fanSensors: (state) => state.fanSensors, }, mutations: { setSensors: (state, sensors) => { state.sensors = uniqBy([...state.sensors, ...sensors], 'name'); }, + setFanSensors: (state, fanSensors) => { + state.fanSensors = uniqBy([...state.fanSensors, ...fanSensors], 'name'); + }, }, actions: { async getAllSensors({ dispatch }) { @@ -26,6 +31,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 +78,35 @@ 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, + units: data.ReadingUnits, + }; + }); + commit('setFanSensors', sensorData); + }) + ); + }, async getThermalSensors({ commit }, id) { return await api .get(`${id}/Thermal`) |