diff options
author | Sneha Patel <Snehaben.Patel@ibm.com> | 2021-09-09 20:40:38 +0300 |
---|---|---|
committer | Dixsie Wolmers <dixsiew@gmail.com> | 2021-09-23 16:37:11 +0300 |
commit | a02c6f94bd541b07067ac30bab609896b3f6f988 (patch) | |
tree | 5e29f169f589609f5c50897c83419eed3755832b /src/store | |
parent | c9cb8d433b7ed5f4d37cd8d946c2593d4d886ce1 (diff) | |
download | webui-vue-a02c6f94bd541b07067ac30bab609896b3f6f988.tar.xz |
Add Assemblies schema to Hardware Status - Inventory and LEDs
Signed-off-by: Sneha Patel <Snehaben.Patel@ibm.com>
Change-Id: I1a4edae664d008a4f618d03d62e2319d8157ed6d
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/index.js | 2 | ||||
-rw-r--r-- | src/store/modules/HardwareStatus/AssemblyStore.js | 66 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/store/index.js b/src/store/index.js index 2408055d..d7c1b22d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -23,6 +23,7 @@ import FanStore from './modules/HardwareStatus/FanStore'; import ChassisStore from './modules/HardwareStatus/ChassisStore'; import BmcStore from './modules/HardwareStatus/BmcStore'; import ProcessorStore from './modules/HardwareStatus/ProcessorStore'; +import AssemblyStore from './modules/HardwareStatus/AssemblyStore'; import PostCodeLogsStore from './modules/Logs/PostCodeLogsStore'; import PoliciesStore from './modules/SecurityAndAccess/PoliciesStore'; import FactoryResetStore from './modules/Operations/FactoryResetStore'; @@ -61,6 +62,7 @@ export default new Vuex.Store({ chassis: ChassisStore, bmc: BmcStore, processors: ProcessorStore, + assemblies: AssemblyStore, postCodeLogs: PostCodeLogsStore, virtualMedia: VirtualMediaStore, policies: PoliciesStore, diff --git a/src/store/modules/HardwareStatus/AssemblyStore.js b/src/store/modules/HardwareStatus/AssemblyStore.js new file mode 100644 index 00000000..56e5631d --- /dev/null +++ b/src/store/modules/HardwareStatus/AssemblyStore.js @@ -0,0 +1,66 @@ +import api from '@/store/api'; +import i18n from '@/i18n'; + +const AssemblyStore = { + namespaced: true, + state: { + assemblies: null, + }, + getters: { + assemblies: (state) => state.assemblies, + }, + mutations: { + setAssemblyInfo: (state, data) => { + state.assemblies = data.map((assembly) => { + const { + MemberId, + PartNumber, + SerialNumber, + SparePartNumber, + Model, + Name, + Location, + LocationIndicatorActive, + } = assembly; + return { + id: MemberId, + partNumber: PartNumber, + serialNumber: SerialNumber, + sparePartNumber: SparePartNumber, + model: Model, + name: Name, + locationNumber: Location?.PartLocation?.ServiceLabel, + identifyLed: LocationIndicatorActive, + uri: assembly['@odata.id'], + }; + }); + }, + }, + actions: { + async getAssemblyInfo({ commit }) { + return await api + .get('/redfish/v1/Chassis/chassis/Assembly') + .then(({ data }) => commit('setAssemblyInfo', data?.Assemblies)) + .catch((error) => console.log(error)); + }, + async updateIdentifyLedValue({ dispatch }, led) { + const uri = led.uri; + const updatedIdentifyLedValue = { + LocationIndicatorActive: led.identifyLed, + }; + return await api.patch(uri, updatedIdentifyLedValue).catch((error) => { + dispatch('getAssemblyInfo'); + console.log('error', error); + if (led.identifyLed) { + throw new Error(i18n.t('pageInventory.toast.errorEnableIdentifyLed')); + } else { + throw new Error( + i18n.t('pageInventory.toast.errorDisableIdentifyLed') + ); + } + }); + }, + }, +}; + +export default AssemblyStore; |