diff --git a/fittrackee_api/fittrackee_api/application/utils.py b/fittrackee_api/fittrackee_api/application/utils.py index 032c102b..b56ba562 100644 --- a/fittrackee_api/fittrackee_api/application/utils.py +++ b/fittrackee_api/fittrackee_api/application/utils.py @@ -11,8 +11,8 @@ def init_config(): """ init application configuration if not existing in database - Note: get some configuration values from env variables (for FitTrackee versions - prior to v0.3.0) + Note: get some configuration values from env variables + (for FitTrackee versions prior to v0.3.0) """ existing_config = AppConfig.query.one_or_none() if not existing_config: diff --git a/fittrackee_client/src/actions/activities.js b/fittrackee_client/src/actions/activities.js index 997f1084..ceb25a31 100644 --- a/fittrackee_client/src/actions/activities.js +++ b/fittrackee_client/src/actions/activities.js @@ -43,6 +43,10 @@ export const addActivity = form => dispatch => dispatch(loadProfile()) history.push('/') } + } else if (ret.status === 413) { + dispatch( + setError('activities|File size is greater than the allowed size') + ) } else { dispatch(setError(`activities|${ret.message}`)) } diff --git a/fittrackee_client/src/actions/application.js b/fittrackee_client/src/actions/application.js new file mode 100644 index 00000000..bab6e8ae --- /dev/null +++ b/fittrackee_client/src/actions/application.js @@ -0,0 +1,38 @@ +import FitTrackeeGenericApi from '../fitTrackeeApi' +import { setError } from './index' + +export const setAppConfig = data => ({ + type: 'SET_APP_CONFIG', + data, +}) + +export const setAppStats = data => ({ + type: 'SET_APP_STATS', + data, +}) + +export const getAppData = target => dispatch => + FitTrackeeGenericApi.getData(target) + .then(ret => { + if (ret.status === 'success') { + if (target === 'config') { + dispatch(setAppConfig(ret.data)) + } else if (target === 'stats/all') { + dispatch(setAppStats(ret.data)) + } + } else { + dispatch(setError(`application|${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`application|${error}`))) + +export const updateAppConfig = formData => dispatch => + FitTrackeeGenericApi.updateData('config', formData) + .then(ret => { + if (ret.status === 'success') { + dispatch(setAppConfig(ret.data)) + } else { + dispatch(setError(`application|${ret.message}`)) + } + }) + .catch(error => dispatch(setError(`application|${error}`))) diff --git a/fittrackee_client/src/actions/stats.js b/fittrackee_client/src/actions/stats.js index 844378e0..834e65d4 100644 --- a/fittrackee_client/src/actions/stats.js +++ b/fittrackee_client/src/actions/stats.js @@ -1,22 +1,6 @@ import FitTrackeeGenericApi from '../fitTrackeeApi' import { setData, setError } from './index' -export const setAppStats = data => ({ - type: 'SET_APP_STATS', - data, -}) - -export const getAppStats = () => dispatch => - FitTrackeeGenericApi.getData('stats/all') - .then(ret => { - if (ret.status === 'success') { - dispatch(setAppStats(ret.data)) - } else { - dispatch(setError(`application|${ret.message}`)) - } - }) - .catch(error => dispatch(setError(`application|${error}`))) - export const getStats = (userId, type, data) => dispatch => FitTrackeeGenericApi.getData(`stats/${userId}/${type}`, data) .then(ret => { diff --git a/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx b/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx index eda7addd..3f1a9c0d 100644 --- a/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx +++ b/fittrackee_client/src/components/Activity/ActivityForms/FormWithGpx.jsx @@ -5,17 +5,27 @@ import { connect } from 'react-redux' import { setLoading } from '../../../actions/index' import { addActivity, editActivity } from '../../../actions/activities' import { history } from '../../../index' -import { fileSizeLimit, gpxLimit, zipSizeLimit } from '../../../utils' +import { getFileSize } from '../../../utils' import { translateSports } from '../../../utils/activities' function FormWithGpx(props) { - const { activity, loading, onAddActivity, onEditActivity, sports, t } = props + const { + activity, + appConfig, + loading, + onAddActivity, + onEditActivity, + sports, + t, + } = props const sportId = activity ? activity.sport_id : '' const translatedSports = translateSports(sports, t, true) - // prettier-ignore - const zipTooltip = - `${t('activities:no folder inside')}, ${gpxLimit} ${ - t('activities:files max')}, ${t('activities:max size')}: ${zipSizeLimit}` + const zipTooltip = `${t('activities:no folder inside')}, ${ + appConfig.gpx_limit_import + } ${t('activities:files max')}, ${t('activities:max size')}: ${getFileSize( + appConfig.max_zip_file_size + )}` + const fileSizeLimit = getFileSize(appConfig.max_single_file_size) return (