diff options
author | Vitalii Lysak <v.lysak@dunice.net> | 2022-07-07 18:37:45 +0300 |
---|---|---|
committer | Vitalii Lysak <v.lysak@dunice.net> | 2022-07-07 18:37:45 +0300 |
commit | ff057d62b8ae347c0c937bf9388f03dcf42164da (patch) | |
tree | a9ce51c0664723fde6d1a5f16ec306270920a17b /src/store | |
parent | c568c0558ac417fa6348840b20560dd4675c573e (diff) | |
download | webui-vue-ff057d62b8ae347c0c937bf9388f03dcf42164da.tar.xz |
upd logic
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/modules/HardwareStatus/SensorsStore.js | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/store/modules/HardwareStatus/SensorsStore.js b/src/store/modules/HardwareStatus/SensorsStore.js index 1e57158b..585be484 100644 --- a/src/store/modules/HardwareStatus/SensorsStore.js +++ b/src/store/modules/HardwareStatus/SensorsStore.js @@ -7,11 +7,13 @@ const SensorsStore = { sensors: [], fanSensors: [], tempSensors: [], + memorySensors: [], }, getters: { sensors: (state) => state.sensors, fanSensors: (state) => state.fanSensors, tempSensors: (state) => state.tempSensors, + memorySensors: (state) => state.memorySensors, }, mutations: { setSensors: (state, sensors) => { @@ -26,6 +28,12 @@ const SensorsStore = { 'name' ); }, + setMemorySensors: (state, memorySensors) => { + state.memorySensors = uniqBy( + [...state.memorySensors, ...memorySensors], + 'name' + ); + }, }, actions: { async getAllSensors({ dispatch }) { @@ -39,6 +47,15 @@ const SensorsStore = { }, []); return await api.all(promises); }, + async getMemorySensors({ dispatch }) { + const collection = await dispatch('getChassisCollection'); + if (!collection) return; + const promises = collection.reduce((acc, id) => { + acc.push(dispatch('getOnlyMemorySensors', id)); + return acc; + }, []); + return await api.all(promises); + }, async getTempSensors({ dispatch }) { const collection = await dispatch('getChassisCollection'); if (!collection) return; @@ -95,6 +112,30 @@ const SensorsStore = { }) ); }, + async getOnlyMemorySensors({ commit }, id) { + return await api + .get(`${id}/Thermal`) + .then(({ data: { Temperatures = [] } }) => { + const sensorData = []; + Temperatures.forEach((sensor) => { + sensorData.push({ + name: sensor.Name, + status: sensor.Status.Health, + currentValue: sensor.ReadingCelsius, + lowerCaution: sensor.LowerThresholdNonCritical, + upperCaution: sensor.UpperThresholdNonCritical, + lowerCritical: sensor.LowerThresholdCritical, + upperCritical: sensor.UpperThresholdCritical, + units: '℃', + }); + }); + const memorySensors = sensorData.filter((sensor) => { + return sensor.name.toLowerCase().includes('dimm'); + }); + commit('setMemorySensors', memorySensors); + }) + .catch((error) => console.log(error)); + }, async getOnlyFanSensors({ commit }, id) { return await api .get(`${id}/Thermal`) @@ -105,8 +146,8 @@ const SensorsStore = { name: sensor.Name, status: sensor.Status.Health, currentValue: sensor.Reading, - lowerCaution: sensor.LowerThresholdNonCritical, - upperCaution: sensor.UpperThresholdNonCritical, + lowerCaution: sensor.MinReadingRange, + upperCaution: sensor.MaxReadingRange, lowerCritical: sensor.LowerThresholdCritical, upperCritical: sensor.UpperThresholdCritical, units: sensor.ReadingUnits, |