Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 1 | import api from '@/store/api'; |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 2 | import i18n from '@/i18n'; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 3 | |
| 4 | const SystemStore = { |
| 5 | namespaced: true, |
| 6 | state: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 7 | systems: [], |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 8 | }, |
| 9 | getters: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 10 | systems: (state) => state.systems, |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 11 | }, |
| 12 | mutations: { |
| 13 | setSystemInfo: (state, data) => { |
| 14 | const system = {}; |
| 15 | system.assetTag = data.AssetTag; |
| 16 | system.description = data.Description; |
Yoshie Muranaka | c687f10 | 2020-06-02 12:01:27 -0700 | [diff] [blame] | 17 | system.firmwareVersion = data.BiosVersion; |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 18 | system.hardwareType = data.Name; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 19 | system.health = data.Status.Health; |
| 20 | system.id = data.Id; |
SurenNeware | bbf896c | 2021-01-27 21:50:22 +0530 | [diff] [blame] | 21 | system.locationIndicatorActive = data.LocationIndicatorActive; |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 22 | system.locationNumber = data.LocationNumber; |
Yoshie Muranaka | c687f10 | 2020-06-02 12:01:27 -0700 | [diff] [blame] | 23 | system.manufacturer = data.Manufacturer; |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 24 | system.memorySummaryHealth = data.MemorySummary.Status.Health; |
| 25 | system.memorySummaryHealthRollup = data.MemorySummary.Status.HealthRollup; |
| 26 | system.memorySummaryState = data.MemorySummary.Status.State; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 27 | system.model = data.Model; |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 28 | system.processorSummaryCount = data.ProcessorSummary.Count; |
| 29 | system.processorSummaryHealth = data.ProcessorSummary.Status.Health; |
| 30 | system.processorSummaryHealthRoll = |
| 31 | data.ProcessorSummary.Status.HealthRollup; |
| 32 | system.processorSummaryState = data.ProcessorSummary.Status.State; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 33 | system.powerState = data.PowerState; |
| 34 | system.serialNumber = data.SerialNumber; |
| 35 | system.healthRollup = data.Status.HealthRollup; |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 36 | system.subModel = data.SubModel; |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 37 | system.statusState = data.Status.State; |
| 38 | system.systemType = data.SystemType; |
| 39 | state.systems = [system]; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 40 | }, |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 41 | }, |
| 42 | actions: { |
| 43 | async getSystem({ commit }) { |
| 44 | return await api |
| 45 | .get('/redfish/v1/Systems/system') |
| 46 | .then(({ data }) => commit('setSystemInfo', data)) |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 47 | .catch((error) => console.log(error)); |
| 48 | }, |
Sukanya Pandey | eb4cef3 | 2021-04-09 15:40:27 +0530 | [diff] [blame^] | 49 | changeIdentifyLedState({ dispatch }, ledState) { |
| 50 | api |
| 51 | .patch('/redfish/v1/Systems/system', { |
| 52 | LocationIndicatorActive: ledState, |
| 53 | }) |
| 54 | .then(() => dispatch('getSystem')) |
| 55 | .catch((error) => { |
| 56 | dispatch('getSystem'); |
| 57 | console.log('error', error); |
| 58 | if (ledState) { |
| 59 | throw new Error( |
| 60 | i18n.t('pageHardwareStatus.toast.errorTurnOnIdentifyLed') |
| 61 | ); |
| 62 | } else { |
| 63 | throw new Error( |
| 64 | i18n.t('pageHardwareStatus.toast.errorTurnOffIdentifyLed') |
| 65 | ); |
| 66 | } |
| 67 | }); |
| 68 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 69 | }, |
Yoshie Muranaka | 56ee769 | 2020-05-28 13:28:29 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | export default SystemStore; |