summaryrefslogtreecommitdiffstats
path: root/webapp/src/store/permissions.js
blob: 5f16045140483755bc73f84fbc04f4b7f911a048 (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
import axios from 'axios'

export default {
  namespaced: true,
  state: {
    roles: [],
    permissionsList: [],
    selectedUsers: [],
    dialog: { show: false, type: null, info: {} }
  },
  mutations: {
    setRoles (state, value) { state.roles = value },
    setSelectedUsers (state, value) { state.selectedUsers = value },
    setPermissions (state, value) { state.permissionsList = 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: {
    loadRoles (context) {
      axios.get('/api/roles').then(response => {
        context.commit('setRoles', response.data)
      })
    },
    loadPermissions (context) {
      axios.get('/api/permissions').then(response => {
        context.commit('setPermissions', response.data)
      })
    },
    loadLists (context) {
      context.dispatch('loadRoles')
      context.dispatch('loadPermissions')
    }
  }
}