From 214d4d58742478b1e9ad3d0549568a92114179b8 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Mon, 29 Aug 2022 17:45:10 +0300 Subject: one req for fans, dynamic --- src/store/modules/HardwareStatus/FanStore.js | 52 ++++++++-------------------- 1 file changed, 14 insertions(+), 38 deletions(-) (limited to 'src/store') diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index 98dfb5be..43baf6b1 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -4,18 +4,16 @@ import i18n from '@/i18n'; const FanStore = { namespaced: true, state: { - fansCpu: [], - fansCpuLastHour: [], - fansSystem: [], - fansSystemLastHour: [], + fans: [], + fansLastHour: [], limits: [], + isLoading: false, }, getters: { - fansCpu: (state) => state.fansCpu, - fansCpuLastHour: (state) => state.fansCpuLastHour, - fansSystem: (state) => state.fansCpu, - fansSystemLastHour: (state) => state.fansCpuLastHour, + fans: (state) => state.fansCpu, + fansLastHour: (state) => state.fansCpuLastHour, limits: (state) => state.limits, + isLoading: (state) => state.isLoading, }, mutations: { setFanInfo: (state, data) => { @@ -47,21 +45,18 @@ const FanStore = { }); }, - setFansCpu: (state, data) => { + setFans: (state, data) => { state.fansCpu = data; }, - setFansCpuLastHour: (state, data) => { + setFansLastHour: (state, data) => { state.fansCpuLastHour = data; }, - setFansSystem: (state, data) => { - state.fansSystem = data; - }, - setFansSystemLastHour: (state, data) => { - state.fansSystemLastHour = data; - }, setLimits: (state, data) => { state.limits = data; }, + setIsLoading: (state, data) => { + state.isLoading = data; + }, }, actions: { async patchLimits({ dispatch }, { warning, critical, groups }) { @@ -98,26 +93,7 @@ const FanStore = { }) .catch((error) => console.log(error)); }, - 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 }) { + async getFans({ commit }, { lastHour }) { let url = null; if (lastHour) { url = @@ -129,9 +105,9 @@ const FanStore = { .get(url) .then(({ data: { MetricValues = [] } }) => { if (lastHour) { - commit('setFansSystemLastHour', MetricValues); + commit('setFansLastHour', MetricValues); } else { - commit('setFansSystem', MetricValues); + commit('setFans', MetricValues); } }) .catch((error) => console.log(error)); -- cgit v1.2.3