diff options
author | Sukanya Pandey <sukapan1@in.ibm.com> | 2020-12-09 13:44:19 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2020-12-16 02:16:56 +0300 |
commit | c5c2ae99f6e9b91526ea5896b3029ab8a7480c6f (patch) | |
tree | 5992782ede6c5f457f15a7037c5f71902588845a /src/store | |
parent | f6df801b384118b946bb3b7b3248832ec70cfd0a (diff) | |
download | webui-vue-c5c2ae99f6e9b91526ea5896b3029ab8a7480c6f.tar.xz |
Show asset name in the app header
Signed-off-by: Sukanya Pandey <sukapan1@in.ibm.com>
Change-Id: If5394604d6c91b3604eaadb33178376fe6da672c
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/modules/GlobalStore.js | 24 |
1 files changed, 15 insertions, 9 deletions
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)); }, }, |