diff --git a/.env.development b/.env.development
index 0f3dd2fa..b1aa0d49 100644
--- a/.env.development
+++ b/.env.development
@@ -15,6 +15,7 @@ VUE_APP_LOG_LEVEL=${WEB_LOG_LEVEL}
# The reference source
VUE_APP_BI_REFERENCE_SOURCE=${BRAPI_REFERENCE_SOURCE}
+VUE_APP_MAX_GENOTYPE_UPLOAD_MB=${MAX_GENOTYPE_UPLOAD_MB}
# feature flags
VUE_APP_BRAPI_VENDOR_SUBMISSION_ENABLED=${BRAPI_VENDOR_SUBMISSION_ENABLED}
diff --git a/src/views/import/ImportGeno.vue b/src/views/import/ImportGeno.vue
index ff8615ab..26480267 100644
--- a/src/views/import/ImportGeno.vue
+++ b/src/views/import/ImportGeno.vue
@@ -68,9 +68,12 @@
{{upload.file.name}}
-
-
+
@@ -115,6 +118,8 @@ export default class ImportExperiment extends ProgramsBase {
private importState: DataFormEventBusHandler = new DataFormEventBusHandler();
private currentImport?: ImportResponse = new ImportResponse({});
private systemImportTemplateId?: string;
+ private fileSelectorKey: number = 0;
+ private defaultMaxGenotypeUploadMb: number = 800;
upload: Upload = new Upload({});
@@ -123,6 +128,36 @@ export default class ImportExperiment extends ProgramsBase {
file: {required}
}
+ private getMaxGenotypeUploadLimitMb(): number {
+ const configuredLimit = Number(process.env.VUE_APP_MAX_GENOTYPE_UPLOAD_MB);
+ if (!Number.isFinite(configuredLimit) || configuredLimit <= 0) {
+ return this.defaultMaxGenotypeUploadMb;
+ }
+ return configuredLimit;
+ }
+
+ private getMaxGenotypeUploadBytes(): number {
+ return this.getMaxGenotypeUploadLimitMb() * 1024 * 1024;
+ }
+
+ private showMaxGenotypeUploadError() {
+ this.$emit(
+ 'show-error-notification',
+ `Uploaded file exceeds the maximum file size limit of ${this.getMaxGenotypeUploadLimitMb()} MB.`
+ );
+ }
+
+ handleFileSelected(file: File) {
+ if (file.size > this.getMaxGenotypeUploadBytes()) {
+ this.clearFile();
+ this.fileSelectorKey += 1;
+ this.showMaxGenotypeUploadError();
+ return;
+ }
+
+ this.upload.file = file;
+ }
+
mounted() {
this.loadSampleSubmissions();
this.getSystemImportTemplateMapping();
@@ -142,6 +177,12 @@ export default class ImportExperiment extends ProgramsBase {
async save() {
try {
this.$store.commit( DEACTIVATE_ALL_NOTIFICATIONS );
+
+ if (this.upload.file!.size > this.getMaxGenotypeUploadBytes()) {
+ this.showMaxGenotypeUploadError();
+ return;
+ }
+
this.currentImport = await GenoService.uploadData(this.activeProgram!.id!, this.upload.submissionId!, this.upload.file!);
const response: ImportResponse = await this.getDataUpload();
if (response.progress!.statuscode == 500) {
diff --git a/vue.config.js b/vue.config.js
index eed14c1f..196301ab 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -27,6 +27,7 @@ process.env.VUE_APP_OPENID_LOGOUT_URL = process.env.VUE_APP_OPENID_LOGOUT_URL ||
process.env.VUE_APP_BI_API_V1_PATH = process.env.VUE_APP_BI_API_ROOT + "/v1";
process.env.VUE_APP_LOG_LEVEL = process.env.VUE_APP_LOG_LEVEL || 'error';
process.env.VUE_APP_BI_REFERENCE_SOURCE = process.env.VUE_APP_BI_REFERENCE_SOURCE || 'breedinginsight.org';
+process.env.VUE_APP_MAX_GENOTYPE_UPLOAD_MB = process.env.VUE_APP_MAX_GENOTYPE_UPLOAD_MB || '800';
process.env.VUE_APP_BRAPI_VENDOR_SUBMISSION_ENABLED = ('true' === process.env.VUE_APP_BRAPI_VENDOR_SUBMISSION_ENABLED);
process.env.VUE_APP_ALTERNATE_AUTHENTICATION_ENABLED = ('true' === process.env.VUE_APP_ALTERNATE_AUTHENTICATION_ENABLED);