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/index.js | 4 +- src/store/modules/HardwareStatus/FanStore.js | 31 +++++++++ .../modules/HardwareStatus/MotherboardStore.js | 45 ++++++++++++ src/store/modules/_sila/HardwareStatus/FanStore.js | 81 ---------------------- .../_sila/HardwareStatus/MotherboardStore.js | 45 ------------ 5 files changed, 78 insertions(+), 128 deletions(-) create mode 100644 src/store/modules/HardwareStatus/MotherboardStore.js delete mode 100644 src/store/modules/_sila/HardwareStatus/FanStore.js delete mode 100644 src/store/modules/_sila/HardwareStatus/MotherboardStore.js diff --git a/src/store/index.js b/src/store/index.js index fa857b3a..fb911a40 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -19,8 +19,8 @@ import ServerLedStore from './modules/HardwareStatus/ServerLedStore'; import SystemStore from './modules/HardwareStatus/SystemStore'; import PowerSupplyStore from './modules/HardwareStatus/PowerSupplyStore'; import MemoryStore from './modules/HardwareStatus/MemoryStore'; -import FanStore from './modules/_sila/HardwareStatus/FanStore'; -import MotherboardStore from './modules/_sila/HardwareStatus/MotherboardStore'; +import FanStore from './modules/HardwareStatus/FanStore'; +import MotherboardStore from './modules/HardwareStatus/MotherboardStore'; import ChassisStore from './modules/HardwareStatus/ChassisStore'; import BmcStore from './modules/HardwareStatus/BmcStore'; import ProcessorStore from './modules/HardwareStatus/ProcessorStore'; 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; diff --git a/src/store/modules/_sila/HardwareStatus/FanStore.js b/src/store/modules/_sila/HardwareStatus/FanStore.js deleted file mode 100644 index fed3f742..00000000 --- a/src/store/modules/_sila/HardwareStatus/FanStore.js +++ /dev/null @@ -1,81 +0,0 @@ -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) => { - state.fans = data.map((fan) => { - const { - IndicatorLED, - Location, - MemberId, - Name, - Reading, - ReadingUnits, - Status = {}, - PartNumber, - SerialNumber, - } = fan; - return { - id: MemberId, - health: Status.Health, - partNumber: PartNumber, - serialNumber: SerialNumber, - healthRollup: Status.HealthRollup, - identifyLed: IndicatorLED, - 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') - .then(({ data: { Fans = [] } }) => commit('setFanInfo', Fans)) - .catch((error) => console.log(error)); - }, - }, -}; - -export default FanStore; diff --git a/src/store/modules/_sila/HardwareStatus/MotherboardStore.js b/src/store/modules/_sila/HardwareStatus/MotherboardStore.js deleted file mode 100644 index 7b2fe032..00000000 --- a/src/store/modules/_sila/HardwareStatus/MotherboardStore.js +++ /dev/null @@ -1,45 +0,0 @@ -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