aboutsummaryrefslogtreecommitdiff
path: root/src/site/store/images.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/site/store/images.js')
-rw-r--r--src/site/store/images.js45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/site/store/images.js b/src/site/store/images.js
index 14f475a..d02219f 100644
--- a/src/site/store/images.js
+++ b/src/site/store/images.js
@@ -1,19 +1,21 @@
-/* eslint-disable no-shadow */
export const state = () => ({
files: [],
isLoading: false,
pagination: {
page: 1,
limit: 30,
- totalFiles: 0
- }
+ totalFiles: 0,
+ },
+ name: null,
+ downloadEnabled: false,
});
export const getters = {
getTotalFiles: ({ pagination }) => pagination.totalFiles,
getFetchedCount: ({ files }) => files.length,
shouldPaginate: ({ pagination }) => pagination.totalFiles > pagination.limit,
- getLimit: ({ pagination }) => pagination.limit
+ getLimit: ({ pagination }) => pagination.limit,
+ getName: ({ name }) => name,
};
export const actions = {
@@ -23,34 +25,37 @@ export const actions = {
page = page || 1;
try {
- const response = await this.$axios.$get(`files`, { params: { limit: state.pagination.limit, page } });
+ const response = await this.$axios.$get('files', { params: { limit: state.pagination.limit, page } });
- commit('setFiles', { files: response.files });
- commit('updatePaginationMeta', { totalFiles: response.count, page });
+ commit('setFilesAndMeta', { ...response, page });
} catch (e) {
dispatch('alert/set', { text: e.message, error: true }, { root: true });
}
},
- async fetchById({ commit, dispatch }) {
- try {
- const response = await this.$axios.$get('verify');
- commit('loginSuccess', response);
- } catch (e) {
- dispatch('alert/set', { text: e.message, error: true }, { root: true });
- }
- }
+ async fetchByAlbumId({ commit, dispatch, state }, { id, page }) {
+ commit('setIsLoading');
+
+ page = page || 1;
+
+ const response = await this.$axios.$get(`album/${id}/full`, {
+ params: { limit: state.pagination.limit, page },
+ });
+
+ commit('setFilesAndMeta', { ...response, page });
+ },
};
export const mutations = {
setIsLoading(state) {
state.isLoading = true;
},
- setFiles(state, { files }) {
+ setFilesAndMeta(state, {
+ files, name, page, count,
+ }) {
state.files = files || [];
+ state.name = name ?? null;
state.isLoading = false;
- },
- updatePaginationMeta(state, { page, totalFiles }) {
state.pagination.page = page || 1;
- state.pagination.totalFiles = totalFiles || 0;
- }
+ state.pagination.totalFiles = count || 0;
+ },
};