Skip to content

Commit

Permalink
Fix pressing Refresh button not removing deleted sensors
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
HuyLeAnh committed Oct 9, 2023
1 parent c3cf361 commit 710f121
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/store/modules/HardwareStatus/SensorsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ const SensorsStore = {
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));
Expand All @@ -34,6 +38,9 @@ const SensorsStore = {
)
.catch((error) => console.log(error));
},
async resetSensors({ commit }) {
commit('setSensorsDefault');
},
async getSensors({ commit }, id) {
const sensors = await api
.get(`${id}/Sensors`)
Expand Down

0 comments on commit 710f121

Please sign in to comment.