diff options
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/index.js | 4 | ||||
-rw-r--r-- | src/store/modules/Health/ChassisStore.js | 55 |
2 files changed, 58 insertions, 1 deletions
diff --git a/src/store/index.js b/src/store/index.js index c4c0948f..0f921759 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -18,6 +18,7 @@ import SystemStore from './modules/Health/SystemStore'; import PowerSupplyStore from './modules/Health/PowerSupplyStore'; import MemoryStore from './modules/Health/MemoryStore'; import FanStore from './modules/Health/FanStore'; +import ChassisStore from './modules/Health/ChassisStore'; import WebSocketPlugin from './plugins/WebSocketPlugin'; @@ -44,7 +45,8 @@ export default new Vuex.Store({ serverLed: ServerLedStore, system: SystemStore, memory: MemoryStore, - fan: FanStore + fan: FanStore, + chassis: ChassisStore }, plugins: [WebSocketPlugin] }); diff --git a/src/store/modules/Health/ChassisStore.js b/src/store/modules/Health/ChassisStore.js new file mode 100644 index 00000000..e9e58e72 --- /dev/null +++ b/src/store/modules/Health/ChassisStore.js @@ -0,0 +1,55 @@ +import api from '@/store/api'; + +const ChassisStore = { + namespaced: true, + state: { + chassis: [] + }, + getters: { + chassis: state => state.chassis + }, + mutations: { + setChassisInfo: (state, data) => { + state.chassis = data.map(chassis => { + const { + Id, + Status = {}, + PartNumber, + SerialNumber, + ChassisType, + Manufacturer, + PowerState + } = chassis; + + return { + id: Id, + health: Status.Health, + partNumber: PartNumber, + serialNumber: SerialNumber, + chassisType: ChassisType, + manufacturer: Manufacturer, + powerState: PowerState, + statusState: Status.State, + healthRollup: Status.HealthRollup + }; + }); + } + }, + actions: { + async getChassisInfo({ commit }) { + return await api + .get('/redfish/v1/Chassis') + .then(({ data: { Members = [] } }) => + Members.map(member => api.get(member['@odata.id'])) + ) + .then(promises => api.all(promises)) + .then(response => { + const data = response.map(({ data }) => data); + commit('setChassisInfo', data); + }) + .catch(error => console.log(error)); + } + } +}; + +export default ChassisStore; |