import axios from 'axios' export default { namespaced: true, state: { events: [], configList: [], dialog: { show: false, type: null, info: {} } }, mutations: { setEvents (state, value) { state.events = value }, setConfigList (state, value) { state.configList = value }, setDialog (state, { show, type, info }) { if (show !== undefined) state.dialog.show = show if (type !== undefined) state.dialog.type = type if (info !== undefined) state.dialog.info = info } }, actions: { loadEvents (context) { axios.get('/api/events').then(response => { for (let i = 0; i < response.data.length; i++) { if (response.data[i].config !== null) { response.data[i].configName = response.data[i].config.name } } context.commit('setEvents', response.data) }) }, loadConfigs (context) { axios.get('/api/ipxeconfigs').then(response => { context.commit('setConfigList', response.data) }) }, loadLists (context) { context.dispatch('loadEvents') context.dispatch('loadConfigs') } } }