From 710f121e5af912e6b622740b9ded43dff69b8f31 Mon Sep 17 00:00:00 2001 From: HuyLe Date: Mon, 9 Oct 2023 11:18:31 +0700 Subject: 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 --- src/store/modules/HardwareStatus/SensorsStore.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/store/modules/HardwareStatus/SensorsStore.js b/src/store/modules/HardwareStatus/SensorsStore.js index 5a237bd4..32bf13b7 100644 --- a/src/store/modules/HardwareStatus/SensorsStore.js +++ b/src/store/modules/HardwareStatus/SensorsStore.js @@ -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)); @@ -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`) -- cgit v1.2.3