From c5c2ae99f6e9b91526ea5896b3029ab8a7480c6f Mon Sep 17 00:00:00 2001 From: Sukanya Pandey Date: Wed, 9 Dec 2020 16:14:19 +0530 Subject: Show asset name in the app header Signed-off-by: Sukanya Pandey Change-Id: If5394604d6c91b3604eaadb33178376fe6da672c --- src/store/modules/GlobalStore.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/store') diff --git a/src/store/modules/GlobalStore.js b/src/store/modules/GlobalStore.js index 218feb67..6e9bd962 100644 --- a/src/store/modules/GlobalStore.js +++ b/src/store/modules/GlobalStore.js @@ -29,6 +29,7 @@ const hostStateMapper = (hostState) => { const GlobalStore = { namespaced: true, state: { + assetTag: null, bmcTime: null, hostStatus: 'unreachable', languagePreference: localStorage.getItem('storedLanguage') || 'en-US', @@ -39,6 +40,7 @@ const GlobalStore = { isAuthorized: true, }, getters: { + assetTag: (state) => state.assetTag, hostStatus: (state) => state.hostStatus, bmcTime: (state) => state.bmcTime, languagePreference: (state) => state.languagePreference, @@ -47,6 +49,7 @@ const GlobalStore = { isAuthorized: (state) => state.isAuthorized, }, mutations: { + setAssetTag: (state, assetTag) => (state.assetTag = assetTag), setBmcTime: (state, bmcTime) => (state.bmcTime = bmcTime), setHostStatus: (state, hostState) => (state.hostStatus = hostStateMapper(hostState)), @@ -75,16 +78,19 @@ const GlobalStore = { getHostStatus({ commit }) { api .get('/redfish/v1/Systems/system') - .then(({ data: { PowerState, Status: { State } = {} } } = {}) => { - if (State === 'Quiesced' || State === 'InTest') { - // OpenBMC's host state interface is mapped to 2 Redfish - // properties "Status""State" and "PowerState". Look first - // at State for certain cases. - commit('setHostStatus', State); - } else { - commit('setHostStatus', PowerState); + .then( + ({ data: { AssetTag, PowerState, Status: { State } = {} } } = {}) => { + commit('setAssetTag', AssetTag); + if (State === 'Quiesced' || State === 'InTest') { + // OpenBMC's host state interface is mapped to 2 Redfish + // properties "Status""State" and "PowerState". Look first + // at State for certain cases. + commit('setHostStatus', State); + } else { + commit('setHostStatus', PowerState); + } } - }) + ) .catch((error) => console.log(error)); }, }, -- cgit v1.2.3