Fix pressing Refresh button not removing deleted sensors
Issue: when clicking the Refresh button at top right corner of the
WebUI, sensors that were removed from Redfish are not removed from the
WebUI but still shown with old sensor values.
Root cause: current code keeps a list of sensors. Click on Refresh
button just checks and updates sensors returned by Redfish, it does not
check if sensors are still present or not. This is incorrect for
sensors on hot plug devices or PLDM sensors when the sensor source is
not available. In this case, sensors are completely removed instead of
just their values changed to n/a.
Solution: Initialize an empty array sensor state to retrieve
existing sensor data whenever loading sensors.
Change-Id: Ifb0c0586fdba22b6f446c58b3d5b937a3f3ee750
Signed-off-by: HuyLe <hule@amperecomputing.com>
diff --git a/src/store/modules/HardwareStatus/SensorsStore.js b/src/store/modules/HardwareStatus/SensorsStore.js
index 5a237bd..32bf13b 100644
--- a/src/store/modules/HardwareStatus/SensorsStore.js
+++ b/src/store/modules/HardwareStatus/SensorsStore.js
@@ -13,11 +13,15 @@
setSensors: (state, sensors) => {
state.sensors = uniqBy([...sensors, ...state.sensors], 'name');
},
+ setSensorsDefault: (state) => {
+ state.sensors = [];
+ },
},
actions: {
async getAllSensors({ dispatch }) {
const collection = await dispatch('getChassisCollection');
if (!collection) return;
+ dispatch('resetSensors');
const promises = collection.reduce((acc, id) => {
acc.push(dispatch('getSensors', id));
acc.push(dispatch('getThermalSensors', id));
@@ -34,6 +38,9 @@
)
.catch((error) => console.log(error));
},
+ async resetSensors({ commit }) {
+ commit('setSensorsDefault');
+ },
async getSensors({ commit }, id) {
const sensors = await api
.get(`${id}/Sensors`)