diff options
| author | Zephyrrus <[email protected]> | 2020-07-10 01:13:51 +0300 |
|---|---|---|
| committer | Zephyrrus <[email protected]> | 2020-07-10 01:13:51 +0300 |
| commit | 0f66d807035d3e32a66c7dc9bf55fb3be99aedac (patch) | |
| tree | 93ff9fd13a0434d91fb1ae7ca0da48d6929c4d00 /src/site/store/admin.js | |
| parent | fix: stop leaking user passwords to admins AGAIN (diff) | |
| download | host.fuwn.me-0f66d807035d3e32a66c7dc9bf55fb3be99aedac.tar.xz host.fuwn.me-0f66d807035d3e32a66c7dc9bf55fb3be99aedac.zip | |
refactor: finish refactoring all the components to use vuex
Diffstat (limited to 'src/site/store/admin.js')
| -rw-r--r-- | src/site/store/admin.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/site/store/admin.js b/src/site/store/admin.js index 2586a18..b31c446 100644 --- a/src/site/store/admin.js +++ b/src/site/store/admin.js @@ -15,6 +15,12 @@ export const state = () => ({ }); export const actions = { + async fetchSettings({ commit }) { + const response = await this.$axios.$get('service/config'); + commit('setSettings', response); + + return response; + }, async fetchUsers({ commit }) { const response = await this.$axios.$get('admin/users'); commit('setUsers', response); @@ -22,11 +28,23 @@ export const actions = { return response; }, async fetchUser({ commit }, id) { - const response = await this.$axios.$get(`/admin/users/${id}`); + const response = await this.$axios.$get(`admin/users/${id}`); + commit('setUserInfo', response); + + return response; + }, + async fetchFile({ commit }, id) { + const response = await this.$axios.$get(`file/${id}`); + commit('setFile', response); commit('setUserInfo', response); return response; }, + async banIP(_, ip) { + const response = await this.$axios.$post('admin/ban/ip', { ip }); + + return response; + }, async enableUser({ commit }, id) { const response = await this.$axios.$post('admin/users/enable', { id }); @@ -60,9 +78,17 @@ export const actions = { return response; }, + async restartService() { + const response = await this.$axios.$post('service/restart'); + + return response; + }, }; export const mutations = { + setSettings(state, { config }) { + state.settings = config; + }, setUsers(state, { users }) { state.users = users; }, @@ -70,6 +96,9 @@ export const mutations = { state.user = { ...state.user, ...user }; state.user.files = files || []; }, + setFile(state, { file }) { + state.file = file || {}; + }, changeUserState(state, { userId, enabled, isAdmin }) { const foundIndex = state.users.findIndex(({ id }) => id === userId); if (foundIndex > -1) { |