summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuyLe <hule@amperecomputing.com>2023-10-09 07:18:31 +0300
committerHuyLe <hule@amperecomputing.com>2023-10-09 07:18:31 +0300
commit710f121e5af912e6b622740b9ded43dff69b8f31 (patch)
treea306b4b90612dd4f3beffd44c14479817d5b9682
parentc3cf3610b3c9ed59b6afa28b98dd8d87678f538e (diff)
downloadwebui-vue-710f121e5af912e6b622740b9ded43dff69b8f31.tar.xz
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>
-rw-r--r--src/store/modules/HardwareStatus/SensorsStore.js7
1 files changed, 7 insertions, 0 deletions
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`)