diff --git a/geonode_mapstore_client/client/js/routes/UploadDataset.jsx b/geonode_mapstore_client/client/js/routes/UploadDataset.jsx index 0d595df6ff..f7d70b32e8 100644 --- a/geonode_mapstore_client/client/js/routes/UploadDataset.jsx +++ b/geonode_mapstore_client/client/js/routes/UploadDataset.jsx @@ -25,6 +25,7 @@ import uuidv1 from 'uuid/v1'; import axios from '@mapstore/framework/libs/ajax'; import UploadListContainer from '@js/routes/upload/UploadListContainer'; import UploadContainer from '@js/routes/upload/UploadContainer'; +import { getConfigProp } from '@mapstore/framework/utils/ConfigUtils'; const supportedDatasetTypes = [ { @@ -209,17 +210,6 @@ function UploadList({ .then((responses) => { const successfulUploads = responses.filter(({ status }) => status === 'success'); const errorUploads = responses.filter(({ status }) => status === 'error'); - if (errorUploads.length > 0) { - const failedUploads = errorUploads.map(({ baseName: name, error }) => ({ - id: uuidv1(), - name, - progress: 100, - state: 'INVALID', - create_date: Date.now(), - error - })); - onSuccess(failedUploads); - } if (successfulUploads.length > 0) { const successfulUploadsIds = successfulUploads.map(({ data }) => data?.id); const successfulUploadsNames = successfulUploads.map(({ baseName }) => baseName); @@ -235,6 +225,17 @@ function UploadList({ } else { setLoading(false); } + if (errorUploads.length > 0) { + const failedUploads = errorUploads.map(({ baseName: name, error }) => ({ + id: uuidv1(), + name, + progress: 100, + state: 'INVALID', + create_date: Date.now(), + error + })); + onSuccess(failedUploads); + } }) .catch(() => { setLoading(false); @@ -252,6 +253,8 @@ function UploadList({ return files.forEach((file) => sources[file].cancel()); }, []); + const { maxParallelUploads } = getConfigProp('geoNodeSettings'); + return ( updateWaitingUploads(omit(waitingUploads, baseName))} unsupported={unsupported} disabledUpload={Object.keys(readyUploads).length === 0} + disableOnParallelLmit={Object.keys(readyUploads).length > maxParallelUploads} onUpload={handleUploadProcess} loading={loading} progress={uploadContainerProgress} diff --git a/geonode_mapstore_client/client/js/routes/UploadDocument.jsx b/geonode_mapstore_client/client/js/routes/UploadDocument.jsx index 7d88488c01..6de8f7ffb2 100644 --- a/geonode_mapstore_client/client/js/routes/UploadDocument.jsx +++ b/geonode_mapstore_client/client/js/routes/UploadDocument.jsx @@ -149,6 +149,8 @@ function UploadList({ return files.forEach((file) => sources[file].cancel()); }, []); + const { maxParallelUploads } = getConfigProp('geoNodeSettings'); + return ( removeFile(waitingUploads, baseName)} unsupported={unsupported} disabledUpload={Object.keys(waitingUploads).length === 0} + disableOnParallelLmit={Object.keys(waitingUploads).length > maxParallelUploads} onUpload={handleUploadProcess} loading={loading} progress={uploadContainerProgress} diff --git a/geonode_mapstore_client/client/js/routes/upload/UploadCard.jsx b/geonode_mapstore_client/client/js/routes/upload/UploadCard.jsx index 7e747ab02e..750d37b870 100644 --- a/geonode_mapstore_client/client/js/routes/upload/UploadCard.jsx +++ b/geonode_mapstore_client/client/js/routes/upload/UploadCard.jsx @@ -38,7 +38,7 @@ function UploadCard({ type }) { - const { datasetMaxUploadSize, documentMaxUploadSize } = getConfigProp('geoNodeSettings'); + const { datasetMaxUploadSize, documentMaxUploadSize, maxParallelUploads } = getConfigProp('geoNodeSettings'); const maxAllowedBytes = type !== 'document' ? datasetMaxUploadSize : documentMaxUploadSize; const maxAllowedSize = Math.floor(maxAllowedBytes / (1024 * 1024)); @@ -51,6 +51,16 @@ function UploadCard({ return fileExceeds; }; + const errorToolTip = ({ code }) => { + switch (code) { + case "upload_parallelism_limit_exceeded": { + return "gnviewer.parallelLimitError"; + } + default: + return "gnviewer.invalidUploadMessageErrorTooltip"; + } + }; + return (
@@ -97,7 +107,7 @@ function UploadCard({ : null} {state === 'INVALID' - ? exceedingSizeError(error) ? } /> : + ? exceedingSizeError(error) ? } /> : } /> : null}
diff --git a/geonode_mapstore_client/client/js/routes/upload/UploadContainer.jsx b/geonode_mapstore_client/client/js/routes/upload/UploadContainer.jsx index 3e72832592..c82bf14281 100644 --- a/geonode_mapstore_client/client/js/routes/upload/UploadContainer.jsx +++ b/geonode_mapstore_client/client/js/routes/upload/UploadContainer.jsx @@ -37,6 +37,7 @@ function UploadContainer({ onRemove, unsupported, disabledUpload, + disableOnParallelLmit, onUpload, loading, progress, @@ -62,7 +63,7 @@ function UploadContainer({ return Math.ceil(bytes / (1024 * 1024)); }; - const { datasetMaxUploadSize, documentMaxUploadSize } = getConfigProp('geoNodeSettings'); + const { datasetMaxUploadSize, documentMaxUploadSize, maxParallelUploads } = getConfigProp('geoNodeSettings'); const maxAllowedBytes = type === 'dataset' ? datasetMaxUploadSize : documentMaxUploadSize; const maxAllowedSize = Math.floor(maxAllowedBytes / (1024 * 1024)); @@ -91,14 +92,15 @@ function UploadContainer({ activeClassName="gn-dropzone-active" rejectClassName="gn-dropzone-reject" disableClick + maxFiles={maxParallelUploads} >
- +
{waitingUploadNames.length > 0 ? ( @@ -138,29 +140,34 @@ function UploadContainer({ textAlign: 'center' }} > -
: {supportedLabels}
+
: {supportedLabels}
)}
{unsupported.length > 0 ? - : {unsupported.map(({ file }) => file?.name).join(', ')} + : {unsupported.map(({ file }) => file?.name).join(', ')} : null} {(waitingUploadNames.length > 0 && getExceedingFileSize(waitingUploadNames, maxAllowedSize)) ? - } > + } > - : - !loading ? : } + + : disableOnParallelLmit ? + } > + + + : + !loading ? : }
} diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json b/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json index 6e97ffe069..24df00fb50 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.de-DE.json @@ -275,7 +275,9 @@ "fileExceeds": "Die Dateigröße überschreitet {limit} MB. Bitte versuchen Sie es erneut mit einer kleineren Datei.", "exceedingFileMsg": "Algunos de sus archivos exceden el límite de carga de {limit} MB. Por favor, elimínelos de la lista.", "cannotPerfomAction": "Die Aktion für diese Ressource konnte nicht ausgeführt werden.", - "cancelUpload": "Hochladen abbrechen" + "cancelUpload": "Hochladen abbrechen", + "parallelUploadLimit": "Die ausgewählte Anzahl von Dateien überschreitet das zulässige Limit von {limit} Dateien. Bitte entfernen Sie einige Dateien aus der Liste.", + "parallelLimitError": "Die Anzahl aktiver paralleler Uploads überschreitet {limit}. Warten Sie, bis die ausstehenden abgeschlossen sind." } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json b/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json index fb90d15180..dacc45592d 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.en-US.json @@ -275,7 +275,9 @@ "fileExceeds": "File size size exceeds {limit} MB. Please try again with a smaller file.", "exceedingFileMsg": "Some of your files exceed the upload limit of {limit} MB. Please remove them from the list.", "cannotPerfomAction": "Failed to perform action on this resource.", - "cancelUpload": "Cancel upload" + "cancelUpload": "Cancel upload", + "parallelUploadLimit": "The selected number of files exceeds the allowed limit of {limit} files. Please remove some files from the list.", + "parallelLimitError": "The number of active parallel uploads exceeds {limit}. Wait for the pending ones to finish." } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json b/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json index 9d4ebfc2e9..68f4617915 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.es-ES.json @@ -273,7 +273,9 @@ "fileExceeds": "El tamaño del archivo supera los {limit} MB. Vuelva a intentarlo con un archivo más pequeño.", "exceedingFileMsg": "Algunos de sus archivos exceden el límite de carga de {limit} MB. Por favor, elimínelos de la lista.", "cannotPerfomAction": "No se pudo realizar la acción en este recurso.", - "cancelUpload": "Cancelar carga" + "cancelUpload": "Cancelar carga", + "parallelUploadLimit": "El número de archivos seleccionado supera el límite permitido de {limit} archivos. Elimine algunos archivos de la lista.", + "parallelLimitError": "El número de subidas paralelas activas supera {limit}. Espera a que terminen las pendientes." } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json b/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json index 20b1f0c534..f1b96b4db3 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.fr-FR.json @@ -274,7 +274,9 @@ "fileExceeds": "La taille du fichier dépasse {Limit} Mo. Veuillez réessayer avec un fichier plus petit.", "exceedingFileMsg": "Certains de vos fichiers dépassent la limite de téléchargement de {limit} Mo. Veuillez les supprimer de la liste.", "cannotPerfomAction": "Échec de l'exécution de l'action sur cette ressource.", - "cancelUpload": "Annuler le téléchargement" + "cancelUpload": "Annuler le téléchargement", + "parallelUploadLimit": "Le nombre de fichiers sélectionné dépasse la limite autorisée de {limit} fichiers. Veuillez supprimer certains fichiers de la liste.", + "parallelLimitError": "Le nombre de téléchargements parallèles actifs dépasse {limit}. Attendez que ceux en attente se terminent." } } } diff --git a/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json b/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json index fd8e88aa80..9614e27e1e 100644 --- a/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json +++ b/geonode_mapstore_client/client/static/mapstore/translations/data.it-IT.json @@ -276,7 +276,9 @@ "fileExceeds": "La dimensione del file supera i {limit} MB. Riprova con un file più piccolo.", "exceedingFileMsg": "Alcuni dei tuoi file superano il limite di caricamento di {limit} MB. Si prega di rimuoverli dall'elenco.", "cannotPerfomAction": "Impossibile eseguire l'azione su questa risorsa.", - "cancelUpload": "Annulla caricamento" + "cancelUpload": "Annulla caricamento", + "parallelUploadLimit": "Il numero selezionato di file supera il limite consentito di {limit} file. Si prega di rimuovere alcuni file dall'elenco.", + "parallelLimitError": "Il numero di caricamenti paralleli attivi supera {limit}. Aspetta che quelli in sospeso finiscano." } } }