summaryrefslogtreecommitdiffstats
path: root/webapp/src/store/events.js
blob: 207a307001ee215f7a950cad0b4a6e9c633ea9ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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(result => {
        context.commit('setConfigList', result.data)
      })
    },
    loadLists (context) {
      context.dispatch('loadEvents')
      context.dispatch('loadConfigs')
    }
  }
}