From ff057d62b8ae347c0c937bf9388f03dcf42164da Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Thu, 7 Jul 2022 18:37:45 +0300 Subject: upd logic --- src/store/modules/HardwareStatus/SensorsStore.js | 45 ++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/store/modules/HardwareStatus/SensorsStore.js') 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, -- cgit v1.2.3