Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 1 | import api from '@/store/api'; |
| 2 | |
| 3 | const SystemStore = { |
| 4 | namespaced: true, |
| 5 | state: { |
| 6 | systems: [] |
| 7 | }, |
| 8 | getters: { |
| 9 | systems: state => state.systems |
| 10 | }, |
| 11 | mutations: { |
| 12 | setSystemInfo: (state, data) => { |
| 13 | const system = {}; |
| 14 | system.assetTag = data.AssetTag; |
| 15 | system.description = data.Description; |
Yoshie Muranaka | c687f10 | 2020-06-02 12:01:27 -0700 | [diff] [blame^] | 16 | system.firmwareVersion = data.BiosVersion; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 17 | system.health = data.Status.Health; |
| 18 | system.id = data.Id; |
| 19 | system.indicatorLed = data.IndicatorLED; |
Yoshie Muranaka | c687f10 | 2020-06-02 12:01:27 -0700 | [diff] [blame^] | 20 | system.manufacturer = data.Manufacturer; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 21 | system.model = data.Model; |
| 22 | system.partNumber = data.PartNumber; |
| 23 | system.powerState = data.PowerState; |
| 24 | system.serialNumber = data.SerialNumber; |
| 25 | system.healthRollup = data.Status.HealthRollup; |
| 26 | system.statusState = data.Status.State; |
| 27 | system.systemType = data.SystemType; |
| 28 | state.systems = [system]; |
| 29 | } |
| 30 | }, |
| 31 | actions: { |
| 32 | async getSystem({ commit }) { |
| 33 | return await api |
| 34 | .get('/redfish/v1/Systems/system') |
| 35 | .then(({ data }) => commit('setSystemInfo', data)) |
| 36 | .catch(error => console.log(error)); |
| 37 | } |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | export default SystemStore; |