Improved performance in Sensors page
- The Sensors page takes too long to load, It is because we are
trying to call the redfish endpoint: /Sensors' Members one by one
and setting in the GUI. The change made is that we are using the
query parameters' expand option to call only once and get all
the required responses.
- We are using query parameters only for those which have MaxLevels>0,
else calling the APIs one by one.
- Tested: Checked on a p10 system. For 306 records, it used to take
1 minute 20 seconds, now takes 7 seconds to load.
Signed-off-by: Nikhil Ashoka <a.nikhil@ibm.com>
Change-Id: Ife3447e48d4f5617dcf4563ceac486e4502b2de1
diff --git a/src/store/modules/HardwareStatus/SensorsStore.js b/src/store/modules/HardwareStatus/SensorsStore.js
index 5d1ac42..bb26561 100644
--- a/src/store/modules/HardwareStatus/SensorsStore.js
+++ b/src/store/modules/HardwareStatus/SensorsStore.js
@@ -41,7 +41,19 @@
async resetSensors({ commit }) {
commit('setSensorsDefault');
},
- async getSensors({ commit }, id) {
+ async getSensors({ dispatch }, id) {
+ await api
+ .get('/redfish/v1/')
+ .then(({ data }) => {
+ if (data?.ProtocolFeaturesSupported?.ExpandQuery?.MaxLevels > 0) {
+ return dispatch('getSensorsUsingQueryParams', id);
+ } else {
+ return dispatch('getSensorsWithoutQueryParams', id);
+ }
+ })
+ .catch((error) => console.log(error));
+ },
+ async getSensorsWithoutQueryParams({ commit }, id) {
const sensors = await api
.get(`${id}/Sensors`)
.then((response) => response.data.Members)
@@ -72,6 +84,31 @@
commit('setSensors', sensorData);
});
},
+ async getSensorsUsingQueryParams({ commit }, id) {
+ await api
+ .get(`${id}/Sensors?$expand=.($levels=1)`)
+ .then((response) => {
+ let sensorData = [];
+ response.data.Members.map((sensor) => {
+ const oneSensordata = {
+ name: sensor.Name,
+ status: sensor.Status?.Health,
+ currentValue: sensor.Reading,
+ lowerCaution: sensor.Thresholds?.LowerCaution?.Reading,
+ upperCaution: sensor.Thresholds?.UpperCaution?.Reading,
+ lowerCritical: sensor.Thresholds?.LowerCritical?.Reading,
+ upperCritical: sensor.Thresholds?.UpperCritical?.Reading,
+ units: sensor.ReadingUnits,
+ };
+ sensorData.push(oneSensordata);
+ commit('setSensors', sensorData);
+ });
+ })
+ .then(() => {
+ return;
+ })
+ .catch((error) => console.log(error));
+ },
async getThermalSensors({ commit }, id) {
return await api
.get(`${id}/Thermal`)