API & Client - archive max size must be greater than files size - #70

This commit is contained in:
Sam
2021-02-20 14:14:26 +01:00
parent ae53aaecd7
commit c4e579dd25
14 changed files with 92 additions and 23 deletions

View File

@ -1,4 +1,5 @@
import FitTrackeeGenericApi from '../fitTrackeeApi'
import { history } from '../index'
import { setError } from './index'
export const setAppConfig = data => ({
@ -31,6 +32,7 @@ export const updateAppConfig = formData => dispatch =>
.then(ret => {
if (ret.status === 'success') {
dispatch(setAppConfig(ret.data))
history.push('/admin/application')
} else {
dispatch(setError(`application|${ret.message}`))
}

View File

@ -2,7 +2,7 @@ import React from 'react'
import { connect } from 'react-redux'
import Message from '../Common/Message'
import { updateAppConfig } from '../../actions/application'
import { getAppData, updateAppConfig } from '../../actions/application'
import { history } from '../../index'
import { getFileSizeInMB } from '../../utils'
@ -11,7 +11,6 @@ class AdminApplication extends React.Component {
super(props, context)
this.state = {
formData: {},
isInEdition: false,
}
}
@ -44,15 +43,15 @@ class AdminApplication extends React.Component {
this.setState(formData)
}
toggleInEdition(e) {
e.preventDefault()
const { isInEdition } = this.state
this.setState({ isInEdition: !isInEdition })
}
render() {
const { message, onHandleConfigFormSubmit, t } = this.props
const { formData, isInEdition } = this.state
const {
isInEdition,
loadAppConfig,
message,
onHandleConfigFormSubmit,
t,
} = this.props
const { formData } = this.state
return (
<div>
{message && <Message message={message} t={t} />}
@ -71,7 +70,7 @@ class AdminApplication extends React.Component {
isInEdition ? '' : 'form-disabled'
}`}
onSubmit={e => {
this.toggleInEdition(e)
e.preventDefault()
onHandleConfigFormSubmit(formData)
}}
>
@ -169,7 +168,11 @@ class AdminApplication extends React.Component {
<input
type="submit"
className="btn btn-secondary"
onClick={e => this.toggleInEdition(e)}
onClick={e => {
e.preventDefault()
loadAppConfig()
history.push('/admin/application')
}}
value={t('common:Cancel')}
/>
</>
@ -179,7 +182,8 @@ class AdminApplication extends React.Component {
type="submit"
className="btn btn-primary"
onClick={e => {
this.toggleInEdition(e)
e.preventDefault()
history.push('/admin/application/edit')
}}
value={t('common:Edit')}
/>
@ -207,6 +211,9 @@ export default connect(
message: state.message,
}),
dispatch => ({
loadAppConfig: () => {
dispatch(getAppData('config'))
},
onHandleConfigFormSubmit: formData => {
const data = Object.assign({}, formData)
data.max_single_file_size *= 1048576

View File

@ -28,7 +28,20 @@ function Admin(props) {
<Route
exact
path="/admin/application"
render={() => <AdminApplication appConfig={appConfig} t={t} />}
render={() => (
<AdminApplication
appConfig={appConfig}
t={t}
isInEdition={false}
/>
)}
/>
<Route
exact
path="/admin/application/edit"
render={() => (
<AdminApplication appConfig={appConfig} t={t} isInEdition />
)}
/>
<Route
exact

View File

@ -2,7 +2,7 @@
"3 to 12 characters required for username.": "3 to 12 characters required for username.",
"8 characters required for password.": "8 characters required for password.",
"An error occurred. Please contact the administrator.": "An error occurred. Please contact the administrator.",
"workouts": "workouts",
"application": "application",
"Error during picture deletion.": "Error during picture deletion.",
"Error during picture update.": "Error during picture update.",
"Error during picture update, file size exceeds max size.": "Error during picture update, file size exceeds max size.",
@ -14,6 +14,7 @@
"Invalid credentials.": "Invalid credentials.",
"Invalid payload.": "Invalid payload.",
"Invalid token. Please log in again.": "Invalid token. Please log in again.",
"Max. size of zip archive must be equal or greater than max. size of uploaded files": "Max. size of zip archive must be equal or greater than max. size of uploaded files",
"No file part.": "No file part.",
"No picture.": "No picture.",
"No selected file.": "No selected file.",
@ -30,6 +31,7 @@
"statistics": "statistiques",
"User does not exist.": "User does not exist.",
"Valid email must be provided.\n": "Valid email must be provided.",
"workouts": "workouts",
"You can not delete your account, no other user has admin rights.": "You can not delete your account, no other user has admin rights.",
"You do not have permissions.": "You do not have permissions."
}

View File

@ -2,7 +2,7 @@
"3 to 12 characters required for username.": "3 à 12 caractères requis pour le nom.",
"8 characters required for password.": "8 caractères minimum pour le mot de passe.",
"An error occurred. Please contact the administrator.": "Une erreur s'est produite. Merci de contacter l'administrateur.",
"workouts": "séances",
"application": "application",
"Error during picture deletion.": "Erreur lors de la suppression de l'image.",
"Error during picture update.": "Erreur lors de la mise à jour de l'image.",
"Error during picture update, file size exceeds max size.": "Erreur lors de la mise à jour de l'image, la taille du ficher dépasse la taille maximum autorisée",
@ -14,6 +14,7 @@
"Invalid credentials.": "Identifiants invalides.",
"Invalid payload.": "Données incorrectes.",
"Invalid token. Please log in again.": "Jeton invalide. Merci de vous reconnecter.",
"Max. size of zip archive must be equal or greater than max. size of uploaded files": "La taille max. d'une archive doit être supérieure ou égale à la taille max. d'un fichier",
"No file part.": "Pas de fichier fourni.",
"No picture.": "Pas d'image.",
"No selected file.": "Pas de fichier sélectionné.",
@ -30,6 +31,7 @@
"statistics": "statistics",
"User does not exist.": "L'utilisateur n'existe pas.",
"Valid email must be provided.\n": "L'email fourni n'est pas valide.",
"workouts": "séances",
"You can not delete your account, no other user has admin rights.": "Vous ne pouvez pas supprimer votre compte, aucun autre utilisateur n'a des droits d'administration.",
"You do not have permissions.": "Vous n'avez pas les permissions nécessaires."
}

View File

@ -110,6 +110,7 @@ const message = (state = initial.message, action) => {
return action.message
case 'LOGOUT':
case 'PROFILE_SUCCESS':
case 'SET_APP_CONFIG':
case 'SET_RESULTS':
case '@@router/LOCATION_CHANGE':
return ''