diff --git a/fittrackee_client/src/App.vue b/fittrackee_client/src/App.vue
index 641aa71e..8a0f88db 100644
--- a/fittrackee_client/src/App.vue
+++ b/fittrackee_client/src/App.vue
@@ -7,8 +7,10 @@
diff --git a/fittrackee_client/src/store/constants.ts b/fittrackee_client/src/store/constants.ts
index ffb17684..d870fdbe 100644
--- a/fittrackee_client/src/store/constants.ts
+++ b/fittrackee_client/src/store/constants.ts
@@ -1,4 +1,8 @@
-import { RootGetters, RootMutations } from '@/store/modules/root/enums'
+import {
+ RootActions,
+ RootGetters,
+ RootMutations,
+} from '@/store/modules/root/enums'
import {
UserActions,
UserGetters,
@@ -6,6 +10,7 @@ import {
} from '@/store/modules/user/enums'
export const ROOT_STORE = {
+ ACTIONS: RootActions,
GETTERS: RootGetters,
MUTATIONS: RootMutations,
}
diff --git a/fittrackee_client/src/store/modules/root/actions.ts b/fittrackee_client/src/store/modules/root/actions.ts
new file mode 100644
index 00000000..b29524fc
--- /dev/null
+++ b/fittrackee_client/src/store/modules/root/actions.ts
@@ -0,0 +1,27 @@
+import { ActionContext, ActionTree } from 'vuex'
+
+import { ROOT_STORE } from '@/store/constants'
+import { IRootActions, IRootState } from '@/store/modules/root/interfaces'
+import authApi from '@/api/authApi'
+import { handleError } from '@/utils'
+
+export const actions: ActionTree & IRootActions = {
+ [ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
+ context: ActionContext
+ ): void {
+ context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
+ authApi
+ .get('config')
+ .then((res) => {
+ if (res.data.status === 'success') {
+ context.commit(
+ ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_CONFIG,
+ res.data.data
+ )
+ } else {
+ handleError(context, null)
+ }
+ })
+ .catch((error) => handleError(context, error))
+ },
+}
diff --git a/fittrackee_client/src/store/modules/root/enums.ts b/fittrackee_client/src/store/modules/root/enums.ts
index 71ba92f1..425dcb57 100644
--- a/fittrackee_client/src/store/modules/root/enums.ts
+++ b/fittrackee_client/src/store/modules/root/enums.ts
@@ -1,3 +1,7 @@
+export enum RootActions {
+ GET_APPLICATION_CONFIG = 'GET_APPLICATION_CONFIG',
+}
+
export enum RootGetters {
ERROR_MESSAGES = 'ERROR_MESSAGES',
LANGUAGE = 'LANGUAGE',
@@ -6,5 +10,6 @@ export enum RootGetters {
export enum RootMutations {
EMPTY_ERROR_MESSAGES = 'EMPTY_ERROR_MESSAGES',
SET_ERROR_MESSAGES = 'SET_ERROR_MESSAGES',
+ UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
UPDATE_LANG = 'UPDATE_LANG',
}
diff --git a/fittrackee_client/src/store/modules/root/index.ts b/fittrackee_client/src/store/modules/root/index.ts
index 5e967040..e07a7d7b 100644
--- a/fittrackee_client/src/store/modules/root/index.ts
+++ b/fittrackee_client/src/store/modules/root/index.ts
@@ -1,5 +1,6 @@
import { Module, ModuleTree } from 'vuex'
+import { actions } from '@/store/modules/root/actions'
import { getters } from '@/store/modules/root/getters'
import { IRootState } from '@/store/modules/root/interfaces'
import { mutations } from '@/store/modules/root/mutations'
@@ -12,6 +13,7 @@ const modules: ModuleTree = {
const root: Module = {
state,
+ actions,
getters,
mutations,
modules,
diff --git a/fittrackee_client/src/store/modules/root/interfaces.ts b/fittrackee_client/src/store/modules/root/interfaces.ts
index 15724d46..4ed19b0a 100644
--- a/fittrackee_client/src/store/modules/root/interfaces.ts
+++ b/fittrackee_client/src/store/modules/root/interfaces.ts
@@ -1,9 +1,39 @@
import { ROOT_STORE } from '@/store/constants'
+import { ActionContext } from 'vuex'
+
+export interface IAppStatistics {
+ sports: number
+ uploads_dir_size: number
+ users: number
+ workouts: number
+}
+
+export interface IAppConfig {
+ federation_enabled: boolean
+ gpx_limit_import: number | null
+ is_registration_enabled: boolean
+ map_attribution: string
+ max_single_file_size: number | null
+ max_users: number | null
+ max_zip_file_size: number | null
+}
+
+export interface IApplication {
+ statistics: IAppStatistics
+ config: IAppConfig
+}
export interface IRootState {
root: boolean
language: string
errorMessages: string | string[] | null
+ application: IApplication
+}
+
+export interface IRootActions {
+ [ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
+ context: ActionContext
+ ): void
}
export interface IRootGetters {
diff --git a/fittrackee_client/src/store/modules/root/mutations.ts b/fittrackee_client/src/store/modules/root/mutations.ts
index d23a05e5..962d2905 100644
--- a/fittrackee_client/src/store/modules/root/mutations.ts
+++ b/fittrackee_client/src/store/modules/root/mutations.ts
@@ -1,7 +1,7 @@
import { MutationTree } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
-import { IRootState } from '@/store/modules/root/interfaces'
+import { IAppConfig, IRootState } from '@/store/modules/root/interfaces'
import { TRootMutations } from '@/store/modules/root/types'
export const mutations: MutationTree & TRootMutations = {
@@ -14,6 +14,12 @@ export const mutations: MutationTree & TRootMutations = {
) {
state.errorMessages = errorMessages
},
+ [ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_CONFIG](
+ state: IRootState,
+ config: IAppConfig
+ ) {
+ state.application.config = config
+ },
[ROOT_STORE.MUTATIONS.UPDATE_LANG](state: IRootState, language: string) {
state.language = language
},
diff --git a/fittrackee_client/src/store/modules/root/state.ts b/fittrackee_client/src/store/modules/root/state.ts
index 4074f50a..755124d0 100644
--- a/fittrackee_client/src/store/modules/root/state.ts
+++ b/fittrackee_client/src/store/modules/root/state.ts
@@ -1,7 +1,9 @@
import { IRootState } from '@/store/modules/root/interfaces'
+import { IApplication } from '@/store/modules/root/interfaces'
export const state: IRootState = {
root: true,
language: 'en',
errorMessages: null,
+ application: {},
}
diff --git a/fittrackee_client/src/store/modules/root/types.ts b/fittrackee_client/src/store/modules/root/types.ts
index 3317791f..41531055 100644
--- a/fittrackee_client/src/store/modules/root/types.ts
+++ b/fittrackee_client/src/store/modules/root/types.ts
@@ -1,7 +1,11 @@
-import { Store as VuexStore, CommitOptions } from 'vuex'
+import { Store as VuexStore, CommitOptions, DispatchOptions } from 'vuex'
import { ROOT_STORE } from '@/store/constants'
-import { IRootGetters, IRootState } from '@/store/modules/root/interfaces'
+import {
+ IRootActions,
+ IRootGetters,
+ IRootState,
+} from '@/store/modules/root/interfaces'
export type TRootMutations = {
[ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES](state: S): void
@@ -16,6 +20,12 @@ export type TRootStoreModule = Omit<
VuexStore,
'commit' | 'getters' | 'dispatch'
> & {
+ dispatch(
+ key: K,
+ payload?: Parameters[1],
+ options?: DispatchOptions
+ ): ReturnType
+} & {
getters: {
[K in keyof IRootGetters]: ReturnType
}
diff --git a/fittrackee_client/src/utils.ts b/fittrackee_client/src/utils.ts
index 8bb14389..8be6c24c 100644
--- a/fittrackee_client/src/utils.ts
+++ b/fittrackee_client/src/utils.ts
@@ -14,7 +14,9 @@ export const getApiUrl = (): string => {
const removeLastEndOfLine = (text: string): string => text.replace(/\n$/gm, '')
const removeLastDot = (text: string): string => text.replace(/\.$/gm, '')
export const handleError = (
- context: ActionContext,
+ context:
+ | ActionContext
+ | ActionContext,
error: AxiosError | null,
msg = 'UNKNOWN'
): void => {