From 5463c8aec08dfa07a01f95646e44a3b4bee070fe Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Fri, 26 Aug 2022 14:50:55 +0300 Subject: optimization for dynamic --- src/store/modules/HardwareStatus/FanStore.js | 51 ++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'src/store/modules/HardwareStatus/FanStore.js') diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index 8cae4d77..98dfb5be 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -4,13 +4,17 @@ import i18n from '@/i18n'; const FanStore = { namespaced: true, state: { - fans: [], - fansLastHour: [], + fansCpu: [], + fansCpuLastHour: [], + fansSystem: [], + fansSystemLastHour: [], limits: [], }, getters: { - fans: (state) => state.fans, - fansLastHour: (state) => state.fansLastHour, + fansCpu: (state) => state.fansCpu, + fansCpuLastHour: (state) => state.fansCpuLastHour, + fansSystem: (state) => state.fansCpu, + fansSystemLastHour: (state) => state.fansCpuLastHour, limits: (state) => state.limits, }, mutations: { @@ -43,11 +47,17 @@ const FanStore = { }); }, - setFansDynamic: (state, data) => { - state.fans = data; + setFansCpu: (state, data) => { + state.fansCpu = data; }, - setFansDynamicLastHour: (state, data) => { - state.fansLastHour = data; + setFansCpuLastHour: (state, data) => { + state.fansCpuLastHour = data; + }, + setFansSystem: (state, data) => { + state.fansSystem = data; + }, + setFansSystemLastHour: (state, data) => { + state.fansSystemLastHour = data; }, setLimits: (state, data) => { state.limits = data; @@ -88,7 +98,26 @@ const FanStore = { }) .catch((error) => console.log(error)); }, - async getFansDynamic({ commit }, { lastHour }) { + async getFansCpu({ commit }, { lastHour }) { + let url = null; + if (lastHour) { + url = + '/redfish/v1/TelemetryService/MetricReports/fans&period=last_hour'; + } else { + url = '/redfish/v1/TelemetryService/MetricReports/fans'; + } + return await api + .get(url) + .then(({ data: { MetricValues = [] } }) => { + if (lastHour) { + commit('setFansCpuLastHour', MetricValues); + } else { + commit('setFansCpu', MetricValues); + } + }) + .catch((error) => console.log(error)); + }, + async getFansSystem({ commit }, { lastHour }) { let url = null; if (lastHour) { url = @@ -100,9 +129,9 @@ const FanStore = { .get(url) .then(({ data: { MetricValues = [] } }) => { if (lastHour) { - commit('setFansDynamicLastHour', MetricValues); + commit('setFansSystemLastHour', MetricValues); } else { - commit('setFansDynamic', MetricValues); + commit('setFansSystem', MetricValues); } }) .catch((error) => console.log(error)); -- cgit v1.2.3