1import api from '@/store/api'; 2import i18n from '@/i18n'; 3 4const SystemStore = { 5 namespaced: true, 6 state: { 7 systems: [], 8 }, 9 getters: { 10 systems: (state) => state.systems, 11 }, 12 mutations: { 13 setSystemInfo: (state, data) => { 14 const system = {}; 15 system.assetTag = data.AssetTag; 16 system.description = data.Description; 17 system.firmwareVersion = data.BiosVersion; 18 system.hardwareType = data.Name; 19 system.health = data.Status.Health; 20 system.id = data.Id; 21 system.locationIndicatorActive = data.LocationIndicatorActive; 22 system.locationNumber = data.LocationNumber; 23 system.manufacturer = data.Manufacturer; 24 system.memorySummaryHealth = data.MemorySummary.Status.Health; 25 system.memorySummaryHealthRollup = data.MemorySummary.Status.HealthRollup; 26 system.memorySummaryState = data.MemorySummary.Status.State; 27 system.model = data.Model; 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; 33 system.powerState = data.PowerState; 34 system.serialNumber = data.SerialNumber; 35 system.healthRollup = data.Status.HealthRollup; 36 system.subModel = data.SubModel; 37 system.statusState = data.Status.State; 38 system.systemType = data.SystemType; 39 state.systems = [system]; 40 }, 41 }, 42 actions: { 43 async getSystem({ commit }) { 44 return await api 45 .get('/redfish/v1/Systems/system') 46 .then(({ data }) => commit('setSystemInfo', data)) 47 .catch((error) => console.log(error)); 48 }, 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.errorEnableIdentifyLed') 61 ); 62 } else { 63 throw new Error( 64 i18n.t('pageHardwareStatus.toast.errorDisableIdentifyLed') 65 ); 66 } 67 }); 68 }, 69 }, 70}; 71 72export default SystemStore; 73