Skip to content

Commit

Permalink
use config file to limit upload images
Browse files Browse the repository at this point in the history
  • Loading branch information
sumn2u committed Jun 13, 2024
1 parent b3e6d6c commit 596804d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ if (typeof import.meta !== 'undefined' && import.meta.env) {

const config = {
DEMO_SITE_URL:"https://annotate-docs.dwaste.live/",
VITE_SERVER_URL
VITE_SERVER_URL,
UPLOAD_LIMIT: 5,
};

export default config;
Expand Down
7 changes: 4 additions & 3 deletions client/src/ImageUpload/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DeleteIcon from '@mui/icons-material/Delete';
import axios from 'axios';
import { useSnackbar } from '../SnackbarContext';
import { useTranslation } from "react-i18next"
import config from '../../config.js';

const ImageUpload = ({ onImageUpload }) => {
const { t } = useTranslation();
Expand All @@ -23,7 +24,7 @@ const ImageUpload = ({ onImageUpload }) => {
}

const totalImages = images.length + acceptedFiles.length;
if (totalImages > 2) {
if (totalImages > config.UPLOAD_LIMIT) {
showSnackbar(t("error.configuration.image_upload.max"), "error");
return;
}
Expand Down Expand Up @@ -108,7 +109,7 @@ const ImageUpload = ({ onImageUpload }) => {
onDrop,
accept: 'image/*',
multiple: true,
maxFiles: 2,
maxFiles: config.UPLOAD_LIMIT,
});

return (
Expand Down Expand Up @@ -148,7 +149,7 @@ const ImageUpload = ({ onImageUpload }) => {
</>
) : (
<Typography sx={{fontSize: "14px", color: "rgb(117, 117, 117)" }}>
{t("configuration.image_upload.description")}
{t("configuration.image_upload.description")} {config.UPLOAD_LIMIT}
</Typography>
)}
</>
Expand Down
2 changes: 1 addition & 1 deletion client/src/Localization/translation-de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const translationDeDE = {
"configuration.regions": "Standard-Regionstyp",
"configuration.regions.description": "Wählen Sie den Standard-Regionstyp, der auf dem Bild gezeichnet werden kann.",
"error.configuration.image_upload.max": "Maximale Anzahl von Bildern erreicht",
"configuration.image_upload.description": "Laden Sie Bilder hoch, die annotiert werden sollen, oder ziehen Sie Bilder hierher. Unterstützte Dateien: .jpg, .jpeg, .png und maximale Anzahl von Bildern: 2",
"configuration.image_upload.description": "Laden Sie Bilder hoch, die annotiert werden sollen, oder ziehen Sie Bilder hierher. Unterstützte Dateien: .jpg, .jpeg, .png und maximale Anzahl von Bildern:",
"configuration.image_upload.file_drop": "Dateien hierher ziehen",
"download.configuration": "Konfiguration",
"download.image_mask": "Maskiertes Bild",
Expand Down
2 changes: 1 addition & 1 deletion client/src/Localization/translation-en-EN.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const translationEnEN = {
"configuration.regions": "Default Region Type",
"configuration.regions.description": "Choose default region type that can be drawn on the image.",
"error.configuration.image_upload.max": "Maximum number of images reached",
"configuration.image_upload.description": "Upload images to be annotated, or drag and drop images here. Files supported: .jpg, .jpeg, .png and max number of images: 2",
"configuration.image_upload.description": "Upload images to be annotated, or drag and drop images here. Files supported: .jpg, .jpeg, .png and max number of images:",
"configuration.image_upload.file_drop": "Drop files here",
"download.configuration": "Configuration",
"download.image_mask": "Masked Image",
Expand Down

0 comments on commit 596804d

Please sign in to comment.