aboutsummaryrefslogtreecommitdiff
path: root/src/site/store
diff options
context:
space:
mode:
Diffstat (limited to 'src/site/store')
-rw-r--r--src/site/store/admin.js31
-rw-r--r--src/site/store/auth.js6
-rw-r--r--src/site/store/images.js15
3 files changed, 43 insertions, 9 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) {
diff --git a/src/site/store/auth.js b/src/site/store/auth.js
index 465de7d..96631e2 100644
--- a/src/site/store/auth.js
+++ b/src/site/store/auth.js
@@ -1,6 +1,10 @@
const getDefaultState = () => ({
loggedIn: false,
- user: null,
+ user: {
+ id: null,
+ isAdmin: false,
+ username: null,
+ },
token: null,
});
diff --git a/src/site/store/images.js b/src/site/store/images.js
index a7581e0..acac286 100644
--- a/src/site/store/images.js
+++ b/src/site/store/images.js
@@ -10,7 +10,8 @@ export const getDefaultState = () => ({
},
name: null,
downloadEnabled: false,
- filesAlbums: {}, // map of file ids with a list of album objects the file is in
+ fileAlbumsMap: {}, // map of file ids with a list of album objects the file is in
+ filesTags: {}, // map of file ids with a list of tag objects for the file
});
export const state = getDefaultState;
@@ -105,19 +106,19 @@ export const mutations = {
}
},
setFileAlbums(state, { fileId, albums }) {
- Vue.set(state.filesAlbums, fileId, albums);
+ Vue.set(state.fileAlbumsMap, fileId, albums);
},
addAlbumToFile(state, { fileId, album }) {
- if (!state.filesAlbums[fileId]) return;
+ if (!state.fileAlbumsMap[fileId]) return;
- state.filesAlbums[fileId].push(album);
+ state.fileAlbumsMap[fileId].push(album);
},
removeAlbumFromFile(state, { fileId, albumId }) {
- if (!state.filesAlbums[fileId]) return;
+ if (!state.fileAlbumsMap[fileId]) return;
- const foundIndex = state.filesAlbums[fileId].findIndex(({ id }) => id === albumId);
+ const foundIndex = state.fileAlbumsMap[fileId].findIndex(({ id }) => id === albumId);
if (foundIndex > -1) {
- state.filesAlbums[fileId].splice(foundIndex, 1);
+ state.fileAlbumsMap[fileId].splice(foundIndex, 1);
}
},
resetState(state) {