From 58860854beb269e6fa3d62e08be2c9ebb95997f2 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Wed, 3 Aug 2022 09:18:36 +0300 Subject: upd FanStore --- src/store/modules/HardwareStatus/FanStore.js | 31 +++++++++++++++ .../modules/HardwareStatus/MotherboardStore.js | 45 ++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/store/modules/HardwareStatus/MotherboardStore.js (limited to 'src/store/modules/HardwareStatus') diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index fca1f326..fed3f742 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -1,12 +1,15 @@ import api from '@/store/api'; +import { fanType } from '@/utilities/_sila/tableParser'; const FanStore = { namespaced: true, state: { fans: [], + fansLastHour: [], }, getters: { fans: (state) => state.fans, + fansLastHour: (state) => state.fansLastHour, }, mutations: { setFanInfo: (state, data) => { @@ -32,12 +35,40 @@ const FanStore = { locationNumber: Location, name: Name, speed: Reading + ' ' + ReadingUnits, + speedRPM: Reading, + type: fanType(Name), statusState: Status.State, }; }); }, + + setFansDynamic: (state, data) => { + state.fans = data; + }, + setFansDynamicLastHour: (state, data) => { + state.fansLastHour = data; + }, }, actions: { + async getFansDynamic({ commit }, { lastHour }) { + let url = null; + if (lastHour) { + url = + '/redfish/v1/TelemetryService/MetricReports/hour_data&id=fans&period=last_hour'; + } else { + url = '/redfish/v1/TelemetryService/MetricReports/hour_data&id=fans'; + } + return await api + .get(url) + .then(({ data: { MetricValues = [] } }) => { + if (lastHour) { + commit('setFansDynamicLastHour', MetricValues); + } else { + commit('setFansDynamic', MetricValues); + } + }) + .catch((error) => console.log(error)); + }, async getFanInfo({ commit }) { return await api .get('/redfish/v1/Chassis/chassis/Thermal') diff --git a/src/store/modules/HardwareStatus/MotherboardStore.js b/src/store/modules/HardwareStatus/MotherboardStore.js new file mode 100644 index 00000000..7b2fe032 --- /dev/null +++ b/src/store/modules/HardwareStatus/MotherboardStore.js @@ -0,0 +1,45 @@ +import api from '@/store/api'; + +const MotherboardStore = { + namespaced: true, + state: { + motherboard: [], + motherboardLastHour: [], + }, + getters: { + motherboard: (state) => state.motherboard, + motherboardLastHour: (state) => state.motherboardLastHour, + }, + mutations: { + setMotherboardDynamic: (state, data) => { + state.motherboard = data; + }, + setMotherboardDynamicLastHour: (state, data) => { + state.motherboardLastHour = data; + }, + }, + actions: { + async getMotherboardDynamic({ commit }, { lastHour }) { + let url = null; + if (lastHour) { + url = + '/redfish/v1/TelemetryService/MetricReports/hour_data&id=other_temp&period=last_hour'; + } else { + url = + '/redfish/v1/TelemetryService/MetricReports/hour_data&id=other_temp'; + } + return await api + .get(url) + .then(({ data: { MetricValues = [] } }) => { + if (lastHour) { + commit('setMotherboardDynamicLastHour', MetricValues); + } else { + commit('setMotherboardDynamic', MetricValues); + } + }) + .catch((error) => console.log(error)); + }, + }, +}; + +export default MotherboardStore; -- cgit v1.2.3